From: Sangchul Lee Date: Wed, 29 Dec 2021 08:34:53 +0000 (+0900) Subject: webrtc_ini: Add new item to set in-band FEC and packet loss percentage X-Git-Tag: submit/tizen/20220103.020323^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F268677%2F4;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_ini: Add new item to set in-band FEC and packet loss percentage 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 --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index eea7ebf6..40518c37 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -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; diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index b55b8b84..8fd9af83 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.3.35 +Version: 0.3.36 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_ini.c b/src/webrtc_ini.c index 8e486552..e5a29598 100644 --- a/src/webrtc_ini.c +++ b/src/webrtc_ini.c @@ -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) diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 0bee0756..62503976 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -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;