From 7906d764fce61e2dae4394bc2445923ca143f17d Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Tue, 16 Nov 2021 12:38:00 +0900 Subject: [PATCH] webrtc_private: Add excluded element list to CREATE_ELEMENT_FROM_REGISTRY() The excluded element list from ini file is now referenced by two locations. 1. sink side (previous one) - _decodebin_autoplug_select_cb() 2. source side - CREATE_ELEMENT_FROM_REGISTRY() in __create_rest_of_elements() [Version] 0.2.152 [Issue Type] Improvement Change-Id: I277dfd574d8abbb9cd25e961a46efbaff7855ffc Signed-off-by: Sangchul Lee --- include/webrtc_private.h | 4 +++- packaging/capi-media-webrtc.spec | 2 +- src/webrtc_private.c | 15 +++++++++++++-- src/webrtc_sink.c | 2 +- src/webrtc_source.c | 4 ++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 37da9ce4..17dce4c6 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -178,11 +178,12 @@ do { \ g_free(caps_str); \ } while (0) -#define CREATE_ELEMENT_FROM_REGISTRY(x_elem_info, x_klass_name, x_sink_caps, x_src_caps, x_element) \ +#define CREATE_ELEMENT_FROM_REGISTRY(x_elem_info, x_klass_name, x_sink_caps, x_src_caps, x_excluded_elements, x_element) \ do { \ x_elem_info.klass_name = x_klass_name; \ x_elem_info.sink_caps = x_sink_caps; \ x_elem_info.src_caps = x_src_caps; \ + x_elem_info.excluded_elements = x_excluded_elements; \ x_element = _create_element_from_registry(&x_elem_info); \ if (!x_element) \ LOG_ERROR("failed to create element of [%s]", x_klass_name); \ @@ -517,6 +518,7 @@ typedef struct _element_info_s { const gchar *klass_name; GstCaps *src_caps; GstCaps *sink_caps; + gchar **excluded_elements; } element_info_s; typedef struct _webrtc_signal_s { diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 5536271b..1e4eecb9 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.2.151 +Version: 0.2.152 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 213750f4..99fad14f 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -645,18 +645,29 @@ static gboolean __element_filter(GstPluginFeature *feature, gpointer data) element_info_s *elem_info = (element_info_s *)data; gboolean src_can_accept = FALSE; gboolean sink_can_accept = FALSE; + gchar *factory_name; GstElementFactory *factory = NULL; const gchar *factory_klass = NULL; + gchar **str_arr; if (!GST_IS_ELEMENT_FACTORY(feature)) return FALSE; factory = GST_ELEMENT_FACTORY(feature); + factory_name = GST_OBJECT_NAME(factory); factory_klass = gst_element_factory_get_klass(factory); if (!elem_info || !g_strrstr(factory_klass, elem_info->klass_name)) return FALSE; + str_arr = elem_info->excluded_elements; + while (str_arr && *str_arr) { + if (g_strrstr(factory_name, *str_arr++)) { + LOG_WARNING("this element[%s] is an item of excluded element list in ini file, skip it", factory_name); + return FALSE; + } + } + if (g_strrstr(factory_klass, GST_KLASS_NAME_PAYLOADER_RTP) && !__is_acceptable_element(factory, GST_PAD_SRC)) return FALSE; else if (g_strrstr(factory_klass, GST_KLASS_NAME_DEPAYLOADER_RTP) && !__is_acceptable_element(factory, GST_PAD_SINK)) @@ -670,14 +681,14 @@ static gboolean __element_filter(GstPluginFeature *feature, gpointer data) if (GST_IS_CAPS(elem_info->src_caps) && GST_IS_CAPS(elem_info->sink_caps)) { if (src_can_accept && sink_can_accept) { - LOG_DEBUG("found compatible factory [%s] for klass [%s]", GST_OBJECT_NAME(factory), factory_klass); + LOG_DEBUG("found compatible factory [%s] for klass [%s]", factory_name, factory_klass); return TRUE; } return FALSE; } if (src_can_accept || sink_can_accept) { - LOG_DEBUG("found compatible factory [%s] for klass [%s]", GST_OBJECT_NAME(factory), factory_klass); + LOG_DEBUG("found compatible factory [%s] for klass [%s]", factory_name, factory_klass); return TRUE; } diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index 5b9fdc38..71348767 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -863,7 +863,7 @@ int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_video) g_free(bin_name); - CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_DEPAYLOADER_RTP, gst_pad_get_current_caps(src_pad), NULL, depayloader); + CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_DEPAYLOADER_RTP, gst_pad_get_current_caps(src_pad), NULL, NULL, depayloader); if (!depayloader) goto error_before_insert; diff --git a/src/webrtc_source.c b/src/webrtc_source.c index cfd9f75b..85e80206 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -910,6 +910,7 @@ static int __create_rest_of_elements(webrtc_s *webrtc, webrtc_gst_slot_s *source CREATE_ELEMENT_FROM_REGISTRY(elem_info, encoder_klass_name, __make_default_raw_caps(source, &webrtc->ini), __make_default_encoded_caps(source, &webrtc->ini, NULL), + webrtc->ini.general.gst_excluded_elements, encoder); if (encoder == NULL) { __remove_probe_from_pad_for_render(source, idx); @@ -938,6 +939,7 @@ skip_encoder: CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_PAYLOADER_RTP, __make_default_encoded_caps(source, &webrtc->ini, &media_type), NULL, + NULL, payloader); if (payloader == NULL) goto error; @@ -992,6 +994,7 @@ static int __create_rest_of_elements_for_encoded_format(webrtc_s *webrtc, webrtc CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_PAYLOADER_RTP, __make_encoded_caps_from_media_format(source, &media_type), NULL, + NULL, payloader); if (payloader == NULL) { g_free(media_type); @@ -1855,6 +1858,7 @@ static GstElement * __create_payloader_for_filesrc_pipeline(GstPad *pad, bool is CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_PAYLOADER_RTP, gst_pad_get_current_caps(pad), NULL, + NULL, payloader); RET_VAL_IF(payloader == NULL, NULL, "payloader is NULL"); -- 2.34.1