Add internal API to find a specific element by name inside of the bin 42/236142/6
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 15 Jun 2020 06:58:58 +0000 (15:58 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 15 Jun 2020 22:47:00 +0000 (07:47 +0900)
ms_find_element_in_bin_by_name() is added.

[Version] 0.1.62
[Issue Type] New feature

Change-Id: I2223fd6598d7093f369ece4d7255731dd0d7bc4c
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/media_streamer_gst.h
packaging/capi-media-streamer.spec
src/media_streamer_gst.c

index 275a9f4..a0ad917 100644 (file)
@@ -178,6 +178,8 @@ int ms_find_type(media_streamer_s *ms_streamer, GstElement *element);
 
 GstElement *ms_find_element_in_bin_by_type(GstElement *bin, node_info_s *node_klass_type);
 
+GstElement *ms_find_element_in_bin_by_name(GstElement *bin, const gchar *name);
+
 int ms_add_no_target_ghostpad(GstElement *gst_bin, const char *ghost_pad_name, GstPadDirection pad_direction);
 
 void ms_rtpbin_pad_added_cb(GstElement *element, GstPad *new_pad, gpointer user_data);
index 4c8584e..ef8ad8b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamer
 Summary:    A Media Streamer API
-Version:    0.1.61
+Version:    0.1.62
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 7eae374..4e5ddbe 100644 (file)
@@ -500,7 +500,6 @@ GstElement *ms_find_element_in_bin_by_type(GstElement *bin, node_info_s *node_kl
                next_element = (GstElement *) g_value_get_object(&element_value);
                found_klass = gst_element_factory_get_klass(gst_element_get_factory(next_element));
 
-               /* Check if found element is of appropriate needed plugin class */
                if (g_strrstr(found_klass, node_klass_type->klass_name) ||
                        g_strrstr(GST_ELEMENT_NAME(next_element), node_klass_type->default_name)) {
                        ms_info("Found element by type [%s]", GST_ELEMENT_NAME(next_element));
@@ -518,6 +517,39 @@ GstElement *ms_find_element_in_bin_by_type(GstElement *bin, node_info_s *node_kl
        return found_element;
 }
 
+GstElement *ms_find_element_in_bin_by_name(GstElement *bin, const gchar *name)
+{
+       GValue element_value = G_VALUE_INIT;
+       GstElement *found_element = NULL;
+       GstElement *next_element = NULL;
+       GstIterator *bin_iterator = NULL;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(!bin, NULL, "bin is NULL");
+       ms_retvm_if(!name, NULL, "name is NULL");
+
+       bin_iterator = gst_bin_iterate_sorted(GST_BIN(bin));
+
+       while (GST_ITERATOR_OK == gst_iterator_next(bin_iterator, &element_value)) {
+               next_element = (GstElement *) g_value_get_object(&element_value);
+
+               if (g_strrstr(GST_ELEMENT_NAME(next_element), name)) {
+                       ms_info("Found element by name [%s]", GST_ELEMENT_NAME(next_element));
+                       found_element = next_element;
+                       break;
+               }
+
+               g_value_reset(&element_value);
+       }
+
+       gst_iterator_free(bin_iterator);
+
+       ms_debug_fleave();
+
+       return found_element;
+}
+
 static int __ms_factory_rank_compare(GstPluginFeature *first_feature, GstPluginFeature *second_feature)
 {
        ms_debug_fenter();