From: Sangchul Lee Date: Fri, 7 Oct 2022 00:53:37 +0000 (+0900) Subject: webrtc_private: Move _gst_set_element_properties() to _source_private.c X-Git-Tag: accepted/tizen/unified/20221107.173038~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=699e010e1e1c5aefaf5400fa6f17317a896af4a5;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_private: Move _gst_set_element_properties() to _source_private.c [Version] 0.3.256 [Issue Type] Refactoring Change-Id: I2ce2ade6789480d6b9485815d89d56734b6bd165 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 75cbb094..187b74df 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -827,7 +827,6 @@ int _gst_init(webrtc_s *webrtc); int _gst_build_pipeline(webrtc_s *webrtc); void _gst_destroy_pipeline(webrtc_s *webrtc); int _gst_pipeline_set_state(webrtc_s *webrtc, GstState state); -void _gst_set_element_properties(GstElement *element, GStrv key_value_pairs); GstElement *_create_element(const char *factory_name, const char *name); GstElement *_create_element_from_registry(element_info_s *elem_info); diff --git a/include/webrtc_source_private.h b/include/webrtc_source_private.h index 00f17836..cceafd88 100644 --- a/include/webrtc_source_private.h +++ b/include/webrtc_source_private.h @@ -94,5 +94,6 @@ void _set_video_src_origin_resolution(webrtc_gst_slot_s *source, int width, int GstCaps *_make_video_raw_caps_with_resolution(webrtc_gst_slot_s *source, webrtc_ini_s *ini, int width, int height); void _release_request_pad(webrtc_gst_slot_s *source); bool _set_default_video_info(webrtc_gst_slot_s *source, const ini_item_media_source_s *ini_source); +void _gst_set_element_properties(GstElement *element, GStrv key_value_pairs); #endif /* __TIZEN_MEDIA_WEBRTC_SOURCE_COMMON_H__ */ diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 8fd83972..423cbb37 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.255 +Version: 0.3.256 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 75c95d1a..fcdffcb5 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -1722,78 +1722,6 @@ bool _remove_elements_from_bin(GstBin *bin, GList *element_list) } //LCOV_EXCL_STOP -static void __parse_type_and_set_value(GType type, GstElement *element, GStrv key_value_pair) -{ - RET_IF(element == NULL, "element is NULL"); - RET_IF(key_value_pair == NULL, "key_value_pairs is NULL"); - RET_IF(key_value_pair[0] == NULL, "key is NULL"); - RET_IF(key_value_pair[1] == NULL, "value is NULL"); - - switch (type) { - case G_TYPE_STRING: - g_object_set(G_OBJECT(element), key_value_pair[0], key_value_pair[1], NULL); - break; - case G_TYPE_INT: - case G_TYPE_INT64: - case G_TYPE_ENUM: { - gint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10); - g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL); - break; - } - case G_TYPE_UINT: - case G_TYPE_UINT64: - case G_TYPE_BOOLEAN: { - guint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10); - g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL); - break; - } - case G_TYPE_FLOAT: - case G_TYPE_DOUBLE: { - gdouble value = g_ascii_strtod((const gchar *)key_value_pair[1], NULL); - g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL); - break; - } - default: - LOG_DEBUG("not supported type(0x%x) exactly, but try it with int64 type", (unsigned int)type); /* e.g.) custom enum type falls through here */ - gint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10); - g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL); - break; - } - - LOG_DEBUG("element[%s] property[%s] value[type:0x%x, %s]", GST_ELEMENT_NAME(element), key_value_pair[0], (unsigned int)type, key_value_pair[1]); -} - -void _gst_set_element_properties(GstElement *element, GStrv key_value_pairs) -{ - GStrv key_value_pair; - GParamSpec *param_spec; - - RET_IF(element == NULL, "element is NULL"); - - if (!key_value_pairs) - return; - - while (key_value_pairs && *key_value_pairs) { - key_value_pair = g_strsplit(*key_value_pairs++, "=", 2); - - if (!g_strcmp0(key_value_pair[0], "") || !g_strcmp0(key_value_pair[1], "")) { - LOG_ERROR("invalid key_value_pair, key[%s], value[%s]", key_value_pair[0], key_value_pair[1]); - g_strfreev(key_value_pair); - continue; - } - - if (!(param_spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(element)), g_strstrip(key_value_pair[0])))) { - LOG_ERROR("element[%s] does not have this property[%s]", GST_ELEMENT_NAME(element), key_value_pair[0]); - g_strfreev(key_value_pair); - continue; - } - - __parse_type_and_set_value(param_spec->value_type, element, key_value_pair); - - g_strfreev(key_value_pair); - } -} - static gboolean __check_id_equal_cb(gpointer key, gpointer value, gpointer user_data) { webrtc_gst_slot_s *slot = value; diff --git a/src/webrtc_source_private.c b/src/webrtc_source_private.c index 7e7a88ba..f4e1a469 100644 --- a/src/webrtc_source_private.c +++ b/src/webrtc_source_private.c @@ -1002,3 +1002,75 @@ bool _set_default_video_info(webrtc_gst_slot_s *source, const ini_item_media_sou return true; } + +static void __parse_type_and_set_value(GType type, GstElement *element, GStrv key_value_pair) +{ + RET_IF(element == NULL, "element is NULL"); + RET_IF(key_value_pair == NULL, "key_value_pairs is NULL"); + RET_IF(key_value_pair[0] == NULL, "key is NULL"); + RET_IF(key_value_pair[1] == NULL, "value is NULL"); + + switch (type) { + case G_TYPE_STRING: + g_object_set(G_OBJECT(element), key_value_pair[0], key_value_pair[1], NULL); + break; + case G_TYPE_INT: + case G_TYPE_INT64: + case G_TYPE_ENUM: { + gint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10); + g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL); + break; + } + case G_TYPE_UINT: + case G_TYPE_UINT64: + case G_TYPE_BOOLEAN: { + guint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10); + g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL); + break; + } + case G_TYPE_FLOAT: + case G_TYPE_DOUBLE: { + gdouble value = g_ascii_strtod((const gchar *)key_value_pair[1], NULL); + g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL); + break; + } + default: + LOG_DEBUG("not supported type(0x%x) exactly, but try it with int64 type", (unsigned int)type); /* e.g.) custom enum type falls through here */ + gint64 value = g_ascii_strtoll((const gchar *)key_value_pair[1], NULL, 10); + g_object_set(G_OBJECT(element), key_value_pair[0], value, NULL); + break; + } + + LOG_DEBUG("element[%s] property[%s] value[type:0x%x, %s]", GST_ELEMENT_NAME(element), key_value_pair[0], (unsigned int)type, key_value_pair[1]); +} + +void _gst_set_element_properties(GstElement *element, GStrv key_value_pairs) +{ + GStrv key_value_pair; + GParamSpec *param_spec; + + RET_IF(element == NULL, "element is NULL"); + + if (!key_value_pairs) + return; + + while (key_value_pairs && *key_value_pairs) { + key_value_pair = g_strsplit(*key_value_pairs++, "=", 2); + + if (!g_strcmp0(key_value_pair[0], "") || !g_strcmp0(key_value_pair[1], "")) { + LOG_ERROR("invalid key_value_pair, key[%s], value[%s]", key_value_pair[0], key_value_pair[1]); + g_strfreev(key_value_pair); + continue; + } + + if (!(param_spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(element)), g_strstrip(key_value_pair[0])))) { + LOG_ERROR("element[%s] does not have this property[%s]", GST_ELEMENT_NAME(element), key_value_pair[0]); + g_strfreev(key_value_pair); + continue; + } + + __parse_type_and_set_value(param_spec->value_type, element, key_value_pair); + + g_strfreev(key_value_pair); + } +} \ No newline at end of file