webrtc_ini: Move FEC setting from [general] to [media source] category 00/262000/2 accepted/tizen/unified/20210804.094651 submit/tizen/20210804.071712
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 30 Jul 2021 09:33:57 +0000 (18:33 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 3 Aug 2021 02:26:28 +0000 (11:26 +0900)
Now the FEC setting values can be set per media source rather than
system general.

For example, if camera source uses MJPEG encoded codec directly, it is
shown that the performance is better without FEC enabled. This patch
makes the FEC disable only in case of this media source type.

[Version] 0.2.65
[Issue Type] Improvement

Change-Id: Ied2e48cc27a5b050a367abd5e17dbb1370dace90
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 e61eda93d38333a9407ce6ef15ad538c2071ed0e..43fc5efeb75b9887c19d64384ee00eff03e49366 100644 (file)
@@ -282,8 +282,6 @@ typedef     struct _ini_item_general_s {
        gchar **gst_excluded_elements;
        const char *stun_server;
        int jitterbuffer_latency;
-       bool use_ulpfec_red;
-       int fec_percentage;
 } ini_item_general_s;
 
 typedef struct _ini_item_media_source_s {
@@ -303,6 +301,9 @@ typedef struct _ini_item_media_source_s {
        int a_channels;
        const char *a_codec;
        const char *a_hw_encoder_element;
+       /* forward error correction */
+       bool use_ulpfec_red;
+       int fec_percentage;
 } ini_item_media_source_s;
 
 typedef struct _ini_item_rendering_sink_s {
index a7d5c78a295f7f388664ad0c62633359c07e2570..e25007a639170804420636acc76cd924e60057d0 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.64
+Version:    0.2.65
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 25548d70adfd5ff327d826a932ec70bfe454391a..af4ef7935581f4e4b99c100bfab91929bae99431 100644 (file)
@@ -21,8 +21,6 @@
 #define DEFAULT_GENERATE_DOT              true
 #define DEFAULT_DOT_PATH                  "/tmp"
 #define DEFAULT_JITTERBUFFER_LATENCY      200  /* ms */
-#define DEFAULT_USE_ULPFEC_RED            true
-#define DEFAULT_FEC_PERCENTAGE            100  /* FEC overhead percentage for the whole stream */
 
 /* categories */
 #define INI_CATEGORY_GENERAL              "general"
@@ -47,8 +45,6 @@
 #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"
-#define INI_ITEM_USE_ULPFEC_RED           "use ulpfec red"
-#define INI_ITEM_FEC_PERCENTAGE           "fec percentage"
 
 /* items for media source */
 #define INI_ITEM_SOURCE_ELEMENT            "source element"
@@ -65,6 +61,8 @@
 #define INI_ITEM_AUDIO_CHANNELS            "audio channels"
 #define INI_ITEM_AUDIO_CODEC               "audio codec"
 #define INI_ITEM_AUDIO_HW_ENCODER_ELEMENT  "audio hw encoder element"
+#define INI_ITEM_USE_ULPFEC_RED            "use ulpfec red"
+#define INI_ITEM_FEC_PERCENTAGE            "fec percentage"
 
 #define DEFAULT_VIDEO_RAW_FORMAT          "I420"
 #define DEFAULT_VIDEO_WIDTH               320
@@ -79,6 +77,9 @@
 #define DEFAULT_VIDEO_CODEC               "vp8"
 #define DEFAULT_AUDIO_CODEC               "opus"
 
+#define DEFAULT_USE_ULPFEC_RED            true
+#define DEFAULT_FEC_PERCENTAGE            100  /* FEC overhead percentage for the whole stream */
+
 /* items for rendering sink */
 #define INI_ITEM_AUDIO_SINK_ELEMENT               "audio sink element"
 #define INI_ITEM_VIDEO_SINK_ELEMENT               "video sink element"
@@ -184,6 +185,8 @@ static void __dump_items_of_source(ini_item_media_source_s *source)
        __dump_item(INI_ITEM_AUDIO_CHANNELS, INI_ITEM_TYPE_INT, &source->a_channels);
        __dump_item(INI_ITEM_AUDIO_CODEC, INI_ITEM_TYPE_STRING, (void *)source->a_codec);
        __dump_item(INI_ITEM_AUDIO_HW_ENCODER_ELEMENT, INI_ITEM_TYPE_STRING, (void *)source->a_hw_encoder_element);
+       __dump_item(INI_ITEM_USE_ULPFEC_RED, INI_ITEM_TYPE_BOOL, &source->use_ulpfec_red);
+       __dump_item(INI_ITEM_FEC_PERCENTAGE, INI_ITEM_TYPE_INT, &source->fec_percentage);
 }
 
 static bool __is_vpx(const char *v_codec)
@@ -205,8 +208,6 @@ static void __dump_ini(webrtc_ini_s *ini)
        __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);
-       __dump_item(INI_ITEM_USE_ULPFEC_RED, INI_ITEM_TYPE_BOOL, &ini->general.use_ulpfec_red);
-       __dump_item(INI_ITEM_FEC_PERCENTAGE, INI_ITEM_TYPE_INT, &ini->general.fec_percentage);
 
        LOG_INFO("[%s]", INI_CATEGORY_MEDIA_SOURCE);
        __dump_items_of_source(&ini->media_source);
@@ -404,6 +405,10 @@ static void __apply_media_source_setting(webrtc_ini_s *ini, ini_item_media_sourc
                        is_default ? DEFAULT_AUDIO_CODEC : ini->media_source.a_codec);
        source->a_hw_encoder_element = __ini_get_string(ini->dict, category, INI_ITEM_AUDIO_HW_ENCODER_ELEMENT,
                        is_default ? NULL : ini->media_source.a_hw_encoder_element);
+       source->use_ulpfec_red = __ini_get_boolean(ini->dict, category, INI_ITEM_USE_ULPFEC_RED,
+                       is_default ? DEFAULT_USE_ULPFEC_RED : ini->media_source.use_ulpfec_red);
+       source->fec_percentage = __ini_get_int(ini->dict, category, INI_ITEM_FEC_PERCENTAGE,
+                       is_default ? DEFAULT_FEC_PERCENTAGE : ini->media_source.fec_percentage);
 }
 
 int _load_ini(webrtc_s *webrtc)
