From: Sangchul Lee Date: Wed, 18 Nov 2020 05:57:20 +0000 (+0900) Subject: webrtc_ini: Add new item to set jitterbuffer latency inside of rtpbin X-Git-Tag: submit/tizen/20210729.023123~185 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F86%2F247886%2F3;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_ini: Add new item to set jitterbuffer latency inside of rtpbin This property can be set in ini file as below. [general] rtp jitterbuffer latency = [Version] 0.1.57 [Issue Type] Improvement Change-Id: I052f86539fb2b3b8f887ef9fe128f76a46027bce Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 1ad28a4b..aa7ab50b 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -161,6 +161,7 @@ typedef struct _ini_item_general_s { gchar **gst_args; gchar **gst_excluded_elements; const char *stun_server; + int jitterbuffer_latency; } ini_item_general_s; typedef struct _ini_item_media_source_s { diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 76d0aecf..3dff5cd6 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.1.56 +Version: 0.1.57 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_ini.c b/src/webrtc_ini.c index a96ee286..661bf762 100644 --- a/src/webrtc_ini.c +++ b/src/webrtc_ini.c @@ -17,9 +17,10 @@ #include "webrtc.h" #include "webrtc_private.h" -#define WEBRTC_INI_PATH "/etc/multimedia/mmfw_webrtc.ini" -#define DEFAULT_GENERATE_DOT true -#define DEFAULT_DOT_PATH "/tmp" +#define WEBRTC_INI_PATH "/etc/multimedia/mmfw_webrtc.ini" +#define DEFAULT_GENERATE_DOT true +#define DEFAULT_DOT_PATH "/tmp" +#define DEFAULT_JITTERBUFFER_LATENCY 200 /* ms */ /* categories */ #define INI_CATEGORY_GENERAL "general" @@ -36,6 +37,7 @@ #define INI_ITEM_GST_ARGS "gstreamer arguments" #define INI_ITEM_GST_EXCLUDED_ELEMENTS "gstreamer excluded elements" #define INI_ITEM_STUN_SERVER "stun server" +#define INI_ITEM_RTP_JITTERBUFFER_LATENCY "rtp jitterbuffer latency" /* items for media source */ #define INI_ITEM_VIDEO_RAW_FORMAT "video raw format" @@ -151,6 +153,7 @@ static void __dump_ini(webrtc_ini_s *ini) __dump_item(INI_ITEM_GST_ARGS, INI_ITEM_TYPE_STRINGS, ini->general.gst_args); __dump_item(INI_ITEM_GST_EXCLUDED_ELEMENTS, INI_ITEM_TYPE_STRINGS, ini->general.gst_excluded_elements); __dump_item(INI_ITEM_STUN_SERVER, INI_ITEM_TYPE_STRING, (void *)ini->general.stun_server); + __dump_item(INI_ITEM_RTP_JITTERBUFFER_LATENCY, INI_ITEM_TYPE_INT, &ini->general.jitterbuffer_latency); LOG_INFO("[%s]", INI_CATEGORY_MEDIA_SOURCE); __dump_items_of_source(&ini->media_source); @@ -329,6 +332,7 @@ int _load_ini(webrtc_s *webrtc) __ini_read_list(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_GST_ARGS, &ini->general.gst_args); __ini_read_list(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_GST_EXCLUDED_ELEMENTS, &ini->general.gst_excluded_elements); ini->general.stun_server = __ini_get_string(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_STUN_SERVER, NULL); + ini->general.jitterbuffer_latency = __ini_get_int(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_RTP_JITTERBUFFER_LATENCY, DEFAULT_JITTERBUFFER_LATENCY); /* default setting for a media source */ __apply_media_source_setting(ini, &ini->media_source, INI_CATEGORY_MEDIA_SOURCE); diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 2f01e8ad..a2ed4dc4 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -805,6 +805,8 @@ static void __webrtcbin_on_new_transceiver_cb(GstElement *webrtcbin, GstWebRTCRT int _gst_build_pipeline(webrtc_s *webrtc) { + GstElement *rtpbin; + RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); webrtc->gst.pipeline = gst_pipeline_new("webrtc-pipeline"); @@ -831,6 +833,13 @@ int _gst_build_pipeline(webrtc_s *webrtc) LOG_INFO("stun_server[%s]", webrtc->stun_server_url); } + if (!(rtpbin = gst_bin_get_by_name(GST_BIN(webrtc->gst.webrtcbin), "rtpbin"))) { + LOG_ERROR("failed to get rtpbin"); + goto error; + } + g_object_set(G_OBJECT(rtpbin), "latency", webrtc->ini.general.jitterbuffer_latency, NULL); + gst_object_unref(rtpbin); + _connect_and_append_signal(&webrtc->signals, (GObject *)webrtc->gst.webrtcbin, "on-negotiation-needed", G_CALLBACK(__webrtcbin_on_negotiation_needed_cb), webrtc); _connect_and_append_signal(&webrtc->signals, (GObject *)webrtc->gst.webrtcbin, "on-ice-candidate", G_CALLBACK(__webrtcbin_on_ice_candidate_cb), webrtc); _connect_and_append_signal(&webrtc->signals, (GObject *)webrtc->gst.webrtcbin, "notify::connection-state", G_CALLBACK(__webrtcbin_peer_connection_state_cb), webrtc);