diff options
author | Rob Clark <rob@ti.com> | 2010-03-29 08:07:24 -0500 |
---|---|---|
committer | Felipe Contreras <felipe.contreras@nokia.com> | 2010-04-16 17:47:29 +0300 |
commit | 4d955c27c602ac967eb9effd9794abb52f5a8154 (patch) | |
tree | 15b004d29345753c3a9ff8fb29c90dc65e00e84d | |
parent | b340cf1ddceb923d52fe4abd40536a73a9327a0f (diff) |
Add property helpers
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.
Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
-rw-r--r-- | omx/gstomx.c | 32 | ||||
-rw-r--r-- | omx/gstomx.h | 10 | ||||
-rw-r--r-- | omx/gstomx_base_filter.c | 24 | ||||
-rw-r--r-- | omx/gstomx_base_sink.c | 26 | ||||
-rw-r--r-- | omx/gstomx_base_src.c | 26 |
5 files changed, 55 insertions, 63 deletions
diff --git a/omx/gstomx.c b/omx/gstomx.c index 76b9c42..760b7f3 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -342,6 +342,38 @@ gstomx_core_new (void *object, GType type) return core; } +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 e646300..e875bee 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -30,10 +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_core_new (void *object, 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 diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c index 337e435..8278040 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 a6ede59..3cc5f99 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 b61b6fb..af0bd01 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); } } |