From: Rob C. <ro...@ti...> - 2010-03-29 13:07:32
|
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. --- v2: resolve conflicts after changes to previous patch omx/gstomx.c | 32 ++++++++++++++++++++++++++++++++ omx/gstomx.h | 10 ++++++++++ omx/gstomx_base_filter.c | 24 +++++------------------- omx/gstomx_base_sink.c | 26 ++++---------------------- omx/gstomx_base_src.c | 26 ++++---------------------- 5 files changed, 55 insertions(+), 63 deletions(-) diff --git a/omx/gstomx.c b/omx/gstomx.c index 2a3a0b7..6871e98 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -346,6 +346,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 4f07fd6..00888d6 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 4e7fb28..2dbf850 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); } } -- 1.6.6 |