|
From: Rob C. <ro...@ti...> - 2010-03-17 23:58:45
|
Rebased on top of 'port cleanups' patchset.
Now, OMX component is instantiated when GOmxCore is constructed. So the
patchset no longer includes the g_omx_core_{get,set}_{config,param} helper
functions as these were not needed as much anymore. (Although it might be
nice to add them later, so at least there is a common place to put an error
traces if any of the OMX_{Get,Set}{Config,Param}() calls returns an error.)
Rob Clark (8):
core: call OMX_GetHandle in g_omx_core_new
Add some debug traces
Add G_OMX_INIT_PARAM utility macro
Handle properties common to all gstomx base classes with helper
functions
Add component-role support
Add input-buffers/output-buffers properties to the base classes
Add some debug traces
Add GstOmxBaseAudioDec base class
omx/Makefile.am | 1 +
omx/gstomx.c | 46 ++++++++++++++++++-
omx/gstomx.h | 12 +++++
omx/gstomx_aacdec.c | 50 +--------------------
omx/gstomx_aacdec.h | 6 +-
omx/gstomx_aacenc.c | 22 ++-------
omx/gstomx_adpcmdec.c | 8 +---
omx/gstomx_adpcmenc.c | 12 +----
omx/gstomx_amrnbdec.c | 53 +---------------------
omx/gstomx_amrnbdec.h | 6 +-
omx/gstomx_amrnbenc.c | 12 +----
omx/gstomx_amrwbdec.c | 53 +---------------------
omx/gstomx_amrwbdec.h | 6 +-
omx/gstomx_amrwbenc.c | 12 +----
omx/gstomx_audiosink.c | 7 +---
omx/gstomx_base_audiodec.c | 97 +++++++++++++++++++++++++++++++++++++++
omx/gstomx_base_audiodec.h | 53 +++++++++++++++++++++
omx/gstomx_base_filter.c | 108 +++++++++++++++++++++++++++++++++-----------
omx/gstomx_base_sink.c | 103 +++++++++++++++++++++++++++++++----------
omx/gstomx_base_src.c | 95 ++++++++++++++++++++++++++++++---------
omx/gstomx_base_videodec.c | 18 +------
omx/gstomx_base_videoenc.c | 13 ++----
omx/gstomx_g711dec.c | 8 +--
omx/gstomx_g711enc.c | 7 +--
omx/gstomx_g729dec.c | 4 +-
omx/gstomx_g729dec.h | 6 +-
omx/gstomx_g729enc.c | 7 +---
omx/gstomx_h263enc.c | 7 +---
omx/gstomx_h264enc.c | 7 +---
omx/gstomx_ilbcdec.c | 1 +
omx/gstomx_jpegenc.c | 20 ++-------
omx/gstomx_mp2dec.c | 60 +------------------------
omx/gstomx_mp2dec.h | 6 +-
omx/gstomx_mp3dec.c | 61 +------------------------
omx/gstomx_mp3dec.h | 6 +-
omx/gstomx_mpeg4enc.c | 7 +---
omx/gstomx_util.c | 79 ++++++++++++++++++++++++++++----
omx/gstomx_util.h | 14 +++++-
omx/gstomx_videosink.c | 17 ++-----
omx/gstomx_volume.c | 7 +---
omx/gstomx_vorbisdec.c | 50 +--------------------
omx/gstomx_vorbisdec.h | 6 +-
42 files changed, 589 insertions(+), 584 deletions(-)
create mode 100644 omx/gstomx_base_audiodec.c
create mode 100644 omx/gstomx_base_audiodec.h
|
|
From: Rob C. <ro...@ti...> - 2010-03-17 23:58:45
|
This way omx_handle is always valid, and can be used in get/set_property
methods.
---
omx/gstomx_base_filter.c | 8 +-------
omx/gstomx_base_sink.c | 5 +----
omx/gstomx_base_src.c | 5 +----
omx/gstomx_util.c | 23 ++++++++++++++++++-----
omx/gstomx_util.h | 4 +---
5 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index e12fcd2..871c395 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -101,7 +101,6 @@ change_state (GstElement *element,
switch (transition)
{
case GST_STATE_CHANGE_NULL_TO_READY:
- g_omx_core_init (core);
if (core->omx_state != OMX_StateLoaded)
{
ret = GST_STATE_CHANGE_FAILURE;
@@ -141,10 +140,6 @@ change_state (GstElement *element,
}
break;
- case GST_STATE_CHANGE_READY_TO_NULL:
- g_omx_core_deinit (core);
- break;
-
default:
break;
}
@@ -875,8 +870,7 @@ type_instance_init (GTypeInstance *instance,
self->use_timestamps = TRUE;
- self->gomx = g_omx_core_new (self);
- gstomx_get_component_info (self->gomx, G_TYPE_FROM_CLASS (g_class));
+ self->gomx = g_omx_core_new (self, g_class);
self->in_port = g_omx_core_new_port (self->gomx, 0);
self->out_port = g_omx_core_new_port (self->gomx, 1);
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index b6a8955..e78db32 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -381,8 +381,6 @@ activate_push (GstPad *pad,
static inline gboolean
omx_init (GstOmxBaseSink *self)
{
- g_omx_core_init (self->gomx);
-
if (self->gomx->omx_error)
return FALSE;
@@ -421,8 +419,7 @@ type_instance_init (GTypeInstance *instance,
GST_LOG_OBJECT (self, "begin");
- self->gomx = g_omx_core_new (self);
- gstomx_get_component_info (self->gomx, G_TYPE_FROM_CLASS (g_class));
+ self->gomx = g_omx_core_new (self, g_class);
self->in_port = g_omx_core_new_port (self->gomx, 0);
{
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index fea7631..888a447 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -54,7 +54,6 @@ start (GstBaseSrc *gst_base)
GST_LOG_OBJECT (self, "begin");
- g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -74,7 +73,6 @@ stop (GstBaseSrc *gst_base)
g_omx_core_stop (self->gomx);
g_omx_core_unload (self->gomx);
- g_omx_core_deinit (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -406,8 +404,7 @@ type_instance_init (GTypeInstance *instance,
GST_LOG_OBJECT (self, "begin");
- self->gomx = g_omx_core_new (self);
- gstomx_get_component_info (self->gomx, G_TYPE_FROM_CLASS (g_class));
+ self->gomx = g_omx_core_new (self, g_class);
self->out_port = g_omx_core_new_port (self->gomx, 1);
GST_LOG_OBJECT (self, "end");
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index b1c869a..115ca84 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -79,6 +79,9 @@ omx_error_to_str (OMX_ERRORTYPE omx_error);
static inline GOmxPort * get_port (GOmxCore *core, guint index);
+static void core_init (GOmxCore *core);
+static void core_deinit (GOmxCore *core);
+
static inline void
port_free_buffers (GOmxPort *port);
@@ -264,7 +267,7 @@ g_omx_deinit (void)
*/
GOmxCore *
-g_omx_core_new (void *object)
+g_omx_core_new (void *object, gpointer g_class)
{
GOmxCore *core;
@@ -282,12 +285,22 @@ g_omx_core_new (void *object)
core->omx_state = OMX_StateInvalid;
+ /* it is a bit awkward to have to pass the element's g_class to
+ * g_omx_core_new(), but since this is called from type_inistance_init
+ * function, we can't rely on G_OBJECT_TYPE()..
+ */
+ gstomx_get_component_info (core, G_TYPE_FROM_CLASS (g_class));
+
+ core_init (core);
+
return core;
}
void
g_omx_core_free (GOmxCore *core)
{
+ core_deinit (core);
+
g_sem_free (core->port_sem);
g_sem_free (core->flush_sem);
g_sem_free (core->done_sem);
@@ -300,8 +313,8 @@ g_omx_core_free (GOmxCore *core)
g_free (core);
}
-void
-g_omx_core_init (GOmxCore *core)
+static void
+core_init (GOmxCore *core)
{
core->imp = request_imp (core->library_name);
@@ -316,8 +329,8 @@ g_omx_core_init (GOmxCore *core)
core->omx_state = OMX_StateLoaded;
}
-void
-g_omx_core_deinit (GOmxCore *core)
+static void
+core_deinit (GOmxCore *core)
{
if (!core->imp)
return;
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index 456f9a8..d373193 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -117,10 +117,8 @@ struct GOmxPort
void g_omx_init (void);
void g_omx_deinit (void);
-GOmxCore *g_omx_core_new (void *object);
+GOmxCore *g_omx_core_new (void *object, gpointer g_class);
void g_omx_core_free (GOmxCore *core);
-void g_omx_core_init (GOmxCore *core);
-void g_omx_core_deinit (GOmxCore *core);
void g_omx_core_prepare (GOmxCore *core);
void g_omx_core_start (GOmxCore *core);
void g_omx_core_pause (GOmxCore *core);
--
1.6.3.2
|
|
From: Rob C. <ro...@ti...> - 2010-03-17 23:58:50
|
---
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 86db3c3..70a789f 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;
}
@@ -342,6 +346,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",
@@ -357,6 +366,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 20414cb..1ef73f2 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 bbf699b..103c919 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -320,8 +320,10 @@ g_omx_core_free (GOmxCore *core)
static void
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);
@@ -337,7 +339,23 @@ 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);
+
+ strcpy((char*)param.cRole, core->component_role);
+
+ OMX_SetParameter (core->omx_handle, OMX_IndexParamStandardComponentRole, ¶m);
+ }
+ }
}
static void
@@ -364,6 +382,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 8608a66..19047da 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.3.2
|
|
From: Felipe C. <fel...@gm...> - 2010-03-23 22:38:22
|
On Thu, Mar 18, 2010 at 1:58 AM, Rob Clark <ro...@ti...> wrote:
> @@ -337,7 +339,23 @@ 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);
> +
> + strcpy((char*)param.cRole, core->component_role);
How about strncpy with OMX_MAX_STRINGNAME_SIZE instead?
Otherwise looks ok. Thanks.
--
Felipe Contreras
|
|
From: Rob C. <ro...@ti...> - 2010-03-29 13:08:28
|
---
v2: use strncpy since now component-role is coming from a config file
rather than a built in table
omx/gstomx.c | 14 ++-
omx/gstomx.c.orig | 390 +++++++++++++++++++++++++++++++++++++++++++++++++++++
omx/gstomx.h | 1 +
omx/gstomx.h.orig | 53 +++++++
omx/gstomx_util.c | 23 +++-
omx/gstomx_util.h | 1 +
6 files changed, 479 insertions(+), 3 deletions(-)
create mode 100644 omx/gstomx.c.orig
create mode 100644 omx/gstomx.h.orig
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.c.orig b/omx/gstomx.c.orig
new file mode 100644
index 0000000..cf08245
--- /dev/null
+++ b/omx/gstomx.c.orig
@@ -0,0 +1,390 @@
+/*
+ * Copyright (C) 2007-2009 Nokia Corporation.
+ *
+ * Author: Felipe Contreras <fel...@no...>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gst/gststructure.h>
+
+#include "gstomx.h"
+#include "gstomx_dummy.h"
+#include "gstomx_mpeg4dec.h"
+#include "gstomx_h263dec.h"
+#include "gstomx_h264dec.h"
+#include "gstomx_wmvdec.h"
+#include "gstomx_mpeg4enc.h"
+#include "gstomx_h264enc.h"
+#include "gstomx_h263enc.h"
+#include "gstomx_vorbisdec.h"
+#include "gstomx_mp3dec.h"
+#ifdef EXPERIMENTAL
+#include "gstomx_mp2dec.h"
+#include "gstomx_aacdec.h"
+#include "gstomx_aacenc.h"
+#include "gstomx_amrnbdec.h"
+#include "gstomx_amrnbenc.h"
+#include "gstomx_amrwbdec.h"
+#include "gstomx_amrwbenc.h"
+#include "gstomx_adpcmdec.h"
+#include "gstomx_adpcmenc.h"
+#include "gstomx_g711dec.h"
+#include "gstomx_g711enc.h"
+#include "gstomx_g729dec.h"
+#include "gstomx_g729enc.h"
+#include "gstomx_ilbcdec.h"
+#include "gstomx_ilbcenc.h"
+#include "gstomx_jpegenc.h"
+#endif /* EXPERIMENTAL */
+#include "gstomx_audiosink.h"
+#ifdef EXPERIMENTAL
+#include "gstomx_videosink.h"
+#include "gstomx_filereadersrc.h"
+#endif /* EXPERIMENTAL */
+#include "gstomx_volume.h"
+
+GST_DEBUG_CATEGORY (gstomx_debug);
+
+const static GstStructure *element_table;
+static GQuark element_name_quark;
+
+extern const gchar *default_config;
+
+static GType (*get_type[]) (void) = {
+ gst_omx_dummy_get_type,
+ gst_omx_mpeg4dec_get_type,
+ gst_omx_h264dec_get_type,
+ gst_omx_h263dec_get_type,
+ gst_omx_wmvdec_get_type,
+ gst_omx_mpeg4enc_get_type,
+ gst_omx_h264enc_get_type,
+ gst_omx_h263enc_get_type,
+ gst_omx_vorbisdec_get_type,
+ gst_omx_mp3dec_get_type,
+#ifdef EXPERIMENTAL
+ gst_omx_mp2dec_get_type,
+ gst_omx_amrnbdec_get_type,
+ gst_omx_amrnbenc_get_type,
+ gst_omx_amrwbdec_get_type,
+ gst_omx_amrwbenc_get_type,
+ gst_omx_aacdec_get_type,
+ gst_omx_aacenc_get_type,
+ gst_omx_adpcmdec_get_type,
+ gst_omx_adpcmenc_get_type,
+ gst_omx_g711dec_get_type,
+ gst_omx_g711enc_get_type,
+ gst_omx_g729dec_get_type,
+ gst_omx_g729enc_get_type,
+ gst_omx_ilbcdec_get_type,
+ gst_omx_ilbcenc_get_type,
+ gst_omx_jpegenc_get_type,
+#endif /* EXPERIMENTAL */
+ gst_omx_audiosink_get_type,
+#ifdef EXPERIMENTAL
+ gst_omx_videosink_get_type,
+ gst_omx_filereadersrc_get_type,
+#endif /* EXPERIMENTAL */
+ gst_omx_volume_get_type,
+};
+
+static gchar *
+get_config_path (void)
+{
+ gchar *path;
+ const gchar *const *dirs;
+ int i;
+
+ path = g_strdup (g_getenv ("OMX_CONFIG"));
+
+ if (path)
+ return path;
+
+ dirs = g_get_system_config_dirs ();
+ for (i = 0; dirs[i]; i++)
+ {
+ path = g_build_filename (dirs[i], "gstreamer-0.10", "gst-openmax.conf", NULL);
+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
+ return path;
+ g_free (path);
+ }
+
+ return g_build_filename (g_get_user_config_dir (),
+ "gst-openmax.conf", NULL);
+}
+
+static void
+fetch_element_table (GstPlugin *plugin)
+{
+ gchar *path;
+ gchar *config, *s;
+ GstStructure *tmp, *element;
+
+ element_table = gst_plugin_get_cache_data (plugin);
+
+ if (element_table)
+ return;
+
+ path = get_config_path ();
+
+ if (!g_file_get_contents (path, &config, NULL, NULL))
+ {
+ g_warning ("could not find config file '%s'.. using defaults!", path);
+ config = (gchar *) default_config;
+ }
+
+ gst_plugin_add_dependency_simple (plugin, "ONX_CONFIG", path, NULL,
+ GST_PLUGIN_DEPENDENCY_FLAG_NONE);
+
+ g_free (path);
+
+ GST_DEBUG ("parsing config:\n%s", config);
+
+ tmp = gst_structure_empty_new ("element_table");
+
+ s = config;
+
+ while ((element = gst_structure_from_string (s, &s)))
+ {
+ const gchar *element_name = gst_structure_get_name (element);
+ gst_structure_set (tmp,
+ element_name, GST_TYPE_STRUCTURE, element, NULL);
+ }
+
+ if (config != default_config)
+ g_free (config);
+
+ GST_DEBUG ("element_table=%" GST_PTR_FORMAT, tmp);
+
+ gst_plugin_set_cache_data (plugin, tmp);
+
+ element_table = tmp;
+}
+
+static GstStructure *
+get_element_entry (const gchar *element_name)
+{
+ GstStructure *element;
+
+ if (!gst_structure_get ((GstStructure *) element_table, element_name,
+ GST_TYPE_STRUCTURE, &element, NULL))
+ {
+ element = NULL;
+ }
+
+ /* This assert should never fail, because plugin elements are registered
+ * based on the entries in this table. Someone would have to manually
+ * override the type qdata for this to fail.
+ */
+ g_assert (element);
+
+ return element;
+}
+
+/* register a new dynamic sub-class with the name 'type_name'.. this gives us
+ * a way to use the same (for example) GstOmxMp3Dec element mapping to
+ * multiple different element names with different OMX library implementations
+ * and/or component names
+ */
+static GType
+create_subtype (GType parent_type, const gchar *type_name)
+{
+ GTypeQuery q;
+ GTypeInfo i = {0};
+
+ if (!type_name)
+ return 0;
+
+ g_type_query (parent_type, &q);
+
+ i.class_size = q.class_size;
+ i.instance_size = q.instance_size;
+
+ return g_type_register_static (parent_type, type_name, &i, 0);
+}
+
+static gboolean
+plugin_init (GstPlugin *plugin)
+{
+ gint i, cnt;
+
+ GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
+ GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
+
+ element_name_quark = g_quark_from_static_string ("element-name");
+
+ /*
+ * First, call all the _get_type() functions to ensure the types are
+ * registered.
+ */
+ for (i = 0; i < G_N_ELEMENTS (get_type); i++)
+ get_type[i] ();
+
+ fetch_element_table (plugin);
+
+ g_omx_init ();
+
+ cnt = gst_structure_n_fields (element_table);
+ for (i = 0; i < cnt; i++)
+ {
+ 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;
+ GType type;
+ gint rank;
+
+ GST_DEBUG ("element_name=%s, element=%" GST_PTR_FORMAT, element_name, element);
+
+ 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");
+ library_name = gst_structure_get_string (element, "library-name");
+
+ if (!type_name || !component_name || !library_name)
+ {
+ g_warning ("malformed config file: missing required fields for %s",
+ element_name);
+ return FALSE;
+ }
+
+ if (parent_type_name)
+ {
+ type = g_type_from_name (parent_type_name);
+ if (type)
+ {
+ type = create_subtype (type, type_name);
+ }
+ else
+ {
+ g_warning ("malformed config file: invalid parent-type '%s' for %s",
+ parent_type_name, element_name);
+ return FALSE;
+ }
+ }
+ else
+ {
+ type = g_type_from_name (type_name);
+ }
+
+ if (!type)
+ {
+ g_warning ("malformed config file: invalid type '%s' for %s",
+ type_name, element_name);
+ return FALSE;
+ }
+
+ g_type_set_qdata (type, element_name_quark, (gpointer) element_name);
+
+ if (!gst_structure_get_int (element, "rank", &rank))
+ {
+ /* use default rank: */
+ rank = GST_RANK_NONE;
+ }
+
+ if (!gst_element_register (plugin, element_name, rank, type))
+ {
+ g_warning ("failed registering '%s'", element_name);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+gboolean
+gstomx_get_component_info (void *core,
+ GType type)
+{
+ GOmxCore *rcore = core;
+ const gchar *element_name;
+ GstStructure *element;
+ const gchar *str;
+
+ element_name = g_type_get_qdata (type, element_name_quark);
+ element = get_element_entry (element_name);
+
+ if (!element)
+ return FALSE;
+
+ str = gst_structure_get_string (element, "library-name");
+ rcore->library_name = g_strdup (str);
+
+ str = gst_structure_get_string (element, "component-name");
+ rcore->component_name = g_strdup (str);
+
+ return TRUE;
+}
+
+<<<<<<< HEAD
+/* for now, to keep gst out of g_omx.. if later g_omx becomes gstomx
+ * then this could be combined with the existing g_omx_core_new()
+ * and g_omx_core_init() could be made static/private
+ */
+void *
+gstomx_core_new (void *object, GType type)
+{
+ GOmxCore *core = g_omx_core_new (object);
+ gstomx_get_component_info (core, type);
+ g_omx_core_init (core);
+ 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;
+ }
+>>>>>>> abd4b5d... Handle properties common to all gstomx base classes with helper functions
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "omx",
+ "OpenMAX IL",
+ plugin_init,
+ PACKAGE_VERSION,
+ GST_LICENSE,
+ GST_PACKAGE_NAME,
+ GST_PACKAGE_ORIGIN)
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.h.orig b/omx/gstomx.h.orig
new file mode 100644
index 0000000..b1e2ce9
--- /dev/null
+++ b/omx/gstomx.h.orig
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007-2009 Nokia Corporation.
+ *
+ * Author: Felipe Contreras <fel...@no...>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef GSTOMX_H
+#define GSTOMX_H
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+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);
+
+<<<<<<< HEAD
+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);
+>>>>>>> abd4b5d... Handle properties common to all gstomx base classes with helper functions
+
+G_END_DECLS
+
+#endif /* GSTOMX_H */
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, ¶m);
+ }
+ }
}
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
|
|
From: Felipe C. <fel...@gm...> - 2010-03-29 14:57:10
|
On Mon, Mar 29, 2010 at 4:08 PM, Rob Clark <ro...@ti...> wrote:
> ---
> v2: use strncpy since now component-role is coming from a config file
> rather than a built in table
> +<<<<<<< HEAD
> +/* for now, to keep gst out of g_omx.. if later g_omx becomes gstomx
> + * then this could be combined with the existing g_omx_core_new()
> + * and g_omx_core_init() could be made static/private
> + */
> +void *
> +gstomx_core_new (void *object, GType type)
> +{
> + GOmxCore *core = g_omx_core_new (object);
> + gstomx_get_component_info (core, type);
> + g_omx_core_init (core);
> + return core;
> +=======
Looks like there are some unresolved conflicts.
--
Felipe Contreras
|
|
From: Rob C. <ro...@ti...> - 2010-03-29 16:00:26
|
---
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, ¶m);
+ }
+ }
}
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
|
|
From: Felipe C. <fel...@gm...> - 2010-04-16 14:55:40
|
On Mon, Mar 29, 2010 at 7:00 PM, Rob Clark <ro...@ti...> wrote: > --- > 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(-) Applied with minor changes, please check the diff. -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-03-17 23:58:50
|
---
omx/gstomx_util.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 115ca84..f14cc86 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -160,7 +160,12 @@ imp_new (const gchar *name)
{
void *handle;
+ GST_DEBUG ("loading: %s", name);
+
imp->dl_handle = handle = dlopen (name, RTLD_LAZY);
+
+ GST_DEBUG ("dlopen(%s) -> %p", name, handle);
+
if (!handle)
{
g_warning ("%s\n", dlerror ());
@@ -316,6 +321,9 @@ g_omx_core_free (GOmxCore *core)
static void
core_init (GOmxCore *core)
{
+ GST_DEBUG_OBJECT (core->object, "loading: %s (%s)",
+ core->component_name, core->library_name);
+
core->imp = request_imp (core->library_name);
if (!core->imp)
@@ -325,6 +333,10 @@ core_init (GOmxCore *core)
(char *) core->component_name,
core,
&callbacks);
+
+ GST_DEBUG_OBJECT (core->object, "OMX_GetHandle(&%p) -> %d",
+ core->omx_handle, core->omx_error);
+
if (!core->omx_error)
core->omx_state = OMX_StateLoaded;
}
@@ -339,7 +351,16 @@ core_deinit (GOmxCore *core)
core->omx_state == OMX_StateInvalid)
{
if (core->omx_handle)
+ {
core->omx_error = core->imp->sym_table.free_handle (core->omx_handle);
+ GST_DEBUG_OBJECT (core->object, "OMX_FreeHandle(%p) -> %d",
+ core->omx_handle, core->omx_error);
+ }
+ }
+ else
+ {
+ GST_WARNING_OBJECT (core->object, "Incorrect state: %s",
+ omx_state_to_str (core->omx_state));
}
g_free (core->library_name);
@@ -530,6 +551,10 @@ g_omx_port_setup (GOmxPort *port)
port->num_buffers = param.nBufferCountActual;
port->buffer_size = param.nBufferSize;
+ GST_DEBUG_OBJECT (port->core->object,
+ "type=%d, num_buffers=%d, buffer_size=%ld, port_index=%d",
+ port->type, port->num_buffers, port->buffer_size, port->port_index);
+
g_free (port->buffers);
port->buffers = g_new0 (OMX_BUFFERHEADERTYPE *, port->num_buffers);
}
@@ -862,6 +887,8 @@ EventHandler (OMX_HANDLETYPE omx_handle,
cmd = (OMX_COMMANDTYPE) data_1;
+ GST_DEBUG_OBJECT (core->object, "OMX_EventCmdComplete: %d", cmd);
+
switch (cmd)
{
case OMX_CommandStateSet:
@@ -880,6 +907,7 @@ EventHandler (OMX_HANDLETYPE omx_handle,
}
case OMX_EventBufferFlag:
{
+ GST_DEBUG_OBJECT (core->object, "OMX_EventBufferFlag");
if (data_2 & OMX_BUFFERFLAG_EOS)
{
g_omx_core_set_done (core);
@@ -888,6 +916,7 @@ EventHandler (OMX_HANDLETYPE omx_handle,
}
case OMX_EventPortSettingsChanged:
{
+ GST_DEBUG_OBJECT (core->object, "OMX_EventPortSettingsChanged");
/** @todo only on the relevant port. */
if (core->settings_changed_cb)
{
--
1.6.3.2
|
|
From: Felipe C. <fel...@gm...> - 2010-03-23 22:34:46
|
On Thu, Mar 18, 2010 at 1:58 AM, Rob Clark <ro...@ti...> wrote: > --- > omx/gstomx_util.c | 29 +++++++++++++++++++++++++++++ > 1 files changed, 29 insertions(+), 0 deletions(-) ACK. -- Felipe Contreras |
|
From: Felipe C. <fel...@no...> - 2010-04-16 14:44:11
|
On Thu, Mar 18, 2010 at 12:58:55AM +0100, Rob Clark wrote: > --- > omx/gstomx_util.c | 29 +++++++++++++++++++++++++++++ > 1 files changed, 29 insertions(+), 0 deletions(-) There was a small conflict due to changes on the previous patch. Also, I changed a bit some whitespaces. Thanks. -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-03-17 23:58:51
|
---
omx/gstomx_aacdec.c | 7 +------
omx/gstomx_aacenc.c | 22 ++++------------------
omx/gstomx_adpcmdec.c | 7 +------
omx/gstomx_adpcmenc.c | 12 ++----------
omx/gstomx_amrnbdec.c | 7 +------
omx/gstomx_amrnbenc.c | 12 ++----------
omx/gstomx_amrwbdec.c | 7 +------
omx/gstomx_amrwbenc.c | 12 ++----------
omx/gstomx_audiosink.c | 7 +------
omx/gstomx_base_filter.c | 2 +-
omx/gstomx_base_sink.c | 2 +-
omx/gstomx_base_src.c | 2 +-
omx/gstomx_base_videodec.c | 18 +++---------------
omx/gstomx_base_videoenc.c | 13 ++++---------
omx/gstomx_g711dec.c | 7 ++-----
omx/gstomx_g711enc.c | 7 ++-----
omx/gstomx_g729enc.c | 7 +------
omx/gstomx_h263enc.c | 7 +------
omx/gstomx_h264enc.c | 7 +------
omx/gstomx_jpegenc.c | 20 ++++----------------
omx/gstomx_mp2dec.c | 7 +------
omx/gstomx_mp3dec.c | 7 +------
omx/gstomx_mpeg4enc.c | 7 +------
omx/gstomx_util.c | 6 +-----
omx/gstomx_util.h | 9 +++++++++
omx/gstomx_videosink.c | 17 ++++-------------
omx/gstomx_volume.c | 7 +------
omx/gstomx_vorbisdec.c | 7 +------
28 files changed, 55 insertions(+), 197 deletions(-)
diff --git a/omx/gstomx_aacdec.c b/omx/gstomx_aacdec.c
index 1f22dd8..b8f0fb2 100644
--- a/omx/gstomx_aacdec.c
+++ b/omx/gstomx_aacdec.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxAacDec, gst_omx_aacdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -143,10 +141,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_aacenc.c b/omx/gstomx_aacenc.c
index 565bc82..2eb0e96 100644
--- a/omx/gstomx_aacenc.c
+++ b/omx/gstomx_aacenc.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
enum
{
ARG_0,
@@ -303,10 +301,7 @@ sink_setcaps (GstPad *pad,
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
@@ -349,10 +344,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
{
OMX_AUDIO_PARAM_AACPROFILETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_AACPROFILETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
/* Output port configuration. */
{
@@ -378,10 +370,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
@@ -393,10 +382,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
{
OMX_AUDIO_PARAM_AACPROFILETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_AACPROFILETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac, ¶m);
diff --git a/omx/gstomx_adpcmdec.c b/omx/gstomx_adpcmdec.c
index 12ee81f..63151d9 100644
--- a/omx/gstomx_adpcmdec.c
+++ b/omx/gstomx_adpcmdec.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxAdpcmDec, gst_omx_adpcmdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -125,10 +123,7 @@ sink_setcaps (GstPad *pad,
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_adpcmenc.c b/omx/gstomx_adpcmenc.c
index fea6bf4..fabb4bd 100644
--- a/omx/gstomx_adpcmenc.c
+++ b/omx/gstomx_adpcmenc.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxAdpcmEnc, gst_omx_adpcmenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -116,10 +114,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_ADPCMTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_ADPCMTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAdpcm, ¶m);
@@ -180,10 +175,7 @@ sink_setcaps (GstPad *pad,
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_amrnbdec.c b/omx/gstomx_amrnbdec.c
index f32b15f..6d0cbaf 100644
--- a/omx/gstomx_amrnbdec.c
+++ b/omx/gstomx_amrnbdec.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxAmrNbDec, gst_omx_amrnbdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -116,10 +114,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_amrnbenc.c b/omx/gstomx_amrnbenc.c
index cc3486f..5e1ccff 100644
--- a/omx/gstomx_amrnbenc.c
+++ b/omx/gstomx_amrnbenc.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
enum
{
ARG_0,
@@ -181,10 +179,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_AMRTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_AMRTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr, ¶m);
@@ -231,10 +226,7 @@ sink_setcaps (GstPad *pad,
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_amrwbdec.c b/omx/gstomx_amrwbdec.c
index 20dddcb..cb41789 100644
--- a/omx/gstomx_amrwbdec.c
+++ b/omx/gstomx_amrwbdec.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxAmrWbDec, gst_omx_amrwbdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -116,10 +114,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_amrwbenc.c b/omx/gstomx_amrwbenc.c
index 3d95272..352b93f 100644
--- a/omx/gstomx_amrwbenc.c
+++ b/omx/gstomx_amrwbenc.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
enum
{
ARG_0,
@@ -181,10 +179,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_AMRTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_AMRTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr, ¶m);
@@ -231,10 +226,7 @@ sink_setcaps (GstPad *pad,
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_audiosink.c b/omx/gstomx_audiosink.c
index 6c912f0..5f63d4c 100644
--- a/omx/gstomx_audiosink.c
+++ b/omx/gstomx_audiosink.c
@@ -22,8 +22,6 @@
#include "gstomx_audiosink.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxAudioSink, gst_omx_audiosink, GstOmxBaseSink, GST_OMX_BASE_SINK_TYPE);
static GstCaps *
@@ -109,10 +107,7 @@ setcaps (GstBaseSink *gst_sink,
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = self->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 871c395..7c388b5 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -23,7 +23,7 @@
#include "gstomx.h"
#include "gstomx_interface.h"
-#include <string.h> /* for memset, memcpy */
+#include <string.h> /* for memcpy */
enum
{
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index e78db32..20c9ab7 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -26,7 +26,7 @@
#include "gstomx.h"
#include "gstomx_interface.h"
-#include <string.h> /* for memset, memcpy */
+#include <string.h> /* for memcpy */
static gboolean share_input_buffer;
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 888a447..2c3fe11 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -22,7 +22,7 @@
#include "gstomx_base_src.h"
#include "gstomx.h"
-#include <string.h> /* for memset, memcpy */
+#include <string.h> /* for memcpy */
enum
{
diff --git a/omx/gstomx_base_videodec.c b/omx/gstomx_base_videodec.c
index 5c6d1e1..56b79d1 100644
--- a/omx/gstomx_base_videodec.c
+++ b/omx/gstomx_base_videodec.c
@@ -22,8 +22,6 @@
#include "gstomx_base_videodec.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxBaseVideoDec, gst_omx_base_videodec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -110,11 +108,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
-
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
@@ -197,10 +191,7 @@ sink_setcaps (GstPad *pad,
}
}
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
{
const GValue *codec_data;
@@ -243,10 +234,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
/* Input port configuration. */
{
diff --git a/omx/gstomx_base_videoenc.c b/omx/gstomx_base_videoenc.c
index d243fbd..f469494 100644
--- a/omx/gstomx_base_videoenc.c
+++ b/omx/gstomx_base_videoenc.c
@@ -22,7 +22,7 @@
#include "gstomx_base_videoenc.h"
#include "gstomx.h"
-#include <string.h> /* for memset, strcmp */
+#include <string.h> /* for strcmp */
enum
{
@@ -215,10 +215,8 @@ sink_setcaps (GstPad *pad,
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+
+ G_OMX_INIT_PARAM (param);
/* Input port configuration. */
{
@@ -257,10 +255,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
/* Output port configuration. */
{
diff --git a/omx/gstomx_g711dec.c b/omx/gstomx_g711dec.c
index bc2fb18..623101e 100644
--- a/omx/gstomx_g711dec.c
+++ b/omx/gstomx_g711dec.c
@@ -23,7 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset, strcmp */
+#include <string.h> /* for strcmp */
GSTOMX_BOILERPLATE (GstOmxG711Dec, gst_omx_g711dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
@@ -137,10 +137,7 @@ sink_setcaps (GstPad *pad,
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_g711enc.c b/omx/gstomx_g711enc.c
index ba8d297..003058e 100644
--- a/omx/gstomx_g711enc.c
+++ b/omx/gstomx_g711enc.c
@@ -23,7 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset, strcmp */
+#include <string.h> /* for strcmp */
GSTOMX_BOILERPLATE (GstOmxG711Enc, gst_omx_g711enc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
@@ -147,10 +147,7 @@ sink_setcaps (GstPad *pad,
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_g729enc.c b/omx/gstomx_g729enc.c
index 67f9b38..89d58db 100644
--- a/omx/gstomx_g729enc.c
+++ b/omx/gstomx_g729enc.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
#define DEFAULT_DTX TRUE
enum
@@ -225,10 +223,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
{
OMX_AUDIO_PARAM_G729TYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_G729TYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, ¶m);
diff --git a/omx/gstomx_h263enc.c b/omx/gstomx_h263enc.c
index 2d2a1a0..9caaff7 100644
--- a/omx/gstomx_h263enc.c
+++ b/omx/gstomx_h263enc.c
@@ -22,8 +22,6 @@
#include "gstomx_h263enc.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxH263Enc, gst_omx_h263enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
@@ -92,10 +90,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base_filter->out_port->port_index;
OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, ¶m);
diff --git a/omx/gstomx_h264enc.c b/omx/gstomx_h264enc.c
index 7d2c2b6..efc4092 100644
--- a/omx/gstomx_h264enc.c
+++ b/omx/gstomx_h264enc.c
@@ -22,8 +22,6 @@
#include "gstomx_h264enc.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxH264Enc, gst_omx_h264enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
@@ -91,10 +89,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base_filter->out_port->port_index;
OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, ¶m);
diff --git a/omx/gstomx_jpegenc.c b/omx/gstomx_jpegenc.c
index 63ff8fe..e34c3fc 100644
--- a/omx/gstomx_jpegenc.c
+++ b/omx/gstomx_jpegenc.c
@@ -206,10 +206,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
@@ -287,10 +284,7 @@ sink_setcaps (GstPad *pad,
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
/* Input port configuration. */
{
@@ -322,10 +316,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
/* Output port configuration. */
{
@@ -341,10 +332,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
{
OMX_IMAGE_PARAM_QFACTORTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_IMAGE_PARAM_QFACTORTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nQFactor = self->quality;
param.nPortIndex = omx_base->out_port->port_index;
diff --git a/omx/gstomx_mp2dec.c b/omx/gstomx_mp2dec.c
index 6e78e5f..564e14c 100644
--- a/omx/gstomx_mp2dec.c
+++ b/omx/gstomx_mp2dec.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxMp2Dec, gst_omx_mp2dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -119,10 +117,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_mp3dec.c b/omx/gstomx_mp3dec.c
index 3824a9d..a766689 100644
--- a/omx/gstomx_mp3dec.c
+++ b/omx/gstomx_mp3dec.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxMp3Dec, gst_omx_mp3dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -119,10 +117,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_mpeg4enc.c b/omx/gstomx_mpeg4enc.c
index f365639..3f97fb0 100644
--- a/omx/gstomx_mpeg4enc.c
+++ b/omx/gstomx_mpeg4enc.c
@@ -22,8 +22,6 @@
#include "gstomx_mpeg4enc.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxMpeg4Enc, gst_omx_mpeg4enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
@@ -93,10 +91,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base_filter->out_port->port_index;
OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, ¶m);
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index f14cc86..bbf699b 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -22,7 +22,6 @@
#include "gstomx_util.h"
#include <dlfcn.h>
-#include <string.h> /* for memset */
#include "gstomx.h"
@@ -526,10 +525,7 @@ g_omx_port_setup (GOmxPort *port)
GOmxPortType type = -1;
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = port->port_index;
OMX_GetParameter (port->core->omx_handle, OMX_IndexParamPortDefinition, ¶m);
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index d373193..8608a66 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -192,4 +192,13 @@ GType type_as_function ## _get_type (void) \
GSTOMX_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
__GST_DO_NOTHING)
+#include <string.h> /* for memset */
+#define G_OMX_INIT_PARAM(param) G_STMT_START { \
+ memset (&(param), 0, sizeof ((param))); \
+ (param).nSize = sizeof (param); \
+ (param).nVersion.s.nVersionMajor = 1; \
+ (param).nVersion.s.nVersionMinor = 1; \
+ } G_STMT_END
+
+
#endif /* GSTOMX_UTIL_H */
diff --git a/omx/gstomx_videosink.c b/omx/gstomx_videosink.c
index 7c5849b..4cfc300 100644
--- a/omx/gstomx_videosink.c
+++ b/omx/gstomx_videosink.c
@@ -23,7 +23,7 @@
#include "gstomx_base_sink.h"
#include "gstomx.h"
-#include <string.h> /* for memset, strcmp */
+#include <string.h> /* for strcmp */
GSTOMX_BOILERPLATE (GstOmxVideoSink, gst_omx_videosink, GstOmxBaseSink, GST_OMX_BASE_SINK_TYPE);
@@ -161,10 +161,7 @@ setcaps (GstBaseSink *gst_sink,
{
OMX_PARAM_PORTDEFINITIONTYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
@@ -200,10 +197,7 @@ setcaps (GstBaseSink *gst_sink,
{
OMX_CONFIG_ROTATIONTYPE config;
- memset (&config, 0, sizeof (config));
- config.nSize = sizeof (OMX_CONFIG_ROTATIONTYPE);
- config.nVersion.s.nVersionMajor = 1;
- config.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (config);
config.nPortIndex = omx_base->in_port->port_index;
OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
@@ -216,10 +210,7 @@ setcaps (GstBaseSink *gst_sink,
{
OMX_CONFIG_SCALEFACTORTYPE config;
- memset (&config, 0, sizeof (config));
- config.nSize = sizeof (OMX_CONFIG_SCALEFACTORTYPE);
- config.nVersion.s.nVersionMajor = 1;
- config.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (config);
config.nPortIndex = omx_base->in_port->port_index;
OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
diff --git a/omx/gstomx_volume.c b/omx/gstomx_volume.c
index 91e116e..61c7f79 100644
--- a/omx/gstomx_volume.c
+++ b/omx/gstomx_volume.c
@@ -24,8 +24,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxVolume, gst_omx_volume, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -121,10 +119,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
diff --git a/omx/gstomx_vorbisdec.c b/omx/gstomx_vorbisdec.c
index aad896a..fa532df 100644
--- a/omx/gstomx_vorbisdec.c
+++ b/omx/gstomx_vorbisdec.c
@@ -23,8 +23,6 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for memset */
-
GSTOMX_BOILERPLATE (GstOmxVorbisDec, gst_omx_vorbisdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
@@ -114,10 +112,7 @@ settings_changed_cb (GOmxCore *core)
{
OMX_AUDIO_PARAM_PCMMODETYPE param;
- memset (¶m, 0, sizeof (param));
- param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
- param.nVersion.s.nVersionMajor = 1;
- param.nVersion.s.nVersionMinor = 1;
+ G_OMX_INIT_PARAM (param);
param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
--
1.6.3.2
|
|
From: Felipe C. <fel...@gm...> - 2010-03-23 22:31:42
|
On Thu, Mar 18, 2010 at 1:58 AM, Rob Clark <ro...@ti...> wrote: > --- > omx/gstomx_aacdec.c | 7 +------ > omx/gstomx_aacenc.c | 22 ++++------------------ > omx/gstomx_adpcmdec.c | 7 +------ > omx/gstomx_adpcmenc.c | 12 ++---------- > omx/gstomx_amrnbdec.c | 7 +------ > omx/gstomx_amrnbenc.c | 12 ++---------- > omx/gstomx_amrwbdec.c | 7 +------ > omx/gstomx_amrwbenc.c | 12 ++---------- > omx/gstomx_audiosink.c | 7 +------ > omx/gstomx_base_filter.c | 2 +- > omx/gstomx_base_sink.c | 2 +- > omx/gstomx_base_src.c | 2 +- > omx/gstomx_base_videodec.c | 18 +++--------------- > omx/gstomx_base_videoenc.c | 13 ++++--------- > omx/gstomx_g711dec.c | 7 ++----- > omx/gstomx_g711enc.c | 7 ++----- > omx/gstomx_g729enc.c | 7 +------ > omx/gstomx_h263enc.c | 7 +------ > omx/gstomx_h264enc.c | 7 +------ > omx/gstomx_jpegenc.c | 20 ++++---------------- > omx/gstomx_mp2dec.c | 7 +------ > omx/gstomx_mp3dec.c | 7 +------ > omx/gstomx_mpeg4enc.c | 7 +------ > omx/gstomx_util.c | 6 +----- > omx/gstomx_util.h | 9 +++++++++ > omx/gstomx_videosink.c | 17 ++++------------- > omx/gstomx_volume.c | 7 +------ > omx/gstomx_vorbisdec.c | 7 +------ > 28 files changed, 55 insertions(+), 197 deletions(-) Looks fine to me. ACK. -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-03-17 23:58:53
|
---
omx/gstomx_base_filter.c | 62 ++++++++++++++++++++++++++++++++++++++
omx/gstomx_base_sink.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
omx/gstomx_base_src.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 210 insertions(+), 0 deletions(-)
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 98b40d5..76ec085 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -28,6 +28,8 @@
enum
{
ARG_USE_TIMESTAMPS = GSTOMX_NUM_COMMON_PROP,
+ ARG_NUM_INPUT_BUFFERS,
+ ARG_NUM_OUTPUT_BUFFERS,
};
static void init_interfaces (GType type);
@@ -182,6 +184,36 @@ set_property (GObject *obj,
case ARG_USE_TIMESTAMPS:
self->use_timestamps = g_value_get_boolean (value);
break;
+ case ARG_NUM_INPUT_BUFFERS:
+ case ARG_NUM_OUTPUT_BUFFERS:
+ if (G_LIKELY (self->gomx->omx_handle))
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_U32 nBufferCountActual = g_value_get_uint (value);
+ GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
+ self->in_port : self->out_port;
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = port->port_index;
+ OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ if (nBufferCountActual < param.nBufferCountMin)
+ {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
+
+ param.nBufferCountActual = nBufferCountActual;
+
+ OMX_SetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+ }
+ else
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -206,6 +238,27 @@ get_property (GObject *obj,
case ARG_USE_TIMESTAMPS:
g_value_set_boolean (value, self->use_timestamps);
break;
+ case ARG_NUM_INPUT_BUFFERS:
+ case ARG_NUM_OUTPUT_BUFFERS:
+ if (G_LIKELY (self->gomx->omx_handle))
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
+ self->in_port : self->out_port;
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = port->port_index;
+ OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ g_value_set_uint (value, param.nBufferCountActual);
+ }
+ else
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -241,6 +294,15 @@ type_class_init (gpointer g_class,
g_param_spec_boolean ("use-timestamps", "Use timestamps",
"Whether or not to use timestamps",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
+ g_param_spec_uint ("input-buffers", "Input buffers",
+ "The number of OMX input buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
+ g_param_spec_uint ("output-buffers", "Output buffers",
+ "The number of OMX output buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
}
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 7fd61d5..ce70df8 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -28,6 +28,11 @@
#include <string.h> /* for memcpy */
+enum
+{
+ ARG_NUM_INPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
+};
+
static gboolean share_input_buffer;
static inline gboolean omx_init (GstOmxBaseSink *self);
@@ -265,6 +270,51 @@ handle_event (GstBaseSink *gst_base,
}
static void
+set_property (GObject *obj,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GstOmxBaseSink *self;
+
+ self = GST_OMX_BASE_SINK (obj);
+
+ switch (prop_id)
+ {
+ case ARG_NUM_INPUT_BUFFERS:
+ if (G_LIKELY (self->gomx->omx_handle))
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_U32 nBufferCountActual = g_value_get_uint (value);
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->in_port->port_index;
+ OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ if (nBufferCountActual < param.nBufferCountMin)
+ {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
+
+ param.nBufferCountActual = nBufferCountActual;
+
+ OMX_SetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+ }
+ else
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
get_property (GObject *obj,
guint prop_id,
GValue *value,
@@ -279,6 +329,24 @@ get_property (GObject *obj,
switch (prop_id)
{
+ case ARG_NUM_INPUT_BUFFERS:
+ if (G_LIKELY (self->gomx->omx_handle))
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->in_port->port_index;
+ OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ g_value_set_uint (value, param.nBufferCountActual);
+ }
+ else
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -312,9 +380,15 @@ type_class_init (gpointer g_class,
/* Properties stuff */
{
+ gobject_class->set_property = set_property;
gobject_class->get_property = get_property;
gstomx_install_property_helper (gobject_class);
+
+ g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
+ g_param_spec_uint ("input-buffers", "Input buffers",
+ "The number of OMX input buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
}
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 00d27b6..66ed11d 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -24,6 +24,11 @@
#include <string.h> /* for memcpy */
+enum
+{
+ ARG_NUM_OUTPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
+};
+
GSTOMX_BOILERPLATE (GstOmxBaseSrc, gst_omx_base_src, GstBaseSrc, GST_TYPE_BASE_SRC);
static void
@@ -326,6 +331,51 @@ handle_event (GstBaseSrc *gst_base,
}
static void
+set_property (GObject *obj,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GstOmxBaseSrc *self;
+
+ self = GST_OMX_BASE_SRC (obj);
+
+ switch (prop_id)
+ {
+ case ARG_NUM_OUTPUT_BUFFERS:
+ if (G_LIKELY (self->gomx->omx_handle))
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_U32 nBufferCountActual = g_value_get_uint (value);
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->out_port->port_index;
+ OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ if (nBufferCountActual < param.nBufferCountMin)
+ {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
+
+ param.nBufferCountActual = nBufferCountActual;
+
+ OMX_SetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+ }
+ else
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
get_property (GObject *obj,
guint prop_id,
GValue *value,
@@ -340,6 +390,24 @@ get_property (GObject *obj,
switch (prop_id)
{
+ case ARG_NUM_OUTPUT_BUFFERS:
+ if (G_LIKELY (self->gomx->omx_handle))
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->out_port->port_index;
+ OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ g_value_set_uint (value, param.nBufferCountActual);
+ }
+ else
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -370,9 +438,15 @@ type_class_init (gpointer g_class,
/* Properties stuff */
{
+ gobject_class->set_property = set_property;
gobject_class->get_property = get_property;
gstomx_install_property_helper (gobject_class);
+
+ g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
+ g_param_spec_uint ("output-buffers", "Output buffers",
+ "The number of OMX output buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
}
--
1.6.3.2
|
|
From: Felipe C. <fel...@gm...> - 2010-03-23 22:44:03
|
On Thu, Mar 18, 2010 at 1:58 AM, Rob Clark <ro...@ti...> wrote:
> ---
> omx/gstomx_base_filter.c | 62 ++++++++++++++++++++++++++++++++++++++
> omx/gstomx_base_sink.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
> omx/gstomx_base_src.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 210 insertions(+), 0 deletions(-)
>
> diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
> index 98b40d5..76ec085 100644
> --- a/omx/gstomx_base_filter.c
> +++ b/omx/gstomx_base_filter.c
> @@ -28,6 +28,8 @@
> enum
> {
> ARG_USE_TIMESTAMPS = GSTOMX_NUM_COMMON_PROP,
> + ARG_NUM_INPUT_BUFFERS,
> + ARG_NUM_OUTPUT_BUFFERS,
> };
>
> static void init_interfaces (GType type);
> @@ -182,6 +184,36 @@ set_property (GObject *obj,
> case ARG_USE_TIMESTAMPS:
> self->use_timestamps = g_value_get_boolean (value);
> break;
> + case ARG_NUM_INPUT_BUFFERS:
> + case ARG_NUM_OUTPUT_BUFFERS:
> + if (G_LIKELY (self->gomx->omx_handle))
> + {
Too nested.
How about:
if (G_UNLIKELY(!omx_handle)) {
GST_WARNING_OBJECT(self, "no component");
break;
}
/* rest of the stuff */
This applies all over the place.
> + OMX_PARAM_PORTDEFINITIONTYPE param;
> + OMX_U32 nBufferCountActual = g_value_get_uint (value);
> + GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
> + self->in_port : self->out_port;
> +
> + G_OMX_INIT_PARAM (param);
> +
> + param.nPortIndex = port->port_index;
> + OMX_GetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
> +
> + if (nBufferCountActual < param.nBufferCountMin)
> + {
> + GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
> + nBufferCountActual, param.nBufferCountMin);
> + return;
> + }
> +
> + param.nBufferCountActual = nBufferCountActual;
> +
> + OMX_SetParameter (self->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
> + }
> + else
> + {
> + GST_WARNING_OBJECT (self, "no component");
> + }
> + break;
--
Felipe Contreras
|
|
From: Rob C. <ro...@ti...> - 2010-03-29 13:09:37
|
---
v2: update with changes suggested by Felipe to reduce nesting
omx/gstomx_base_filter.c | 68 +++++++++++++++++++++++++++++++++++++++
omx/gstomx_base_sink.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
omx/gstomx_base_src.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 228 insertions(+), 0 deletions(-)
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 2dbf850..4821f3b 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -28,6 +28,8 @@
enum
{
ARG_USE_TIMESTAMPS = GSTOMX_NUM_COMMON_PROP,
+ ARG_NUM_INPUT_BUFFERS,
+ ARG_NUM_OUTPUT_BUFFERS,
};
static void init_interfaces (GType type);
@@ -182,6 +184,40 @@ set_property (GObject *obj,
case ARG_USE_TIMESTAMPS:
self->use_timestamps = g_value_get_boolean (value);
break;
+ case ARG_NUM_INPUT_BUFFERS:
+ case ARG_NUM_OUTPUT_BUFFERS:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ OMX_U32 nBufferCountActual;
+ GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
+ self->in_port : self->out_port;
+
+ if (G_UNLIKELY (!omx_handle))
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ break;
+ }
+
+ nBufferCountActual = g_value_get_uint (value);
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ if (nBufferCountActual < param.nBufferCountMin)
+ {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
+
+ param.nBufferCountActual = nBufferCountActual;
+
+ OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -206,6 +242,29 @@ get_property (GObject *obj,
case ARG_USE_TIMESTAMPS:
g_value_set_boolean (value, self->use_timestamps);
break;
+ case ARG_NUM_INPUT_BUFFERS:
+ case ARG_NUM_OUTPUT_BUFFERS:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
+ self->in_port : self->out_port;
+
+ if (G_UNLIKELY (!omx_handle))
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ break;
+ }
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ g_value_set_uint (value, param.nBufferCountActual);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -241,6 +300,15 @@ type_class_init (gpointer g_class,
g_param_spec_boolean ("use-timestamps", "Use timestamps",
"Whether or not to use timestamps",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
+ g_param_spec_uint ("input-buffers", "Input buffers",
+ "The number of OMX input buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
+ g_param_spec_uint ("output-buffers", "Output buffers",
+ "The number of OMX output buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
}
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 3cc5f99..66e32d6 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -28,6 +28,11 @@
#include <string.h> /* for memcpy */
+enum
+{
+ ARG_NUM_INPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
+};
+
static gboolean share_input_buffer;
static inline gboolean omx_init (GstOmxBaseSink *self);
@@ -265,6 +270,55 @@ handle_event (GstBaseSink *gst_base,
}
static void
+set_property (GObject *obj,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GstOmxBaseSink *self;
+
+ self = GST_OMX_BASE_SINK (obj);
+
+ switch (prop_id)
+ {
+ case ARG_NUM_INPUT_BUFFERS:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ OMX_U32 nBufferCountActual;
+
+ if (G_UNLIKELY (!omx_handle))
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ break;
+ }
+
+ nBufferCountActual = g_value_get_uint (value);
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->in_port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ if (nBufferCountActual < param.nBufferCountMin)
+ {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
+
+ param.nBufferCountActual = nBufferCountActual;
+
+ OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
get_property (GObject *obj,
guint prop_id,
GValue *value,
@@ -279,6 +333,26 @@ get_property (GObject *obj,
switch (prop_id)
{
+ case ARG_NUM_INPUT_BUFFERS:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+
+ if (G_UNLIKELY (!omx_handle))
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ break;
+ }
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->in_port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ g_value_set_uint (value, param.nBufferCountActual);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -312,9 +386,15 @@ type_class_init (gpointer g_class,
/* Properties stuff */
{
+ gobject_class->set_property = set_property;
gobject_class->get_property = get_property;
gstomx_install_property_helper (gobject_class);
+
+ g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
+ g_param_spec_uint ("input-buffers", "Input buffers",
+ "The number of OMX input buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
}
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index af0bd01..37b29f9 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -24,6 +24,11 @@
#include <string.h> /* for memcpy */
+enum
+{
+ ARG_NUM_OUTPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
+};
+
GSTOMX_BOILERPLATE (GstOmxBaseSrc, gst_omx_base_src, GstBaseSrc, GST_TYPE_BASE_SRC);
static void
@@ -326,6 +331,55 @@ handle_event (GstBaseSrc *gst_base,
}
static void
+set_property (GObject *obj,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GstOmxBaseSrc *self;
+
+ self = GST_OMX_BASE_SRC (obj);
+
+ switch (prop_id)
+ {
+ case ARG_NUM_OUTPUT_BUFFERS:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ OMX_U32 nBufferCountActual;
+
+ if (G_UNLIKELY (omx_handle))
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ break;
+ }
+
+ nBufferCountActual = g_value_get_uint (value);
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->out_port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ if (nBufferCountActual < param.nBufferCountMin)
+ {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
+
+ param.nBufferCountActual = nBufferCountActual;
+
+ OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
get_property (GObject *obj,
guint prop_id,
GValue *value,
@@ -340,6 +394,26 @@ get_property (GObject *obj,
switch (prop_id)
{
+ case ARG_NUM_OUTPUT_BUFFERS:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+
+ if (G_UNLIKELY (!omx_handle))
+ {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ break;
+ }
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->out_port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, ¶m);
+
+ g_value_set_uint (value, param.nBufferCountActual);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -370,9 +444,15 @@ type_class_init (gpointer g_class,
/* Properties stuff */
{
+ gobject_class->set_property = set_property;
gobject_class->get_property = get_property;
gstomx_install_property_helper (gobject_class);
+
+ g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
+ g_param_spec_uint ("output-buffers", "Output buffers",
+ "The number of OMX output buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
}
--
1.6.6
|
|
From: Felipe C. <fel...@gm...> - 2010-04-16 14:58:32
|
On Mon, Mar 29, 2010 at 4:09 PM, Rob Clark <ro...@ti...> wrote: > --- > v2: update with changes suggested by Felipe to reduce nesting > > omx/gstomx_base_filter.c | 68 +++++++++++++++++++++++++++++++++++++++ > omx/gstomx_base_sink.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++ > omx/gstomx_base_src.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 228 insertions(+), 0 deletions(-) ACK. -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-03-17 23:58:53
|
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
|
|
From: Felipe C. <fel...@gm...> - 2010-03-23 22:33:15
|
On Thu, Mar 18, 2010 at 1:58 AM, Rob Clark <ro...@ti...> wrote: > 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. A bit hacky for my taste, but I guess there's no better way to implement this. ACK. -- Felipe Contreras |
|
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
|
|
From: Felipe C. <fel...@gm...> - 2010-04-16 14:49:30
|
On Mon, Mar 29, 2010 at 4:07 PM, Rob Clark <ro...@ti...> wrote: > 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. Please try to keep the commit summary short: < 50 characters. -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-03-17 23:58:56
|
---
omx/gstomx_base_filter.c | 12 ++++++++++++
omx/gstomx_util.c | 2 ++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 76ec085..3f6677f 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -63,6 +63,7 @@ setup_ports (GstOmxBaseFilter *self)
/* @todo: read from config file: */
if (g_getenv ("OMX_ALLOCATE_ON"))
{
+ GST_DEBUG_OBJECT (self, "OMX_ALLOCATE_ON");
self->in_port->omx_allocate = TRUE;
self->out_port->omx_allocate = TRUE;
self->share_input_buffer = FALSE;
@@ -70,14 +71,25 @@ setup_ports (GstOmxBaseFilter *self)
}
else if (g_getenv ("OMX_SHARE_HACK_ON"))
{
+ GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_ON");
self->share_input_buffer = TRUE;
self->share_output_buffer = TRUE;
}
else if (g_getenv ("OMX_SHARE_HACK_OFF"))
{
+ GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_OFF");
self->share_input_buffer = FALSE;
self->share_output_buffer = FALSE;
}
+ else
+ {
+ GST_DEBUG_OBJECT (self, "default sharing and allocation");
+ }
+
+ GST_DEBUG_OBJECT (self, "omx_allocate: in: %d, out: %d",
+ self->in_port->omx_allocate, self->out_port->omx_allocate);
+ GST_DEBUG_OBJECT (self, "share_buffer: in: %d, out: %d",
+ self->share_input_buffer, self->share_output_buffer);
}
static GstStateChangeReturn
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 103c919..1fe0722 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -586,6 +586,7 @@ port_allocate_buffers (GOmxPort *port)
{
if (port->omx_allocate)
{
+ GST_DEBUG_OBJECT (port->core->object, "%d: OMX_AllocateBuffer(), size=%"G_GSIZE_FORMAT, i, size);
OMX_AllocateBuffer (port->core->omx_handle,
&port->buffers[i],
port->port_index,
@@ -596,6 +597,7 @@ port_allocate_buffers (GOmxPort *port)
{
gpointer buffer_data;
buffer_data = g_malloc (size);
+ GST_DEBUG_OBJECT (port->core->object, "%d: OMX_UseBuffer(), size=%"G_GSIZE_FORMAT, i, size);
OMX_UseBuffer (port->core->omx_handle,
&port->buffers[i],
port->port_index,
--
1.6.3.2
|
|
From: Felipe C. <fel...@gm...> - 2010-03-23 22:35:39
|
On Thu, Mar 18, 2010 at 1:59 AM, Rob Clark <ro...@ti...> wrote: > --- > omx/gstomx_base_filter.c | 12 ++++++++++++ > omx/gstomx_util.c | 2 ++ > 2 files changed, 14 insertions(+), 0 deletions(-) ACK. -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-03-17 23:59:00
|
Refactor some common functionality, in particular the settings_changed_cb,
into an abstract base class.
---
omx/Makefile.am | 1 +
omx/gstomx_aacdec.c | 45 +--------------------
omx/gstomx_aacdec.h | 6 +-
omx/gstomx_adpcmdec.c | 1 +
omx/gstomx_amrnbdec.c | 48 +---------------------
omx/gstomx_amrnbdec.h | 6 +-
omx/gstomx_amrwbdec.c | 48 +---------------------
omx/gstomx_amrwbdec.h | 6 +-
omx/gstomx_base_audiodec.c | 97 ++++++++++++++++++++++++++++++++++++++++++++
omx/gstomx_base_audiodec.h | 53 ++++++++++++++++++++++++
omx/gstomx_g711dec.c | 1 +
omx/gstomx_g729dec.c | 4 +-
omx/gstomx_g729dec.h | 6 +-
omx/gstomx_ilbcdec.c | 1 +
omx/gstomx_mp2dec.c | 55 +------------------------
omx/gstomx_mp2dec.h | 6 +-
omx/gstomx_mp3dec.c | 56 +-------------------------
omx/gstomx_mp3dec.h | 6 +-
omx/gstomx_vorbisdec.c | 45 +--------------------
omx/gstomx_vorbisdec.h | 6 +-
20 files changed, 183 insertions(+), 314 deletions(-)
create mode 100644 omx/gstomx_base_audiodec.c
create mode 100644 omx/gstomx_base_audiodec.h
diff --git a/omx/Makefile.am b/omx/Makefile.am
index 80e7d9a..7e9f81f 100644
--- a/omx/Makefile.am
+++ b/omx/Makefile.am
@@ -6,6 +6,7 @@ libgstomx_la_SOURCES = gstomx.c gstomx.h \
gstomx_base_filter.c gstomx_base_filter.h \
gstomx_base_videodec.c gstomx_base_videodec.h \
gstomx_base_videoenc.c gstomx_base_videoenc.h \
+ gstomx_base_audiodec.c gstomx_base_audiodec.h \
gstomx_dummy.c gstomx_dummy.h \
gstomx_volume.c gstomx_volume.h \
gstomx_mpeg4dec.c gstomx_mpeg4dec.h \
diff --git a/omx/gstomx_aacdec.c b/omx/gstomx_aacdec.c
index b8f0fb2..1916216 100644
--- a/omx/gstomx_aacdec.c
+++ b/omx/gstomx_aacdec.c
@@ -20,10 +20,9 @@
*/
#include "gstomx_aacdec.h"
-#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxAacDec, gst_omx_aacdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAacDec, gst_omx_aacdec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -127,46 +126,6 @@ type_class_init (gpointer g_class,
{
}
-static void
-settings_changed_cb (GOmxCore *core)
-{
- GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
-
- omx_base = core->object;
-
- GST_DEBUG_OBJECT (omx_base, "settings changed");
-
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
-
- rate = param.nSamplingRate;
- channels = param.nChannels;
- }
-
- {
- GstCaps *new_caps;
-
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, rate,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "channels", G_TYPE_INT, channels,
- NULL);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
-}
-
static gboolean
sink_setcaps (GstPad *pad,
GstCaps *caps)
@@ -204,7 +163,5 @@ type_instance_init (GTypeInstance *instance,
omx_base = GST_OMX_BASE_FILTER (instance);
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
-
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_aacdec.h b/omx/gstomx_aacdec.h
index b53b030..1b431fd 100644
--- a/omx/gstomx_aacdec.h
+++ b/omx/gstomx_aacdec.h
@@ -32,16 +32,16 @@ G_BEGIN_DECLS
typedef struct GstOmxAacDec GstOmxAacDec;
typedef struct GstOmxAacDecClass GstOmxAacDecClass;
-#include "gstomx_base_filter.h"
+#include "gstomx_base_audiodec.h"
struct GstOmxAacDec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxAacDecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_aacdec_get_type (void);
diff --git a/omx/gstomx_adpcmdec.c b/omx/gstomx_adpcmdec.c
index 63151d9..d33de1a 100644
--- a/omx/gstomx_adpcmdec.c
+++ b/omx/gstomx_adpcmdec.c
@@ -23,6 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
+/* should this class extend GstOmxBaseAudioDec? */
GSTOMX_BOILERPLATE (GstOmxAdpcmDec, gst_omx_adpcmdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
diff --git a/omx/gstomx_amrnbdec.c b/omx/gstomx_amrnbdec.c
index 6d0cbaf..0362731 100644
--- a/omx/gstomx_amrnbdec.c
+++ b/omx/gstomx_amrnbdec.c
@@ -20,10 +20,9 @@
*/
#include "gstomx_amrnbdec.h"
-#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxAmrNbDec, gst_omx_amrnbdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAmrNbDec, gst_omx_amrnbdec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -101,52 +100,7 @@ type_class_init (gpointer g_class,
}
static void
-settings_changed_cb (GOmxCore *core)
-{
- GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
-
- omx_base = core->object;
-
- GST_DEBUG_OBJECT (omx_base, "settings changed");
-
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
-
- rate = param.nSamplingRate;
- channels = param.nChannels;
- }
-
- {
- GstCaps *new_caps;
-
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, rate,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "channels", G_TYPE_INT, channels,
- NULL);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
-}
-
-static void
type_instance_init (GTypeInstance *instance,
gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
-
- omx_base = GST_OMX_BASE_FILTER (instance);
-
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_amrnbdec.h b/omx/gstomx_amrnbdec.h
index 3ec66c2..781e4ed 100644
--- a/omx/gstomx_amrnbdec.h
+++ b/omx/gstomx_amrnbdec.h
@@ -32,16 +32,16 @@ G_BEGIN_DECLS
typedef struct GstOmxAmrNbDec GstOmxAmrNbDec;
typedef struct GstOmxAmrNbDecClass GstOmxAmrNbDecClass;
-#include "gstomx_base_filter.h"
+#include "gstomx_base_audiodec.h"
struct GstOmxAmrNbDec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxAmrNbDecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_amrnbdec_get_type (void);
diff --git a/omx/gstomx_amrwbdec.c b/omx/gstomx_amrwbdec.c
index cb41789..581b3da 100644
--- a/omx/gstomx_amrwbdec.c
+++ b/omx/gstomx_amrwbdec.c
@@ -20,10 +20,9 @@
*/
#include "gstomx_amrwbdec.h"
-#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxAmrWbDec, gst_omx_amrwbdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAmrWbDec, gst_omx_amrwbdec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -101,52 +100,7 @@ type_class_init (gpointer g_class,
}
static void
-settings_changed_cb (GOmxCore *core)
-{
- GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
-
- omx_base = core->object;
-
- GST_DEBUG_OBJECT (omx_base, "settings changed");
-
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
-
- rate = param.nSamplingRate;
- channels = param.nChannels;
- }
-
- {
- GstCaps *new_caps;
-
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, rate,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "channels", G_TYPE_INT, channels,
- NULL);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
-}
-
-static void
type_instance_init (GTypeInstance *instance,
gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
-
- omx_base = GST_OMX_BASE_FILTER (instance);
-
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_amrwbdec.h b/omx/gstomx_amrwbdec.h
index ae0a2cf..61870b8 100644
--- a/omx/gstomx_amrwbdec.h
+++ b/omx/gstomx_amrwbdec.h
@@ -32,16 +32,16 @@ G_BEGIN_DECLS
typedef struct GstOmxAmrWbDec GstOmxAmrWbDec;
typedef struct GstOmxAmrWbDecClass GstOmxAmrWbDecClass;
-#include "gstomx_base_filter.h"
+#include "gstomx_base_audiodec.h"
struct GstOmxAmrWbDec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxAmrWbDecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_amrwbdec_get_type (void);
diff --git a/omx/gstomx_base_audiodec.c b/omx/gstomx_base_audiodec.c
new file mode 100644
index 0000000..8dc37d7
--- /dev/null
+++ b/omx/gstomx_base_audiodec.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2009 Texas Instruments, Inc - http://www.ti.com/
+ *
+ * Description: Base audio decoder element
+ * Created on: Aug 2, 2009
+ * Author: Rob Clark <ro...@ti...>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "gstomx_base_audiodec.h"
+#include "gstomx.h"
+
+GSTOMX_BOILERPLATE (GstOmxBaseAudioDec, gst_omx_base_audiodec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+
+static void
+type_base_init (gpointer g_class)
+{
+}
+
+static void
+type_class_init (gpointer g_class,
+ gpointer class_data)
+{
+}
+
+static void
+settings_changed_cb (GOmxCore *core)
+{
+ GstOmxBaseFilter *omx_base;
+ guint rate;
+ guint channels;
+
+ omx_base = core->object;
+
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
+
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
+
+ rate = param.nSamplingRate;
+ channels = param.nChannels;
+ if (rate == 0)
+ {
+ /** @todo: this shouldn't happen. */
+ GST_WARNING_OBJECT (omx_base, "Bad samplerate");
+ rate = 44100;
+ }
+ }
+
+ {
+ GstCaps *new_caps;
+
+ new_caps = gst_caps_new_simple ("audio/x-raw-int",
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, rate,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "channels", G_TYPE_INT, channels,
+ NULL);
+
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
+}
+
+static void
+type_instance_init (GTypeInstance *instance,
+ gpointer g_class)
+{
+ GstOmxBaseFilter *omx_base;
+
+ omx_base = GST_OMX_BASE_FILTER (instance);
+
+ GST_DEBUG_OBJECT (omx_base, "start");
+
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
+}
diff --git a/omx/gstomx_base_audiodec.h b/omx/gstomx_base_audiodec.h
new file mode 100644
index 0000000..83472e6
--- /dev/null
+++ b/omx/gstomx_base_audiodec.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 Texas Instruments, Inc - http://www.ti.com/
+ *
+ * Description: Base audio decoder element
+ * Created on: Aug 2, 2009
+ * Author: Rob Clark <ro...@ti...>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GSTOMX_BASE_AUDIODEC_H
+#define GSTOMX_BASE_AUDIODEC_H
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+#define GST_OMX_BASE_AUDIODEC(obj) (GstOmxBaseAudioDec *) (obj)
+#define GST_OMX_BASE_AUDIODEC_TYPE (gst_omx_base_audiodec_get_type ())
+
+typedef struct GstOmxBaseAudioDec GstOmxBaseAudioDec;
+typedef struct GstOmxBaseAudioDecClass GstOmxBaseAudioDecClass;
+
+#include "gstomx_base_filter.h"
+
+struct GstOmxBaseAudioDec
+{
+ GstOmxBaseFilter omx_base;
+};
+
+struct GstOmxBaseAudioDecClass
+{
+ GstOmxBaseFilterClass parent_class;
+};
+
+GType gst_omx_base_audiodec_get_type (void);
+
+G_END_DECLS
+
+#endif /* GSTOMX_BASE_AUDIODEC_H */
diff --git a/omx/gstomx_g711dec.c b/omx/gstomx_g711dec.c
index 623101e..2067953 100644
--- a/omx/gstomx_g711dec.c
+++ b/omx/gstomx_g711dec.c
@@ -25,6 +25,7 @@
#include <string.h> /* for strcmp */
+/* should this class extend GstOmxBaseAudioDec? */
GSTOMX_BOILERPLATE (GstOmxG711Dec, gst_omx_g711dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
diff --git a/omx/gstomx_g729dec.c b/omx/gstomx_g729dec.c
index 666d5ab..a558011 100644
--- a/omx/gstomx_g729dec.c
+++ b/omx/gstomx_g729dec.c
@@ -20,10 +20,9 @@
*/
#include "gstomx_g729dec.h"
-#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxG729Dec, gst_omx_g729dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxG729Dec, gst_omx_g729dec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -105,6 +104,7 @@ type_class_init (gpointer g_class,
{
}
+/* should we be overriding the settings_changed_cb from parent class like this?? */
static void
settings_changed_cb (GOmxCore *core)
{
diff --git a/omx/gstomx_g729dec.h b/omx/gstomx_g729dec.h
index abe5504..49e525f 100644
--- a/omx/gstomx_g729dec.h
+++ b/omx/gstomx_g729dec.h
@@ -32,16 +32,16 @@ G_BEGIN_DECLS
typedef struct GstOmxG729Dec GstOmxG729Dec;
typedef struct GstOmxG729DecClass GstOmxG729DecClass;
-#include "gstomx_base_filter.h"
+#include "gstomx_base_audiodec.h"
struct GstOmxG729Dec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxG729DecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_g729dec_get_type (void);
diff --git a/omx/gstomx_ilbcdec.c b/omx/gstomx_ilbcdec.c
index 9d03f01..ff899ac 100644
--- a/omx/gstomx_ilbcdec.c
+++ b/omx/gstomx_ilbcdec.c
@@ -23,6 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
+/* should this class extend GstOmxBaseAudioDec? */
GSTOMX_BOILERPLATE (GstOmxIlbcDec, gst_omx_ilbcdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
diff --git a/omx/gstomx_mp2dec.c b/omx/gstomx_mp2dec.c
index 564e14c..319ef8e 100644
--- a/omx/gstomx_mp2dec.c
+++ b/omx/gstomx_mp2dec.c
@@ -23,7 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxMp2Dec, gst_omx_mp2dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxMp2Dec, gst_omx_mp2dec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -104,60 +104,7 @@ type_class_init (gpointer g_class,
}
static void
-settings_changed_cb (GOmxCore *core)
-{
- GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
-
- omx_base = core->object;
-
- GST_DEBUG_OBJECT (omx_base, "settings changed");
-
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
-
- rate = param.nSamplingRate;
- channels = param.nChannels;
- if (rate == 0)
- {
- /** @todo: this shouldn't happen. */
- GST_WARNING_OBJECT (omx_base, "Bad samplerate");
- rate = 44100;
- }
- }
-
- {
- GstCaps *new_caps;
-
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, rate,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "channels", G_TYPE_INT, channels,
- NULL);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
-}
-
-static void
type_instance_init (GTypeInstance *instance,
gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
-
- omx_base = GST_OMX_BASE_FILTER (instance);
-
- GST_DEBUG_OBJECT (omx_base, "start");
-
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_mp2dec.h b/omx/gstomx_mp2dec.h
index 877d3c5..c6c517e 100644
--- a/omx/gstomx_mp2dec.h
+++ b/omx/gstomx_mp2dec.h
@@ -32,16 +32,16 @@ G_BEGIN_DECLS
typedef struct GstOmxMp2Dec GstOmxMp2Dec;
typedef struct GstOmxMp2DecClass GstOmxMp2DecClass;
-#include "gstomx_base_filter.h"
+#include "gstomx_base_audiodec.h"
struct GstOmxMp2Dec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxMp2DecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_mp2dec_get_type (void);
diff --git a/omx/gstomx_mp3dec.c b/omx/gstomx_mp3dec.c
index a766689..8a1f465 100644
--- a/omx/gstomx_mp3dec.c
+++ b/omx/gstomx_mp3dec.c
@@ -20,10 +20,9 @@
*/
#include "gstomx_mp3dec.h"
-#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxMp3Dec, gst_omx_mp3dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxMp3Dec, gst_omx_mp3dec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -104,60 +103,7 @@ type_class_init (gpointer g_class,
}
static void
-settings_changed_cb (GOmxCore *core)
-{
- GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
-
- omx_base = core->object;
-
- GST_DEBUG_OBJECT (omx_base, "settings changed");
-
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
-
- rate = param.nSamplingRate;
- channels = param.nChannels;
- if (rate == 0)
- {
- /** @todo: this shouldn't happen. */
- GST_WARNING_OBJECT (omx_base, "Bad samplerate");
- rate = 44100;
- }
- }
-
- {
- GstCaps *new_caps;
-
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, rate,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "channels", G_TYPE_INT, channels,
- NULL);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
-}
-
-static void
type_instance_init (GTypeInstance *instance,
gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
-
- omx_base = GST_OMX_BASE_FILTER (instance);
-
- GST_DEBUG_OBJECT (omx_base, "start");
-
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_mp3dec.h b/omx/gstomx_mp3dec.h
index f353ee5..c0a7d78 100644
--- a/omx/gstomx_mp3dec.h
+++ b/omx/gstomx_mp3dec.h
@@ -32,16 +32,16 @@ G_BEGIN_DECLS
typedef struct GstOmxMp3Dec GstOmxMp3Dec;
typedef struct GstOmxMp3DecClass GstOmxMp3DecClass;
-#include "gstomx_base_filter.h"
+#include "gstomx_base_audiodec.h"
struct GstOmxMp3Dec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxMp3DecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_mp3dec_get_type (void);
diff --git a/omx/gstomx_vorbisdec.c b/omx/gstomx_vorbisdec.c
index fa532df..afd53fd 100644
--- a/omx/gstomx_vorbisdec.c
+++ b/omx/gstomx_vorbisdec.c
@@ -20,10 +20,9 @@
*/
#include "gstomx_vorbisdec.h"
-#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxVorbisDec, gst_omx_vorbisdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxVorbisDec, gst_omx_vorbisdec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -99,46 +98,6 @@ type_class_init (gpointer g_class,
}
static void
-settings_changed_cb (GOmxCore *core)
-{
- GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
-
- omx_base = core->object;
-
- GST_DEBUG_OBJECT (omx_base, "settings changed");
-
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
-
- rate = param.nSamplingRate;
- channels = param.nChannels;
- }
-
- {
- GstCaps *new_caps;
-
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "rate", G_TYPE_INT, rate,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, channels,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- NULL);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
-}
-
-static void
type_instance_init (GTypeInstance *instance,
gpointer g_class)
{
@@ -149,6 +108,4 @@ type_instance_init (GTypeInstance *instance,
GST_DEBUG_OBJECT (omx_base, "start");
omx_base->use_timestamps = FALSE;
-
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_vorbisdec.h b/omx/gstomx_vorbisdec.h
index 05ce070..c7737a3 100644
--- a/omx/gstomx_vorbisdec.h
+++ b/omx/gstomx_vorbisdec.h
@@ -32,16 +32,16 @@ G_BEGIN_DECLS
typedef struct GstOmxVorbisDec GstOmxVorbisDec;
typedef struct GstOmxVorbisDecClass GstOmxVorbisDecClass;
-#include "gstomx_base_filter.h"
+#include "gstomx_base_audiodec.h"
struct GstOmxVorbisDec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxVorbisDecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_vorbisdec_get_type (void);
--
1.6.3.2
|
|
From: Felipe C. <fel...@gm...> - 2010-03-23 22:45:59
|
On Thu, Mar 18, 2010 at 1:59 AM, Rob Clark <ro...@ti...> wrote: > Refactor some common functionality, in particular the settings_changed_cb, > into an abstract base class. I don't have much interest in the audio stuff, so I just quickly glanced over it. Looks ok. -- Felipe Contreras |