[Gstreamer-openmax] [PATCH 3/5] Reorganize {library, component}-name assigns

Felipe Contreras felipe.contreras at nokia.com
Wed Mar 3 14:51:13 PST 2010


Based on a patch by Rob Clark.

Signed-off-by: Felipe Contreras <felipe.contreras at nokia.com>
---
 omx/gstomx.c             |   30 ++++++++++++++++++++++++------
 omx/gstomx.h             |    3 +++
 omx/gstomx_base_filter.c |   11 +----------
 omx/gstomx_base_sink.c   |   11 +----------
 omx/gstomx_base_src.c    |   11 +----------
 5 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/omx/gstomx.c b/omx/gstomx.c
index 89c9db5..f3c6470 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -208,16 +208,12 @@ create_subtype (GType parent_type, const gchar *type_name)
 static gboolean
 plugin_init (GstPlugin *plugin)
 {
-    GQuark library_name_quark;
-    GQuark component_name_quark;
     gint i, cnt;
     GstStructure *element_table;
 
     GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
     GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
 
-    library_name_quark = g_quark_from_static_string ("library-name");
-    component_name_quark = g_quark_from_static_string ("component-name");
     element_name_quark = g_quark_from_static_string ("element-name");
 
     /*
@@ -281,8 +277,6 @@ plugin_init (GstPlugin *plugin)
             return FALSE;
         }
 
-        g_type_set_qdata (type, library_name_quark, (gpointer) library_name);
-        g_type_set_qdata (type, component_name_quark, (gpointer) component_name);
         g_type_set_qdata (type, element_name_quark, (gpointer) element_name);
 
         if (!gst_structure_get_int (element, "rank", &rank))
@@ -301,6 +295,30 @@ plugin_init (GstPlugin *plugin)
     return TRUE;
 }
 
+gboolean
+gstomx_get_component_info (void *core,
+                           GType type)
+{
+    GOmxCore *rcore = core;
+    const gchar *element_name;
+    GstStructure *element;
+    const gchar *str;
+
+    element_name = g_type_get_qdata (type, element_name_quark);
+    element = get_element_entry (element_name);
+
+    if (!element)
+        return FALSE;
+
+    str = gst_structure_get_string (element, "library-name");
+    rcore->library_name = g_strdup (str);
+
+    str = gst_structure_get_string (element, "component-name");
+    rcore->component_name = g_strdup (str);
+
+    return TRUE;
+}
+
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
                    GST_VERSION_MINOR,
                    "omx",
diff --git a/omx/gstomx.h b/omx/gstomx.h
index 7d5fa04..b62773c 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -30,6 +30,9 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
 GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
 #define GST_CAT_DEFAULT gstomx_debug
 
+gboolean gstomx_get_component_info (void *core,
+                                    GType type);
+
 G_END_DECLS
 
 #endif /* GSTOMX_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 626f979..01ca10a 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -898,6 +898,7 @@ type_instance_init (GTypeInstance *instance,
     {
         GOmxCore *gomx;
         self->gomx = gomx = g_omx_core_new (self);
+        gstomx_get_component_info (gomx, G_TYPE_FROM_CLASS (g_class));
     }
 
     self->ready_lock = g_mutex_new ();
@@ -918,16 +919,6 @@ type_instance_init (GTypeInstance *instance,
     gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
     gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
 
-    {
-        const char *tmp;
-        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
-                                g_quark_from_static_string ("library-name"));
-        self->gomx->library_name = g_strdup (tmp);
-        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
-                                g_quark_from_static_string ("component-name"));
-        self->gomx->component_name = g_strdup (tmp);
-    }
-
     GST_LOG_OBJECT (self, "end");
 }
 
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index aec2b68..ac32799 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -461,16 +461,7 @@ type_instance_init (GTypeInstance *instance,
     {
         GOmxCore *gomx;
         self->gomx = gomx = g_omx_core_new (self);
-    }
-
-    {
-        const char *tmp;
-        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
-                                g_quark_from_static_string ("library-name"));
-        self->gomx->library_name = g_strdup (tmp);
-        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
-                                g_quark_from_static_string ("component-name"));
-        self->gomx->component_name = g_strdup (tmp);
+        gstomx_get_component_info (gomx, G_TYPE_FROM_CLASS (g_class));
     }
 
     {
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 9439455..51aa189 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -447,16 +447,7 @@ type_instance_init (GTypeInstance *instance,
     {
         GOmxCore *gomx;
         self->gomx = gomx = g_omx_core_new (self);
-    }
-
-    {
-        const char *tmp;
-        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
-                                g_quark_from_static_string ("library-name"));
-        self->gomx->library_name = g_strdup (tmp);
-        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
-                                g_quark_from_static_string ("component-name"));
-        self->gomx->component_name = g_strdup (tmp);
+        gstomx_get_component_info (gomx, G_TYPE_FROM_CLASS (g_class));
     }
 
     GST_LOG_OBJECT (self, "end");
-- 
1.7.0.1





More information about the Gstreamer-openmax mailing list