webrtc_ini: Add new item to set jitterbuffer latency inside of rtpbin 86/247886/3
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 18 Nov 2020 05:57:20 +0000 (14:57 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 19 Nov 2020 23:47:00 +0000 (08:47 +0900)
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 <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_ini.c
src/webrtc_private.c

index 1ad28a4b9c48c9db27d36203d9ecf5a468515d0a..aa7ab50b52241bd0a1064aa5378e86ad8c27e360 100644 (file)
@@ -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 {
index 76d0aecf3bfcbc82f0d92ab12f9dc3c938a26423..3dff5cd6bb049abe95f8bd6847045d6c31b3ff7b 100644 (file)
@@ -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
index a96ee28614b73e25c05d0a2da5767df7ba749c3a..661bf762c782853d0c6cd5c1d17908f1e57c8cad 100644 (file)
 #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);
index 2f01e8ad028e51ea44362dab297c8ca9224a163a..a2ed4dc475dac78474ff4a50fd1832f8cae5aaa7 100644 (file)
@@ -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);