|
From: Rob C. <ro...@ti...> - 2010-03-06 21:04:33
|
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 | 38 ++++++++++++--------------------------
omx/gstomx_base_sink.c | 34 ++++++++--------------------------
omx/gstomx_base_src.c | 34 ++++++++--------------------------
5 files changed, 71 insertions(+), 78 deletions(-)
diff --git a/omx/gstomx.c b/omx/gstomx.c
index cc8f3f8..e35ef3d 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -319,6 +319,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..7557fd4 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_LAST_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 6ddfc85..400cf9c 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_LAST_COMMON_PROP,
};
static GstElementClass *parent_class;
@@ -220,20 +217,17 @@ get_property (GObject *obj,
self = GST_OMX_BASE_FILTER (obj);
- switch (prop_id)
+ if (! gstomx_get_property_helper (self->gomx, prop_id, value))
{
- 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;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
+ switch (prop_id)
+ {
+ case ARG_USE_TIMESTAMPS:
+ g_value_set_boolean (value, self->use_timestamps);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
}
@@ -257,15 +251,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 560a0f1..3dbaba0 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 GstElementClass *parent_class;
static void
@@ -293,17 +286,14 @@ get_property (GObject *obj,
self = GST_OMX_BASE_SINK (obj);
- switch (prop_id)
+ if (! gstomx_get_property_helper (self->gomx, prop_id, value))
{
- 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;
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
}
@@ -333,15 +323,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 d09a8d2..9baae01 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -24,13 +24,6 @@
#include <string.h> /* for memset, memcpy */
-enum
-{
- ARG_0,
- ARG_COMPONENT_NAME,
- ARG_LIBRARY_NAME,
-};
-
static GstElementClass *parent_class;
static void
@@ -357,17 +350,14 @@ get_property (GObject *obj,
self = GST_OMX_BASE_SRC (obj);
- switch (prop_id)
+ if (! gstomx_get_property_helper (self->gomx, prop_id, value))
{
- 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;
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
}
@@ -394,15 +384,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
|