From: Sangchul Lee Date: Wed, 18 Nov 2020 02:21:16 +0000 (+0900) Subject: webrtc_ini: Add new category for supporting hw decoder elements X-Git-Tag: submit/tizen/20210729.023123~186 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5c6bf2714558ff1d49857afed5f77871dd40d25;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_ini: Add new category for supporting hw decoder elements For rendering audio or video data from the remote peer, we are leaning on the decodebin to manipulate the rendering pipeline. There can be cases that some elements of h/w decoder should not be used in the rendering pipepline. Therefore this patch is added to skip the h/w decoder element that is not specified in the ini file. The new category and items will be added in ini file as below. [rendering sink] ; comma separated list of elements, it should be one by one per codec type audio hw decoder elements = video hw decoder elements = [Version] 0.1.56 [Issue Type] Improvement Change-Id: I13faa9fc2632a2b4b4082d70c9a86e67ef3d923b Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index de32b4ec..1ad28a4b 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -179,10 +179,16 @@ typedef struct _ini_item_media_source_s { const char *a_hw_encoder_element; } ini_item_media_source_s; +typedef struct _ini_item_rendering_sink_s { + gchar **a_hw_decoder_elements; + gchar **v_hw_decoder_elements; +} ini_item_rendering_sink_s; + typedef struct _webrtc_ini_s { dictionary *dict; ini_item_general_s general; ini_item_media_source_s media_source; + ini_item_rendering_sink_s rendering_sink; GHashTable *sources; } webrtc_ini_s; diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index df2c2fc3..76d0aecf 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.55 +Version: 0.1.56 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_ini.c b/src/webrtc_ini.c index 7150ed7f..a96ee286 100644 --- a/src/webrtc_ini.c +++ b/src/webrtc_ini.c @@ -28,6 +28,7 @@ #define INI_CATEGORY_SOURCE_MIC "source mic" #define INI_CATEGORY_SOURCE_AUDIOTEST "source audiotest" #define INI_CATEGORY_SOURCE_VIDEOTEST "source videotest" +#define INI_CATEGORY_RENDERING_SINK "rendering sink" /* items for general */ #define INI_ITEM_DOT_PATH "dot path" @@ -60,6 +61,10 @@ #define DEFAULT_VIDEO_CODEC "vp8" #define DEFAULT_AUDIO_CODEC "opus" +/* items for rendering sink */ +#define INI_ITEM_AUDIO_HW_DECODER_ELEMENTS "audio hw decoder elements" +#define INI_ITEM_VIDEO_HW_DECODER_ELEMENTS "video hw decoder elements" + typedef enum { INI_ITEM_TYPE_BOOL, INI_ITEM_TYPE_INT, @@ -157,6 +162,9 @@ static void __dump_ini(webrtc_ini_s *ini) __dump_items_of_source(source); } } + + __dump_item(INI_ITEM_AUDIO_HW_DECODER_ELEMENTS, INI_ITEM_TYPE_STRINGS, ini->rendering_sink.a_hw_decoder_elements); + __dump_item(INI_ITEM_VIDEO_HW_DECODER_ELEMENTS, INI_ITEM_TYPE_STRINGS, ini->rendering_sink.v_hw_decoder_elements); } static const char* __get_delimiter(const char *ini_path) @@ -337,6 +345,9 @@ int _load_ini(webrtc_s *webrtc) } } + __ini_read_list(ini->dict, INI_CATEGORY_RENDERING_SINK, INI_ITEM_AUDIO_HW_DECODER_ELEMENTS, &ini->rendering_sink.a_hw_decoder_elements); + __ini_read_list(ini->dict, INI_CATEGORY_RENDERING_SINK, INI_ITEM_VIDEO_HW_DECODER_ELEMENTS, &ini->rendering_sink.v_hw_decoder_elements); + __dump_ini(ini); return WEBRTC_ERROR_NONE; @@ -365,6 +376,12 @@ void _unload_ini(webrtc_s *webrtc) RET_IF(webrtc == NULL, "webrtc is NULL"); RET_IF(webrtc->ini.dict == NULL, "ini.dict is NULL"); + g_strfreev(webrtc->ini.rendering_sink.a_hw_decoder_elements); + webrtc->ini.rendering_sink.a_hw_decoder_elements = NULL; + + g_strfreev(webrtc->ini.rendering_sink.v_hw_decoder_elements); + webrtc->ini.rendering_sink.v_hw_decoder_elements = NULL; + g_hash_table_destroy(webrtc->ini.sources); webrtc->ini.sources = NULL; diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index 8379ea88..c26d111b 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -215,16 +215,16 @@ static void __decodebin_pad_added_cb(GstElement *decodebin, GstPad *new_pad, gpo static int __decodebin_autoplug_select_cb(GstElement *decodebin, GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer user_data) { - /* NOTE : GstAutoplugSelectResult is defined in gstplay-enum.h but not exposed */ - typedef enum { + /* NOTE : Similar enum is defined with GstAutoplugSelectResult in gstplay-enum.h but not exposed */ + enum { GST_AUTOPLUG_SELECT_TRY, GST_AUTOPLUG_SELECT_EXPOSE, GST_AUTOPLUG_SELECT_SKIP - } GstAutoplugSelectResult; + }; gchar *factory_name; const gchar *klass; - GstAutoplugSelectResult result = GST_AUTOPLUG_SELECT_TRY; webrtc_s *webrtc = (webrtc_s *)user_data; + gchar **str_arr; RET_VAL_IF(webrtc == NULL, GST_AUTOPLUG_SELECT_SKIP, "webrtc is NULL, skip it"); @@ -233,7 +233,21 @@ static int __decodebin_autoplug_select_cb(GstElement *decodebin, GstPad *pad, Gs LOG_INFO("factory [name:%s, klass:%s]", factory_name, klass); - return result; + if (g_strrstr(klass, "Decoder/Audio/Hardware")) { + str_arr = webrtc->ini.rendering_sink.a_hw_decoder_elements; + if (str_arr == NULL || !g_strv_contains((const gchar * const *)str_arr, factory_name)) { + LOG_DEBUG("this audio hw decoder element[%s] is not specified in ini file, skip it", factory_name); + return GST_AUTOPLUG_SELECT_SKIP; + } + } else if (g_strrstr(klass, "Decoder/Video/Hardware")) { + str_arr = webrtc->ini.rendering_sink.v_hw_decoder_elements; + if (str_arr == NULL || !g_strv_contains((const gchar * const *)str_arr, factory_name)) { + LOG_DEBUG("this video hw decoder element[%s] is not specified in ini file, skip it", factory_name); + return GST_AUTOPLUG_SELECT_SKIP; + } + } + + return GST_AUTOPLUG_SELECT_TRY; } void _sink_slot_destroy_cb(gpointer data)