webrtc_ini: Add new category for supporting hw decoder elements 78/247878/4
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 18 Nov 2020 02:21:16 +0000 (11:21 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 18 Nov 2020 06:15:19 +0000 (15:15 +0900)
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 <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_ini.c
src/webrtc_sink.c

index de32b4ecf3c8853eb33c61040398e1b8ca73c4f2..1ad28a4b9c48c9db27d36203d9ecf5a468515d0a 100644 (file)
@@ -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;
 
index df2c2fc30fb975bead860afbadee0530fbfa80b3..76d0aecf3bfcbc82f0d92ab12f9dc3c938a26423 100644 (file)
@@ -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
index 7150ed7f2b87fca645afc1d8af55a6fdaad88c75..a96ee28614b73e25c05d0a2da5767df7ba749c3a 100644 (file)
@@ -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"
 #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;
 
index 8379ea88dd16f2134d231641f3ce183a4ca919da..c26d111b7ab6c0622afadc7bf18d4491d8697e92 100644 (file)
@@ -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)