[Gstreamer-openmax] [PATCH 5/8] Add component-role support

Rob Clark rob at ti.com
Mon Mar 29 09:00:16 PDT 2010


---
v2: use strncpy since now component-role is coming from a config file
rather than a built in table
v3: remove .orig files that were not supposed to be committed

 omx/gstomx.c      |   14 +++++++++++++-
 omx/gstomx.h      |    1 +
 omx/gstomx_util.c |   23 +++++++++++++++++++++--
 omx/gstomx_util.h |    1 +
 4 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/omx/gstomx.c b/omx/gstomx.c
index 6871e98..8f4cdf0 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -247,7 +247,7 @@ plugin_init (GstPlugin *plugin)
         const gchar *element_name = gst_structure_nth_field_name (element_table, i);
         GstStructure *element = get_element_entry (element_name);
         const gchar *type_name, *parent_type_name;
-        const gchar *component_name, *library_name;
+        const gchar *component_name, *component_role, *library_name;
         GType type;
         gint rank;
 
@@ -256,6 +256,7 @@ plugin_init (GstPlugin *plugin)
         parent_type_name = gst_structure_get_string (element, "parent-type");
         type_name = gst_structure_get_string (element, "type");
         component_name = gst_structure_get_string (element, "component-name");
+        component_role = gst_structure_get_string (element, "component-role");
         library_name = gst_structure_get_string (element, "library-name");
 
         if (!type_name || !component_name || !library_name)
@@ -330,6 +331,9 @@ gstomx_get_component_info (void *core,
     str = gst_structure_get_string (element, "component-name");
     rcore->component_name = g_strdup (str);
 
+    str = gst_structure_get_string (element, "component-role");
+    rcore->component_role = g_strdup (str);
+
     return TRUE;
 }
 
@@ -355,6 +359,11 @@ gstomx_install_property_helper (GObjectClass *gobject_class)
                                                           "Name of the OpenMAX IL component to use",
                                                           NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
+    g_object_class_install_property (gobject_class, ARG_COMPONENT_ROLE,
+                                     g_param_spec_string ("component-role", "Component role",
+                                                          "Role of the OpenMAX IL component",
+                                                          NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
     g_object_class_install_property (gobject_class, ARG_LIBRARY_NAME,
                                      g_param_spec_string ("library-name", "Library name",
                                                           "Name of the OpenMAX IL implementation library to use",
@@ -370,6 +379,9 @@ gstomx_get_property_helper (void *core, guint prop_id, GValue *value)
         case ARG_COMPONENT_NAME:
             g_value_set_string (value, gomx->component_name);
             return TRUE;
+        case ARG_COMPONENT_ROLE:
+            g_value_set_string (value, gomx->component_role);
+            return TRUE;
         case ARG_LIBRARY_NAME:
             g_value_set_string (value, gomx->library_name);
             return TRUE;
diff --git a/omx/gstomx.h b/omx/gstomx.h
index 00888d6..eb163ab 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -34,6 +34,7 @@ enum
 {
     GSTOMX_ARG_0,
     ARG_COMPONENT_NAME,
+    ARG_COMPONENT_ROLE,
     ARG_LIBRARY_NAME,
     GSTOMX_NUM_COMMON_PROP
 };
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 4d91b6b..aae2c02 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -311,8 +311,10 @@ g_omx_core_free (GOmxCore *core)
 void
 g_omx_core_init (GOmxCore *core)
 {
-    GST_DEBUG_OBJECT (core->object, "loading: %s (%s)",
-            core->component_name, core->library_name);
+    GST_DEBUG_OBJECT (core->object, "loading: %s %s (%s)",
+            core->component_name,
+            core->component_role ? core->component_role : "",
+            core->library_name);
 
     core->imp = request_imp (core->library_name);
 
@@ -328,7 +330,23 @@ g_omx_core_init (GOmxCore *core)
             core->omx_handle, core->omx_error);
 
     if (!core->omx_error)
+    {
         core->omx_state = OMX_StateLoaded;
+
+        if (core->component_role)
+        {
+            OMX_PARAM_COMPONENTROLETYPE param;
+
+            GST_DEBUG_OBJECT (core->object, "setting component role: %s",
+                    core->component_role);
+
+            G_OMX_INIT_PARAM (param);
+
+            strncpy((char*)param.cRole, core->component_role, OMX_MAX_STRINGNAME_SIZE);
+
+            OMX_SetParameter (core->omx_handle, OMX_IndexParamStandardComponentRole, &param);
+        }
+    }
 }
 
 static void
@@ -355,6 +373,7 @@ core_deinit (GOmxCore *core)
 
     g_free (core->library_name);
     g_free (core->component_name);
+    g_free (core->component_role);
 
     release_imp (core->imp);
     core->imp = NULL;
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index fefdbfd..68832d3 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -94,6 +94,7 @@ struct GOmxCore
 
     gchar *library_name;
     gchar *component_name;
+    gchar *component_role;
 };
 
 struct GOmxPort
-- 
1.6.6





More information about the Gstreamer-openmax mailing list