webrtc_ini: Add new item to set in-band FEC and packet loss percentage 77/268677/4 accepted/tizen/unified/20220103.130045 submit/tizen/20220103.020323
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 29 Dec 2021 08:34:53 +0000 (17:34 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 31 Dec 2021 08:12:43 +0000 (17:12 +0900)
e.g)
[media source]
use inbandfec = no
packet loss percentage = 0

[source audiotest]
; values below will override the default one of [media source] above
use inbandfec = yes
packet loss percentage = 10

[Version] 0.3.36
[Issue Type] Improvement

Change-Id: If4fb6b658d02d7890ddb9924ebe3aceb5cdc4f08
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_ini.c
src/webrtc_source.c

index eea7ebf641e70c75259da03c4e57c44aaec4c806..40518c37083d31b97cba767e35d226e50b97a055 100644 (file)
@@ -319,9 +319,13 @@ typedef struct _ini_item_media_source_s {
        int a_channels;
        const char *a_codec;
        const char *a_hw_encoder_element;
-       /* forward error correction */
+       /* Forward Error Correction */
+       /* ULPFEC */
        bool use_ulpfec_red;
        int fec_percentage;
+       /* in-band FEC */
+       bool use_inbandfec;
+       int packet_loss_percentage;
 } ini_item_media_source_s;
 
 typedef struct _ini_item_rendering_sink_s {
@@ -480,6 +484,7 @@ typedef struct _webrtc_gst_slot_s {
                gulong src_pad_probe_id;
                bool pause;
                bool inbandfec;
+               int packet_loss_percentage;
                unsigned int pt;
                struct {
                        unsigned int track_id;
index b55b8b84d985d1ed8bc22a495a1d3839ae61839f..8fd9af8397773f5c01ba19502ed5955be4de14c4 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.35
+Version:    0.3.36
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 8e486552cddc77facb48f3cf7657b8d91dec9c6e..e5a29598ee011d45ee03b6f50135e44975d079be 100644 (file)
@@ -76,6 +76,8 @@ bool g_verbose = false;
 #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 INI_ITEM_USE_INBANDFEC             "use inbandfec"
+#define INI_ITEM_PACKET_LOSS_PERCENTAGE    "packet loss percentage"
 
 #define DEFAULT_VIDEO_RAW_FORMAT          "I420"
 #define DEFAULT_VIDEO_WIDTH               320
@@ -92,6 +94,8 @@ bool g_verbose = false;
 
 #define DEFAULT_USE_ULPFEC_RED            false
 #define DEFAULT_FEC_PERCENTAGE            100  /* FEC overhead percentage for the whole stream */
+#define DEFAULT_USE_INBANDFEC             false
+#define DEFAULT_PACKET_LOSS_PERCENTAGE    10
 
 /* items for rendering sink */
 #define INI_ITEM_AUDIO_SINK_ELEMENT               "audio sink element"
@@ -201,6 +205,8 @@ static void __dump_items_of_source(ini_item_media_source_s *source)
        __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);
+       __dump_item(INI_ITEM_USE_INBANDFEC, INI_ITEM_TYPE_BOOL, &source->use_inbandfec);
+       __dump_item(INI_ITEM_PACKET_LOSS_PERCENTAGE, INI_ITEM_TYPE_INT, &source->packet_loss_percentage);
 }
 
 static bool __is_vpx(const char *v_codec)
@@ -435,6 +441,10 @@ static void __apply_media_source_setting(webrtc_ini_s *ini, ini_item_media_sourc
                        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);
+       source->use_inbandfec = __ini_get_boolean(ini->dict, category, INI_ITEM_USE_INBANDFEC,
+                       is_default ? DEFAULT_USE_INBANDFEC : ini->media_source.use_inbandfec);
+       source->packet_loss_percentage = __ini_get_int(ini->dict, category, INI_ITEM_PACKET_LOSS_PERCENTAGE,
+                       is_default ? DEFAULT_PACKET_LOSS_PERCENTAGE : ini->media_source.packet_loss_percentage);
 }
 
 int _load_ini(webrtc_s *webrtc)
index 0bee0756c8a05a1ec6cc303e3806238d22ed2329..625039768c46157416f1908bdc4f0189d9e564de 100644 (file)
@@ -893,9 +893,13 @@ static GstElement * __prepare_encoder(webrtc_s *webrtc, webrtc_gst_slot_s *sourc
 
        } else if (g_strrstr(encoder_name, "opusenc")) {
                if (source->av[AV_IDX_AUDIO].inbandfec) {
-                       g_object_set(G_OBJECT(encoder), "inband-fec", TRUE, NULL);
-                       g_object_set(G_OBJECT(encoder), "packet-loss-percentage", 10, NULL); /* TODO: set this value from ini or API */
-                       LOG_DEBUG("[%s] inband-fec(%d)", encoder_name, TRUE);
+                       g_object_set(G_OBJECT(encoder),
+                               "inband-fec", TRUE,
+                               "packet-loss-percentage", source->av[AV_IDX_AUDIO].packet_loss_percentage,
+                               NULL);
+
+                       LOG_DEBUG("[%s] inband-fec(%d), packet-loss-percentage(%d)",
+                               encoder_name, TRUE, source->av[AV_IDX_AUDIO].packet_loss_percentage);
                }
        }
 
@@ -1519,6 +1523,9 @@ static int __build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, bool us
                goto exit;
        APPEND_ELEMENT(element_list, volume);
 
+       source->av[AV_IDX_AUDIO].inbandfec = ini_source->use_inbandfec;
+       source->av[AV_IDX_AUDIO].packet_loss_percentage = ini_source->packet_loss_percentage;
+
        if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, true)) != WEBRTC_ERROR_NONE)
                goto exit;
 
@@ -1722,6 +1729,9 @@ static int __build_custom_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
                goto exit;
        APPEND_ELEMENT(element_list, volume);
 
+       source->av[AV_IDX_AUDIO].inbandfec = ini_source->use_inbandfec;
+       source->av[AV_IDX_AUDIO].packet_loss_percentage = ini_source->packet_loss_percentage;
+
        if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, true)) != WEBRTC_ERROR_NONE)
                goto exit;