@@ -433,8 +438,6 @@ int _load_ini(webrtc_s *webrtc)
        __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);
-       ini->general.use_ulpfec_red = __ini_get_boolean(webrtc->ini.dict, INI_CATEGORY_GENERAL, INI_ITEM_USE_ULPFEC_RED, DEFAULT_USE_ULPFEC_RED);
-       ini->general.fec_percentage = __ini_get_int(webrtc->ini.dict, INI_CATEGORY_GENERAL, INI_ITEM_FEC_PERCENTAGE, DEFAULT_FEC_PERCENTAGE);
 
        /* default setting for a media source */
        __apply_media_source_setting(ini, &ini->media_source, INI_CATEGORY_MEDIA_SOURCE);
index a3297afb5c19f4705dd0333ccf693bcb52e17cdf..be87cfd34870014a55dd2aa287d52d2fdf78f7c5 100644 (file)
@@ -920,22 +920,27 @@ int _set_ghost_pad_target(GstPad *ghost_pad, GstElement *target_element, bool is
        return WEBRTC_ERROR_NONE;
 }
 
-static void __webrtcbin_transceiver_set_ulpfec_red(webrtc_s *webrtc, GstWebRTCRTPTransceiver *transceiver)
+static void __webrtcbin_transceiver_set_ulpfec_red(webrtc_s *webrtc, int source_type, GstWebRTCRTPTransceiver *transceiver)
 {
+       ini_item_media_source_s *ini_source;
        GstElement *rtpbin;
 
        RET_IF(webrtc == NULL, "webrtc is NULL");
        RET_IF(transceiver == NULL, "transceiver is NULL");
 
-       if (!webrtc->ini.general.use_ulpfec_red)
+       ini_source = _ini_get_source_by_type(&webrtc->ini, source_type);
+       if (ini_source == NULL)
+               ini_source = &(webrtc->ini.media_source);
+
+       if (!ini_source->use_ulpfec_red)
                return;
 
        g_object_set(transceiver,
                "fec-type", GST_WEBRTC_FEC_TYPE_ULP_RED,
-               "fec-percentage", webrtc->ini.general.fec_percentage,
+               "fec-percentage", ini_source->fec_percentage,
                NULL);
 
-       LOG_INFO("set ULPFEC/RED[percentage: %d] to transceiver[%p]", webrtc->ini.general.fec_percentage, transceiver);
+       LOG_INFO("set ULPFEC/RED[percentage: %d] to transceiver[%p]", ini_source->fec_percentage, transceiver);
 
        if (!(rtpbin = gst_bin_get_by_name(GST_BIN(webrtc->gst.webrtcbin), "rtpbin"))) {
                LOG_ERROR("failed to get rtpbin");
@@ -1043,7 +1048,7 @@ static void __webrtcbin_on_new_transceiver_cb(GstElement *webrtcbin, GstWebRTCRT
                                LOG_DEBUG("source[%s, id:%u, mline:%d for %s]",
                                        (gchar*)key, source->id, source->av[i].mline, i == AV_IDX_AUDIO ? "AUDIO" : "VIDEO");
 
-                               __webrtcbin_transceiver_set_ulpfec_red(webrtc, transceiver);
+                               __webrtcbin_transceiver_set_ulpfec_red(webrtc, source->type, transceiver);
                        }
                }
        }