[Gstreamer-openmax] [PATCH 4/8] Handle properties common to all gstomx base classes with helper functions

Rob Clark rob at ti.com
Wed Mar 17 16:58:57 PDT 2010


This removes some common code from all base classes, and makes it easier to
add new common properties.

For now (and the foreseeable future)  all common properties are read-only,
but a gstomx_set_property_helper() could be added later if needed.
---
 omx/gstomx.c             |   32 ++++++++++++++++++++++++++++++++
 omx/gstomx.h             |   11 +++++++++++
 omx/gstomx_base_filter.c |   24 +++++-------------------
 omx/gstomx_base_sink.c   |   26 ++++----------------------
 omx/gstomx_base_src.c    |   26 ++++----------------------
 5 files changed, 56 insertions(+), 63 deletions(-)

diff --git a/omx/gstomx.c b/omx/gstomx.c
index ff232b0..86db3c3 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -333,6 +333,38 @@ gstomx_get_component_info (void *core,
     return TRUE;
 }
 
+void
+gstomx_install_property_helper (GObjectClass *gobject_class)
+{
+
+    g_object_class_install_property (gobject_class, ARG_COMPONENT_NAME,
+                                     g_param_spec_string ("component-name", "Component name",
+                                                          "Name of the OpenMAX IL component to use",
+                                                          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",
+                                                          NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+}
+
+gboolean
+gstomx_get_property_helper (void *core, guint prop_id, GValue *value)
+{
+    GOmxCore *gomx = core;
+    switch (prop_id)
+    {
+        case ARG_COMPONENT_NAME:
+            g_value_set_string (value, gomx->component_name);
+            return TRUE;
+        case ARG_LIBRARY_NAME:
+            g_value_set_string (value, gomx->library_name);
+            return TRUE;
+        default:
+            return FALSE;
+    }
+}
+
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
                    GST_VERSION_MINOR,
                    "omx",
diff --git a/omx/gstomx.h b/omx/gstomx.h
index b62773c..20414cb 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -30,9 +30,20 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
 GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
 #define GST_CAT_DEFAULT gstomx_debug
 
+enum
+{
+    GSTOMX_ARG_0,
+    ARG_COMPONENT_NAME,
+    ARG_LIBRARY_NAME,
+    GSTOMX_NUM_COMMON_PROP
+};
+
 gboolean gstomx_get_component_info (void *core,
                                     GType type);
 
+void gstomx_install_property_helper (GObjectClass *gobject_class);
+gboolean gstomx_get_property_helper (void *core, guint prop_id, GValue *value);
+
 G_END_DECLS
 
 #endif /* GSTOMX_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 7c388b5..98b40d5 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -27,10 +27,7 @@
 
 enum
 {
-    ARG_0,
-    ARG_COMPONENT_NAME,
-    ARG_LIBRARY_NAME,
-    ARG_USE_TIMESTAMPS,
+    ARG_USE_TIMESTAMPS = GSTOMX_NUM_COMMON_PROP,
 };
 
 static void init_interfaces (GType type);
@@ -201,14 +198,11 @@ get_property (GObject *obj,
 
     self = GST_OMX_BASE_FILTER (obj);
 
+    if (gstomx_get_property_helper (self->gomx, prop_id, value))
+        return;
+
     switch (prop_id)
     {
-        case ARG_COMPONENT_NAME:
-            g_value_set_string (value, self->gomx->component_name);
-            break;
-        case ARG_LIBRARY_NAME:
-            g_value_set_string (value, self->gomx->library_name);
-            break;
         case ARG_USE_TIMESTAMPS:
             g_value_set_boolean (value, self->use_timestamps);
             break;
@@ -241,15 +235,7 @@ type_class_init (gpointer g_class,
         gobject_class->set_property = set_property;
         gobject_class->get_property = get_property;
 
-        g_object_class_install_property (gobject_class, ARG_COMPONENT_NAME,
-                                         g_param_spec_string ("component-name", "Component name",
-                                                              "Name of the OpenMAX IL component to use",
-                                                              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",
-                                                              NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+        gstomx_install_property_helper (gobject_class);
 
         g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
                                          g_param_spec_boolean ("use-timestamps", "Use timestamps",
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 20c9ab7..7fd61d5 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -32,13 +32,6 @@ static gboolean share_input_buffer;
 
 static inline gboolean omx_init (GstOmxBaseSink *self);
 
-enum
-{
-    ARG_0,
-    ARG_COMPONENT_NAME,
-    ARG_LIBRARY_NAME,
-};
-
 static void init_interfaces (GType type);
 GSTOMX_BOILERPLATE_FULL (GstOmxBaseSink, gst_omx_base_sink, GstBaseSink, GST_TYPE_BASE_SINK, init_interfaces);
 
@@ -281,14 +274,11 @@ get_property (GObject *obj,
 
     self = GST_OMX_BASE_SINK (obj);
 
+    if (gstomx_get_property_helper (self->gomx, prop_id, value))
+        return;
+
     switch (prop_id)
     {
-        case ARG_COMPONENT_NAME:
-            g_value_set_string (value, self->gomx->component_name);
-            break;
-        case ARG_LIBRARY_NAME:
-            g_value_set_string (value, self->gomx->library_name);
-            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -324,15 +314,7 @@ type_class_init (gpointer g_class,
     {
         gobject_class->get_property = get_property;
 
-        g_object_class_install_property (gobject_class, ARG_COMPONENT_NAME,
-                                         g_param_spec_string ("component-name", "Component name",
-                                                              "Name of the OpenMAX IL component to use",
-                                                              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",
-                                                              NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+        gstomx_install_property_helper (gobject_class);
     }
 }
 
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 2c3fe11..00d27b6 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -24,13 +24,6 @@
 
 #include <string.h> /* for memcpy */
 
-enum
-{
-    ARG_0,
-    ARG_COMPONENT_NAME,
-    ARG_LIBRARY_NAME,
-};
-
 GSTOMX_BOILERPLATE (GstOmxBaseSrc, gst_omx_base_src, GstBaseSrc, GST_TYPE_BASE_SRC);
 
 static void
@@ -342,14 +335,11 @@ get_property (GObject *obj,
 
     self = GST_OMX_BASE_SRC (obj);
 
+    if (gstomx_get_property_helper (self->gomx, prop_id, value))
+        return;
+
     switch (prop_id)
     {
-        case ARG_COMPONENT_NAME:
-            g_value_set_string (value, self->gomx->component_name);
-            break;
-        case ARG_LIBRARY_NAME:
-            g_value_set_string (value, self->gomx->library_name);
-            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
             break;
@@ -382,15 +372,7 @@ type_class_init (gpointer g_class,
     {
         gobject_class->get_property = get_property;
 
-        g_object_class_install_property (gobject_class, ARG_COMPONENT_NAME,
-                                         g_param_spec_string ("component-name", "Component name",
-                                                              "Name of the OpenMAX IL component to use",
-                                                              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",
-                                                              NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+        gstomx_install_property_helper (gobject_class);
     }
 }
 
-- 
1.6.3.2





More information about the Gstreamer-openmax mailing list