You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
|
Dec
(8) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(5) |
Feb
(3) |
Mar
|
Apr
(2) |
May
(4) |
Jun
(1) |
Jul
(11) |
Aug
(31) |
Sep
(2) |
Oct
(21) |
Nov
(16) |
Dec
(56) |
| 2009 |
Jan
(12) |
Feb
(5) |
Mar
(34) |
Apr
(9) |
May
(5) |
Jun
(7) |
Jul
(18) |
Aug
(5) |
Sep
(2) |
Oct
(6) |
Nov
(50) |
Dec
|
| 2010 |
Jan
(3) |
Feb
(67) |
Mar
(135) |
Apr
(30) |
May
(2) |
Jun
(11) |
Jul
|
Aug
(18) |
Sep
(12) |
Oct
(4) |
Nov
(17) |
Dec
(11) |
| 2011 |
Jan
(14) |
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Clark, R. <ro...@ti...> - 2010-03-01 16:00:25
|
On Mar 1, 2010, at 9:43 AM, Felipe Contreras wrote: > On Sat, Feb 27, 2010 at 8:24 PM, Rob Clark <ro...@ti...> wrote: >> btw, I'm thinking about this one again.. >> >> how about, in case of setting all params: >> >> OMX_AUDIO_PARAM_PCMMODETYPE param; >> >> G_OMX_INIT_PARAM (param); > > I think it should be: > > G_OMX_INIT_PARAM (OMX_AUDIO_PARAM_PCMMODETYPE, param); is this to declare the 'param' variable, as in G_OMX_DECLARE_PARAM()? Otherwise, why does the type need to be passed? > >> ... set params ... >> >> G_OMX_PORT_SET_PARAM (port, OMX_IndexParamAudioPcm, ¶m); > > I don't see a big difference to: > > param.nPortIndex = 1; > OMX_SetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m); there are two things I prefer about having a utility function/macro above the OMX_SetParameter() call: G_OMX_PORT_SET_PARAM (self->out_port, OMX_IndexParamAudioPcm, ¶m); 1) this makes it clearer *which* port it is related to, than 'param.nPortIndex = 1'.. which becomes more important with components that have many ports 2) it can deal w/ case where omx_handle isn't constructed yet.. which is important if you want to have properties on gst element that pass through to OMX config or params. BR, -R > >> or in case where you just want to set a few params: >> >> OMX_AUDIO_PARAM_PCMMODETYPE param; > > You forgot the init I guess. > >> G_OMX_PORT_GET_PARAM (port, OMX_IndexParamAudioPcm, ¶m); >> >> ... set params ... >> >> G_OMX_PORT_SET_PARAM (port, OMX_IndexParamAudioPcm, ¶m); > > Again, I don't see a big difference to: > > param.nPortIndex = 1; > OMX_GetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m); > > ... set params ... > > OMX_SetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m); > > Cheers. > > -- > Felipe Contreras |
|
From: Felipe C. <fel...@gm...> - 2010-03-01 15:44:01
|
On Sat, Feb 27, 2010 at 8:24 PM, Rob Clark <ro...@ti...> wrote: > btw, I'm thinking about this one again.. > > how about, in case of setting all params: > > OMX_AUDIO_PARAM_PCMMODETYPE param; > > G_OMX_INIT_PARAM (param); I think it should be: G_OMX_INIT_PARAM (OMX_AUDIO_PARAM_PCMMODETYPE, param); > ... set params ... > > G_OMX_PORT_SET_PARAM (port, OMX_IndexParamAudioPcm, ¶m); I don't see a big difference to: param.nPortIndex = 1; OMX_SetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m); > or in case where you just want to set a few params: > > OMX_AUDIO_PARAM_PCMMODETYPE param; You forgot the init I guess. > G_OMX_PORT_GET_PARAM (port, OMX_IndexParamAudioPcm, ¶m); > > ... set params ... > > G_OMX_PORT_SET_PARAM (port, OMX_IndexParamAudioPcm, ¶m); Again, I don't see a big difference to: param.nPortIndex = 1; OMX_GetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m); ... set params ... OMX_SetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m); Cheers. -- Felipe Contreras |
|
From: Felipe C. <fel...@gm...> - 2010-03-01 15:32:51
|
On Sun, Feb 28, 2010 at 10:22 PM, Rob Clark <ro...@ti...> wrote:
> These work like the GST_BOILERPLATE macros, but following the naming conventions for init functions used in the gst-openmax code, to remove a lot of gobject related boilerplate code.
> ---
> --- a/omx/gstomx_util.h
> +++ b/omx/gstomx_util.h
> @@ -142,4 +142,48 @@ void g_omx_port_enable (GOmxPort *port);
> void g_omx_port_disable (GOmxPort *port);
> void g_omx_port_finish (GOmxPort *port);
>
> +/* Utility Macros */
> +
> +/**
> + * Basically like GST_BOILERPLATE / GST_BOILERPLATE_FULL, but follows the
> + * init fxn naming conventions used by gst-openmax. It expects the following
> + * functions to be defined in the same src file following this macro
> + * <ul>
> + * <li> type_base_init(gpointer g_class)
> + * <li> type_class_init(gpointer g_class, gpointer class_data)
> + * <li> type_instance_init(GTypeInstance *instance, gpointer g_class)
> + * </ul>
> + */
> +#define GSTOMX_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations) \
> +static void type_base_init (gpointer g_class); \
> +static void type_class_init (gpointer g_class, gpointer class_data); \
> +static void type_instance_init (GTypeInstance *instance, gpointer g_class); \
> +static parent_type ## Class *parent_class; \
> +static void type_class_init_trampoline (gpointer g_class, gpointer class_data)\
> +{ \
> + parent_class = g_type_class_ref (parent_type_macro); \
> + type_class_init (g_class, class_data); \
> +} \
> +GType type_as_function ## _get_type (void) \
> +{ \
> + static GType _type = 0; \
> + if (G_UNLIKELY (_type == 0)) \
> + { \
> + GTypeInfo *type_info; \
> + type_info = g_new0 (GTypeInfo, 1); \
> + type_info->class_size = sizeof (type ## Class); \
> + type_info->base_init = type_base_init; \
> + type_info->class_init = type_class_init_trampoline; \
> + type_info->instance_size = sizeof (type); \
> + type_info->instance_init = type_instance_init; \
> + _type = g_type_register_static (parent_type_macro, #type, type_info, 0);\
> + g_free (type_info); \
> + additional_initializations (_type); \
> + } \
> + return _type; \
> +}
> +#define GSTOMX_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro) \
> + GSTOMX_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
> + __GST_DO_NOTHING)
> +
> #endif /* GSTOMX_UTIL_H */
Ahg, my eyes!
However, I don't see a better way to do this... ACK'ed.
--
Felipe Contreras
|
|
From: Felipe C. <fel...@gm...> - 2010-03-01 15:30:29
|
On Sun, Feb 28, 2010 at 10:24 PM, Rob Clark <ro...@ti...> wrote: > Reading and writing an int is not sufficient synchronization without barrier instructions. Using g_once_init_enter() (which uses g_atomic_pointer_get()) provides SMP safety. Looks fine to me. -- Felipe Contreras |
|
From: Felipe C. <fel...@gm...> - 2010-03-01 15:29:25
|
On Mon, Mar 1, 2010 at 1:36 AM, Rob Clark <ro...@ti...> wrote: > Latest (and hopefully final) version of patch fixes small memory leak You should specify the version of your patch (v6?), you can do that with easily with format-patch --subject-prefix="PATCH v6". Otherwise it's hard to keep track of them. Stefan, can I get your ACK for this? Cheers. -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-02-28 23:36:56
|
Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names
using the same gst-openmax class but different OMX library-name and/or component-name.
In the simple case, of one OMX component per gst-openmax class, specify the gst-openmax class as the 'type', and the 'library-name' and 'compnent-name' of the OMX component, and
optionally the 'rank' (defaults to 0 or GST_RANK_NONE):
----
omx_h264dec,
type=GstOmxH264Dec,
library-name=libomxil-bellagio.so.0,
component-name=OMX.st.video_decoder.avc,
rank=256;
----
Or in the advanced case of multiple OMX components per gst-openmax class, specify the gst-openmax class as the 'parent-type' and a dynamically created sub-class for the 'type':
----
omx_mp3dec_ti,
parent-type=GstOmxMp3Dec,
type=GstOmxMp3DecTi
library-name=libOMX_Core.so.0,
component-name=OMX.TI.AUDIO.DECODE,
component-role=audio_decode.dsp.mp3,
rank=256;
omx_mp3dec_nokia,
parent-type=GstOmxMp3Dec,
type=GstOmxMp3DecNokia
library-name=libomxil_bellagio.so.0,
component-name=OMX.nokia.audio_decode.mp3,
rank=128;
----
by default, the config file is stored in $HOME/.config/gst-openmax.conf, although if none is found a default config will be created.
---
Latest (and hopefully final) version of patch fixes small memory leak
omx/Makefile.am | 8 +-
omx/gstomx.c | 376 +++++++++++++++++++++++++++++++++++++++-------
omx/gstomx.conf | 203 +++++++++++++++++++++++++
omx/gstomx.h | 6 +
omx/gstomx_base_filter.c | 31 +----
omx/gstomx_base_filter.h | 2 -
omx/gstomx_base_sink.c | 31 +----
omx/gstomx_base_sink.h | 3 -
omx/gstomx_base_src.c | 38 +----
omx/gstomx_base_src.h | 2 -
omx/gstomx_util.c | 16 ++-
omx/gstomx_util.h | 2 +-
12 files changed, 564 insertions(+), 154 deletions(-)
create mode 100644 omx/gstomx.conf
diff --git a/omx/Makefile.am b/omx/Makefile.am
index 4a3fbf9..01243ff 100644
--- a/omx/Makefile.am
+++ b/omx/Makefile.am
@@ -18,7 +18,8 @@ libgstomx_la_SOURCES = gstomx.c gstomx.h \
gstomx_vorbisdec.c gstomx_vorbisdec.h \
gstomx_mp3dec.c gstomx_mp3dec.h \
gstomx_base_sink.c gstomx_base_sink.h \
- gstomx_audiosink.c gstomx_audiosink.h
+ gstomx_audiosink.c gstomx_audiosink.h \
+ gstomx_conf.c
if EXPERIMENTAL
libgstomx_la_SOURCES += gstomx_amrnbdec.c gstomx_amrnbdec.h \
@@ -47,3 +48,8 @@ libgstomx_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(top_builddir)/util/libutil.
libgstomx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
EXTRA_DIST = headers
+
+gstomx_conf.c: gstomx.conf
+ echo "const char * default_config =" > $@
+ cat $^ | $(CPP) $(CFLAGS) $(libgstomx_la_CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) - | grep -v "^#" | sed 's/^.*/\"&\\\n"/' >> $@
+ echo ";" >> $@
diff --git a/omx/gstomx.c b/omx/gstomx.c
index 6756f54..6fa9b09 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -21,6 +21,10 @@
#include "config.h"
+#include <string.h>
+
+#include <gst/gststructure.h>
+
#include "gstomx.h"
#include "gstomx_dummy.h"
#include "gstomx_mpeg4dec.h"
@@ -59,90 +63,348 @@
GST_DEBUG_CATEGORY (gstomx_debug);
-typedef struct TableItem
-{
- const gchar *name;
- const gchar *library_name;
- const gchar *component_name;
- guint rank;
- GType (*get_type) (void);
-} TableItem;
-
-static TableItem element_table[] =
-{
- { "omx_dummy", "libomxil-bellagio.so.0", "OMX.st.dummy", GST_RANK_NONE, gst_omx_dummy_get_type },
- { "omx_mpeg4dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4dec_get_type },
- { "omx_h264dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.avc", GST_RANK_PRIMARY, gst_omx_h264dec_get_type },
- { "omx_h263dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.h263", GST_RANK_PRIMARY, gst_omx_h263dec_get_type },
- { "omx_wmvdec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.wmv", GST_RANK_PRIMARY, gst_omx_wmvdec_get_type },
- { "omx_mpeg4enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4enc_get_type },
- { "omx_h264enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.avc", GST_RANK_PRIMARY, gst_omx_h264enc_get_type },
- { "omx_h263enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.h263", GST_RANK_PRIMARY, gst_omx_h263enc_get_type },
- { "omx_vorbisdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ogg.single", GST_RANK_SECONDARY, gst_omx_vorbisdec_get_type },
- { "omx_mp3dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp3dec_get_type },
+static GstStructure *element_table = NULL;
+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
- { "omx_mp2dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp2dec_get_type },
- { "omx_amrnbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbdec_get_type },
- { "omx_amrnbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbenc_get_type },
- { "omx_amrwbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbdec_get_type },
- { "omx_amrwbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbenc_get_type },
- { "omx_aacdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.aac", GST_RANK_PRIMARY, gst_omx_aacdec_get_type },
- { "omx_aacenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.aac", GST_RANK_PRIMARY, gst_omx_aacenc_get_type },
- { "omx_adpcmdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmdec_get_type },
- { "omx_adpcmenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmenc_get_type },
- { "omx_g711dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g711", GST_RANK_PRIMARY, gst_omx_g711dec_get_type },
- { "omx_g711enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g711", GST_RANK_PRIMARY, gst_omx_g711enc_get_type },
- { "omx_g729dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g729", GST_RANK_PRIMARY, gst_omx_g729dec_get_type },
- { "omx_g729enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g729", GST_RANK_PRIMARY, gst_omx_g729enc_get_type },
- { "omx_ilbcdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcdec_get_type },
- { "omx_ilbcenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcenc_get_type },
- { "omx_jpegenc", "libomxil-bellagio.so.0", "OMX.st.image_encoder.jpeg", GST_RANK_PRIMARY, gst_omx_jpegenc_get_type },
+ 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 */
- { "omx_audiosink", "libomxil-bellagio.so.0", "OMX.st.alsa.alsasink", GST_RANK_NONE, gst_omx_audiosink_get_type },
+ gst_omx_audiosink_get_type,
#ifdef EXPERIMENTAL
- { "omx_videosink", "libomxil-bellagio.so.0", "OMX.st.videosink", GST_RANK_NONE, gst_omx_videosink_get_type },
- { "omx_filereadersrc", "libomxil-bellagio.so.0", "OMX.st.audio_filereader", GST_RANK_NONE, gst_omx_filereadersrc_get_type },
+ gst_omx_videosink_get_type,
+ gst_omx_filereadersrc_get_type,
#endif /* EXPERIMENTAL */
- { "omx_volume", "libomxil-bellagio.so.0", "OMX.st.volume.component", GST_RANK_NONE, gst_omx_volume_get_type },
- { NULL, NULL, NULL, 0, NULL },
+ gst_omx_volume_get_type,
};
+/* TODO: we can cache table w/ gst_plugin_{get,set}_cache_data..
+ */
+static GstStructure *
+get_element_table (void)
+{
+ static volatile gsize gonce_data = 0;
+ if (g_once_init_enter (&gonce_data))
+ {
+ gchar *path;
+ gchar *config, *s;
+ GstStructure *element;
+
+ path = g_strdup (g_getenv ("OMX_REGISTRY"));
+ if (!path)
+ {
+ path = g_build_filename (g_get_user_config_dir (),
+ "gst-openmax.conf", NULL);
+ }
+
+ if (!g_file_get_contents (path, &config, NULL, NULL))
+ {
+ g_warning ("could not find config file '%s'.. using defaults!", path);
+ config = (gchar *) default_config;
+
+ g_file_set_contents (path, config, -1, NULL);
+ }
+
+ GST_DEBUG ("parsing config:\n%s", config);
+
+ element_table = 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 (element_table,
+ element_name, GST_TYPE_STRUCTURE, element, NULL);
+ }
+
+ if (config != default_config)
+ {
+ g_free (config);
+ }
+
+ g_free (path);
+
+ GST_DEBUG ("element_table=%"GST_PTR_FORMAT, element_table);
+
+ g_once_init_leave (&gonce_data, 1);
+ }
+
+ return element_table;
+}
+
+static GstStructure *
+get_element_entry (const gchar *element_name)
+{
+ GstStructure *element_table = get_element_table ();
+ GstStructure *element;
+
+ if (! gst_structure_get (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;
+}
+
+static const gchar *
+get_element_name (gpointer object)
+{
+ return g_type_get_qdata (G_OBJECT_TYPE (object), element_name_quark);
+}
+
+/* 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)
{
- GQuark library_name_quark;
- GQuark component_name_quark;
+ gint i, cnt;
+ GstStructure *element_table;
+
GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
- library_name_quark = g_quark_from_static_string ("library-name");
- component_name_quark = g_quark_from_static_string ("component-name");
+ 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] ();
+ }
+
+ element_table = get_element_table ();
g_omx_init ();
+ cnt = gst_structure_n_fields (element_table);
+ for (i = 0; i < cnt; i++)
{
- guint i;
- for (i = 0; element_table[i].name; i++)
- {
- TableItem *element;
- GType type;
+ 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;
+ GType type;
+ gint rank;
+
+ GST_DEBUG ("element_name=%s, element=%"GST_PTR_FORMAT, element_name, element);
- element = &element_table[i];
- type = element->get_type ();
- g_type_set_qdata (type, library_name_quark, (gpointer) element->library_name);
- g_type_set_qdata (type, component_name_quark, (gpointer) element->component_name);
+ parent_type_name = gst_structure_get_string (element, "parent-type");
+ type_name = gst_structure_get_string (element, "type");
- if (!gst_element_register (plugin, element->name, element->rank, type))
+ if (parent_type_name)
+ {
+ type = g_type_from_name (parent_type_name);
+ if (type)
+ {
+ type = create_subtype (type, type_name);
+ }
+ else
{
- g_warning ("failed registering '%s'", element->name);
+ g_warning ("malformed config file: invalid parent-type '%s' for %s",
+ parent_type_name, element_name);
return FALSE;
}
}
+ else if (type_name)
+ {
+ type = g_type_from_name (type_name);
+ }
+
+ if (!type_name)
+ {
+ g_warning ("malformed config file: missing 'type' for %s",
+ element_name);
+ return FALSE;
+ }
+
+ 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;
}
+/**
+ * g_omx_get_component_info:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @library_name: library-name, returned by reference (or NULL)
+ * @component_name: component-name, returned by reference (or NULL)
+ *
+ * Get library-name and component-name for an element.
+ *
+ * note: this function will gain another parameter later when component-role
+ * is added
+ */
+gboolean
+g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name)
+{
+ gboolean ret = TRUE;
+ const gchar *element_name = get_element_name (object);
+ GstStructure *element = get_element_entry (element_name);
+
+ if (!element)
+ return FALSE;
+
+ /* initialize ptrs to NULL so that in error cases we can tell what needs
+ * to be freed:
+ */
+ if (library_name) *library_name = NULL;
+ if (component_name) *component_name = NULL;
+
+ if (library_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "library-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'library-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *library_name = g_strdup (str);
+ }
+
+ if (component_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "component-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'component-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *component_name = g_strdup (str);
+ }
+
+exit:
+
+ /* if we failed, free any memory that might have been allocated:
+ */
+ if (!ret)
+ {
+ if (library_name) g_free (*library_name);
+ if (component_name) g_free (*component_name);
+ }
+
+
+ return ret;
+}
+
+static gboolean
+set_value_helper (GValue *value, gchar *str)
+{
+ g_value_take_string (value, str);
+ return TRUE;
+}
+
+/**
+ * g_omx_get_library_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "library-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_library_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, &str, NULL) &&
+ set_value_helper (val, str);
+}
+
+/**
+ * g_omx_get_component_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "component-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_component_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, NULL, &str) &&
+ set_value_helper (val, str);
+}
+
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"omx",
diff --git a/omx/gstomx.conf b/omx/gstomx.conf
new file mode 100644
index 0000000..c22c6d6
--- /dev/null
+++ b/omx/gstomx.conf
@@ -0,0 +1,203 @@
+#include "config.h"
+
+/* in case of multiple OMX components mapping to a single gst-openmax element
+ * class, a dynamic subclass can be created by specifying the gst-openmax
+ * type as the 'parent-type' and specifying a new unique type name as the
+ * 'type' parameter:
+ */
+omx_dummy,
+ parent-type=GstOmxDummy,
+ type=GstOmxDummyOne,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.bellagio.dummy,
+ rank=0;
+
+/* for testing: */
+omx_dummy_2,
+ parent-type=GstOmxDummy,
+ type=GstOmxDummyTwo,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.dummy2,
+ rank=256;
+
+omx_mpeg4dec,
+ type=GstOmxMpeg4Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.mpeg4,
+ rank=256;
+
+omx_h264dec,
+ type=GstOmxH264Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.avc,
+ rank=256;
+
+omx_h263dec,
+ type=GstOmxH263Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.h263,
+ rank=256;
+
+omx_wmvdec,
+ type=GstOmxWmvDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.wmv,
+ rank=256;
+
+omx_mpeg4enc,
+ type=GstOmxMpeg4Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.mpeg4,
+ rank=256;
+
+omx_h264enc,
+ type=GstOmxH264Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.avc,
+ rank=256;
+
+omx_h263enc,
+ type=GstOmxH263Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.h263,
+ rank=256;
+
+omx_vorbisdec,
+ type=GstOmxVorbisDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.ogg.single,
+ rank=128;
+
+omx_mp3dec,
+ type=GstOmxMp3Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.mp3.mad,
+ rank=256;
+
+#ifdef EXPERIMENTAL
+
+omx_mp2dec,
+ type=GstOmxMp2Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.mp3.mad,
+ rank=256;
+
+omx_amrnbdec,
+ type=GstOmxAmrNbDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.amrnb,
+ rank=256;
+
+omx_amrnbenc,
+ type=GstOmxAmrNbEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.amrnb,
+ rank=256;
+
+omx_amrwbdec,
+ type=GstOmxAmrWbDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.amrwb,
+ rank=256;
+
+omx_amrwbenc,
+ type=GstOmxAmrWbEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.amrwb,
+ rank=256;
+
+omx_aacdec,
+ type=GstOmxAacDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.aac,
+ rank=256;
+
+omx_aacenc,
+ type=GstOmxAacEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.aac,
+ rank=256;
+
+omx_adpcmdec,
+ type=GstOmxAdpcmDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.adpcm,
+ rank=256;
+
+omx_adpcmenc,
+ type=GstOmxAdpcmEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.adpcm,
+ rank=256;
+
+omx_g711dec,
+ type=GstOmxG711Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.g711,
+ rank=256;
+
+omx_g711enc,
+ type=GstOmxG711Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.g711,
+ rank=256;
+
+omx_g729dec,
+ type=GstOmxG729Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.g729,
+ rank=256;
+
+omx_g729enc,
+ type=GstOmxG729Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.g729,
+ rank=256;
+
+omx_ilbcdec,
+ type=GstOmxIlbcDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.ilbc,
+ rank=256;
+
+omx_ilbcenc,
+ type=GstOmxIlbcEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.ilbc,
+ rank=256;
+
+omx_jpegenc,
+ type=GstOmxJpegEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.image_encoder.jpeg,
+ rank=256;
+
+#endif /* EXPERIMENTAL */
+
+omx_audiosink,
+ type=GstOmxAudioSink,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.alsa.alsasink,
+ rank=0;
+
+#ifdef EXPERIMENTAL
+
+omx_videosink,
+ type=GstOmxVideoSink,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.videosink,
+ rank=0;
+
+omx_filereadersrc,
+ type=GstOmxFilereaderSrc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_filereader,
+ rank=0;
+
+#endif /* EXPERIMENTAL */
+
+omx_volume,
+ type=GstOmxVolume,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.volume.component,
+ rank=0;
diff --git a/omx/gstomx.h b/omx/gstomx.h
index 7d5fa04..063437d 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -30,6 +30,12 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
#define GST_CAT_DEFAULT gstomx_debug
+gboolean g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name);
+gboolean g_omx_get_library_name_value (gpointer object, GValue *val);
+gboolean g_omx_get_component_name_value (gpointer object, GValue *val);
+
G_END_DECLS
#endif /* GSTOMX_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index b0353cb..2a30502 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -115,7 +115,7 @@ change_state (GstElement *element,
switch (transition)
{
case GST_STATE_CHANGE_NULL_TO_READY:
- g_omx_core_init (core, self->omx_library, self->omx_component);
+ g_omx_core_init (core);
if (core->omx_state != OMX_StateLoaded)
{
ret = GST_STATE_CHANGE_FAILURE;
@@ -184,9 +184,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
g_mutex_free (self->ready_lock);
G_OBJECT_CLASS (parent_class)->finalize (obj);
@@ -204,14 +201,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
case ARG_USE_TIMESTAMPS:
self->use_timestamps = g_value_get_boolean (value);
break;
@@ -234,10 +223,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
case ARG_USE_TIMESTAMPS:
g_value_set_boolean (value, self->use_timestamps);
@@ -271,12 +260,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
g_param_spec_boolean ("use-timestamps", "Use timestamps",
@@ -922,16 +911,6 @@ type_instance_init (GTypeInstance *instance,
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_filter.h b/omx/gstomx_base_filter.h
index 4baf181..99b5d72 100644
--- a/omx/gstomx_base_filter.h
+++ b/omx/gstomx_base_filter.h
@@ -48,8 +48,6 @@ struct GstOmxBaseFilter
GOmxPort *in_port;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
gboolean use_timestamps; /** @todo remove; timestamps should always be used */
gboolean ready;
GMutex *ready_lock;
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index c1a2076..7911167 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -141,9 +141,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -298,14 +295,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -325,10 +314,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -366,12 +355,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -420,7 +409,7 @@ activate_push (GstPad *pad,
static inline gboolean
omx_init (GstOmxBaseSink *self)
{
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return FALSE;
@@ -468,16 +457,6 @@ type_instance_init (GTypeInstance *instance,
}
{
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
- {
GstPad *sinkpad;
self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
index 681e939..589c441 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -46,9 +46,6 @@ struct GstOmxBaseSink
GOmxCore *gomx;
GOmxPort *in_port;
- char *omx_component;
- char *omx_library;
-
gboolean ready;
GstPadActivateModeFunction base_activatepush;
gboolean initialized;
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 9b02b22..dd9767e 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -67,7 +67,7 @@ start (GstBaseSrc *gst_base)
GST_LOG_OBJECT (self, "begin");
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -106,9 +106,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -362,20 +359,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- if (self->omx_component)
- {
- g_free (self->omx_component);
- }
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- if (self->omx_library)
- {
- g_free (self->omx_library);
- }
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -395,10 +378,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -433,12 +416,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -459,17 +442,6 @@ type_instance_init (GTypeInstance *instance,
gomx->object = self;
}
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_src.h b/omx/gstomx_base_src.h
index 85e4c13..adab894 100644
--- a/omx/gstomx_base_src.h
+++ b/omx/gstomx_base_src.h
@@ -44,8 +44,6 @@ struct GstOmxBaseSrc
GOmxCore *gomx;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
GstOmxBaseSrcCb setup_ports;
};
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 39d900b..dae3f67 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -301,10 +301,17 @@ g_omx_core_free (GOmxCore *core)
}
void
-g_omx_core_init (GOmxCore *core,
- const gchar *library_name,
- const gchar *component_name)
+g_omx_core_init (GOmxCore *core)
{
+ gchar *library_name, *component_name;
+
+ if (!g_omx_get_component_info (core->object,
+ &library_name, &component_name))
+ {
+ GST_ERROR_OBJECT (core->object, "missing component info");
+ return;
+ }
+
core->imp = request_imp (library_name);
if (!core->imp)
@@ -316,6 +323,9 @@ g_omx_core_init (GOmxCore *core,
&callbacks);
if (!core->omx_error)
core->omx_state = OMX_StateLoaded;
+
+ g_free (library_name);
+ g_free (component_name);
}
void
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index f0cf045..c3ac441 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -116,7 +116,7 @@ void g_omx_deinit (void);
GOmxCore *g_omx_core_new (void);
void g_omx_core_free (GOmxCore *core);
-void g_omx_core_init (GOmxCore *core, const gchar *library_name, const gchar *component_name);
+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);
--
1.6.3.2
|
|
From: Rob C. <ro...@ti...> - 2010-02-28 20:24:56
|
Reading and writing an int is not sufficient synchronization without barrier instructions. Using g_once_init_enter() (which uses g_atomic_pointer_get()) provides SMP safety.
---
omx/gstomx_util.h | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index 586ad6b..14bf60b 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -166,9 +166,12 @@ static void type_class_init_trampoline (gpointer g_class, gpointer class_data)\
} \
GType type_as_function ## _get_type (void) \
{ \
- static GType _type = 0; \
- if (G_UNLIKELY (_type == 0)) \
- { \
+ /* The typedef for GType may be gulong or gsize, depending on the \
+ * system and whether the compiler is c++ or not. The g_once_init_* \
+ * functions always take a gsize * though ... */ \
+ static volatile gsize gonce_data = 0; \
+ if (g_once_init_enter (&gonce_data)) { \
+ GType _type; \
GTypeInfo *type_info; \
type_info = g_new0 (GTypeInfo, 1); \
type_info->class_size = sizeof (type ## Class); \
@@ -179,9 +182,11 @@ GType type_as_function ## _get_type (void) \
_type = g_type_register_static (parent_type_macro, #type, type_info, 0);\
g_free (type_info); \
additional_initializations (_type); \
+ g_once_init_leave (&gonce_data, (gsize) _type); \
} \
- return _type; \
+ return (GType) gonce_data; \
}
+
#define GSTOMX_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro) \
GSTOMX_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
__GST_DO_NOTHING)
--
1.6.3.2
|
|
From: Rob C. <ro...@ti...> - 2010-02-28 20:24:21
|
These work like the GST_BOILERPLATE macros, but following the naming conventions for init functions used in the gst-openmax code, to remove a lot of gobject related boilerplate code.
---
omx/gstomx_aacdec.c | 27 +----------------------
omx/gstomx_aacenc.c | 28 +----------------------
omx/gstomx_adpcmdec.c | 27 +----------------------
omx/gstomx_adpcmenc.c | 27 +----------------------
omx/gstomx_amrnbdec.c | 27 +----------------------
omx/gstomx_amrnbenc.c | 28 +----------------------
omx/gstomx_amrwbdec.c | 27 +----------------------
omx/gstomx_amrwbenc.c | 28 +----------------------
omx/gstomx_audiosink.c | 27 +----------------------
omx/gstomx_base_filter.c | 51 +++++++++++++++++--------------------------
omx/gstomx_base_sink.c | 52 ++++++++++++++++---------------------------
omx/gstomx_base_src.c | 32 +++++----------------------
omx/gstomx_base_videodec.c | 27 +----------------------
omx/gstomx_base_videoenc.c | 28 +----------------------
omx/gstomx_dummy.c | 27 +----------------------
omx/gstomx_filereadersrc.c | 27 +----------------------
omx/gstomx_g711dec.c | 27 +----------------------
omx/gstomx_g711enc.c | 27 +----------------------
omx/gstomx_g729dec.c | 27 +----------------------
omx/gstomx_g729enc.c | 28 +----------------------
omx/gstomx_h263dec.c | 27 +----------------------
omx/gstomx_h263enc.c | 27 +----------------------
omx/gstomx_h264dec.c | 27 +----------------------
omx/gstomx_h264enc.c | 27 +----------------------
omx/gstomx_ilbcdec.c | 27 +----------------------
omx/gstomx_ilbcenc.c | 27 +----------------------
omx/gstomx_jpegenc.c | 28 +----------------------
omx/gstomx_mp2dec.c | 27 +----------------------
omx/gstomx_mp3dec.c | 27 +----------------------
omx/gstomx_mpeg4dec.c | 27 +----------------------
omx/gstomx_mpeg4enc.c | 27 +----------------------
omx/gstomx_util.h | 44 +++++++++++++++++++++++++++++++++++++
omx/gstomx_videosink.c | 28 +----------------------
omx/gstomx_volume.c | 27 +----------------------
omx/gstomx_vorbisdec.c | 28 +----------------------
omx/gstomx_wmvdec.c | 27 +----------------------
36 files changed, 121 insertions(+), 930 deletions(-)
diff --git a/omx/gstomx_aacdec.c b/omx/gstomx_aacdec.c
index 2ec2b4d..f72178d 100644
--- a/omx/gstomx_aacdec.c
+++ b/omx/gstomx_aacdec.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAacDec, gst_omx_aacdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -127,7 +127,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -214,27 +213,3 @@ type_instance_init (GTypeInstance *instance,
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
-
-GType
-gst_omx_aacdec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAacDecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAacDec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxAacDec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_aacenc.c b/omx/gstomx_aacenc.c
index eabc855..fc15999 100644
--- a/omx/gstomx_aacenc.c
+++ b/omx/gstomx_aacenc.c
@@ -37,7 +37,7 @@ enum
#define DEFAULT_PROFILE OMX_AUDIO_AACObjectLC
#define DEFAULT_OUTPUT_FORMAT OMX_AUDIO_AACStreamFormatRAW
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAacEnc, gst_omx_aacenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
#define GST_TYPE_OMX_AACENC_PROFILE (gst_omx_aacenc_profile_get_type ())
static GType
@@ -251,8 +251,6 @@ type_class_init (gpointer g_class,
gobject_class = G_OBJECT_CLASS (g_class);
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
-
/* Properties stuff */
{
gobject_class->set_property = set_property;
@@ -430,27 +428,3 @@ type_instance_init (GTypeInstance *instance,
self->profile = DEFAULT_PROFILE;
self->output_format = DEFAULT_OUTPUT_FORMAT;
}
-
-GType
-gst_omx_aacenc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAacEncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAacEnc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxAacEnc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_adpcmdec.c b/omx/gstomx_adpcmdec.c
index 86bb54c..ed77085 100644
--- a/omx/gstomx_adpcmdec.c
+++ b/omx/gstomx_adpcmdec.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAdpcmDec, gst_omx_adpcmdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -101,7 +101,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static gboolean
@@ -171,27 +170,3 @@ type_instance_init (GTypeInstance *instance,
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
-
-GType
-gst_omx_adpcmdec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAdpcmDecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAdpcmDec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxAdpcmDec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_adpcmenc.c b/omx/gstomx_adpcmenc.c
index 967ebf9..ab5ce61 100644
--- a/omx/gstomx_adpcmenc.c
+++ b/omx/gstomx_adpcmenc.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAdpcmEnc, gst_omx_adpcmenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -101,7 +101,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -235,27 +234,3 @@ type_instance_init (GTypeInstance *instance,
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
-
-GType
-gst_omx_adpcmenc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAdpcmEncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAdpcmEnc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxAdpcmEnc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_amrnbdec.c b/omx/gstomx_amrnbdec.c
index bdacb06..a32f162 100644
--- a/omx/gstomx_amrnbdec.c
+++ b/omx/gstomx_amrnbdec.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAmrNbDec, gst_omx_amrnbdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -100,7 +100,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -156,27 +155,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_amrnbdec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAmrNbDecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAmrNbDec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxAmrNbDec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_amrnbenc.c b/omx/gstomx_amrnbenc.c
index d8b921b..10f326c 100644
--- a/omx/gstomx_amrnbenc.c
+++ b/omx/gstomx_amrnbenc.c
@@ -33,7 +33,7 @@ enum
#define DEFAULT_BITRATE 64000
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAmrNbEnc, gst_omx_amrnbenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -155,8 +155,6 @@ type_class_init (gpointer g_class,
gobject_class = G_OBJECT_CLASS (g_class);
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
-
/* Properties stuff */
{
gobject_class->set_property = set_property;
@@ -265,27 +263,3 @@ type_instance_init (GTypeInstance *instance,
self->bitrate = DEFAULT_BITRATE;
}
-
-GType
-gst_omx_amrnbenc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAmrNbEncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAmrNbEnc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxAmrNbEnc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_amrwbdec.c b/omx/gstomx_amrwbdec.c
index 0914f84..26e1692 100644
--- a/omx/gstomx_amrwbdec.c
+++ b/omx/gstomx_amrwbdec.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAmrWbDec, gst_omx_amrwbdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -100,7 +100,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -156,27 +155,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_amrwbdec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAmrWbDecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAmrWbDec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxAmrWbDec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_amrwbenc.c b/omx/gstomx_amrwbenc.c
index 176ccb3..f693934 100644
--- a/omx/gstomx_amrwbenc.c
+++ b/omx/gstomx_amrwbenc.c
@@ -33,7 +33,7 @@ enum
#define DEFAULT_BITRATE 64000
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAmrWbEnc, gst_omx_amrwbenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -155,8 +155,6 @@ type_class_init (gpointer g_class,
gobject_class = G_OBJECT_CLASS (g_class);
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
-
/* Properties stuff */
{
gobject_class->set_property = set_property;
@@ -265,27 +263,3 @@ type_instance_init (GTypeInstance *instance,
self->bitrate = DEFAULT_BITRATE;
}
-
-GType
-gst_omx_amrwbenc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAmrWbEncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAmrWbEnc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxAmrWbEnc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_audiosink.c b/omx/gstomx_audiosink.c
index 8fa1748..a05a7cd 100644
--- a/omx/gstomx_audiosink.c
+++ b/omx/gstomx_audiosink.c
@@ -24,7 +24,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseSinkClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxAudioSink, gst_omx_audiosink, GstOmxBaseSink, GST_OMX_BASE_SINK_TYPE);
static GstCaps *
generate_sink_template (void)
@@ -136,7 +136,6 @@ type_class_init (gpointer g_class,
{
GstBaseSinkClass *gst_base_sink_class;
- parent_class = g_type_class_ref (GST_OMX_BASE_SINK_TYPE);
gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
gst_base_sink_class->set_caps = setcaps;
@@ -152,27 +151,3 @@ type_instance_init (GTypeInstance *instance,
GST_DEBUG_OBJECT (omx_base, "start");
}
-
-GType
-gst_omx_audiosink_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxAudioSinkClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxAudioSink);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_SINK_TYPE, "GstOmxAudioSink", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 2a30502..909d9a6 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -33,7 +33,8 @@ enum
ARG_USE_TIMESTAMPS,
};
-static GstElementClass *parent_class;
+static void init_interfaces (GType type);
+GSTOMX_BOILERPLATE_FULL (GstOmxBaseFilter, gst_omx_base_filter, GstElement, GST_TYPE_ELEMENT, init_interfaces);
static inline void
log_buffer (GstOmxBaseFilter *self,
@@ -238,6 +239,11 @@ get_property (GObject *obj,
}
static void
+type_base_init (gpointer g_class)
+{
+}
+
+static void
type_class_init (gpointer g_class,
gpointer class_data)
{
@@ -247,8 +253,6 @@ type_class_init (gpointer g_class,
gobject_class = G_OBJECT_CLASS (g_class);
gstelement_class = GST_ELEMENT_CLASS (g_class);
- parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
gobject_class->finalize = finalize;
gstelement_class->change_state = change_state;
@@ -933,38 +937,23 @@ interface_init (GstImplementsInterfaceClass *klass)
klass->supported = interface_supported;
}
-GType
-gst_omx_base_filter_get_type (void)
+static void
+init_interfaces (GType type)
{
- static GType type = 0;
+ GInterfaceInfo *iface_info;
+ GInterfaceInfo *omx_info;
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
- GInterfaceInfo *iface_info;
- GInterfaceInfo *omx_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxBaseFilterClass);
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxBaseFilter);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_TYPE_ELEMENT, "GstOmxBaseFilter", type_info, 0);
- g_free (type_info);
- iface_info = g_new0 (GInterfaceInfo, 1);
- iface_info->interface_init = (GInterfaceInitFunc) interface_init;
+ iface_info = g_new0 (GInterfaceInfo, 1);
+ iface_info->interface_init = (GInterfaceInitFunc) interface_init;
- g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, iface_info);
- g_free (iface_info);
+ g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, iface_info);
+ g_free (iface_info);
- omx_info = g_new0 (GInterfaceInfo, 1);
- omx_info->interface_init = (GInterfaceInitFunc) omx_interface_init;
+ omx_info = g_new0 (GInterfaceInfo, 1);
+ omx_info->interface_init = (GInterfaceInitFunc) omx_interface_init;
- g_type_add_interface_static (type, GST_TYPE_OMX, omx_info);
- g_free (omx_info);
- }
-
- return type;
+ g_type_add_interface_static (type, GST_TYPE_OMX, omx_info);
+ g_free (omx_info);
}
+
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 7911167..8c18628 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -39,7 +39,8 @@ enum
ARG_LIBRARY_NAME,
};
-static GstElementClass *parent_class;
+static void init_interfaces (GType type);
+GSTOMX_BOILERPLATE_FULL (GstOmxBaseSink, gst_omx_base_sink, GstBaseSink, GST_TYPE_BASE_SINK, init_interfaces);
static void
setup_ports (GstOmxBaseSink *self)
@@ -326,6 +327,11 @@ get_property (GObject *obj,
}
static void
+type_base_init (gpointer g_class)
+{
+}
+
+static void
type_class_init (gpointer g_class,
gpointer class_data)
{
@@ -337,8 +343,6 @@ type_class_init (gpointer g_class,
gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
gstelement_class = GST_ELEMENT_CLASS (g_class);
- parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
gobject_class->finalize = finalize;
gstelement_class->change_state = change_state;
@@ -485,39 +489,21 @@ interface_init (GstImplementsInterfaceClass *klass)
{
klass->supported = interface_supported;
}
-
-GType
-gst_omx_base_sink_get_type (void)
+static void
+init_interfaces (GType type)
{
- static GType type = 0;
+ GInterfaceInfo *iface_info;
+ GInterfaceInfo *omx_info;
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
- GInterfaceInfo *iface_info;
- GInterfaceInfo *omx_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxBaseSinkClass);
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxBaseSink);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_TYPE_BASE_SINK, "GstOmxBaseSink", type_info, 0);
- g_free (type_info);
+ iface_info = g_new0 (GInterfaceInfo, 1);
+ iface_info->interface_init = (GInterfaceInitFunc) interface_init;
- iface_info = g_new0 (GInterfaceInfo, 1);
- iface_info->interface_init = (GInterfaceInitFunc) interface_init;
+ g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, iface_info);
+ g_free (iface_info);
- g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, iface_info);
- g_free (iface_info);
-
- omx_info = g_new0 (GInterfaceInfo, 1);
- omx_info->interface_init = (GInterfaceInitFunc) omx_interface_init;
-
- g_type_add_interface_static (type, GST_TYPE_OMX, omx_info);
- g_free (omx_info);
- }
+ omx_info = g_new0 (GInterfaceInfo, 1);
+ omx_info->interface_init = (GInterfaceInitFunc) omx_interface_init;
- return type;
+ g_type_add_interface_static (type, GST_TYPE_OMX, omx_info);
+ g_free (omx_info);
}
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index dd9767e..87b474c 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -31,7 +31,7 @@ enum
ARG_LIBRARY_NAME,
};
-static GstElementClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxBaseSrc, gst_omx_base_src, GstBaseSrc, GST_TYPE_BASE_SRC);
static void
setup_ports (GstOmxBaseSrc *self)
@@ -390,6 +390,11 @@ get_property (GObject *obj,
}
static void
+type_base_init (gpointer g_class)
+{
+}
+
+static void
type_class_init (gpointer g_class,
gpointer class_data)
{
@@ -399,8 +404,6 @@ type_class_init (gpointer g_class,
gobject_class = G_OBJECT_CLASS (g_class);
gst_base_src_class = GST_BASE_SRC_CLASS (g_class);
- parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
gobject_class->finalize = finalize;
gst_base_src_class->start = start;
@@ -444,26 +447,3 @@ type_instance_init (GTypeInstance *instance,
GST_LOG_OBJECT (self, "end");
}
-
-GType
-gst_omx_base_src_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxBaseSrcClass);
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxBaseSrc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_TYPE_BASE_SRC, "GstOmxBaseSrc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_base_videodec.c b/omx/gstomx_base_videodec.c
index c6dd364..3ff2f44 100644
--- a/omx/gstomx_base_videodec.c
+++ b/omx/gstomx_base_videodec.c
@@ -24,7 +24,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxBaseVideoDec, gst_omx_base_videodec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -91,7 +91,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -277,27 +276,3 @@ type_instance_init (GTypeInstance *instance,
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
-
-GType
-gst_omx_base_videodec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxBaseVideoDecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxBaseVideoDec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxBaseVideoDec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_base_videoenc.c b/omx/gstomx_base_videoenc.c
index f788817..9d26cfd 100644
--- a/omx/gstomx_base_videoenc.c
+++ b/omx/gstomx_base_videoenc.c
@@ -32,7 +32,7 @@ enum
#define DEFAULT_BITRATE 0
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxBaseVideoEnc, gst_omx_base_videoenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_sink_template (void)
@@ -146,8 +146,6 @@ type_class_init (gpointer g_class,
gobject_class = G_OBJECT_CLASS (g_class);
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
-
/* Properties stuff */
{
gobject_class->set_property = set_property;
@@ -296,27 +294,3 @@ type_instance_init (GTypeInstance *instance,
self->bitrate = DEFAULT_BITRATE;
}
-
-GType
-gst_omx_base_videoenc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxBaseVideoEncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxBaseVideoEnc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxBaseVideoEnc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_dummy.c b/omx/gstomx_dummy.c
index 63fde61..03ebc41 100644
--- a/omx/gstomx_dummy.c
+++ b/omx/gstomx_dummy.c
@@ -23,7 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxDummy, gst_omx_dummy, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -88,7 +88,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -101,27 +100,3 @@ type_instance_init (GTypeInstance *instance,
GST_DEBUG_OBJECT (omx_base, "start");
}
-
-GType
-gst_omx_dummy_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxDummyClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxDummy);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxDummy", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_filereadersrc.c b/omx/gstomx_filereadersrc.c
index cea5ca9..38b6964 100644
--- a/omx/gstomx_filereadersrc.c
+++ b/omx/gstomx_filereadersrc.c
@@ -29,7 +29,7 @@ enum
ARG_FILE_NAME,
};
-static GstOmxBaseSrcClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxFilereaderSrc, gst_omx_filereadersrc, GstOmxBaseSrc, GST_OMX_BASE_SRC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -167,7 +167,6 @@ type_class_init (gpointer g_class,
GstBaseSrcClass *gst_base_src_class;
GObjectClass *gobject_class;
- parent_class = g_type_class_ref (GST_OMX_BASE_SRC_TYPE);
gst_base_src_class = GST_BASE_SRC_CLASS (g_class);
gobject_class = G_OBJECT_CLASS (g_class);
@@ -201,27 +200,3 @@ type_instance_init (GTypeInstance *instance,
GST_DEBUG_OBJECT (omx_base, "end");
}
-
-GType
-gst_omx_filereadersrc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxFilereaderSrcClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxFilereaderSrc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_SRC_TYPE, "GstOmxFilereaderSrc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_g711dec.c b/omx/gstomx_g711dec.c
index f2b5e73..40cd64b 100644
--- a/omx/gstomx_g711dec.c
+++ b/omx/gstomx_g711dec.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset, strcmp */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxG711Dec, gst_omx_g711dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -112,7 +112,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static gboolean
@@ -188,27 +187,3 @@ type_instance_init (GTypeInstance *instance,
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
-
-GType
-gst_omx_g711dec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxG711DecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxG711Dec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxG711Dec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_g711enc.c b/omx/gstomx_g711enc.c
index 440f3f4..16d58aa 100644
--- a/omx/gstomx_g711enc.c
+++ b/omx/gstomx_g711enc.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset, strcmp */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxG711Enc, gst_omx_g711enc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -112,7 +112,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static gboolean
@@ -202,27 +201,3 @@ type_instance_init (GTypeInstance *instance,
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
-
-GType
-gst_omx_g711enc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxG711EncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxG711Enc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxG711Enc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_g729dec.c b/omx/gstomx_g729dec.c
index 1aefa60..666d5ab 100644
--- a/omx/gstomx_g729dec.c
+++ b/omx/gstomx_g729dec.c
@@ -23,7 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxG729Dec, gst_omx_g729dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -103,7 +103,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -142,27 +141,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_g729dec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxG729DecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxG729Dec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxG729Dec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_g729enc.c b/omx/gstomx_g729enc.c
index 1a2c853..3d7e0c7 100644
--- a/omx/gstomx_g729enc.c
+++ b/omx/gstomx_g729enc.c
@@ -33,7 +33,7 @@ enum
ARG_DTX,
};
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxG729Enc, gst_omx_g729enc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -160,8 +160,6 @@ type_class_init (gpointer g_class,
gobject_class = G_OBJECT_CLASS (g_class);
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
-
/* Properties stuff */
{
gobject_class->set_property = set_property;
@@ -259,27 +257,3 @@ type_instance_init (GTypeInstance *instance,
self->dtx = DEFAULT_DTX;
}
-
-GType
-gst_omx_g729enc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxG729EncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxG729Enc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxG729Enc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_h263dec.c b/omx/gstomx_h263dec.c
index 14d65b7..233e041 100644
--- a/omx/gstomx_h263dec.c
+++ b/omx/gstomx_h263dec.c
@@ -22,7 +22,7 @@
#include "gstomx_h263dec.h"
#include "gstomx.h"
-static GstOmxBaseVideoDecClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxH263Dec, gst_omx_h263dec, GstOmxBaseVideoDec, GST_OMX_BASE_VIDEODEC_TYPE);
static GstCaps *
generate_sink_template (void)
@@ -77,7 +77,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_VIDEODEC_TYPE);
}
static void
@@ -90,27 +89,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->compression_format = OMX_VIDEO_CodingH263;
}
-
-GType
-gst_omx_h263dec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxH263DecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxH263Dec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_VIDEODEC_TYPE, "GstOmxH263Dec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_h263enc.c b/omx/gstomx_h263enc.c
index 90237e4..5f39029 100644
--- a/omx/gstomx_h263enc.c
+++ b/omx/gstomx_h263enc.c
@@ -24,7 +24,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxH263Enc, gst_omx_h263enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -74,7 +74,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -135,27 +134,3 @@ type_instance_init (GTypeInstance *instance,
omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_h263enc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxH263EncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxH263Enc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_VIDEOENC_TYPE, "GstOmxH263Enc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_h264dec.c b/omx/gstomx_h264dec.c
index bf13966..4f950df 100644
--- a/omx/gstomx_h264dec.c
+++ b/omx/gstomx_h264dec.c
@@ -22,7 +22,7 @@
#include "gstomx_h264dec.h"
#include "gstomx.h"
-static GstOmxBaseVideoDecClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxH264Dec, gst_omx_h264dec, GstOmxBaseVideoDec, GST_OMX_BASE_VIDEODEC_TYPE);
static GstCaps *
generate_sink_template (void)
@@ -76,7 +76,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_VIDEODEC_TYPE);
}
static void
@@ -89,27 +88,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->compression_format = OMX_VIDEO_CodingAVC;
}
-
-GType
-gst_omx_h264dec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxH264DecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxH264Dec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_VIDEODEC_TYPE, "GstOmxH264Dec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_h264enc.c b/omx/gstomx_h264enc.c
index 3dbf245..336ea9a 100644
--- a/omx/gstomx_h264enc.c
+++ b/omx/gstomx_h264enc.c
@@ -24,7 +24,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxH264Enc, gst_omx_h264enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -73,7 +73,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -133,27 +132,3 @@ type_instance_init (GTypeInstance *instance,
omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_h264enc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxH264EncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxH264Enc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_VIDEOENC_TYPE, "GstOmxH264Enc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_ilbcdec.c b/omx/gstomx_ilbcdec.c
index 0547768..9d03f01 100644
--- a/omx/gstomx_ilbcdec.c
+++ b/omx/gstomx_ilbcdec.c
@@ -23,7 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxIlbcDec, gst_omx_ilbcdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -122,7 +122,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static gboolean
@@ -167,27 +166,3 @@ type_instance_init (GTypeInstance *instance,
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
-
-GType
-gst_omx_ilbcdec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxIlbcDecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxIlbcDec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxIlbcDec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_ilbcenc.c b/omx/gstomx_ilbcenc.c
index 789c381..1da2c53 100644
--- a/omx/gstomx_ilbcenc.c
+++ b/omx/gstomx_ilbcenc.c
@@ -23,7 +23,7 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxIlbcEnc, gst_omx_ilbcenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -122,7 +122,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static gboolean
@@ -167,27 +166,3 @@ type_instance_init (GTypeInstance *instance,
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
-
-GType
-gst_omx_ilbcenc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxIlbcEncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxIlbcEnc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxIlbcEnc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_jpegenc.c b/omx/gstomx_jpegenc.c
index e78b5b1..fa7defe 100644
--- a/omx/gstomx_jpegenc.c
+++ b/omx/gstomx_jpegenc.c
@@ -34,7 +34,7 @@ enum
#define DEFAULT_QUALITY 90
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxJpegEnc, gst_omx_jpegenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -177,8 +177,6 @@ type_class_init (gpointer g_class,
gobject_class = G_OBJECT_CLASS (g_class);
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
-
/* Properties stuff */
{
gobject_class->set_property = set_property;
@@ -376,27 +374,3 @@ type_instance_init (GTypeInstance *instance,
self->framerate_denom = 1;
self->quality = DEFAULT_QUALITY;
}
-
-GType
-gst_omx_jpegenc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxJpegEncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxJpegEnc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxJpegEnc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_mp2dec.c b/omx/gstomx_mp2dec.c
index 90dcb7f..f6c2568 100644
--- a/omx/gstomx_mp2dec.c
+++ b/omx/gstomx_mp2dec.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxMp2Dec, gst_omx_mp2dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -103,7 +103,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -167,27 +166,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_mp2dec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxMp2DecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxMp2Dec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxMp2Dec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_mp3dec.c b/omx/gstomx_mp3dec.c
index ad53d29..08f1896 100644
--- a/omx/gstomx_mp3dec.c
+++ b/omx/gstomx_mp3dec.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxMp3Dec, gst_omx_mp3dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -103,7 +103,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -167,27 +166,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_mp3dec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxMp3DecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxMp3Dec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxMp3Dec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_mpeg4dec.c b/omx/gstomx_mpeg4dec.c
index 614daf6..a23fef0 100644
--- a/omx/gstomx_mpeg4dec.c
+++ b/omx/gstomx_mpeg4dec.c
@@ -22,7 +22,7 @@
#include "gstomx_mpeg4dec.h"
#include "gstomx.h"
-static GstOmxBaseVideoDecClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxMpeg4Dec, gst_omx_mpeg4dec, GstOmxBaseVideoDec, GST_OMX_BASE_VIDEODEC_TYPE);
static GstCaps *
generate_sink_template (void)
@@ -103,7 +103,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_VIDEODEC_TYPE);
}
static void
@@ -116,27 +115,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->compression_format = OMX_VIDEO_CodingMPEG4;
}
-
-GType
-gst_omx_mpeg4dec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxMpeg4DecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxMpeg4Dec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_VIDEODEC_TYPE, "GstOmxMpeg4Dec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_mpeg4enc.c b/omx/gstomx_mpeg4enc.c
index 8f40da1..7a91c1c 100644
--- a/omx/gstomx_mpeg4enc.c
+++ b/omx/gstomx_mpeg4enc.c
@@ -24,7 +24,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxMpeg4Enc, gst_omx_mpeg4enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
generate_src_template (void)
@@ -75,7 +75,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -137,27 +136,3 @@ type_instance_init (GTypeInstance *instance,
omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_mpeg4enc_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxMpeg4EncClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxMpeg4Enc);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_VIDEOENC_TYPE, "GstOmxMpeg4Enc", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index c3ac441..586ad6b 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -142,4 +142,48 @@ void g_omx_port_enable (GOmxPort *port);
void g_omx_port_disable (GOmxPort *port);
void g_omx_port_finish (GOmxPort *port);
+/* Utility Macros */
+
+/**
+ * Basically like GST_BOILERPLATE / GST_BOILERPLATE_FULL, but follows the
+ * init fxn naming conventions used by gst-openmax. It expects the following
+ * functions to be defined in the same src file following this macro
+ * <ul>
+ * <li> type_base_init(gpointer g_class)
+ * <li> type_class_init(gpointer g_class, gpointer class_data)
+ * <li> type_instance_init(GTypeInstance *instance, gpointer g_class)
+ * </ul>
+ */
+#define GSTOMX_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations) \
+static void type_base_init (gpointer g_class); \
+static void type_class_init (gpointer g_class, gpointer class_data); \
+static void type_instance_init (GTypeInstance *instance, gpointer g_class); \
+static parent_type ## Class *parent_class; \
+static void type_class_init_trampoline (gpointer g_class, gpointer class_data)\
+{ \
+ parent_class = g_type_class_ref (parent_type_macro); \
+ type_class_init (g_class, class_data); \
+} \
+GType type_as_function ## _get_type (void) \
+{ \
+ static GType _type = 0; \
+ if (G_UNLIKELY (_type == 0)) \
+ { \
+ GTypeInfo *type_info; \
+ type_info = g_new0 (GTypeInfo, 1); \
+ type_info->class_size = sizeof (type ## Class); \
+ type_info->base_init = type_base_init; \
+ type_info->class_init = type_class_init_trampoline; \
+ type_info->instance_size = sizeof (type); \
+ type_info->instance_init = type_instance_init; \
+ _type = g_type_register_static (parent_type_macro, #type, type_info, 0);\
+ g_free (type_info); \
+ additional_initializations (_type); \
+ } \
+ return _type; \
+}
+#define GSTOMX_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro) \
+ GSTOMX_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
+ __GST_DO_NOTHING)
+
#endif /* GSTOMX_UTIL_H */
diff --git a/omx/gstomx_videosink.c b/omx/gstomx_videosink.c
index 923b5ed..08aae08 100644
--- a/omx/gstomx_videosink.c
+++ b/omx/gstomx_videosink.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset, strcmp */
-static GstOmxBaseSinkClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxVideoSink, gst_omx_videosink, GstOmxBaseSink, GST_OMX_BASE_SINK_TYPE);
enum
{
@@ -298,8 +298,6 @@ type_class_init (gpointer g_class,
gobject_class = (GObjectClass *) g_class;
gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
- parent_class = g_type_class_ref (GST_OMX_BASE_SINK_TYPE);
-
gst_base_sink_class->set_caps = setcaps;
gobject_class->set_property = set_property;
@@ -331,27 +329,3 @@ type_instance_init (GTypeInstance *instance,
GST_DEBUG_OBJECT (omx_base, "start");
}
-
-GType
-gst_omx_videosink_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxVideoSinkClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxVideoSink);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_SINK_TYPE, "GstOmxVideoSink", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_volume.c b/omx/gstomx_volume.c
index 3fbc4e9..cd23103 100644
--- a/omx/gstomx_volume.c
+++ b/omx/gstomx_volume.c
@@ -26,7 +26,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxVolume, gst_omx_volume, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -105,7 +105,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -169,27 +168,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_volume_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxVolumeClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxVolume);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxVolume", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_vorbisdec.c b/omx/gstomx_vorbisdec.c
index 437dc90..2adad9b 100644
--- a/omx/gstomx_vorbisdec.c
+++ b/omx/gstomx_vorbisdec.c
@@ -25,7 +25,7 @@
#include <string.h> /* for memset */
-static GstOmxBaseFilterClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxVorbisDec, gst_omx_vorbisdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
@@ -98,7 +98,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
static void
@@ -158,28 +157,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
-
-GType
-gst_omx_vorbisdec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
-
- type_info->class_size = sizeof (GstOmxVorbisDecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxVorbisDec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxVorbisDec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
diff --git a/omx/gstomx_wmvdec.c b/omx/gstomx_wmvdec.c
index 7c12336..b16fd88 100644
--- a/omx/gstomx_wmvdec.c
+++ b/omx/gstomx_wmvdec.c
@@ -22,7 +22,7 @@
#include "gstomx_wmvdec.h"
#include "gstomx.h"
-static GstOmxBaseVideoDecClass *parent_class;
+GSTOMX_BOILERPLATE (GstOmxWmvDec, gst_omx_wmvdec, GstOmxBaseVideoDec, GST_OMX_BASE_VIDEODEC_TYPE);
static GstCaps *
generate_sink_template (void)
@@ -76,7 +76,6 @@ static void
type_class_init (gpointer g_class,
gpointer class_data)
{
- parent_class = g_type_class_ref (GST_OMX_BASE_VIDEODEC_TYPE);
}
static void
@@ -89,27 +88,3 @@ type_instance_init (GTypeInstance *instance,
omx_base->compression_format = OMX_VIDEO_CodingWMV;
}
-
-GType
-gst_omx_wmvdec_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxWmvDecClass);
- type_info->base_init = type_base_init;
- type_info->class_init = type_class_init;
- type_info->instance_size = sizeof (GstOmxWmvDec);
- type_info->instance_init = type_instance_init;
-
- type = g_type_register_static (GST_OMX_BASE_VIDEODEC_TYPE, "GstOmxWmvDec", type_info, 0);
-
- g_free (type_info);
- }
-
- return type;
-}
--
1.6.3.2
|
|
From: Rob C. <ro...@ti...> - 2010-02-28 17:02:41
|
Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names
using the same gst-openmax class but different OMX library-name and/or component-name.
In the simple case, of one OMX component per gst-openmax class, specify the gst-openmax class as the 'type', and the 'library-name' and 'compnent-name' of the OMX component, and
optionally the 'rank' (defaults to 0 or GST_RANK_NONE):
----
omx_h264dec,
type=GstOmxH264Dec,
library-name=libomxil-bellagio.so.0,
component-name=OMX.st.video_decoder.avc,
rank=256;
----
Or in the advanced case of multiple OMX components per gst-openmax class, specify the gst-openmax class as the 'parent-type' and a dynamically created sub-class for the 'type':
----
omx_mp3dec_ti,
parent-type=GstOmxMp3Dec,
type=GstOmxMp3DecTi
library-name=libOMX_Core.so.0,
component-name=OMX.TI.AUDIO.DECODE,
component-role=audio_decode.dsp.mp3,
rank=256;
omx_mp3dec_nokia,
parent-type=GstOmxMp3Dec,
type=GstOmxMp3DecNokia
library-name=libomxil_bellagio.so.0,
component-name=OMX.nokia.audio_decode.mp3,
rank=128;
----
by default, the config file is stored in $HOME/.config/gst-openmax.conf, although if none is found a default config will be created.
---
Latest version of patch updates the commit msg for more detail about usage of 'type' and 'parent-type' in config file, and also makes some minor changes in error handling to work properly
if G_DISABLE_CHECKS is defined
omx/Makefile.am | 8 +-
omx/gstomx.c | 376 +++++++++++++++++++++++++++++++++++++++-------
omx/gstomx.conf | 203 +++++++++++++++++++++++++
omx/gstomx.h | 6 +
omx/gstomx_base_filter.c | 31 +----
omx/gstomx_base_filter.h | 2 -
omx/gstomx_base_sink.c | 31 +----
omx/gstomx_base_sink.h | 3 -
omx/gstomx_base_src.c | 38 +----
omx/gstomx_base_src.h | 2 -
omx/gstomx_util.c | 13 ++-
omx/gstomx_util.h | 2 +-
12 files changed, 561 insertions(+), 154 deletions(-)
create mode 100644 omx/gstomx.conf
diff --git a/omx/Makefile.am b/omx/Makefile.am
index 4a3fbf9..01243ff 100644
--- a/omx/Makefile.am
+++ b/omx/Makefile.am
@@ -18,7 +18,8 @@ libgstomx_la_SOURCES = gstomx.c gstomx.h \
gstomx_vorbisdec.c gstomx_vorbisdec.h \
gstomx_mp3dec.c gstomx_mp3dec.h \
gstomx_base_sink.c gstomx_base_sink.h \
- gstomx_audiosink.c gstomx_audiosink.h
+ gstomx_audiosink.c gstomx_audiosink.h \
+ gstomx_conf.c
if EXPERIMENTAL
libgstomx_la_SOURCES += gstomx_amrnbdec.c gstomx_amrnbdec.h \
@@ -47,3 +48,8 @@ libgstomx_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(top_builddir)/util/libutil.
libgstomx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
EXTRA_DIST = headers
+
+gstomx_conf.c: gstomx.conf
+ echo "const char * default_config =" > $@
+ cat $^ | $(CPP) $(CFLAGS) $(libgstomx_la_CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) - | grep -v "^#" | sed 's/^.*/\"&\\\n"/' >> $@
+ echo ";" >> $@
diff --git a/omx/gstomx.c b/omx/gstomx.c
index 6756f54..4e3a168 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -21,6 +21,10 @@
#include "config.h"
+#include <string.h>
+
+#include <gst/gststructure.h>
+
#include "gstomx.h"
#include "gstomx_dummy.h"
#include "gstomx_mpeg4dec.h"
@@ -59,90 +63,348 @@
GST_DEBUG_CATEGORY (gstomx_debug);
-typedef struct TableItem
-{
- const gchar *name;
- const gchar *library_name;
- const gchar *component_name;
- guint rank;
- GType (*get_type) (void);
-} TableItem;
-
-static TableItem element_table[] =
-{
- { "omx_dummy", "libomxil-bellagio.so.0", "OMX.st.dummy", GST_RANK_NONE, gst_omx_dummy_get_type },
- { "omx_mpeg4dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4dec_get_type },
- { "omx_h264dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.avc", GST_RANK_PRIMARY, gst_omx_h264dec_get_type },
- { "omx_h263dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.h263", GST_RANK_PRIMARY, gst_omx_h263dec_get_type },
- { "omx_wmvdec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.wmv", GST_RANK_PRIMARY, gst_omx_wmvdec_get_type },
- { "omx_mpeg4enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4enc_get_type },
- { "omx_h264enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.avc", GST_RANK_PRIMARY, gst_omx_h264enc_get_type },
- { "omx_h263enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.h263", GST_RANK_PRIMARY, gst_omx_h263enc_get_type },
- { "omx_vorbisdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ogg.single", GST_RANK_SECONDARY, gst_omx_vorbisdec_get_type },
- { "omx_mp3dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp3dec_get_type },
+static GstStructure *element_table = NULL;
+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
- { "omx_mp2dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp2dec_get_type },
- { "omx_amrnbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbdec_get_type },
- { "omx_amrnbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbenc_get_type },
- { "omx_amrwbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbdec_get_type },
- { "omx_amrwbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbenc_get_type },
- { "omx_aacdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.aac", GST_RANK_PRIMARY, gst_omx_aacdec_get_type },
- { "omx_aacenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.aac", GST_RANK_PRIMARY, gst_omx_aacenc_get_type },
- { "omx_adpcmdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmdec_get_type },
- { "omx_adpcmenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmenc_get_type },
- { "omx_g711dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g711", GST_RANK_PRIMARY, gst_omx_g711dec_get_type },
- { "omx_g711enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g711", GST_RANK_PRIMARY, gst_omx_g711enc_get_type },
- { "omx_g729dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g729", GST_RANK_PRIMARY, gst_omx_g729dec_get_type },
- { "omx_g729enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g729", GST_RANK_PRIMARY, gst_omx_g729enc_get_type },
- { "omx_ilbcdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcdec_get_type },
- { "omx_ilbcenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcenc_get_type },
- { "omx_jpegenc", "libomxil-bellagio.so.0", "OMX.st.image_encoder.jpeg", GST_RANK_PRIMARY, gst_omx_jpegenc_get_type },
+ 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 */
- { "omx_audiosink", "libomxil-bellagio.so.0", "OMX.st.alsa.alsasink", GST_RANK_NONE, gst_omx_audiosink_get_type },
+ gst_omx_audiosink_get_type,
#ifdef EXPERIMENTAL
- { "omx_videosink", "libomxil-bellagio.so.0", "OMX.st.videosink", GST_RANK_NONE, gst_omx_videosink_get_type },
- { "omx_filereadersrc", "libomxil-bellagio.so.0", "OMX.st.audio_filereader", GST_RANK_NONE, gst_omx_filereadersrc_get_type },
+ gst_omx_videosink_get_type,
+ gst_omx_filereadersrc_get_type,
#endif /* EXPERIMENTAL */
- { "omx_volume", "libomxil-bellagio.so.0", "OMX.st.volume.component", GST_RANK_NONE, gst_omx_volume_get_type },
- { NULL, NULL, NULL, 0, NULL },
+ gst_omx_volume_get_type,
};
+/* TODO: we can cache table w/ gst_plugin_{get,set}_cache_data..
+ */
+static GstStructure *
+get_element_table (void)
+{
+ static volatile gsize gonce_data = 0;
+ if (g_once_init_enter (&gonce_data))
+ {
+ gchar *path;
+ gchar *config, *s;
+ GstStructure *element;
+
+ path = g_strdup (g_getenv ("OMX_REGISTRY"));
+ if (!path)
+ {
+ path = g_build_filename (g_get_user_config_dir (),
+ "gst-openmax.conf", NULL);
+ }
+
+ if (!g_file_get_contents (path, &config, NULL, NULL))
+ {
+ g_warning ("could not find config file '%s'.. using defaults!", path);
+ config = (gchar *) default_config;
+
+ g_file_set_contents (path, config, -1, NULL);
+ }
+
+ GST_DEBUG ("parsing config:\n%s", config);
+
+ element_table = 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 (element_table,
+ element_name, GST_TYPE_STRUCTURE, element, NULL);
+ }
+
+ if (config != default_config)
+ {
+ g_free (config);
+ }
+
+ g_free (path);
+
+ GST_DEBUG ("element_table=%"GST_PTR_FORMAT, element_table);
+
+ g_once_init_leave (&gonce_data, 1);
+ }
+
+ return element_table;
+}
+
+static GstStructure *
+get_element_entry (const gchar *element_name)
+{
+ GstStructure *element_table = get_element_table ();
+ GstStructure *element;
+
+ if (! gst_structure_get (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;
+}
+
+static const gchar *
+get_element_name (gpointer object)
+{
+ return g_type_get_qdata (G_OBJECT_TYPE (object), element_name_quark);
+}
+
+/* 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)
{
- GQuark library_name_quark;
- GQuark component_name_quark;
+ gint i, cnt;
+ GstStructure *element_table;
+
GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
- library_name_quark = g_quark_from_static_string ("library-name");
- component_name_quark = g_quark_from_static_string ("component-name");
+ 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] ();
+ }
+
+ element_table = get_element_table ();
g_omx_init ();
+ cnt = gst_structure_n_fields (element_table);
+ for (i = 0; i < cnt; i++)
{
- guint i;
- for (i = 0; element_table[i].name; i++)
- {
- TableItem *element;
- GType type;
+ 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;
+ GType type;
+ gint rank;
+
+ GST_DEBUG ("element_name=%s, element=%"GST_PTR_FORMAT, element_name, element);
- element = &element_table[i];
- type = element->get_type ();
- g_type_set_qdata (type, library_name_quark, (gpointer) element->library_name);
- g_type_set_qdata (type, component_name_quark, (gpointer) element->component_name);
+ parent_type_name = gst_structure_get_string (element, "parent-type");
+ type_name = gst_structure_get_string (element, "type");
- if (!gst_element_register (plugin, element->name, element->rank, type))
+ if (parent_type_name)
+ {
+ type = g_type_from_name (parent_type_name);
+ if (type)
+ {
+ type = create_subtype (type, type_name);
+ }
+ else
{
- g_warning ("failed registering '%s'", element->name);
+ g_warning ("malformed config file: invalid parent-type '%s' for %s",
+ parent_type_name, element_name);
return FALSE;
}
}
+ else if (type_name)
+ {
+ type = g_type_from_name (type_name);
+ }
+
+ if (!type_name)
+ {
+ g_warning ("malformed config file: missing 'type' for %s",
+ element_name);
+ return FALSE;
+ }
+
+ 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;
}
+/**
+ * g_omx_get_component_info:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @library_name: library-name, returned by reference (or NULL)
+ * @component_name: component-name, returned by reference (or NULL)
+ *
+ * Get library-name and component-name for an element.
+ *
+ * note: this function will gain another parameter later when component-role
+ * is added
+ */
+gboolean
+g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name)
+{
+ gboolean ret = TRUE;
+ const gchar *element_name = get_element_name (object);
+ GstStructure *element = get_element_entry (element_name);
+
+ if (!element)
+ return FALSE;
+
+ /* initialize ptrs to NULL so that in error cases we can tell what needs
+ * to be freed:
+ */
+ if (library_name) *library_name = NULL;
+ if (component_name) *component_name = NULL;
+
+ if (library_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "library-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'library-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *library_name = g_strdup (str);
+ }
+
+ if (component_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "component-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'component-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *component_name = g_strdup (str);
+ }
+
+exit:
+
+ /* if we failed, free any memory that might have been allocated:
+ */
+ if (!ret)
+ {
+ if (library_name) g_free (*library_name);
+ if (component_name) g_free (*component_name);
+ }
+
+
+ return ret;
+}
+
+static gboolean
+set_value_helper (GValue *value, gchar *str)
+{
+ g_value_set_string (value, str);
+ return TRUE;
+}
+
+/**
+ * g_omx_get_library_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "library-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_library_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, &str, NULL) &&
+ set_value_helper (val, str);
+}
+
+/**
+ * g_omx_get_component_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "component-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_component_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, NULL, &str) &&
+ set_value_helper (val, str);
+}
+
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"omx",
diff --git a/omx/gstomx.conf b/omx/gstomx.conf
new file mode 100644
index 0000000..c22c6d6
--- /dev/null
+++ b/omx/gstomx.conf
@@ -0,0 +1,203 @@
+#include "config.h"
+
+/* in case of multiple OMX components mapping to a single gst-openmax element
+ * class, a dynamic subclass can be created by specifying the gst-openmax
+ * type as the 'parent-type' and specifying a new unique type name as the
+ * 'type' parameter:
+ */
+omx_dummy,
+ parent-type=GstOmxDummy,
+ type=GstOmxDummyOne,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.bellagio.dummy,
+ rank=0;
+
+/* for testing: */
+omx_dummy_2,
+ parent-type=GstOmxDummy,
+ type=GstOmxDummyTwo,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.dummy2,
+ rank=256;
+
+omx_mpeg4dec,
+ type=GstOmxMpeg4Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.mpeg4,
+ rank=256;
+
+omx_h264dec,
+ type=GstOmxH264Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.avc,
+ rank=256;
+
+omx_h263dec,
+ type=GstOmxH263Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.h263,
+ rank=256;
+
+omx_wmvdec,
+ type=GstOmxWmvDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.wmv,
+ rank=256;
+
+omx_mpeg4enc,
+ type=GstOmxMpeg4Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.mpeg4,
+ rank=256;
+
+omx_h264enc,
+ type=GstOmxH264Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.avc,
+ rank=256;
+
+omx_h263enc,
+ type=GstOmxH263Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.h263,
+ rank=256;
+
+omx_vorbisdec,
+ type=GstOmxVorbisDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.ogg.single,
+ rank=128;
+
+omx_mp3dec,
+ type=GstOmxMp3Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.mp3.mad,
+ rank=256;
+
+#ifdef EXPERIMENTAL
+
+omx_mp2dec,
+ type=GstOmxMp2Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.mp3.mad,
+ rank=256;
+
+omx_amrnbdec,
+ type=GstOmxAmrNbDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.amrnb,
+ rank=256;
+
+omx_amrnbenc,
+ type=GstOmxAmrNbEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.amrnb,
+ rank=256;
+
+omx_amrwbdec,
+ type=GstOmxAmrWbDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.amrwb,
+ rank=256;
+
+omx_amrwbenc,
+ type=GstOmxAmrWbEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.amrwb,
+ rank=256;
+
+omx_aacdec,
+ type=GstOmxAacDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.aac,
+ rank=256;
+
+omx_aacenc,
+ type=GstOmxAacEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.aac,
+ rank=256;
+
+omx_adpcmdec,
+ type=GstOmxAdpcmDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.adpcm,
+ rank=256;
+
+omx_adpcmenc,
+ type=GstOmxAdpcmEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.adpcm,
+ rank=256;
+
+omx_g711dec,
+ type=GstOmxG711Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.g711,
+ rank=256;
+
+omx_g711enc,
+ type=GstOmxG711Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.g711,
+ rank=256;
+
+omx_g729dec,
+ type=GstOmxG729Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.g729,
+ rank=256;
+
+omx_g729enc,
+ type=GstOmxG729Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.g729,
+ rank=256;
+
+omx_ilbcdec,
+ type=GstOmxIlbcDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.ilbc,
+ rank=256;
+
+omx_ilbcenc,
+ type=GstOmxIlbcEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.ilbc,
+ rank=256;
+
+omx_jpegenc,
+ type=GstOmxJpegEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.image_encoder.jpeg,
+ rank=256;
+
+#endif /* EXPERIMENTAL */
+
+omx_audiosink,
+ type=GstOmxAudioSink,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.alsa.alsasink,
+ rank=0;
+
+#ifdef EXPERIMENTAL
+
+omx_videosink,
+ type=GstOmxVideoSink,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.videosink,
+ rank=0;
+
+omx_filereadersrc,
+ type=GstOmxFilereaderSrc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_filereader,
+ rank=0;
+
+#endif /* EXPERIMENTAL */
+
+omx_volume,
+ type=GstOmxVolume,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.volume.component,
+ rank=0;
diff --git a/omx/gstomx.h b/omx/gstomx.h
index 7d5fa04..063437d 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -30,6 +30,12 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
#define GST_CAT_DEFAULT gstomx_debug
+gboolean g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name);
+gboolean g_omx_get_library_name_value (gpointer object, GValue *val);
+gboolean g_omx_get_component_name_value (gpointer object, GValue *val);
+
G_END_DECLS
#endif /* GSTOMX_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index b0353cb..2a30502 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -115,7 +115,7 @@ change_state (GstElement *element,
switch (transition)
{
case GST_STATE_CHANGE_NULL_TO_READY:
- g_omx_core_init (core, self->omx_library, self->omx_component);
+ g_omx_core_init (core);
if (core->omx_state != OMX_StateLoaded)
{
ret = GST_STATE_CHANGE_FAILURE;
@@ -184,9 +184,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
g_mutex_free (self->ready_lock);
G_OBJECT_CLASS (parent_class)->finalize (obj);
@@ -204,14 +201,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
case ARG_USE_TIMESTAMPS:
self->use_timestamps = g_value_get_boolean (value);
break;
@@ -234,10 +223,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
case ARG_USE_TIMESTAMPS:
g_value_set_boolean (value, self->use_timestamps);
@@ -271,12 +260,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
g_param_spec_boolean ("use-timestamps", "Use timestamps",
@@ -922,16 +911,6 @@ type_instance_init (GTypeInstance *instance,
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_filter.h b/omx/gstomx_base_filter.h
index 4baf181..99b5d72 100644
--- a/omx/gstomx_base_filter.h
+++ b/omx/gstomx_base_filter.h
@@ -48,8 +48,6 @@ struct GstOmxBaseFilter
GOmxPort *in_port;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
gboolean use_timestamps; /** @todo remove; timestamps should always be used */
gboolean ready;
GMutex *ready_lock;
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index c1a2076..7911167 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -141,9 +141,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -298,14 +295,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -325,10 +314,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -366,12 +355,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -420,7 +409,7 @@ activate_push (GstPad *pad,
static inline gboolean
omx_init (GstOmxBaseSink *self)
{
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return FALSE;
@@ -468,16 +457,6 @@ type_instance_init (GTypeInstance *instance,
}
{
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
- {
GstPad *sinkpad;
self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
index 681e939..589c441 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -46,9 +46,6 @@ struct GstOmxBaseSink
GOmxCore *gomx;
GOmxPort *in_port;
- char *omx_component;
- char *omx_library;
-
gboolean ready;
GstPadActivateModeFunction base_activatepush;
gboolean initialized;
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 9b02b22..dd9767e 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -67,7 +67,7 @@ start (GstBaseSrc *gst_base)
GST_LOG_OBJECT (self, "begin");
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -106,9 +106,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -362,20 +359,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- if (self->omx_component)
- {
- g_free (self->omx_component);
- }
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- if (self->omx_library)
- {
- g_free (self->omx_library);
- }
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -395,10 +378,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -433,12 +416,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -459,17 +442,6 @@ type_instance_init (GTypeInstance *instance,
gomx->object = self;
}
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_src.h b/omx/gstomx_base_src.h
index 85e4c13..adab894 100644
--- a/omx/gstomx_base_src.h
+++ b/omx/gstomx_base_src.h
@@ -44,8 +44,6 @@ struct GstOmxBaseSrc
GOmxCore *gomx;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
GstOmxBaseSrcCb setup_ports;
};
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 39d900b..6701628 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -301,10 +301,17 @@ g_omx_core_free (GOmxCore *core)
}
void
-g_omx_core_init (GOmxCore *core,
- const gchar *library_name,
- const gchar *component_name)
+g_omx_core_init (GOmxCore *core)
{
+ gchar *library_name, *component_name;
+
+ if (!g_omx_get_component_info (core->object,
+ &library_name, &component_name))
+ {
+ GST_ERROR_OBJECT (core->object, "missing component info");
+ return;
+ }
+
core->imp = request_imp (library_name);
if (!core->imp)
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index f0cf045..c3ac441 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -116,7 +116,7 @@ void g_omx_deinit (void);
GOmxCore *g_omx_core_new (void);
void g_omx_core_free (GOmxCore *core);
-void g_omx_core_init (GOmxCore *core, const gchar *library_name, const gchar *component_name);
+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);
--
1.6.3.2
|
|
From: Rob C. <ro...@ti...> - 2010-02-28 16:45:27
|
---
omx/gstomx_base_filter.c | 12 ++++++------
omx/gstomx_base_sink.c | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 287f50c..b0353cb 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -40,11 +40,11 @@ log_buffer (GstOmxBaseFilter *self,
OMX_BUFFERHEADERTYPE *omx_buffer)
{
GST_DEBUG_OBJECT (self, "omx_buffer: "
- "size=%" G_GUINT32_FORMAT ", "
- "len=%" G_GUINT32_FORMAT ", "
- "flags=%" G_GUINT32_FORMAT ", "
- "offset=%" G_GUINT32_FORMAT ", "
- "timestamp=%" G_GUINT64_FORMAT,
+ "size=%lu, "
+ "len=%lu, "
+ "flags=%lu, "
+ "offset=%lu, "
+ "timestamp=%lld",
omx_buffer->nAllocLen, omx_buffer->nFilledLen, omx_buffer->nFlags,
omx_buffer->nOffset, omx_buffer->nTimeStamp);
}
@@ -450,7 +450,7 @@ output_loop (gpointer data)
}
else
{
- GST_WARNING_OBJECT (self, "couldn't allocate buffer of size %" G_GUINT32_FORMAT,
+ GST_WARNING_OBJECT (self, "couldn't allocate buffer of size %lu",
omx_buffer->nFilledLen);
}
}
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index b50564d..c1a2076 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -161,7 +161,7 @@ render (GstBaseSink *gst_base,
gomx = self->gomx;
GST_LOG_OBJECT (self, "begin");
- GST_LOG_OBJECT (self, "gst_buffer: size=%lu", GST_BUFFER_SIZE (buf));
+ GST_LOG_OBJECT (self, "gst_buffer: size=%u", GST_BUFFER_SIZE (buf));
GST_LOG_OBJECT (self, "state: %d", gomx->omx_state);
--
1.6.3.2
|
|
From: Stefan K. <en...@ho...> - 2010-02-27 19:39:31
|
Am 27.02.2010 00:00, schrieb Felipe Contreras: > On Fri, Feb 26, 2010 at 4:14 PM, Clark, Rob <ro...@ti...> wrote: >> >> On Feb 26, 2010, at 6:05 AM, Felipe Contreras wrote: >> >>> 3) The configuration location should be obtained with >>> g_get_user_config_dir() ($HOME/.config) >> >> >> What do you think about leaving this as-is, but submitting a patch to gstreamer to add API to get the gst registry directory (gst_get_registry_dir() or something like that?), and later changing to using that? >> >> I'm wondering if the config file makes more sense to be located along side gst registry.. > > The problem I have with this approach is that GStreamer registry is > fundamentally different; it's not something the user is supposed to > change. > > In fact, the proper location of the registry should probably be > ~/.cache/gstreamer-0.10 (through g_get_user_cache_dir()). So if we use > use gst_get_registry_dir() the conf might end up in ~/.cache, and I > don't think that's good. regarding the xdg use in gst: https://bugzilla.gnome.org/show_bug.cgi?id=518597 but +1 regarding your comment, just use g_get_user_config_dir() > > In fact, I think the user should be able to configure the rank of > gstreamer elements (not gst-omx). And if such thing gets ever > implemented the configuration would probably be in ~/.config. Until > there's a gst_get_config_dir(), I think it's best to follow my > proposal. Yep, that would be nice to have and it could probably be done simillar to this patch. Then some one could write a UI for that. That could work better than the gconf elements. Stefan > > Cheers. > |
|
From: Rob C. <ro...@ti...> - 2010-02-27 18:24:34
|
On Nov 25, 2009, at 11:21 AM, Felipe Contreras wrote:
> On Mon, Nov 23, 2009 at 7:25 AM, Rob Clark <ro...@ti...> wrote:
>> but an inline function could not figure out sizeof() properly.. so this
>> would have to be passed as an additional parameter. (although a combination
>> of a macro calling an inline fxn could work)
>>
>> sometimes macro's are a necessary evil ;-)
>
> Right, but in my opinion if you need a macro chances are you are doing
> something wrong and the code becomes more convoluted.
>
> I this particular case I think it makes sense to write a macro that wraps:
> OMX_AUDIO_PARAM_PCMMODETYPE param = {
> .nSize = sizeof(param),
> .nVersion = OMX_VERSION,
> };
>
> But that's it. Then a separate inline function that does:
> param.nPortIndex = 1;
> OMX_GetParameter(omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
>
> This way it would be possible to call OMX_SetParameter without
> OMX_GetParameter (in case you are setting all the fields).
btw, I'm thinking about this one again..
how about, in case of setting all params:
OMX_AUDIO_PARAM_PCMMODETYPE param;
G_OMX_INIT_PARAM (param);
... set params ...
G_OMX_PORT_SET_PARAM (port, OMX_IndexParamAudioPcm, ¶m);
or in case where you just want to set a few params:
OMX_AUDIO_PARAM_PCMMODETYPE param;
G_OMX_PORT_GET_PARAM (port, OMX_IndexParamAudioPcm, ¶m);
... set params ...
G_OMX_PORT_SET_PARAM (port, OMX_IndexParamAudioPcm, ¶m);
(SET_PARAM could be a fxn.. but INIT_PARAM and GET_PARAM would have to be a macro... although they could be a simple macro just passing an extra sizeof() param to a helper function rather than a pure macro)
------
the other approach would be something like:
G_OMX_DECLARE_PARAM (OMX_AUDIO_PARAM_PCMMODETYPE, param);
... set params ...
g_omx_port_set_param (port, OMX_IndexParamAudioPcm, ¶m);
or in case where you just want to set a few params:
G_OMX_DECLARE_PARAM (OMX_AUDIO_PARAM_PCMMODETYPE, param);
g_omx_port_get_param (port, OMX_IndexParamAudioPcm, ¶m);
... set params ...
g_omx_port_set_param (port, OMX_IndexParamAudioPcm, ¶m);
in this case {get,set}_{config,param} could be functions.. but the macro to declare the param variable is a bit funny looking.
Or you could do something like:
OMX_AUDIO_PARAM_PCMMODETYPE param = G_OMX_PARAM_INITIALIZER ();
but that forces the variable name to be only 'param', which will cause problems for me..
or:
OMX_AUDIO_PARAM_PCMMODETYPE param = G_OMX_PARAM_INITIALIZER (param);
but again, that seems a bit funny looking to me..
Thoughts?
BR,
-R
|
|
From: Felipe C. <fel...@gm...> - 2010-02-27 11:13:36
|
On Sat, Feb 27, 2010 at 5:25 AM, Rob Clark <ro...@ti...> wrote: > Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names > using the same gst-openmax class but different OMX library-name and/or component-name. For example: Looks fine by me. There are some minor styling issues but there's no point in burdening you with that since the style is going to change anyway. I'll make the minor modifications, test, and commit this. Cheers. -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-02-27 03:25:12
|
Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names
using the same gst-openmax class but different OMX library-name and/or component-name. For example:
----
omx_mp3dec_ti,
type=GstOmxMp3Dec,
library-name=libOMX_Core.so.0,
component-name=OMX.TI.AUDIO.DECODE,
component-role=audio_decode.dsp.mp3,
rank=256;
omx_mp3dec_nokia,
type=GstOmxMp3Dec,
library-name=libomxil_bellagio.so.0,
component-name=OMX.nokia.audio_decode.mp3,
rank=128;
----
by default, the config file is stored in $HOME/.config/gst-openmax.conf, although if none is found a default config will be created.
---
omx/Makefile.am | 8 +-
omx/gstomx.c | 372 +++++++++++++++++++++++++++++++++++++++-------
omx/gstomx.conf | 203 +++++++++++++++++++++++++
omx/gstomx.h | 6 +
omx/gstomx_base_filter.c | 31 +----
omx/gstomx_base_filter.h | 2 -
omx/gstomx_base_sink.c | 31 +----
omx/gstomx_base_sink.h | 3 -
omx/gstomx_base_src.c | 38 +----
omx/gstomx_base_src.h | 2 -
omx/gstomx_util.c | 9 +-
omx/gstomx_util.h | 2 +-
12 files changed, 553 insertions(+), 154 deletions(-)
create mode 100644 omx/gstomx.conf
diff --git a/omx/Makefile.am b/omx/Makefile.am
index 4a3fbf9..01243ff 100644
--- a/omx/Makefile.am
+++ b/omx/Makefile.am
@@ -18,7 +18,8 @@ libgstomx_la_SOURCES = gstomx.c gstomx.h \
gstomx_vorbisdec.c gstomx_vorbisdec.h \
gstomx_mp3dec.c gstomx_mp3dec.h \
gstomx_base_sink.c gstomx_base_sink.h \
- gstomx_audiosink.c gstomx_audiosink.h
+ gstomx_audiosink.c gstomx_audiosink.h \
+ gstomx_conf.c
if EXPERIMENTAL
libgstomx_la_SOURCES += gstomx_amrnbdec.c gstomx_amrnbdec.h \
@@ -47,3 +48,8 @@ libgstomx_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(top_builddir)/util/libutil.
libgstomx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
EXTRA_DIST = headers
+
+gstomx_conf.c: gstomx.conf
+ echo "const char * default_config =" > $@
+ cat $^ | $(CPP) $(CFLAGS) $(libgstomx_la_CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) - | grep -v "^#" | sed 's/^.*/\"&\\\n"/' >> $@
+ echo ";" >> $@
diff --git a/omx/gstomx.c b/omx/gstomx.c
index 6756f54..7049f41 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -21,6 +21,10 @@
#include "config.h"
+#include <string.h>
+
+#include <gst/gststructure.h>
+
#include "gstomx.h"
#include "gstomx_dummy.h"
#include "gstomx_mpeg4dec.h"
@@ -59,90 +63,344 @@
GST_DEBUG_CATEGORY (gstomx_debug);
-typedef struct TableItem
-{
- const gchar *name;
- const gchar *library_name;
- const gchar *component_name;
- guint rank;
- GType (*get_type) (void);
-} TableItem;
-
-static TableItem element_table[] =
-{
- { "omx_dummy", "libomxil-bellagio.so.0", "OMX.st.dummy", GST_RANK_NONE, gst_omx_dummy_get_type },
- { "omx_mpeg4dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4dec_get_type },
- { "omx_h264dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.avc", GST_RANK_PRIMARY, gst_omx_h264dec_get_type },
- { "omx_h263dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.h263", GST_RANK_PRIMARY, gst_omx_h263dec_get_type },
- { "omx_wmvdec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.wmv", GST_RANK_PRIMARY, gst_omx_wmvdec_get_type },
- { "omx_mpeg4enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4enc_get_type },
- { "omx_h264enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.avc", GST_RANK_PRIMARY, gst_omx_h264enc_get_type },
- { "omx_h263enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.h263", GST_RANK_PRIMARY, gst_omx_h263enc_get_type },
- { "omx_vorbisdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ogg.single", GST_RANK_SECONDARY, gst_omx_vorbisdec_get_type },
- { "omx_mp3dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp3dec_get_type },
+static GstStructure *element_table = NULL;
+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
- { "omx_mp2dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp2dec_get_type },
- { "omx_amrnbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbdec_get_type },
- { "omx_amrnbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbenc_get_type },
- { "omx_amrwbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbdec_get_type },
- { "omx_amrwbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbenc_get_type },
- { "omx_aacdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.aac", GST_RANK_PRIMARY, gst_omx_aacdec_get_type },
- { "omx_aacenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.aac", GST_RANK_PRIMARY, gst_omx_aacenc_get_type },
- { "omx_adpcmdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmdec_get_type },
- { "omx_adpcmenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmenc_get_type },
- { "omx_g711dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g711", GST_RANK_PRIMARY, gst_omx_g711dec_get_type },
- { "omx_g711enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g711", GST_RANK_PRIMARY, gst_omx_g711enc_get_type },
- { "omx_g729dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g729", GST_RANK_PRIMARY, gst_omx_g729dec_get_type },
- { "omx_g729enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g729", GST_RANK_PRIMARY, gst_omx_g729enc_get_type },
- { "omx_ilbcdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcdec_get_type },
- { "omx_ilbcenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcenc_get_type },
- { "omx_jpegenc", "libomxil-bellagio.so.0", "OMX.st.image_encoder.jpeg", GST_RANK_PRIMARY, gst_omx_jpegenc_get_type },
+ 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 */
- { "omx_audiosink", "libomxil-bellagio.so.0", "OMX.st.alsa.alsasink", GST_RANK_NONE, gst_omx_audiosink_get_type },
+ gst_omx_audiosink_get_type,
#ifdef EXPERIMENTAL
- { "omx_videosink", "libomxil-bellagio.so.0", "OMX.st.videosink", GST_RANK_NONE, gst_omx_videosink_get_type },
- { "omx_filereadersrc", "libomxil-bellagio.so.0", "OMX.st.audio_filereader", GST_RANK_NONE, gst_omx_filereadersrc_get_type },
+ gst_omx_videosink_get_type,
+ gst_omx_filereadersrc_get_type,
#endif /* EXPERIMENTAL */
- { "omx_volume", "libomxil-bellagio.so.0", "OMX.st.volume.component", GST_RANK_NONE, gst_omx_volume_get_type },
- { NULL, NULL, NULL, 0, NULL },
+ gst_omx_volume_get_type,
};
+/* TODO: we can cache table w/ gst_plugin_{get,set}_cache_data..
+ */
+static GstStructure *
+get_element_table (void)
+{
+ static volatile gsize gonce_data = 0;
+ if (g_once_init_enter (&gonce_data))
+ {
+ gchar *path;
+ gchar *config, *s;
+ GstStructure *element;
+
+ path = g_strdup (g_getenv ("OMX_REGISTRY"));
+ if (!path)
+ {
+ path = g_build_filename (g_get_user_config_dir (),
+ "gst-openmax.conf", NULL);
+ }
+
+ if (!g_file_get_contents (path, &config, NULL, NULL))
+ {
+ g_warning ("could not find config file '%s'.. using defaults!", path);
+ config = (gchar *) default_config;
+
+ g_file_set_contents (path, config, -1, NULL);
+ }
+
+ GST_DEBUG ("parsing config:\n%s", config);
+
+ element_table = 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 (element_table,
+ element_name, GST_TYPE_STRUCTURE, element, NULL);
+ }
+
+ if (config != default_config)
+ {
+ g_free (config);
+ }
+
+ g_free (path);
+
+ GST_DEBUG ("element_table=%"GST_PTR_FORMAT, element_table);
+
+ g_once_init_leave (&gonce_data, 1);
+ }
+
+ return element_table;
+}
+
+static GstStructure *
+get_element_entry (const gchar *element_name)
+{
+ GstStructure *element_table = get_element_table ();
+ GstStructure *element;
+
+ if (! gst_structure_get (element_table,
+ element_name, GST_TYPE_STRUCTURE, &element, NULL))
+ element = NULL;
+
+ g_assert (element);
+
+ return element;
+}
+
+static const gchar *
+get_element_name (gpointer object)
+{
+ return g_type_get_qdata (G_OBJECT_TYPE (object), element_name_quark);
+}
+
+/* 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)
{
- GQuark library_name_quark;
- GQuark component_name_quark;
+ gint i, cnt;
+ GstStructure *element_table;
+
GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
- library_name_quark = g_quark_from_static_string ("library-name");
- component_name_quark = g_quark_from_static_string ("component-name");
+ 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] ();
+ }
+
+ element_table = get_element_table ();
g_omx_init ();
+ cnt = gst_structure_n_fields (element_table);
+ for (i = 0; i < cnt; i++)
{
- guint i;
- for (i = 0; element_table[i].name; i++)
- {
- TableItem *element;
- GType type;
+ 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;
+ GType type;
+ gint rank;
+
+ GST_DEBUG ("element_name=%s, element=%"GST_PTR_FORMAT, element_name, element);
- element = &element_table[i];
- type = element->get_type ();
- g_type_set_qdata (type, library_name_quark, (gpointer) element->library_name);
- g_type_set_qdata (type, component_name_quark, (gpointer) element->component_name);
+ parent_type_name = gst_structure_get_string (element, "parent-type");
+ type_name = gst_structure_get_string (element, "type");
- if (!gst_element_register (plugin, element->name, element->rank, type))
+ if (parent_type_name)
+ {
+ type = g_type_from_name (parent_type_name);
+ if (type)
+ {
+ type = create_subtype (type, type_name);
+ }
+ else
{
- g_warning ("failed registering '%s'", element->name);
+ g_warning ("malformed config file: invalid parent-type '%s' for %s",
+ parent_type_name, element_name);
return FALSE;
}
}
+ else if (type_name)
+ {
+ type = g_type_from_name (type_name);
+ }
+
+ if (!type_name)
+ {
+ g_warning ("malformed config file: missing 'type' for %s",
+ element_name);
+ return FALSE;
+ }
+
+ 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;
}
+/**
+ * g_omx_get_component_info:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @library_name: library-name, returned by reference (or NULL)
+ * @component_name: component-name, returned by reference (or NULL)
+ *
+ * Get library-name and component-name for an element.
+ *
+ * note: this function will gain another parameter later when component-role
+ * is added
+ */
+gboolean
+g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name)
+{
+ gboolean ret = TRUE;
+ const gchar *element_name = get_element_name (object);
+ GstStructure *element = get_element_entry (element_name);
+
+ if (!element)
+ return FALSE;
+
+ /* initialize ptrs to NULL so that in error cases we can tell what needs
+ * to be freed:
+ */
+ if (library_name) *library_name = NULL;
+ if (component_name) *component_name = NULL;
+
+ if (library_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "library-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'library-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *library_name = g_strdup (str);
+ }
+
+ if (component_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "component-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'component-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *component_name = g_strdup (str);
+ }
+
+exit:
+
+ /* if we failed, free any memory that might have been allocated:
+ */
+ if (!ret)
+ {
+ if (library_name) g_free (*library_name);
+ if (component_name) g_free (*component_name);
+ }
+
+
+ return ret;
+}
+
+static gboolean
+set_value_helper (GValue *value, gchar *str)
+{
+ g_value_set_string (value, str);
+ return TRUE;
+}
+
+/**
+ * g_omx_get_library_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "library-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_library_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, &str, NULL) &&
+ set_value_helper (val, str);
+}
+
+/**
+ * g_omx_get_component_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "component-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_component_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, NULL, &str) &&
+ set_value_helper (val, str);
+}
+
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"omx",
diff --git a/omx/gstomx.conf b/omx/gstomx.conf
new file mode 100644
index 0000000..c22c6d6
--- /dev/null
+++ b/omx/gstomx.conf
@@ -0,0 +1,203 @@
+#include "config.h"
+
+/* in case of multiple OMX components mapping to a single gst-openmax element
+ * class, a dynamic subclass can be created by specifying the gst-openmax
+ * type as the 'parent-type' and specifying a new unique type name as the
+ * 'type' parameter:
+ */
+omx_dummy,
+ parent-type=GstOmxDummy,
+ type=GstOmxDummyOne,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.bellagio.dummy,
+ rank=0;
+
+/* for testing: */
+omx_dummy_2,
+ parent-type=GstOmxDummy,
+ type=GstOmxDummyTwo,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.dummy2,
+ rank=256;
+
+omx_mpeg4dec,
+ type=GstOmxMpeg4Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.mpeg4,
+ rank=256;
+
+omx_h264dec,
+ type=GstOmxH264Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.avc,
+ rank=256;
+
+omx_h263dec,
+ type=GstOmxH263Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.h263,
+ rank=256;
+
+omx_wmvdec,
+ type=GstOmxWmvDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_decoder.wmv,
+ rank=256;
+
+omx_mpeg4enc,
+ type=GstOmxMpeg4Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.mpeg4,
+ rank=256;
+
+omx_h264enc,
+ type=GstOmxH264Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.avc,
+ rank=256;
+
+omx_h263enc,
+ type=GstOmxH263Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.video_encoder.h263,
+ rank=256;
+
+omx_vorbisdec,
+ type=GstOmxVorbisDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.ogg.single,
+ rank=128;
+
+omx_mp3dec,
+ type=GstOmxMp3Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.mp3.mad,
+ rank=256;
+
+#ifdef EXPERIMENTAL
+
+omx_mp2dec,
+ type=GstOmxMp2Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.mp3.mad,
+ rank=256;
+
+omx_amrnbdec,
+ type=GstOmxAmrNbDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.amrnb,
+ rank=256;
+
+omx_amrnbenc,
+ type=GstOmxAmrNbEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.amrnb,
+ rank=256;
+
+omx_amrwbdec,
+ type=GstOmxAmrWbDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.amrwb,
+ rank=256;
+
+omx_amrwbenc,
+ type=GstOmxAmrWbEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.amrwb,
+ rank=256;
+
+omx_aacdec,
+ type=GstOmxAacDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.aac,
+ rank=256;
+
+omx_aacenc,
+ type=GstOmxAacEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.aac,
+ rank=256;
+
+omx_adpcmdec,
+ type=GstOmxAdpcmDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.adpcm,
+ rank=256;
+
+omx_adpcmenc,
+ type=GstOmxAdpcmEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.adpcm,
+ rank=256;
+
+omx_g711dec,
+ type=GstOmxG711Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.g711,
+ rank=256;
+
+omx_g711enc,
+ type=GstOmxG711Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.g711,
+ rank=256;
+
+omx_g729dec,
+ type=GstOmxG729Dec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.g729,
+ rank=256;
+
+omx_g729enc,
+ type=GstOmxG729Enc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.g729,
+ rank=256;
+
+omx_ilbcdec,
+ type=GstOmxIlbcDec,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_decoder.ilbc,
+ rank=256;
+
+omx_ilbcenc,
+ type=GstOmxIlbcEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_encoder.ilbc,
+ rank=256;
+
+omx_jpegenc,
+ type=GstOmxJpegEnc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.image_encoder.jpeg,
+ rank=256;
+
+#endif /* EXPERIMENTAL */
+
+omx_audiosink,
+ type=GstOmxAudioSink,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.alsa.alsasink,
+ rank=0;
+
+#ifdef EXPERIMENTAL
+
+omx_videosink,
+ type=GstOmxVideoSink,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.videosink,
+ rank=0;
+
+omx_filereadersrc,
+ type=GstOmxFilereaderSrc,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.audio_filereader,
+ rank=0;
+
+#endif /* EXPERIMENTAL */
+
+omx_volume,
+ type=GstOmxVolume,
+ library-name=libomxil-bellagio.so.0,
+ component-name=OMX.st.volume.component,
+ rank=0;
diff --git a/omx/gstomx.h b/omx/gstomx.h
index 7d5fa04..063437d 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -30,6 +30,12 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
#define GST_CAT_DEFAULT gstomx_debug
+gboolean g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name);
+gboolean g_omx_get_library_name_value (gpointer object, GValue *val);
+gboolean g_omx_get_component_name_value (gpointer object, GValue *val);
+
G_END_DECLS
#endif /* GSTOMX_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index b0353cb..2a30502 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -115,7 +115,7 @@ change_state (GstElement *element,
switch (transition)
{
case GST_STATE_CHANGE_NULL_TO_READY:
- g_omx_core_init (core, self->omx_library, self->omx_component);
+ g_omx_core_init (core);
if (core->omx_state != OMX_StateLoaded)
{
ret = GST_STATE_CHANGE_FAILURE;
@@ -184,9 +184,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
g_mutex_free (self->ready_lock);
G_OBJECT_CLASS (parent_class)->finalize (obj);
@@ -204,14 +201,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
case ARG_USE_TIMESTAMPS:
self->use_timestamps = g_value_get_boolean (value);
break;
@@ -234,10 +223,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
case ARG_USE_TIMESTAMPS:
g_value_set_boolean (value, self->use_timestamps);
@@ -271,12 +260,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
g_param_spec_boolean ("use-timestamps", "Use timestamps",
@@ -922,16 +911,6 @@ type_instance_init (GTypeInstance *instance,
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_filter.h b/omx/gstomx_base_filter.h
index 4baf181..99b5d72 100644
--- a/omx/gstomx_base_filter.h
+++ b/omx/gstomx_base_filter.h
@@ -48,8 +48,6 @@ struct GstOmxBaseFilter
GOmxPort *in_port;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
gboolean use_timestamps; /** @todo remove; timestamps should always be used */
gboolean ready;
GMutex *ready_lock;
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index c1a2076..7911167 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -141,9 +141,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -298,14 +295,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -325,10 +314,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -366,12 +355,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -420,7 +409,7 @@ activate_push (GstPad *pad,
static inline gboolean
omx_init (GstOmxBaseSink *self)
{
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return FALSE;
@@ -468,16 +457,6 @@ type_instance_init (GTypeInstance *instance,
}
{
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
- {
GstPad *sinkpad;
self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
index 681e939..589c441 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -46,9 +46,6 @@ struct GstOmxBaseSink
GOmxCore *gomx;
GOmxPort *in_port;
- char *omx_component;
- char *omx_library;
-
gboolean ready;
GstPadActivateModeFunction base_activatepush;
gboolean initialized;
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 9b02b22..dd9767e 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -67,7 +67,7 @@ start (GstBaseSrc *gst_base)
GST_LOG_OBJECT (self, "begin");
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -106,9 +106,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -362,20 +359,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- if (self->omx_component)
- {
- g_free (self->omx_component);
- }
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- if (self->omx_library)
- {
- g_free (self->omx_library);
- }
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -395,10 +378,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -433,12 +416,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -459,17 +442,6 @@ type_instance_init (GTypeInstance *instance,
gomx->object = self;
}
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_src.h b/omx/gstomx_base_src.h
index 85e4c13..adab894 100644
--- a/omx/gstomx_base_src.h
+++ b/omx/gstomx_base_src.h
@@ -44,8 +44,6 @@ struct GstOmxBaseSrc
GOmxCore *gomx;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
GstOmxBaseSrcCb setup_ports;
};
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 39d900b..ac94953 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -301,10 +301,13 @@ g_omx_core_free (GOmxCore *core)
}
void
-g_omx_core_init (GOmxCore *core,
- const gchar *library_name,
- const gchar *component_name)
+g_omx_core_init (GOmxCore *core)
{
+ gchar *library_name, *component_name;
+
+ g_return_if_fail (g_omx_get_component_info (core->object,
+ &library_name, &component_name));
+
core->imp = request_imp (library_name);
if (!core->imp)
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index f0cf045..c3ac441 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -116,7 +116,7 @@ void g_omx_deinit (void);
GOmxCore *g_omx_core_new (void);
void g_omx_core_free (GOmxCore *core);
-void g_omx_core_init (GOmxCore *core, const gchar *library_name, const gchar *component_name);
+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);
--
1.6.3.2
|
|
From: Rob C. <ro...@ti...> - 2010-02-27 03:22:44
|
On Feb 26, 2010, at 4:20 PM, Felipe Contreras wrote: > On Sat, Feb 27, 2010 at 12:03 AM, Clark, Rob <ro...@ti...> wrote: >> so something like: >> >> ----- >> omx_dummy, >> type=GstOmxDummy, >> derived-type=GstOmxDummyOne, >> library-name=libomxil-bellagio.so, >> component-name=OMX.st.dummy, >> rank=0; >> >> omx_dummy_2, >> type=GstOmxDummy, >> derived-type=GstOmxDummyTwo, >> library-name=libomxil-bellagio.so, >> component-name=OMX.bellagio.dummy, >> rank=256; >> ----- > > Yeah, but type => parent, derived-type = type. > >> it does make the config file more complex (one more thing to misconfigure), and then we need a bit more error handling, in case user specifies a type name that already exists.. so I'm not super-excited about that. > > I don't think we need to spend so much code to check for duplicated > types, the type register would fail. Besides, what happens if you > derive from a class that's not GstOmx; I don't think the proneness to > errors is increasing that much by adding one field more. > >> Also, then we need an additional hash-table to map back to element name (or something like g_type_set_qdata()).. both is possible, but it makes the code slightly less simple. > > Why do we need to map back to element names? As you said; the user can > select any name anyways. (We are using g_type_set_qdata() already) > >> using the element name as the type name seems a simple solution to both. > > Yeah, it's simple but doesn't feel right to me. I am picturing myself > reading some debug log, scratching my head and then saying: ohh, > omx_dummy was the _class_ name! ok, I thought about this for a bit, and think I came up with a reasonable compromise between avoiding too much complexity in the conf file in the simple case (one OMX component for one gst-openmax class), but enough flexibility to still handle the advanced case (multiple different OMX components using same gst-openmax class): In the simple case, where there is only one OMX component for a particular gst-openmax class, you simply specify 'type', and no dynamic subclass is created: ----- omx_mpeg4dec, type=GstOmxMpeg4Dec, library-name=libomxil-bellagio.so.0, component-name=OMX.st.video_decoder.mpeg4, rank=256; ----- in this case, GstOmxMpeg4Dec is used directly with no dynamic subclass created. But in the advanced case, if you want multiple different gst elements of different OMX component but same gst-openmax class, you specify the 'parent-type' (which is the real gst-openmax class), and 'type' (which is the dynamically generated child class): ----- omx_dummy, parent-type=GstOmxDummy, type=GstOmxDummyOne, library-name=libomxil-bellagio.so.0, component-name=OMX.bellagio.dummy, rank=0; omx_dummy_2, parent-type=GstOmxDummy, type=GstOmxDummyTwo, library-name=libomxil-bellagio.so.0, component-name=OMX.st.dummy2, rank=256; ----- in this case 'GstOmxDummy' is the real class, and 'GstOmxDummyOne' and 'GstOmxDummyTwo' are both dynamically generated subclasses. I will send a patch with this solution in a few minutes. Let me know what you think. BR, -R > > Cheers. > > -- > Felipe Contreras |
|
From: Clark, R. <ro...@ti...> - 2010-02-26 22:44:51
|
On Feb 26, 2010, at 4:20 PM, Felipe Contreras wrote: > On Sat, Feb 27, 2010 at 12:03 AM, Clark, Rob <ro...@ti...> wrote: >> so something like: >> >> ----- >> omx_dummy, >> type=GstOmxDummy, >> derived-type=GstOmxDummyOne, >> library-name=libomxil-bellagio.so, >> component-name=OMX.st.dummy, >> rank=0; >> >> omx_dummy_2, >> type=GstOmxDummy, >> derived-type=GstOmxDummyTwo, >> library-name=libomxil-bellagio.so, >> component-name=OMX.bellagio.dummy, >> rank=256; >> ----- > > Yeah, but type => parent, derived-type = type. > >> it does make the config file more complex (one more thing to misconfigure), and then we need a bit more error handling, in case user specifies a type name that already exists.. so I'm not super-excited about that. > > I don't think we need to spend so much code to check for duplicated > types, the type register would fail. Besides, what happens if you > derive from a class that's not GstOmx; I don't think the proneness to > errors is increasing that much by adding one field more. > >> Also, then we need an additional hash-table to map back to element name (or something like g_type_set_qdata()).. both is possible, but it makes the code slightly less simple. > > Why do we need to map back to element names? As you said; the user can > select any name anyways. (We are using g_type_set_qdata() already) sorry that wasn't very clear I don't mean element name, but element type name.. (ie. "omx_dummy", not "omx_dummy0") we need some way to g_omx_get_component_info() from the element instance. Currently I just use type name. I could use typename into a key into a hashtable, or g_type_set_qdata(). I guess it only really changes one function so it doesn't make that much of a difference. My bigger fear is it is just one more thing to be misconfigured, but if you aren't to worried about that, I can change it.. BR, -R > >> using the element name as the type name seems a simple solution to both. > > Yeah, it's simple but doesn't feel right to me. I am picturing myself > reading some debug log, scratching my head and then saying: ohh, > omx_dummy was the _class_ name! > > Cheers. > > -- > Felipe Contreras |
|
From: Felipe C. <fel...@gm...> - 2010-02-26 22:20:42
|
On Sat, Feb 27, 2010 at 12:03 AM, Clark, Rob <ro...@ti...> wrote: > so something like: > > ----- > omx_dummy, > type=GstOmxDummy, > derived-type=GstOmxDummyOne, > library-name=libomxil-bellagio.so, > component-name=OMX.st.dummy, > rank=0; > > omx_dummy_2, > type=GstOmxDummy, > derived-type=GstOmxDummyTwo, > library-name=libomxil-bellagio.so, > component-name=OMX.bellagio.dummy, > rank=256; > ----- Yeah, but type => parent, derived-type = type. > it does make the config file more complex (one more thing to misconfigure), and then we need a bit more error handling, in case user specifies a type name that already exists.. so I'm not super-excited about that. I don't think we need to spend so much code to check for duplicated types, the type register would fail. Besides, what happens if you derive from a class that's not GstOmx; I don't think the proneness to errors is increasing that much by adding one field more. > Also, then we need an additional hash-table to map back to element name (or something like g_type_set_qdata()).. both is possible, but it makes the code slightly less simple. Why do we need to map back to element names? As you said; the user can select any name anyways. (We are using g_type_set_qdata() already) > using the element name as the type name seems a simple solution to both. Yeah, it's simple but doesn't feel right to me. I am picturing myself reading some debug log, scratching my head and then saying: ohh, omx_dummy was the _class_ name! Cheers. -- Felipe Contreras |
|
From: Felipe C. <fel...@gm...> - 2010-02-26 22:04:35
|
On Fri, Feb 26, 2010 at 8:10 PM, Clark, Rob <ro...@ti...> wrote:
>
> On Feb 26, 2010, at 5:47 AM, Felipe Contreras wrote:
>
>> On Thu, Feb 25, 2010 at 3:55 AM, Rob Clark <ro...@ti...> wrote:
>>> ---
>>> omx/gstomx_base_filter.c | 12 ++++++------
>>> omx/gstomx_base_sink.c | 2 +-
>>> 2 files changed, 7 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
>>> index 287f50c..b0353cb 100644
>>> --- a/omx/gstomx_base_filter.c
>>> +++ b/omx/gstomx_base_filter.c
>>> @@ -40,11 +40,11 @@ log_buffer (GstOmxBaseFilter *self,
>>> OMX_BUFFERHEADERTYPE *omx_buffer)
>>> {
>>> GST_DEBUG_OBJECT (self, "omx_buffer: "
>>> - "size=%" G_GUINT32_FORMAT ", "
>>> - "len=%" G_GUINT32_FORMAT ", "
>>> - "flags=%" G_GUINT32_FORMAT ", "
>>> - "offset=%" G_GUINT32_FORMAT ", "
>>> - "timestamp=%" G_GUINT64_FORMAT,
>>> + "size=%lu, "
>>> + "len=%lu, "
>>> + "flags=%lu, "
>>> + "offset=%lu, "
>>> + "timestamp=%lld",
>>> omx_buffer->nAllocLen, omx_buffer->nFilledLen, omx_buffer->nFlags,
>>> omx_buffer->nOffset, omx_buffer->nTimeStamp);
>>> }
>>
>> Interesting, so G_GUINT32_FORMAT doesn't work with OMX_U32.
>>
>> Probably because of this:
>> /** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */
>> typedef unsigned long OMX_U32;
>>
>> Can you do a sizeof(OMX_U32) in your 64-bit system? I guess it's 64
>> bits, and if so, that's a bug in the header files and I wonder if
>> communication between different omx components (64bit client vs 32bit
>> implementation) might be screwed.
>>
>
>
> yup, this becomes 8 bytes.. if I build w/ -m32 to force 32bit binary, then it goes back to 4 bytes. But the compiler complains in either case.
>
> It would be better if OMX header used stdint types for better portability.. but I guess not much thought has gone into using OMX on 64bit platform yet.
stdint is only C99, so I don't think they would have gone for that.
> It is your call on merging this patch.. I don't think it should hurt anything, but probably most people won't need it. But I'll leave it in my own working tree since I need it to build on my laptop.
It wouldn't hurt anything but it feels like a hack, however, I don't
see any better solution for now (modifying the omx headers is very
tempting, but probably a big no-no).
ACK'ed.
Cheers.
--
Felipe Contreras
|
|
From: Clark, R. <ro...@ti...> - 2010-02-26 22:03:33
|
On Feb 26, 2010, at 3:52 PM, Felipe Contreras wrote: > On Fri, Feb 26, 2010 at 3:15 PM, Clark, Rob <ro...@ti...> wrote: >> >> On Feb 26, 2010, at 6:05 AM, Felipe Contreras wrote: >> >>> On Thu, Feb 25, 2010 at 3:56 AM, Rob Clark <ro...@ti...> wrote: >>>> Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names >>>> using the same gst-openmax class but different OMX library-name and/or component-name. For example: >>> >>> In general the patch looks ok, but: >>> >>> 1) I don't like this new class creation, probably the only reason it's >>> needed is because the library-name and component-name are set in the >>> GType, which is not needed. We can set these into the element itself >>> without modifying the original GType. >> >> >> We can set them as properties on the GstElement, but we still need some way to differentiate when the same element is used for two different OMX components in order to set the correct property values.. we can use the name property on the element, because this can be set to anything by the user (and at a minimum, would end up something like "omx_dummy0") >> >> I originally tried without creating new classes, but ran into this problem in the case that we had two different elements with same GType but different OMX components. So I don't see any better solution. > > Yeah, now I see that it can be problematic. But I still don't like > omx_dummy as a GType, I think the proper GType should also be > specified on the config: GstOmxDummy. so something like: ----- omx_dummy, type=GstOmxDummy, derived-type=GstOmxDummyOne, library-name=libomxil-bellagio.so, component-name=OMX.st.dummy, rank=0; omx_dummy_2, type=GstOmxDummy, derived-type=GstOmxDummyTwo, library-name=libomxil-bellagio.so, component-name=OMX.bellagio.dummy, rank=256; ----- it does make the config file more complex (one more thing to misconfigure), and then we need a bit more error handling, in case user specifies a type name that already exists.. so I'm not super-excited about that. Also, then we need an additional hash-table to map back to element name (or something like g_type_set_qdata()).. both is possible, but it makes the code slightly less simple. using the element name as the type name seems a simple solution to both. > >>> 2) gstomx_conf.c looks a bit tricky, I was thinking on a plain text >>> file, just like gst-openmax.conf. I guess the .c file is ok for now, >>> but I don't like this tricky Makefile rule, let's just have a >>> gstomx_conf.c instead. >> >> I think we need something that ends up as a .c file, for the #ifndef EXPERIMENTAL stuff.. and also so we have some default config embedded in libgstomx.so. >> >> That said, it could be a plain gstomx_conf.c file.. I just thought the plain text .conf file generating the .c file was easier to edit. But I can change it back to plain .c file if you don't like my clever makefile rule ;-) > > Now that you show the plain .c file I understand why it's not nice to > use that. I feel there must be a better way to handle this, but for > now I think you original proposal is ok (except the license notice, > which I think is overkill). ok, I can go back to original version of default config .conf file BR, -R > > -- > Felipe Contreras |
|
From: Felipe C. <fel...@gm...> - 2010-02-26 22:01:06
|
On Fri, Feb 26, 2010 at 4:14 PM, Clark, Rob <ro...@ti...> wrote: > > On Feb 26, 2010, at 6:05 AM, Felipe Contreras wrote: > >> 3) The configuration location should be obtained with >> g_get_user_config_dir() ($HOME/.config) > > > What do you think about leaving this as-is, but submitting a patch to gstreamer to add API to get the gst registry directory (gst_get_registry_dir() or something like that?), and later changing to using that? > > I'm wondering if the config file makes more sense to be located along side gst registry.. The problem I have with this approach is that GStreamer registry is fundamentally different; it's not something the user is supposed to change. In fact, the proper location of the registry should probably be ~/.cache/gstreamer-0.10 (through g_get_user_cache_dir()). So if we use use gst_get_registry_dir() the conf might end up in ~/.cache, and I don't think that's good. In fact, I think the user should be able to configure the rank of gstreamer elements (not gst-omx). And if such thing gets ever implemented the configuration would probably be in ~/.config. Until there's a gst_get_config_dir(), I think it's best to follow my proposal. Cheers. -- Felipe Contreras |
|
From: Felipe C. <fel...@gm...> - 2010-02-26 21:53:55
|
On Fri, Feb 26, 2010 at 3:33 PM, Clark, Rob <ro...@ti...> wrote: > On Feb 26, 2010, at 6:36 AM, Tim-Philipp Müller wrote: >> GLib macro is G_N_ELEMENTS, fwiw. > > ahh, brilliant.. I couldn't figure out what macro name to look for, and was hoping for someone to clue me in :-) Let's use that instead then. -- Felipe Contreras |
|
From: Felipe C. <fel...@gm...> - 2010-02-26 21:53:08
|
On Fri, Feb 26, 2010 at 3:15 PM, Clark, Rob <ro...@ti...> wrote: > > On Feb 26, 2010, at 6:05 AM, Felipe Contreras wrote: > >> On Thu, Feb 25, 2010 at 3:56 AM, Rob Clark <ro...@ti...> wrote: >>> Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names >>> using the same gst-openmax class but different OMX library-name and/or component-name. For example: >> >> In general the patch looks ok, but: >> >> 1) I don't like this new class creation, probably the only reason it's >> needed is because the library-name and component-name are set in the >> GType, which is not needed. We can set these into the element itself >> without modifying the original GType. > > > We can set them as properties on the GstElement, but we still need some way to differentiate when the same element is used for two different OMX components in order to set the correct property values.. we can use the name property on the element, because this can be set to anything by the user (and at a minimum, would end up something like "omx_dummy0") > > I originally tried without creating new classes, but ran into this problem in the case that we had two different elements with same GType but different OMX components. So I don't see any better solution. Yeah, now I see that it can be problematic. But I still don't like omx_dummy as a GType, I think the proper GType should also be specified on the config: GstOmxDummy. >> 2) gstomx_conf.c looks a bit tricky, I was thinking on a plain text >> file, just like gst-openmax.conf. I guess the .c file is ok for now, >> but I don't like this tricky Makefile rule, let's just have a >> gstomx_conf.c instead. > > I think we need something that ends up as a .c file, for the #ifndef EXPERIMENTAL stuff.. and also so we have some default config embedded in libgstomx.so. > > That said, it could be a plain gstomx_conf.c file.. I just thought the plain text .conf file generating the .c file was easier to edit. But I can change it back to plain .c file if you don't like my clever makefile rule ;-) Now that you show the plain .c file I understand why it's not nice to use that. I feel there must be a better way to handle this, but for now I think you original proposal is ok (except the license notice, which I think is overkill). -- Felipe Contreras |
|
From: Rob C. <ro...@ti...> - 2010-02-26 21:44:19
|
Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names
using the same gst-openmax class but different OMX library-name and/or component-name. For example:
----
omx_mp3dec_ti,
type=GstOmxMp3Dec,
library-name=libOMX_Core.so.0,
component-name=OMX.TI.AUDIO.DECODE,
component-role=audio_decode.dsp.mp3,
rank=256;
omx_mp3dec_nokia,
type=GstOmxMp3Dec,
library-name=libomxil_bellagio.so.0,
component-name=OMX.nokia.audio_decode.mp3,
rank=128;
----
by default, the config file is stored in $HOME/.config/gst-openmax.conf, although if none is found a default config will be created.
---
omx/Makefile.am | 3 +-
omx/gstomx.c | 351 ++++++++++++++++++++++++++++++++++++++--------
omx/gstomx.h | 6 +
omx/gstomx_base_filter.c | 31 +----
omx/gstomx_base_filter.h | 2 -
omx/gstomx_base_sink.c | 31 +----
omx/gstomx_base_sink.h | 3 -
omx/gstomx_base_src.c | 38 +-----
omx/gstomx_base_src.h | 2 -
omx/gstomx_conf.c | 217 ++++++++++++++++++++++++++++
omx/gstomx_util.c | 9 +-
omx/gstomx_util.h | 2 +-
12 files changed, 537 insertions(+), 158 deletions(-)
create mode 100644 omx/gstomx_conf.c
diff --git a/omx/Makefile.am b/omx/Makefile.am
index 4a3fbf9..6ea9cf5 100644
--- a/omx/Makefile.am
+++ b/omx/Makefile.am
@@ -18,7 +18,8 @@ libgstomx_la_SOURCES = gstomx.c gstomx.h \
gstomx_vorbisdec.c gstomx_vorbisdec.h \
gstomx_mp3dec.c gstomx_mp3dec.h \
gstomx_base_sink.c gstomx_base_sink.h \
- gstomx_audiosink.c gstomx_audiosink.h
+ gstomx_audiosink.c gstomx_audiosink.h \
+ gstomx_conf.c
if EXPERIMENTAL
libgstomx_la_SOURCES += gstomx_amrnbdec.c gstomx_amrnbdec.h \
diff --git a/omx/gstomx.c b/omx/gstomx.c
index 6756f54..f882f64 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -21,6 +21,10 @@
#include "config.h"
+#include <string.h>
+
+#include <gst/gststructure.h>
+
#include "gstomx.h"
#include "gstomx_dummy.h"
#include "gstomx_mpeg4dec.h"
@@ -59,90 +63,315 @@
GST_DEBUG_CATEGORY (gstomx_debug);
-typedef struct TableItem
-{
- const gchar *name;
- const gchar *library_name;
- const gchar *component_name;
- guint rank;
- GType (*get_type) (void);
-} TableItem;
-
-static TableItem element_table[] =
-{
- { "omx_dummy", "libomxil-bellagio.so.0", "OMX.st.dummy", GST_RANK_NONE, gst_omx_dummy_get_type },
- { "omx_mpeg4dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4dec_get_type },
- { "omx_h264dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.avc", GST_RANK_PRIMARY, gst_omx_h264dec_get_type },
- { "omx_h263dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.h263", GST_RANK_PRIMARY, gst_omx_h263dec_get_type },
- { "omx_wmvdec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.wmv", GST_RANK_PRIMARY, gst_omx_wmvdec_get_type },
- { "omx_mpeg4enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4enc_get_type },
- { "omx_h264enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.avc", GST_RANK_PRIMARY, gst_omx_h264enc_get_type },
- { "omx_h263enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.h263", GST_RANK_PRIMARY, gst_omx_h263enc_get_type },
- { "omx_vorbisdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ogg.single", GST_RANK_SECONDARY, gst_omx_vorbisdec_get_type },
- { "omx_mp3dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp3dec_get_type },
+static GstStructure *element_table = NULL;
+
+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
- { "omx_mp2dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp2dec_get_type },
- { "omx_amrnbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbdec_get_type },
- { "omx_amrnbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbenc_get_type },
- { "omx_amrwbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbdec_get_type },
- { "omx_amrwbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbenc_get_type },
- { "omx_aacdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.aac", GST_RANK_PRIMARY, gst_omx_aacdec_get_type },
- { "omx_aacenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.aac", GST_RANK_PRIMARY, gst_omx_aacenc_get_type },
- { "omx_adpcmdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmdec_get_type },
- { "omx_adpcmenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmenc_get_type },
- { "omx_g711dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g711", GST_RANK_PRIMARY, gst_omx_g711dec_get_type },
- { "omx_g711enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g711", GST_RANK_PRIMARY, gst_omx_g711enc_get_type },
- { "omx_g729dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g729", GST_RANK_PRIMARY, gst_omx_g729dec_get_type },
- { "omx_g729enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g729", GST_RANK_PRIMARY, gst_omx_g729enc_get_type },
- { "omx_ilbcdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcdec_get_type },
- { "omx_ilbcenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcenc_get_type },
- { "omx_jpegenc", "libomxil-bellagio.so.0", "OMX.st.image_encoder.jpeg", GST_RANK_PRIMARY, gst_omx_jpegenc_get_type },
+ 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 */
- { "omx_audiosink", "libomxil-bellagio.so.0", "OMX.st.alsa.alsasink", GST_RANK_NONE, gst_omx_audiosink_get_type },
+ gst_omx_audiosink_get_type,
#ifdef EXPERIMENTAL
- { "omx_videosink", "libomxil-bellagio.so.0", "OMX.st.videosink", GST_RANK_NONE, gst_omx_videosink_get_type },
- { "omx_filereadersrc", "libomxil-bellagio.so.0", "OMX.st.audio_filereader", GST_RANK_NONE, gst_omx_filereadersrc_get_type },
+ gst_omx_videosink_get_type,
+ gst_omx_filereadersrc_get_type,
#endif /* EXPERIMENTAL */
- { "omx_volume", "libomxil-bellagio.so.0", "OMX.st.volume.component", GST_RANK_NONE, gst_omx_volume_get_type },
- { NULL, NULL, NULL, 0, NULL },
+ gst_omx_volume_get_type,
};
+/* TODO: we can cache table w/ gst_plugin_{get,set}_cache_data..
+ */
+static GstStructure *
+get_element_table (void)
+{
+ static volatile gsize gonce_data = 0;
+ if (g_once_init_enter (&gonce_data))
+ {
+ gchar *path;
+ gchar *config, *s;
+ GstStructure *element;
+
+ path = g_strdup (g_getenv ("OMX_REGISTRY"));
+ if (!path)
+ {
+ path = g_build_filename (g_get_user_config_dir (),
+ "gst-openmax.conf", NULL);
+ }
+
+ if (!g_file_get_contents (path, &config, NULL, NULL))
+ {
+ g_warning ("could not find config file '%s'.. using defaults!", path);
+ config = (gchar *) default_config;
+
+ g_file_set_contents (path, config, -1, NULL);
+ }
+
+ GST_DEBUG ("parsing config:\n%s", config);
+
+ element_table = 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 (element_table,
+ element_name, GST_TYPE_STRUCTURE, element, NULL);
+ }
+
+ if (config != default_config)
+ {
+ g_free (config);
+ }
+
+ g_free (path);
+
+ GST_DEBUG ("element_table=%"GST_PTR_FORMAT, element_table);
+
+ g_once_init_leave (&gonce_data, 1);
+ }
+
+ return element_table;
+}
+
+static GstStructure *
+get_element_entry (const gchar *element_name)
+{
+ GstStructure *element_table = get_element_table ();
+ GstStructure *element;
+
+ if (! gst_structure_get (element_table,
+ element_name, GST_TYPE_STRUCTURE, &element, NULL))
+ element = NULL;
+
+ g_assert (element);
+
+ return element;
+}
+
+static const gchar *
+get_element_name (gpointer object)
+{
+ return G_OBJECT_TYPE_NAME (object);
+}
+
+/* register a new dynamic sub-class with the omx element as it's 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 type, const gchar *element_name)
+{
+ GTypeQuery q;
+ GTypeInfo i = {0};
+
+ g_type_query (type, &q);
+
+ i.class_size = q.class_size;
+ i.instance_size = q.instance_size;
+
+ return g_type_register_static (type, element_name, &i, 0);
+}
+
static gboolean
plugin_init (GstPlugin *plugin)
{
- GQuark library_name_quark;
- GQuark component_name_quark;
+ gint i, cnt;
+ GstStructure *element_table;
+
GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
- library_name_quark = g_quark_from_static_string ("library-name");
- component_name_quark = g_quark_from_static_string ("component-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] ();
+ }
+
+ element_table = get_element_table ();
g_omx_init ();
+ cnt = gst_structure_n_fields (element_table);
+ for (i = 0; i < cnt; i++)
{
- guint i;
- for (i = 0; element_table[i].name; i++)
+ const gchar *element_name = gst_structure_nth_field_name (element_table, i);
+ GstStructure *element = get_element_entry (element_name);
+ const gchar *type_name;
+ GType type;
+ gint rank;
+
+ GST_DEBUG ("element=%"GST_PTR_FORMAT, element);
+
+ type_name = gst_structure_get_string (element, "type");
+ if (!type_name)
{
- TableItem *element;
- GType type;
-
- element = &element_table[i];
- type = element->get_type ();
- g_type_set_qdata (type, library_name_quark, (gpointer) element->library_name);
- g_type_set_qdata (type, component_name_quark, (gpointer) element->component_name);
-
- if (!gst_element_register (plugin, element->name, element->rank, type))
- {
- g_warning ("failed registering '%s'", element->name);
- return FALSE;
- }
+ g_warning ("malformed config file: missing 'type' for %s", element_name);
+ return FALSE;
+ }
+
+ 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;
+ }
+
+ type = create_subtype (type, 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;
}
+/**
+ * g_omx_get_component_info:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @library_name: library-name, returned by reference (or NULL)
+ * @component_name: component-name, returned by reference (or NULL)
+ *
+ * Get library-name and component-name for an element.
+ *
+ * note: this function will gain another parameter later when component-role
+ * is added
+ */
+gboolean
+g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name)
+{
+ gboolean ret = TRUE;
+ const gchar *element_name = get_element_name (object);
+ GstStructure *element = get_element_entry (element_name);
+
+ if (!element)
+ return FALSE;
+
+ /* initialize ptrs to NULL so that in error cases we can tell what needs
+ * to be freed:
+ */
+ if (library_name) *library_name = NULL;
+ if (component_name) *component_name = NULL;
+
+ if (library_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "library-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'library-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *library_name = g_strdup (str);
+ }
+
+ if (component_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "component-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'component-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *component_name = g_strdup (str);
+ }
+
+exit:
+
+ /* if we failed, free any memory that might have been allocated:
+ */
+ if (!ret)
+ {
+ if (library_name) g_free (*library_name);
+ if (component_name) g_free (*component_name);
+ }
+
+
+ return ret;
+}
+
+static gboolean
+set_value_helper (GValue *value, gchar *str)
+{
+ g_value_set_string (value, str);
+ return TRUE;
+}
+
+/**
+ * g_omx_get_library_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "library-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_library_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, &str, NULL) &&
+ set_value_helper (val, str);
+}
+
+/**
+ * g_omx_get_component_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "component-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_component_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, NULL, &str) &&
+ set_value_helper (val, str);
+}
+
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"omx",
diff --git a/omx/gstomx.h b/omx/gstomx.h
index 7d5fa04..063437d 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -30,6 +30,12 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
#define GST_CAT_DEFAULT gstomx_debug
+gboolean g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name);
+gboolean g_omx_get_library_name_value (gpointer object, GValue *val);
+gboolean g_omx_get_component_name_value (gpointer object, GValue *val);
+
G_END_DECLS
#endif /* GSTOMX_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index b0353cb..2a30502 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -115,7 +115,7 @@ change_state (GstElement *element,
switch (transition)
{
case GST_STATE_CHANGE_NULL_TO_READY:
- g_omx_core_init (core, self->omx_library, self->omx_component);
+ g_omx_core_init (core);
if (core->omx_state != OMX_StateLoaded)
{
ret = GST_STATE_CHANGE_FAILURE;
@@ -184,9 +184,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
g_mutex_free (self->ready_lock);
G_OBJECT_CLASS (parent_class)->finalize (obj);
@@ -204,14 +201,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
case ARG_USE_TIMESTAMPS:
self->use_timestamps = g_value_get_boolean (value);
break;
@@ -234,10 +223,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
case ARG_USE_TIMESTAMPS:
g_value_set_boolean (value, self->use_timestamps);
@@ -271,12 +260,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
g_param_spec_boolean ("use-timestamps", "Use timestamps",
@@ -922,16 +911,6 @@ type_instance_init (GTypeInstance *instance,
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_filter.h b/omx/gstomx_base_filter.h
index 4baf181..99b5d72 100644
--- a/omx/gstomx_base_filter.h
+++ b/omx/gstomx_base_filter.h
@@ -48,8 +48,6 @@ struct GstOmxBaseFilter
GOmxPort *in_port;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
gboolean use_timestamps; /** @todo remove; timestamps should always be used */
gboolean ready;
GMutex *ready_lock;
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index c1a2076..7911167 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -141,9 +141,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -298,14 +295,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -325,10 +314,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -366,12 +355,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -420,7 +409,7 @@ activate_push (GstPad *pad,
static inline gboolean
omx_init (GstOmxBaseSink *self)
{
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return FALSE;
@@ -468,16 +457,6 @@ type_instance_init (GTypeInstance *instance,
}
{
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
- {
GstPad *sinkpad;
self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
index 681e939..589c441 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -46,9 +46,6 @@ struct GstOmxBaseSink
GOmxCore *gomx;
GOmxPort *in_port;
- char *omx_component;
- char *omx_library;
-
gboolean ready;
GstPadActivateModeFunction base_activatepush;
gboolean initialized;
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 9b02b22..dd9767e 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -67,7 +67,7 @@ start (GstBaseSrc *gst_base)
GST_LOG_OBJECT (self, "begin");
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -106,9 +106,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -362,20 +359,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- if (self->omx_component)
- {
- g_free (self->omx_component);
- }
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- if (self->omx_library)
- {
- g_free (self->omx_library);
- }
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -395,10 +378,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -433,12 +416,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -459,17 +442,6 @@ type_instance_init (GTypeInstance *instance,
gomx->object = self;
}
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_src.h b/omx/gstomx_base_src.h
index 85e4c13..adab894 100644
--- a/omx/gstomx_base_src.h
+++ b/omx/gstomx_base_src.h
@@ -44,8 +44,6 @@ struct GstOmxBaseSrc
GOmxCore *gomx;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
GstOmxBaseSrcCb setup_ports;
};
diff --git a/omx/gstomx_conf.c b/omx/gstomx_conf.c
new file mode 100644
index 0000000..d25c173
--- /dev/null
+++ b/omx/gstomx_conf.c
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2010 Texas Instruments, Incorporated
+ * Copyright (C) 2007-2010 Nokia Corporation.
+ *
+ * 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 <glib.h>
+
+#include "config.h"
+
+const gchar * default_config =
+"\n"
+"omx_dummy,\n"
+" type=GstOmxDummy,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.dummy,\n"
+" rank=0;\n"
+"\n"
+/* for testing: */
+"omx_dummy_2,\n"
+" type=GstOmxDummy,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.dummy2,\n"
+" rank=256;\n"
+"\n"
+"omx_mpeg4dec,\n"
+" type=GstOmxMpeg4Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_decoder.mpeg4,\n"
+" rank=256;\n"
+"\n"
+"omx_h264dec,\n"
+" type=GstOmxH264Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_decoder.avc,\n"
+" rank=256;\n"
+"\n"
+"omx_h263dec,\n"
+" type=GstOmxH263Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_decoder.h263,\n"
+" rank=256;\n"
+"\n"
+"omx_wmvdec,\n"
+" type=GstOmxWmvDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_decoder.wmv,\n"
+" rank=256;\n"
+"\n"
+"omx_mpeg4enc,\n"
+" type=GstOmxMpeg4Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_encoder.mpeg4,\n"
+" rank=256;\n"
+"\n"
+"omx_h264enc,\n"
+" type=GstOmxH264Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_encoder.avc,\n"
+" rank=256;\n"
+"\n"
+"omx_h263enc,\n"
+" type=GstOmxH263Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_encoder.h263,\n"
+" rank=256;\n"
+"\n"
+"omx_vorbisdec,\n"
+" type=GstOmxVorbisDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.ogg.single,\n"
+" rank=128;\n"
+"\n"
+"omx_mp3dec,\n"
+" type=GstOmxMp3Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.mp3.mad,\n"
+" rank=256;\n"
+"\n"
+#ifdef EXPERIMENTAL
+"omx_mp2dec,\n"
+" type=GstOmxMp2Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.mp3.mad,\n"
+" rank=256;\n"
+"\n"
+"omx_amrnbdec,\n"
+" type=GstOmxAmrNbDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.amrnb,\n"
+" rank=256;\n"
+"\n"
+"omx_amrnbenc,\n"
+" type=GstOmxAmrNbEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.amrnb,\n"
+" rank=256;\n"
+"\n"
+"omx_amrwbdec,\n"
+" type=GstOmxAmrWbDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.amrwb,\n"
+" rank=256;\n"
+"\n"
+"omx_amrwbenc,\n"
+" type=GstOmxAmrWbEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.amrwb,\n"
+" rank=256;\n"
+"\n"
+"omx_aacdec,\n"
+" type=GstOmxAacDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.aac,\n"
+" rank=256;\n"
+"\n"
+"omx_aacenc,\n"
+" type=GstOmxAacEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.aac,\n"
+" rank=256;\n"
+"\n"
+"omx_adpcmdec,\n"
+" type=GstOmxAdpcmDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.adpcm,\n"
+" rank=256;\n"
+"\n"
+"omx_adpcmenc,\n"
+" type=GstOmxAdpcmEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.adpcm,\n"
+" rank=256;\n"
+"\n"
+"omx_g711dec,\n"
+" type=GstOmxG711Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.g711,\n"
+" rank=256;\n"
+"\n"
+"omx_g711enc,\n"
+" type=GstOmxG711Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.g711,\n"
+" rank=256;\n"
+"\n"
+"omx_g729dec,\n"
+" type=GstOmxG729Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.g729,\n"
+" rank=256;\n"
+"\n"
+"omx_g729enc,\n"
+" type=GstOmxG729Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.g729,\n"
+" rank=256;\n"
+"\n"
+"omx_ilbcdec,\n"
+" type=GstOmxIlbcDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.ilbc,\n"
+" rank=256;\n"
+"\n"
+"omx_ilbcenc,\n"
+" type=GstOmxIlbcEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.ilbc,\n"
+" rank=256;\n"
+"\n"
+"omx_jpegenc,\n"
+" type=GstOmxJpegEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.image_encoder.jpeg,\n"
+" rank=256;\n"
+"\n"
+#endif /* EXPERIMENTAL */
+"omx_audiosink,\n"
+" type=GstOmxAudioSink,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.alsa.alsasink,\n"
+" rank=0;\n"
+"\n"
+#ifdef EXPERIMENTAL
+"omx_videosink,\n"
+" type=GstOmxVideoSink,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.videosink,\n"
+" rank=0;\n"
+"\n"
+"omx_filereadersrc,\n"
+" type=GstOmxFilereaderSrc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_filereader,\n"
+" rank=0;\n"
+"\n"
+#endif /* EXPERIMENTAL */
+"omx_volume,\n"
+" type=GstOmxVolume,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.volume.component,\n"
+" rank=0;\n"
+;
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 39d900b..ac94953 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -301,10 +301,13 @@ g_omx_core_free (GOmxCore *core)
}
void
-g_omx_core_init (GOmxCore *core,
- const gchar *library_name,
- const gchar *component_name)
+g_omx_core_init (GOmxCore *core)
{
+ gchar *library_name, *component_name;
+
+ g_return_if_fail (g_omx_get_component_info (core->object,
+ &library_name, &component_name));
+
core->imp = request_imp (library_name);
if (!core->imp)
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index f0cf045..c3ac441 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -116,7 +116,7 @@ void g_omx_deinit (void);
GOmxCore *g_omx_core_new (void);
void g_omx_core_free (GOmxCore *core);
-void g_omx_core_init (GOmxCore *core, const gchar *library_name, const gchar *component_name);
+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);
--
1.6.3.2
|
|
From: Stefan K. <en...@ho...> - 2010-02-26 20:38:24
|
hi rob,
thanks for the new patch.
Am 26.02.2010 20:31, schrieb Rob Clark:
> Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names
> using the same gst-openmax class but different OMX library-name and/or component-name. For example:
>
> ----
> omx_mp3dec_ti,
> type=GstOmxMp3Dec,
> library-name=libOMX_Core.so.0,
> component-name=OMX.TI.AUDIO.DECODE,
> component-role=audio_decode.dsp.mp3,
> rank=256;
>
> omx_mp3dec_nokia,
> type=GstOmxMp3Dec,
> library-name=libomxil_bellagio.so.0,
> component-name=OMX.nokia.audio_decode.mp3,
> rank=128;
> ----
>
> by default, the config file is stored in $HOME/.gstreamer-0.10/gst-openmax.conf, although if none is found a default config will be created.
> ---
Minor nitpick - this is not true anymore.
> omx/Makefile.am | 3 +-
> omx/gstomx.c | 348 ++++++++++++++++++++++++++++++++++++++--------
> omx/gstomx.h | 6 +
> omx/gstomx_base_filter.c | 31 +----
> omx/gstomx_base_filter.h | 2 -
> omx/gstomx_base_sink.c | 31 +----
> omx/gstomx_base_sink.h | 3 -
> omx/gstomx_base_src.c | 38 +-----
> omx/gstomx_base_src.h | 2 -
> omx/gstomx_conf.c | 217 +++++++++++++++++++++++++++++
> omx/gstomx_util.c | 9 +-
> omx/gstomx_util.h | 2 +-
> 12 files changed, 534 insertions(+), 158 deletions(-)
> create mode 100644 omx/gstomx_conf.c
>
> diff --git a/omx/Makefile.am b/omx/Makefile.am
> index 4a3fbf9..6ea9cf5 100644
> --- a/omx/Makefile.am
> +++ b/omx/Makefile.am
> @@ -18,7 +18,8 @@ libgstomx_la_SOURCES = gstomx.c gstomx.h \
> gstomx_vorbisdec.c gstomx_vorbisdec.h \
> gstomx_mp3dec.c gstomx_mp3dec.h \
> gstomx_base_sink.c gstomx_base_sink.h \
> - gstomx_audiosink.c gstomx_audiosink.h
> + gstomx_audiosink.c gstomx_audiosink.h \
> + gstomx_conf.c
>
> if EXPERIMENTAL
> libgstomx_la_SOURCES += gstomx_amrnbdec.c gstomx_amrnbdec.h \
> diff --git a/omx/gstomx.c b/omx/gstomx.c
> index 6756f54..6a53eda 100644
> --- a/omx/gstomx.c
> +++ b/omx/gstomx.c
> @@ -19,8 +19,12 @@
> *
> */
>
> +#include <string.h>
> +
> #include "config.h"
please keep "config.h" first.
>
> +#include <gst/gststructure.h>
> +
> #include "gstomx.h"
> #include "gstomx_dummy.h"
> #include "gstomx_mpeg4dec.h"
> @@ -59,90 +63,312 @@
>
> GST_DEBUG_CATEGORY (gstomx_debug);
>
> -typedef struct TableItem
> -{
> - const gchar *name;
> - const gchar *library_name;
> - const gchar *component_name;
> - guint rank;
> - GType (*get_type) (void);
> -} TableItem;
> -
> -static TableItem element_table[] =
> -{
> - { "omx_dummy", "libomxil-bellagio.so.0", "OMX.st.dummy", GST_RANK_NONE, gst_omx_dummy_get_type },
> - { "omx_mpeg4dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4dec_get_type },
> - { "omx_h264dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.avc", GST_RANK_PRIMARY, gst_omx_h264dec_get_type },
> - { "omx_h263dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.h263", GST_RANK_PRIMARY, gst_omx_h263dec_get_type },
> - { "omx_wmvdec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.wmv", GST_RANK_PRIMARY, gst_omx_wmvdec_get_type },
> - { "omx_mpeg4enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4enc_get_type },
> - { "omx_h264enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.avc", GST_RANK_PRIMARY, gst_omx_h264enc_get_type },
> - { "omx_h263enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.h263", GST_RANK_PRIMARY, gst_omx_h263enc_get_type },
> - { "omx_vorbisdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ogg.single", GST_RANK_SECONDARY, gst_omx_vorbisdec_get_type },
> - { "omx_mp3dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp3dec_get_type },
> +static GstStructure *element_table = NULL;
> +
> +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
> - { "omx_mp2dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp2dec_get_type },
> - { "omx_amrnbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbdec_get_type },
> - { "omx_amrnbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbenc_get_type },
> - { "omx_amrwbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbdec_get_type },
> - { "omx_amrwbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbenc_get_type },
> - { "omx_aacdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.aac", GST_RANK_PRIMARY, gst_omx_aacdec_get_type },
> - { "omx_aacenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.aac", GST_RANK_PRIMARY, gst_omx_aacenc_get_type },
> - { "omx_adpcmdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmdec_get_type },
> - { "omx_adpcmenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmenc_get_type },
> - { "omx_g711dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g711", GST_RANK_PRIMARY, gst_omx_g711dec_get_type },
> - { "omx_g711enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g711", GST_RANK_PRIMARY, gst_omx_g711enc_get_type },
> - { "omx_g729dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g729", GST_RANK_PRIMARY, gst_omx_g729dec_get_type },
> - { "omx_g729enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g729", GST_RANK_PRIMARY, gst_omx_g729enc_get_type },
> - { "omx_ilbcdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcdec_get_type },
> - { "omx_ilbcenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcenc_get_type },
> - { "omx_jpegenc", "libomxil-bellagio.so.0", "OMX.st.image_encoder.jpeg", GST_RANK_PRIMARY, gst_omx_jpegenc_get_type },
> + 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 */
> - { "omx_audiosink", "libomxil-bellagio.so.0", "OMX.st.alsa.alsasink", GST_RANK_NONE, gst_omx_audiosink_get_type },
> + gst_omx_audiosink_get_type,
> #ifdef EXPERIMENTAL
> - { "omx_videosink", "libomxil-bellagio.so.0", "OMX.st.videosink", GST_RANK_NONE, gst_omx_videosink_get_type },
> - { "omx_filereadersrc", "libomxil-bellagio.so.0", "OMX.st.audio_filereader", GST_RANK_NONE, gst_omx_filereadersrc_get_type },
> + gst_omx_videosink_get_type,
> + gst_omx_filereadersrc_get_type,
> #endif /* EXPERIMENTAL */
> - { "omx_volume", "libomxil-bellagio.so.0", "OMX.st.volume.component", GST_RANK_NONE, gst_omx_volume_get_type },
> - { NULL, NULL, NULL, 0, NULL },
> + gst_omx_volume_get_type,
> };
>
> +/* TODO: we can cache table w/ gst_plugin_{get,set}_cache_data..
> + */
> +static GstStructure *
> +get_element_table (void)
> +{
> + static volatile gsize gonce_data = 0;
> + if (g_once_init_enter (&gonce_data))
> + {
> + gchar *path;
> + gchar *config, *s;
> + GstStructure *element;
> +
> + path = g_strdup (g_getenv ("OMX_REGISTRY"));
> + if (!path)
> + {
> + path = g_build_filename (g_get_user_config_dir (),
> + "gst-openmax.conf", NULL);
> + }
> +
> + if (!g_file_get_contents (path, &config, NULL, NULL))
> + {
> + g_warning ("could not find config file '%s'.. using defaults!", path);
> + config = (gchar *) default_config;
> +
> + g_file_set_contents (path, config, -1, NULL);
> + }
> +
> + GST_DEBUG ("parsing config:\n%s", config);
> +
> + element_table = 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 (element_table,
> + element_name, GST_TYPE_STRUCTURE, element, NULL);
> + }
> +
> + if (config != default_config)
> + {
> + g_free (config);
> + }
> +
> + g_free (path);
> +
> + GST_DEBUG ("element_table=%"GST_PTR_FORMAT, element_table);
> +
> + g_once_init_leave (&gonce_data, 1);
> + }
> +
> + return element_table;
> +}
> +
> +static GstStructure *
> +get_element_entry (const gchar *element_name)
> +{
> + GstStructure *element_table = get_element_table ();
> + GstStructure *element;
> +
> + g_assert (gst_structure_get (element_table,
> + element_name, GST_TYPE_STRUCTURE, &element, NULL));
> +
asserts can be disabled.
gboolean have_field;
have_field = gst_structure_get (element_table,
element_name, GST_TYPE_STRUCTURE, &element, NULL);
g_assert (have_field);
> + return element;
> +}
> +
> +static const gchar *
> +get_element_name (gpointer object)
> +{
> + return g_type_name (G_OBJECT_TYPE (object));
> +}
=> G_OBJECT_TYPE_NAME(obj);
> +
> +/* register a new dynamic sub-class with the omx element as it's 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 type, const gchar *element_name)
> +{
> + GTypeQuery q;
> + GTypeInfo i = {0};
> +
> + g_type_query (type, &q);
> +
> + i.class_size = q.class_size;
> + i.instance_size = q.instance_size;
> +
> + return g_type_register_static (type, element_name, &i, 0);
> +}
> +
> static gboolean
> plugin_init (GstPlugin *plugin)
> {
> - GQuark library_name_quark;
> - GQuark component_name_quark;
> + gint i, cnt;
> + GstStructure *element_table;
> +
> GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
> GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
>
> - library_name_quark = g_quark_from_static_string ("library-name");
> - component_name_quark = g_quark_from_static_string ("component-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] ();
> + }
> +
> + element_table = get_element_table ();
>
> g_omx_init ();
>
> + cnt = gst_structure_n_fields (element_table);
> + for (i = 0; i < cnt; i++)
> {
> - guint i;
> - for (i = 0; element_table[i].name; i++)
> + const gchar *element_name = gst_structure_nth_field_name (element_table, i);
> + GstStructure *element = get_element_entry (element_name);
> + const gchar *type_name;
> + GType type;
> + gint rank;
> +
> + GST_DEBUG ("element=%"GST_PTR_FORMAT, element);
> +
> + type_name = gst_structure_get_string (element, "type");
> + if (!type_name)
> {
> - TableItem *element;
> - GType type;
> -
> - element = &element_table[i];
> - type = element->get_type ();
> - g_type_set_qdata (type, library_name_quark, (gpointer) element->library_name);
> - g_type_set_qdata (type, component_name_quark, (gpointer) element->component_name);
> -
> - if (!gst_element_register (plugin, element->name, element->rank, type))
> - {
> - g_warning ("failed registering '%s'", element->name);
> - return FALSE;
> - }
> + g_warning ("malformed config file: missing 'type' for %s", element_name);
> + return FALSE;
> + }
> +
> + 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;
> + }
> +
> + type = create_subtype (type, 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;
> }
>
> +/**
> + * g_omx_get_component_info:
> + * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
> + * GstOmxBaseSink).
> + * @library_name: library-name, returned by reference (or NULL)
> + * @component_name: component-name, returned by reference (or NULL)
> + *
> + * Get library-name and component-name for an element.
> + *
> + * note: this function will gain another parameter later when component-role
> + * is added
> + */
> +gboolean
> +g_omx_get_component_info (gpointer object,
> + gchar **library_name,
> + gchar **component_name)
> +{
> + gboolean ret = TRUE;
> + const gchar *element_name = get_element_name (object);
> + GstStructure *element = get_element_entry (element_name);
> +
> + g_assert (gst_structure_get (element_table,
> + element_name, GST_TYPE_STRUCTURE, &element, NULL));
> +
see above and more below (not commented specificaly).
> + /* initialize ptrs to NULL so that in error cases we can tell what needs
> + * to be freed:
> + */
> + if (library_name) *library_name = NULL;
> + if (component_name) *component_name = NULL;
> +
> + if (library_name)
> + {
> + const gchar *str = gst_structure_get_string (element, "library-name");
> + if (!str)
> + {
> + g_warning ("malformed config file: missing 'library-name' for %s", element_name);
> + ret = FALSE;
> + goto exit;
> + }
> + *library_name = g_strdup (str);
> + }
> +
> + if (component_name)
> + {
> + const gchar *str = gst_structure_get_string (element, "component-name");
> + if (!str)
> + {
> + g_warning ("malformed config file: missing 'component-name' for %s", element_name);
> + ret = FALSE;
> + goto exit;
> + }
> + *component_name = g_strdup (str);
> + }
> +
> +exit:
> +
> + /* if we failed, free any memory that might have been allocated:
> + */
> + if (!ret)
> + {
> + if (library_name) g_free (*library_name);
> + if (component_name) g_free (*component_name);
> + }
> +
> +
> + return ret;
> +}
> +
> +static gboolean
> +set_value_helper (GValue *value, gchar *str)
> +{
> + g_value_set_string (value, str);
> + return TRUE;
> +}
> +
> +/**
> + * g_omx_get_library_name_value:
> + * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
> + * GstOmxBaseSink).
> + * @val: the GValue to return the value through
> + *
> + * A helper to access the "library-name" as a GValue, mainly for
> + * get_property methods.
> + */
> +gboolean
> +g_omx_get_library_name_value (gpointer object, GValue *val)
> +{
> + gchar *str;
> + return g_omx_get_component_info (object, &str, NULL) &&
> + set_value_helper (val, str);
> +}
> +
> +/**
> + * g_omx_get_component_name_value:
> + * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
> + * GstOmxBaseSink).
> + * @val: the GValue to return the value through
> + *
> + * A helper to access the "component-name" as a GValue, mainly for
> + * get_property methods.
> + */
> +gboolean
> +g_omx_get_component_name_value (gpointer object, GValue *val)
> +{
> + gchar *str;
> + return g_omx_get_component_info (object, NULL, &str) &&
> + set_value_helper (val, str);
> +}
> +
> GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
> GST_VERSION_MINOR,
> "omx",
> diff --git a/omx/gstomx.h b/omx/gstomx.h
> index 7d5fa04..063437d 100644
> --- a/omx/gstomx.h
> +++ b/omx/gstomx.h
> @@ -30,6 +30,12 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
> GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
> #define GST_CAT_DEFAULT gstomx_debug
>
> +gboolean g_omx_get_component_info (gpointer object,
> + gchar **library_name,
> + gchar **component_name);
> +gboolean g_omx_get_library_name_value (gpointer object, GValue *val);
> +gboolean g_omx_get_component_name_value (gpointer object, GValue *val);
> +
> G_END_DECLS
>
> #endif /* GSTOMX_H */
> diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
> index b0353cb..2a30502 100644
> --- a/omx/gstomx_base_filter.c
> +++ b/omx/gstomx_base_filter.c
> @@ -115,7 +115,7 @@ change_state (GstElement *element,
> switch (transition)
> {
> case GST_STATE_CHANGE_NULL_TO_READY:
> - g_omx_core_init (core, self->omx_library, self->omx_component);
> + g_omx_core_init (core);
> if (core->omx_state != OMX_StateLoaded)
> {
> ret = GST_STATE_CHANGE_FAILURE;
> @@ -184,9 +184,6 @@ finalize (GObject *obj)
>
> g_omx_core_free (self->gomx);
>
> - g_free (self->omx_component);
> - g_free (self->omx_library);
> -
> g_mutex_free (self->ready_lock);
>
> G_OBJECT_CLASS (parent_class)->finalize (obj);
> @@ -204,14 +201,6 @@ set_property (GObject *obj,
>
> switch (prop_id)
> {
> - case ARG_COMPONENT_NAME:
> - g_free (self->omx_component);
> - self->omx_component = g_value_dup_string (value);
> - break;
> - case ARG_LIBRARY_NAME:
> - g_free (self->omx_library);
> - self->omx_library = g_value_dup_string (value);
> - break;
> case ARG_USE_TIMESTAMPS:
> self->use_timestamps = g_value_get_boolean (value);
> break;
> @@ -234,10 +223,10 @@ get_property (GObject *obj,
> switch (prop_id)
> {
> case ARG_COMPONENT_NAME:
> - g_value_set_string (value, self->omx_component);
> + g_omx_get_component_name_value (self, value);
> break;
> case ARG_LIBRARY_NAME:
> - g_value_set_string (value, self->omx_library);
> + g_omx_get_library_name_value (self, value);
> break;
> case ARG_USE_TIMESTAMPS:
> g_value_set_boolean (value, self->use_timestamps);
> @@ -271,12 +260,12 @@ type_class_init (gpointer g_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_READWRITE));
> + NULL, G_PARAM_READABLE));
>
> 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_READWRITE));
> + NULL, G_PARAM_READABLE));
>
> g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
> g_param_spec_boolean ("use-timestamps", "Use timestamps",
> @@ -922,16 +911,6 @@ type_instance_init (GTypeInstance *instance,
> gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
> gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
>
> - {
> - const char *tmp;
> - tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
> - g_quark_from_static_string ("library-name"));
> - self->omx_library = g_strdup (tmp);
> - tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
> - g_quark_from_static_string ("component-name"));
> - self->omx_component = g_strdup (tmp);
> - }
> -
> GST_LOG_OBJECT (self, "end");
> }
>
> diff --git a/omx/gstomx_base_filter.h b/omx/gstomx_base_filter.h
> index 4baf181..99b5d72 100644
> --- a/omx/gstomx_base_filter.h
> +++ b/omx/gstomx_base_filter.h
> @@ -48,8 +48,6 @@ struct GstOmxBaseFilter
> GOmxPort *in_port;
> GOmxPort *out_port;
>
> - char *omx_component;
> - char *omx_library;
> gboolean use_timestamps; /** @todo remove; timestamps should always be used */
> gboolean ready;
> GMutex *ready_lock;
> diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
> index c1a2076..7911167 100644
> --- a/omx/gstomx_base_sink.c
> +++ b/omx/gstomx_base_sink.c
> @@ -141,9 +141,6 @@ finalize (GObject *obj)
>
> g_omx_core_free (self->gomx);
>
> - g_free (self->omx_component);
> - g_free (self->omx_library);
> -
> G_OBJECT_CLASS (parent_class)->finalize (obj);
> }
>
> @@ -298,14 +295,6 @@ set_property (GObject *obj,
>
> switch (prop_id)
> {
> - case ARG_COMPONENT_NAME:
> - g_free (self->omx_component);
> - self->omx_component = g_value_dup_string (value);
> - break;
> - case ARG_LIBRARY_NAME:
> - g_free (self->omx_library);
> - self->omx_library = g_value_dup_string (value);
> - break;
> default:
> G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
> break;
> @@ -325,10 +314,10 @@ get_property (GObject *obj,
> switch (prop_id)
> {
> case ARG_COMPONENT_NAME:
> - g_value_set_string (value, self->omx_component);
> + g_omx_get_component_name_value (self, value);
> break;
> case ARG_LIBRARY_NAME:
> - g_value_set_string (value, self->omx_library);
> + g_omx_get_library_name_value (self, value);
> break;
> default:
> G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
> @@ -366,12 +355,12 @@ type_class_init (gpointer g_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_READWRITE));
> + NULL, G_PARAM_READABLE));
>
> 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_READWRITE));
> + NULL, G_PARAM_READABLE));
> }
> }
>
> @@ -420,7 +409,7 @@ activate_push (GstPad *pad,
> static inline gboolean
> omx_init (GstOmxBaseSink *self)
> {
> - g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
> + g_omx_core_init (self->gomx);
>
> if (self->gomx->omx_error)
> return FALSE;
> @@ -468,16 +457,6 @@ type_instance_init (GTypeInstance *instance,
> }
>
> {
> - const char *tmp;
> - tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
> - g_quark_from_static_string ("library-name"));
> - self->omx_library = g_strdup (tmp);
> - tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
> - g_quark_from_static_string ("component-name"));
> - self->omx_component = g_strdup (tmp);
> - }
> -
> - {
> GstPad *sinkpad;
> self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
> self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
> diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
> index 681e939..589c441 100644
> --- a/omx/gstomx_base_sink.h
> +++ b/omx/gstomx_base_sink.h
> @@ -46,9 +46,6 @@ struct GstOmxBaseSink
> GOmxCore *gomx;
> GOmxPort *in_port;
>
> - char *omx_component;
> - char *omx_library;
> -
> gboolean ready;
> GstPadActivateModeFunction base_activatepush;
> gboolean initialized;
> diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
> index 9b02b22..dd9767e 100644
> --- a/omx/gstomx_base_src.c
> +++ b/omx/gstomx_base_src.c
> @@ -67,7 +67,7 @@ start (GstBaseSrc *gst_base)
>
> GST_LOG_OBJECT (self, "begin");
>
> - g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
> + g_omx_core_init (self->gomx);
> if (self->gomx->omx_error)
> return GST_STATE_CHANGE_FAILURE;
>
> @@ -106,9 +106,6 @@ finalize (GObject *obj)
>
> g_omx_core_free (self->gomx);
>
> - g_free (self->omx_component);
> - g_free (self->omx_library);
> -
> G_OBJECT_CLASS (parent_class)->finalize (obj);
> }
>
> @@ -362,20 +359,6 @@ set_property (GObject *obj,
>
> switch (prop_id)
> {
> - case ARG_COMPONENT_NAME:
> - if (self->omx_component)
> - {
> - g_free (self->omx_component);
> - }
> - self->omx_component = g_value_dup_string (value);
> - break;
> - case ARG_LIBRARY_NAME:
> - if (self->omx_library)
> - {
> - g_free (self->omx_library);
> - }
> - self->omx_library = g_value_dup_string (value);
> - break;
> default:
> G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
> break;
> @@ -395,10 +378,10 @@ get_property (GObject *obj,
> switch (prop_id)
> {
> case ARG_COMPONENT_NAME:
> - g_value_set_string (value, self->omx_component);
> + g_omx_get_component_name_value (self, value);
> break;
> case ARG_LIBRARY_NAME:
> - g_value_set_string (value, self->omx_library);
> + g_omx_get_library_name_value (self, value);
> break;
> default:
> G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
> @@ -433,12 +416,12 @@ type_class_init (gpointer g_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_READWRITE));
> + NULL, G_PARAM_READABLE));
>
> 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_READWRITE));
> + NULL, G_PARAM_READABLE));
> }
> }
>
> @@ -459,17 +442,6 @@ type_instance_init (GTypeInstance *instance,
> gomx->object = self;
> }
>
> - {
> - const char *tmp;
> - tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
> - g_quark_from_static_string ("library-name"));
> - self->omx_library = g_strdup (tmp);
> - tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
> - g_quark_from_static_string ("component-name"));
> - self->omx_component = g_strdup (tmp);
> - }
> -
> -
> GST_LOG_OBJECT (self, "end");
> }
>
> diff --git a/omx/gstomx_base_src.h b/omx/gstomx_base_src.h
> index 85e4c13..adab894 100644
> --- a/omx/gstomx_base_src.h
> +++ b/omx/gstomx_base_src.h
> @@ -44,8 +44,6 @@ struct GstOmxBaseSrc
> GOmxCore *gomx;
> GOmxPort *out_port;
>
> - char *omx_component;
> - char *omx_library;
> GstOmxBaseSrcCb setup_ports;
> };
>
> diff --git a/omx/gstomx_conf.c b/omx/gstomx_conf.c
> new file mode 100644
> index 0000000..d25c173
> --- /dev/null
> +++ b/omx/gstomx_conf.c
> @@ -0,0 +1,217 @@
> +/*
> + * Copyright (C) 2010 Texas Instruments, Incorporated
> + * Copyright (C) 2007-2010 Nokia Corporation.
> + *
> + * 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 <glib.h>
> +
> +#include "config.h"
> +
> +const gchar * default_config =
> +"\n"
> +"omx_dummy,\n"
> +" type=GstOmxDummy,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.dummy,\n"
> +" rank=0;\n"
> +"\n"
> +/* for testing: */
> +"omx_dummy_2,\n"
> +" type=GstOmxDummy,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.dummy2,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_mpeg4dec,\n"
> +" type=GstOmxMpeg4Dec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.video_decoder.mpeg4,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_h264dec,\n"
> +" type=GstOmxH264Dec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.video_decoder.avc,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_h263dec,\n"
> +" type=GstOmxH263Dec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.video_decoder.h263,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_wmvdec,\n"
> +" type=GstOmxWmvDec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.video_decoder.wmv,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_mpeg4enc,\n"
> +" type=GstOmxMpeg4Enc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.video_encoder.mpeg4,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_h264enc,\n"
> +" type=GstOmxH264Enc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.video_encoder.avc,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_h263enc,\n"
> +" type=GstOmxH263Enc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.video_encoder.h263,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_vorbisdec,\n"
> +" type=GstOmxVorbisDec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.ogg.single,\n"
> +" rank=128;\n"
> +"\n"
> +"omx_mp3dec,\n"
> +" type=GstOmxMp3Dec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.mp3.mad,\n"
> +" rank=256;\n"
> +"\n"
> +#ifdef EXPERIMENTAL
> +"omx_mp2dec,\n"
> +" type=GstOmxMp2Dec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.mp3.mad,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_amrnbdec,\n"
> +" type=GstOmxAmrNbDec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.amrnb,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_amrnbenc,\n"
> +" type=GstOmxAmrNbEnc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_encoder.amrnb,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_amrwbdec,\n"
> +" type=GstOmxAmrWbDec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.amrwb,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_amrwbenc,\n"
> +" type=GstOmxAmrWbEnc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_encoder.amrwb,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_aacdec,\n"
> +" type=GstOmxAacDec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.aac,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_aacenc,\n"
> +" type=GstOmxAacEnc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_encoder.aac,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_adpcmdec,\n"
> +" type=GstOmxAdpcmDec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.adpcm,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_adpcmenc,\n"
> +" type=GstOmxAdpcmEnc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_encoder.adpcm,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_g711dec,\n"
> +" type=GstOmxG711Dec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.g711,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_g711enc,\n"
> +" type=GstOmxG711Enc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_encoder.g711,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_g729dec,\n"
> +" type=GstOmxG729Dec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.g729,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_g729enc,\n"
> +" type=GstOmxG729Enc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_encoder.g729,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_ilbcdec,\n"
> +" type=GstOmxIlbcDec,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_decoder.ilbc,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_ilbcenc,\n"
> +" type=GstOmxIlbcEnc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_encoder.ilbc,\n"
> +" rank=256;\n"
> +"\n"
> +"omx_jpegenc,\n"
> +" type=GstOmxJpegEnc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.image_encoder.jpeg,\n"
> +" rank=256;\n"
> +"\n"
> +#endif /* EXPERIMENTAL */
> +"omx_audiosink,\n"
> +" type=GstOmxAudioSink,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.alsa.alsasink,\n"
> +" rank=0;\n"
> +"\n"
> +#ifdef EXPERIMENTAL
> +"omx_videosink,\n"
> +" type=GstOmxVideoSink,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.videosink,\n"
> +" rank=0;\n"
> +"\n"
> +"omx_filereadersrc,\n"
> +" type=GstOmxFilereaderSrc,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.audio_filereader,\n"
> +" rank=0;\n"
> +"\n"
> +#endif /* EXPERIMENTAL */
> +"omx_volume,\n"
> +" type=GstOmxVolume,\n"
> +" library-name=libomxil-bellagio.so.0,\n"
> +" component-name=OMX.st.volume.component,\n"
> +" rank=0;\n"
> +;
> diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
> index 39d900b..c429738 100644
> --- a/omx/gstomx_util.c
> +++ b/omx/gstomx_util.c
> @@ -301,10 +301,13 @@ g_omx_core_free (GOmxCore *core)
> }
>
> void
> -g_omx_core_init (GOmxCore *core,
> - const gchar *library_name,
> - const gchar *component_name)
> +g_omx_core_init (GOmxCore *core)
> {
> + gchar *library_name, *component_name;
> +
> + g_assert (g_omx_get_component_info (core->object,
> + &library_name, &component_name));
> +
> core->imp = request_imp (library_name);
>
> if (!core->imp)
> diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
> index f0cf045..c3ac441 100644
> --- a/omx/gstomx_util.h
> +++ b/omx/gstomx_util.h
> @@ -116,7 +116,7 @@ void g_omx_deinit (void);
>
> GOmxCore *g_omx_core_new (void);
> void g_omx_core_free (GOmxCore *core);
> -void g_omx_core_init (GOmxCore *core, const gchar *library_name, const gchar *component_name);
> +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);
|
|
From: Rob C. <ro...@ti...> - 2010-02-26 18:31:29
|
Configurable mapping between gst-openmax elements and OMX library-name and component-name via config file. The config file may even create multiple different elements with unique names
using the same gst-openmax class but different OMX library-name and/or component-name. For example:
----
omx_mp3dec_ti,
type=GstOmxMp3Dec,
library-name=libOMX_Core.so.0,
component-name=OMX.TI.AUDIO.DECODE,
component-role=audio_decode.dsp.mp3,
rank=256;
omx_mp3dec_nokia,
type=GstOmxMp3Dec,
library-name=libomxil_bellagio.so.0,
component-name=OMX.nokia.audio_decode.mp3,
rank=128;
----
by default, the config file is stored in $HOME/.gstreamer-0.10/gst-openmax.conf, although if none is found a default config will be created.
---
omx/Makefile.am | 3 +-
omx/gstomx.c | 348 ++++++++++++++++++++++++++++++++++++++--------
omx/gstomx.h | 6 +
omx/gstomx_base_filter.c | 31 +----
omx/gstomx_base_filter.h | 2 -
omx/gstomx_base_sink.c | 31 +----
omx/gstomx_base_sink.h | 3 -
omx/gstomx_base_src.c | 38 +-----
omx/gstomx_base_src.h | 2 -
omx/gstomx_conf.c | 217 +++++++++++++++++++++++++++++
omx/gstomx_util.c | 9 +-
omx/gstomx_util.h | 2 +-
12 files changed, 534 insertions(+), 158 deletions(-)
create mode 100644 omx/gstomx_conf.c
diff --git a/omx/Makefile.am b/omx/Makefile.am
index 4a3fbf9..6ea9cf5 100644
--- a/omx/Makefile.am
+++ b/omx/Makefile.am
@@ -18,7 +18,8 @@ libgstomx_la_SOURCES = gstomx.c gstomx.h \
gstomx_vorbisdec.c gstomx_vorbisdec.h \
gstomx_mp3dec.c gstomx_mp3dec.h \
gstomx_base_sink.c gstomx_base_sink.h \
- gstomx_audiosink.c gstomx_audiosink.h
+ gstomx_audiosink.c gstomx_audiosink.h \
+ gstomx_conf.c
if EXPERIMENTAL
libgstomx_la_SOURCES += gstomx_amrnbdec.c gstomx_amrnbdec.h \
diff --git a/omx/gstomx.c b/omx/gstomx.c
index 6756f54..6a53eda 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -19,8 +19,12 @@
*
*/
+#include <string.h>
+
#include "config.h"
+#include <gst/gststructure.h>
+
#include "gstomx.h"
#include "gstomx_dummy.h"
#include "gstomx_mpeg4dec.h"
@@ -59,90 +63,312 @@
GST_DEBUG_CATEGORY (gstomx_debug);
-typedef struct TableItem
-{
- const gchar *name;
- const gchar *library_name;
- const gchar *component_name;
- guint rank;
- GType (*get_type) (void);
-} TableItem;
-
-static TableItem element_table[] =
-{
- { "omx_dummy", "libomxil-bellagio.so.0", "OMX.st.dummy", GST_RANK_NONE, gst_omx_dummy_get_type },
- { "omx_mpeg4dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4dec_get_type },
- { "omx_h264dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.avc", GST_RANK_PRIMARY, gst_omx_h264dec_get_type },
- { "omx_h263dec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.h263", GST_RANK_PRIMARY, gst_omx_h263dec_get_type },
- { "omx_wmvdec", "libomxil-bellagio.so.0", "OMX.st.video_decoder.wmv", GST_RANK_PRIMARY, gst_omx_wmvdec_get_type },
- { "omx_mpeg4enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.mpeg4", GST_RANK_PRIMARY, gst_omx_mpeg4enc_get_type },
- { "omx_h264enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.avc", GST_RANK_PRIMARY, gst_omx_h264enc_get_type },
- { "omx_h263enc", "libomxil-bellagio.so.0", "OMX.st.video_encoder.h263", GST_RANK_PRIMARY, gst_omx_h263enc_get_type },
- { "omx_vorbisdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ogg.single", GST_RANK_SECONDARY, gst_omx_vorbisdec_get_type },
- { "omx_mp3dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp3dec_get_type },
+static GstStructure *element_table = NULL;
+
+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
- { "omx_mp2dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.mp3.mad", GST_RANK_PRIMARY, gst_omx_mp2dec_get_type },
- { "omx_amrnbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbdec_get_type },
- { "omx_amrnbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrnb", GST_RANK_PRIMARY, gst_omx_amrnbenc_get_type },
- { "omx_amrwbdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbdec_get_type },
- { "omx_amrwbenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.amrwb", GST_RANK_PRIMARY, gst_omx_amrwbenc_get_type },
- { "omx_aacdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.aac", GST_RANK_PRIMARY, gst_omx_aacdec_get_type },
- { "omx_aacenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.aac", GST_RANK_PRIMARY, gst_omx_aacenc_get_type },
- { "omx_adpcmdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmdec_get_type },
- { "omx_adpcmenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.adpcm", GST_RANK_PRIMARY, gst_omx_adpcmenc_get_type },
- { "omx_g711dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g711", GST_RANK_PRIMARY, gst_omx_g711dec_get_type },
- { "omx_g711enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g711", GST_RANK_PRIMARY, gst_omx_g711enc_get_type },
- { "omx_g729dec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.g729", GST_RANK_PRIMARY, gst_omx_g729dec_get_type },
- { "omx_g729enc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.g729", GST_RANK_PRIMARY, gst_omx_g729enc_get_type },
- { "omx_ilbcdec", "libomxil-bellagio.so.0", "OMX.st.audio_decoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcdec_get_type },
- { "omx_ilbcenc", "libomxil-bellagio.so.0", "OMX.st.audio_encoder.ilbc", GST_RANK_PRIMARY, gst_omx_ilbcenc_get_type },
- { "omx_jpegenc", "libomxil-bellagio.so.0", "OMX.st.image_encoder.jpeg", GST_RANK_PRIMARY, gst_omx_jpegenc_get_type },
+ 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 */
- { "omx_audiosink", "libomxil-bellagio.so.0", "OMX.st.alsa.alsasink", GST_RANK_NONE, gst_omx_audiosink_get_type },
+ gst_omx_audiosink_get_type,
#ifdef EXPERIMENTAL
- { "omx_videosink", "libomxil-bellagio.so.0", "OMX.st.videosink", GST_RANK_NONE, gst_omx_videosink_get_type },
- { "omx_filereadersrc", "libomxil-bellagio.so.0", "OMX.st.audio_filereader", GST_RANK_NONE, gst_omx_filereadersrc_get_type },
+ gst_omx_videosink_get_type,
+ gst_omx_filereadersrc_get_type,
#endif /* EXPERIMENTAL */
- { "omx_volume", "libomxil-bellagio.so.0", "OMX.st.volume.component", GST_RANK_NONE, gst_omx_volume_get_type },
- { NULL, NULL, NULL, 0, NULL },
+ gst_omx_volume_get_type,
};
+/* TODO: we can cache table w/ gst_plugin_{get,set}_cache_data..
+ */
+static GstStructure *
+get_element_table (void)
+{
+ static volatile gsize gonce_data = 0;
+ if (g_once_init_enter (&gonce_data))
+ {
+ gchar *path;
+ gchar *config, *s;
+ GstStructure *element;
+
+ path = g_strdup (g_getenv ("OMX_REGISTRY"));
+ if (!path)
+ {
+ path = g_build_filename (g_get_user_config_dir (),
+ "gst-openmax.conf", NULL);
+ }
+
+ if (!g_file_get_contents (path, &config, NULL, NULL))
+ {
+ g_warning ("could not find config file '%s'.. using defaults!", path);
+ config = (gchar *) default_config;
+
+ g_file_set_contents (path, config, -1, NULL);
+ }
+
+ GST_DEBUG ("parsing config:\n%s", config);
+
+ element_table = 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 (element_table,
+ element_name, GST_TYPE_STRUCTURE, element, NULL);
+ }
+
+ if (config != default_config)
+ {
+ g_free (config);
+ }
+
+ g_free (path);
+
+ GST_DEBUG ("element_table=%"GST_PTR_FORMAT, element_table);
+
+ g_once_init_leave (&gonce_data, 1);
+ }
+
+ return element_table;
+}
+
+static GstStructure *
+get_element_entry (const gchar *element_name)
+{
+ GstStructure *element_table = get_element_table ();
+ GstStructure *element;
+
+ g_assert (gst_structure_get (element_table,
+ element_name, GST_TYPE_STRUCTURE, &element, NULL));
+
+ return element;
+}
+
+static const gchar *
+get_element_name (gpointer object)
+{
+ return g_type_name (G_OBJECT_TYPE (object));
+}
+
+/* register a new dynamic sub-class with the omx element as it's 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 type, const gchar *element_name)
+{
+ GTypeQuery q;
+ GTypeInfo i = {0};
+
+ g_type_query (type, &q);
+
+ i.class_size = q.class_size;
+ i.instance_size = q.instance_size;
+
+ return g_type_register_static (type, element_name, &i, 0);
+}
+
static gboolean
plugin_init (GstPlugin *plugin)
{
- GQuark library_name_quark;
- GQuark component_name_quark;
+ gint i, cnt;
+ GstStructure *element_table;
+
GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
- library_name_quark = g_quark_from_static_string ("library-name");
- component_name_quark = g_quark_from_static_string ("component-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] ();
+ }
+
+ element_table = get_element_table ();
g_omx_init ();
+ cnt = gst_structure_n_fields (element_table);
+ for (i = 0; i < cnt; i++)
{
- guint i;
- for (i = 0; element_table[i].name; i++)
+ const gchar *element_name = gst_structure_nth_field_name (element_table, i);
+ GstStructure *element = get_element_entry (element_name);
+ const gchar *type_name;
+ GType type;
+ gint rank;
+
+ GST_DEBUG ("element=%"GST_PTR_FORMAT, element);
+
+ type_name = gst_structure_get_string (element, "type");
+ if (!type_name)
{
- TableItem *element;
- GType type;
-
- element = &element_table[i];
- type = element->get_type ();
- g_type_set_qdata (type, library_name_quark, (gpointer) element->library_name);
- g_type_set_qdata (type, component_name_quark, (gpointer) element->component_name);
-
- if (!gst_element_register (plugin, element->name, element->rank, type))
- {
- g_warning ("failed registering '%s'", element->name);
- return FALSE;
- }
+ g_warning ("malformed config file: missing 'type' for %s", element_name);
+ return FALSE;
+ }
+
+ 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;
+ }
+
+ type = create_subtype (type, 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;
}
+/**
+ * g_omx_get_component_info:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @library_name: library-name, returned by reference (or NULL)
+ * @component_name: component-name, returned by reference (or NULL)
+ *
+ * Get library-name and component-name for an element.
+ *
+ * note: this function will gain another parameter later when component-role
+ * is added
+ */
+gboolean
+g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name)
+{
+ gboolean ret = TRUE;
+ const gchar *element_name = get_element_name (object);
+ GstStructure *element = get_element_entry (element_name);
+
+ g_assert (gst_structure_get (element_table,
+ element_name, GST_TYPE_STRUCTURE, &element, NULL));
+
+ /* initialize ptrs to NULL so that in error cases we can tell what needs
+ * to be freed:
+ */
+ if (library_name) *library_name = NULL;
+ if (component_name) *component_name = NULL;
+
+ if (library_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "library-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'library-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *library_name = g_strdup (str);
+ }
+
+ if (component_name)
+ {
+ const gchar *str = gst_structure_get_string (element, "component-name");
+ if (!str)
+ {
+ g_warning ("malformed config file: missing 'component-name' for %s", element_name);
+ ret = FALSE;
+ goto exit;
+ }
+ *component_name = g_strdup (str);
+ }
+
+exit:
+
+ /* if we failed, free any memory that might have been allocated:
+ */
+ if (!ret)
+ {
+ if (library_name) g_free (*library_name);
+ if (component_name) g_free (*component_name);
+ }
+
+
+ return ret;
+}
+
+static gboolean
+set_value_helper (GValue *value, gchar *str)
+{
+ g_value_set_string (value, str);
+ return TRUE;
+}
+
+/**
+ * g_omx_get_library_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "library-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_library_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, &str, NULL) &&
+ set_value_helper (val, str);
+}
+
+/**
+ * g_omx_get_component_name_value:
+ * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
+ * GstOmxBaseSink).
+ * @val: the GValue to return the value through
+ *
+ * A helper to access the "component-name" as a GValue, mainly for
+ * get_property methods.
+ */
+gboolean
+g_omx_get_component_name_value (gpointer object, GValue *val)
+{
+ gchar *str;
+ return g_omx_get_component_info (object, NULL, &str) &&
+ set_value_helper (val, str);
+}
+
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"omx",
diff --git a/omx/gstomx.h b/omx/gstomx.h
index 7d5fa04..063437d 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -30,6 +30,12 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
#define GST_CAT_DEFAULT gstomx_debug
+gboolean g_omx_get_component_info (gpointer object,
+ gchar **library_name,
+ gchar **component_name);
+gboolean g_omx_get_library_name_value (gpointer object, GValue *val);
+gboolean g_omx_get_component_name_value (gpointer object, GValue *val);
+
G_END_DECLS
#endif /* GSTOMX_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index b0353cb..2a30502 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -115,7 +115,7 @@ change_state (GstElement *element,
switch (transition)
{
case GST_STATE_CHANGE_NULL_TO_READY:
- g_omx_core_init (core, self->omx_library, self->omx_component);
+ g_omx_core_init (core);
if (core->omx_state != OMX_StateLoaded)
{
ret = GST_STATE_CHANGE_FAILURE;
@@ -184,9 +184,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
g_mutex_free (self->ready_lock);
G_OBJECT_CLASS (parent_class)->finalize (obj);
@@ -204,14 +201,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
case ARG_USE_TIMESTAMPS:
self->use_timestamps = g_value_get_boolean (value);
break;
@@ -234,10 +223,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
case ARG_USE_TIMESTAMPS:
g_value_set_boolean (value, self->use_timestamps);
@@ -271,12 +260,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
g_param_spec_boolean ("use-timestamps", "Use timestamps",
@@ -922,16 +911,6 @@ type_instance_init (GTypeInstance *instance,
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_filter.h b/omx/gstomx_base_filter.h
index 4baf181..99b5d72 100644
--- a/omx/gstomx_base_filter.h
+++ b/omx/gstomx_base_filter.h
@@ -48,8 +48,6 @@ struct GstOmxBaseFilter
GOmxPort *in_port;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
gboolean use_timestamps; /** @todo remove; timestamps should always be used */
gboolean ready;
GMutex *ready_lock;
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index c1a2076..7911167 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -141,9 +141,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -298,14 +295,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- g_free (self->omx_component);
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- g_free (self->omx_library);
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -325,10 +314,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -366,12 +355,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -420,7 +409,7 @@ activate_push (GstPad *pad,
static inline gboolean
omx_init (GstOmxBaseSink *self)
{
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return FALSE;
@@ -468,16 +457,6 @@ type_instance_init (GTypeInstance *instance,
}
{
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
- {
GstPad *sinkpad;
self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
index 681e939..589c441 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -46,9 +46,6 @@ struct GstOmxBaseSink
GOmxCore *gomx;
GOmxPort *in_port;
- char *omx_component;
- char *omx_library;
-
gboolean ready;
GstPadActivateModeFunction base_activatepush;
gboolean initialized;
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 9b02b22..dd9767e 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -67,7 +67,7 @@ start (GstBaseSrc *gst_base)
GST_LOG_OBJECT (self, "begin");
- g_omx_core_init (self->gomx, self->omx_library, self->omx_component);
+ g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -106,9 +106,6 @@ finalize (GObject *obj)
g_omx_core_free (self->gomx);
- g_free (self->omx_component);
- g_free (self->omx_library);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -362,20 +359,6 @@ set_property (GObject *obj,
switch (prop_id)
{
- case ARG_COMPONENT_NAME:
- if (self->omx_component)
- {
- g_free (self->omx_component);
- }
- self->omx_component = g_value_dup_string (value);
- break;
- case ARG_LIBRARY_NAME:
- if (self->omx_library)
- {
- g_free (self->omx_library);
- }
- self->omx_library = g_value_dup_string (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -395,10 +378,10 @@ get_property (GObject *obj,
switch (prop_id)
{
case ARG_COMPONENT_NAME:
- g_value_set_string (value, self->omx_component);
+ g_omx_get_component_name_value (self, value);
break;
case ARG_LIBRARY_NAME:
- g_value_set_string (value, self->omx_library);
+ g_omx_get_library_name_value (self, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -433,12 +416,12 @@ type_class_init (gpointer g_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_READWRITE));
+ NULL, G_PARAM_READABLE));
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_READWRITE));
+ NULL, G_PARAM_READABLE));
}
}
@@ -459,17 +442,6 @@ type_instance_init (GTypeInstance *instance,
gomx->object = self;
}
- {
- const char *tmp;
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("library-name"));
- self->omx_library = g_strdup (tmp);
- tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
- g_quark_from_static_string ("component-name"));
- self->omx_component = g_strdup (tmp);
- }
-
-
GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_src.h b/omx/gstomx_base_src.h
index 85e4c13..adab894 100644
--- a/omx/gstomx_base_src.h
+++ b/omx/gstomx_base_src.h
@@ -44,8 +44,6 @@ struct GstOmxBaseSrc
GOmxCore *gomx;
GOmxPort *out_port;
- char *omx_component;
- char *omx_library;
GstOmxBaseSrcCb setup_ports;
};
diff --git a/omx/gstomx_conf.c b/omx/gstomx_conf.c
new file mode 100644
index 0000000..d25c173
--- /dev/null
+++ b/omx/gstomx_conf.c
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2010 Texas Instruments, Incorporated
+ * Copyright (C) 2007-2010 Nokia Corporation.
+ *
+ * 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 <glib.h>
+
+#include "config.h"
+
+const gchar * default_config =
+"\n"
+"omx_dummy,\n"
+" type=GstOmxDummy,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.dummy,\n"
+" rank=0;\n"
+"\n"
+/* for testing: */
+"omx_dummy_2,\n"
+" type=GstOmxDummy,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.dummy2,\n"
+" rank=256;\n"
+"\n"
+"omx_mpeg4dec,\n"
+" type=GstOmxMpeg4Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_decoder.mpeg4,\n"
+" rank=256;\n"
+"\n"
+"omx_h264dec,\n"
+" type=GstOmxH264Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_decoder.avc,\n"
+" rank=256;\n"
+"\n"
+"omx_h263dec,\n"
+" type=GstOmxH263Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_decoder.h263,\n"
+" rank=256;\n"
+"\n"
+"omx_wmvdec,\n"
+" type=GstOmxWmvDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_decoder.wmv,\n"
+" rank=256;\n"
+"\n"
+"omx_mpeg4enc,\n"
+" type=GstOmxMpeg4Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_encoder.mpeg4,\n"
+" rank=256;\n"
+"\n"
+"omx_h264enc,\n"
+" type=GstOmxH264Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_encoder.avc,\n"
+" rank=256;\n"
+"\n"
+"omx_h263enc,\n"
+" type=GstOmxH263Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.video_encoder.h263,\n"
+" rank=256;\n"
+"\n"
+"omx_vorbisdec,\n"
+" type=GstOmxVorbisDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.ogg.single,\n"
+" rank=128;\n"
+"\n"
+"omx_mp3dec,\n"
+" type=GstOmxMp3Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.mp3.mad,\n"
+" rank=256;\n"
+"\n"
+#ifdef EXPERIMENTAL
+"omx_mp2dec,\n"
+" type=GstOmxMp2Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.mp3.mad,\n"
+" rank=256;\n"
+"\n"
+"omx_amrnbdec,\n"
+" type=GstOmxAmrNbDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.amrnb,\n"
+" rank=256;\n"
+"\n"
+"omx_amrnbenc,\n"
+" type=GstOmxAmrNbEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.amrnb,\n"
+" rank=256;\n"
+"\n"
+"omx_amrwbdec,\n"
+" type=GstOmxAmrWbDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.amrwb,\n"
+" rank=256;\n"
+"\n"
+"omx_amrwbenc,\n"
+" type=GstOmxAmrWbEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.amrwb,\n"
+" rank=256;\n"
+"\n"
+"omx_aacdec,\n"
+" type=GstOmxAacDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.aac,\n"
+" rank=256;\n"
+"\n"
+"omx_aacenc,\n"
+" type=GstOmxAacEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.aac,\n"
+" rank=256;\n"
+"\n"
+"omx_adpcmdec,\n"
+" type=GstOmxAdpcmDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.adpcm,\n"
+" rank=256;\n"
+"\n"
+"omx_adpcmenc,\n"
+" type=GstOmxAdpcmEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.adpcm,\n"
+" rank=256;\n"
+"\n"
+"omx_g711dec,\n"
+" type=GstOmxG711Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.g711,\n"
+" rank=256;\n"
+"\n"
+"omx_g711enc,\n"
+" type=GstOmxG711Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.g711,\n"
+" rank=256;\n"
+"\n"
+"omx_g729dec,\n"
+" type=GstOmxG729Dec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.g729,\n"
+" rank=256;\n"
+"\n"
+"omx_g729enc,\n"
+" type=GstOmxG729Enc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.g729,\n"
+" rank=256;\n"
+"\n"
+"omx_ilbcdec,\n"
+" type=GstOmxIlbcDec,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_decoder.ilbc,\n"
+" rank=256;\n"
+"\n"
+"omx_ilbcenc,\n"
+" type=GstOmxIlbcEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_encoder.ilbc,\n"
+" rank=256;\n"
+"\n"
+"omx_jpegenc,\n"
+" type=GstOmxJpegEnc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.image_encoder.jpeg,\n"
+" rank=256;\n"
+"\n"
+#endif /* EXPERIMENTAL */
+"omx_audiosink,\n"
+" type=GstOmxAudioSink,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.alsa.alsasink,\n"
+" rank=0;\n"
+"\n"
+#ifdef EXPERIMENTAL
+"omx_videosink,\n"
+" type=GstOmxVideoSink,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.videosink,\n"
+" rank=0;\n"
+"\n"
+"omx_filereadersrc,\n"
+" type=GstOmxFilereaderSrc,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.audio_filereader,\n"
+" rank=0;\n"
+"\n"
+#endif /* EXPERIMENTAL */
+"omx_volume,\n"
+" type=GstOmxVolume,\n"
+" library-name=libomxil-bellagio.so.0,\n"
+" component-name=OMX.st.volume.component,\n"
+" rank=0;\n"
+;
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 39d900b..c429738 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -301,10 +301,13 @@ g_omx_core_free (GOmxCore *core)
}
void
-g_omx_core_init (GOmxCore *core,
- const gchar *library_name,
- const gchar *component_name)
+g_omx_core_init (GOmxCore *core)
{
+ gchar *library_name, *component_name;
+
+ g_assert (g_omx_get_component_info (core->object,
+ &library_name, &component_name));
+
core->imp = request_imp (library_name);
if (!core->imp)
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index f0cf045..c3ac441 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -116,7 +116,7 @@ void g_omx_deinit (void);
GOmxCore *g_omx_core_new (void);
void g_omx_core_free (GOmxCore *core);
-void g_omx_core_init (GOmxCore *core, const gchar *library_name, const gchar *component_name);
+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);
--
1.6.3.2
|