summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@nokia.com>2010-10-01 03:57:05 +0300
committerFelipe Contreras <felipe.contreras@nokia.com>2010-10-01 03:57:05 +0300
commit9d16cfba93de509ed057d2acf906288aefff2a5f (patch)
tree06160ac6cef71a493f61bbf9fa3a9037fa6fe3ff
parent673fb214c759e27e2d63c11d0478d2f1f244b808 (diff)
Change to gst coding-style
Ew. Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
-rw-r--r--omx/gstomx.c465
-rw-r--r--omx/gstomx.h22
-rw-r--r--omx/gstomx_aacdec.c158
-rw-r--r--omx/gstomx_aacdec.h7
-rw-r--r--omx/gstomx_aacenc.c522
-rw-r--r--omx/gstomx_aacenc.h13
-rw-r--r--omx/gstomx_adpcmdec.c156
-rw-r--r--omx/gstomx_adpcmdec.h7
-rw-r--r--omx/gstomx_adpcmenc.c235
-rw-r--r--omx/gstomx_adpcmenc.h7
-rw-r--r--omx/gstomx_amrnbdec.c80
-rw-r--r--omx/gstomx_amrnbdec.h7
-rw-r--r--omx/gstomx_amrnbenc.c269
-rw-r--r--omx/gstomx_amrnbenc.h9
-rw-r--r--omx/gstomx_amrwbdec.c80
-rw-r--r--omx/gstomx_amrwbdec.h7
-rw-r--r--omx/gstomx_amrwbenc.c269
-rw-r--r--omx/gstomx_amrwbenc.h9
-rw-r--r--omx/gstomx_audiosink.c157
-rw-r--r--omx/gstomx_audiosink.h7
-rw-r--r--omx/gstomx_base_audiodec.c84
-rw-r--r--omx/gstomx_base_audiodec.h7
-rw-r--r--omx/gstomx_base_filter.c1386
-rw-r--r--omx/gstomx_base_filter.h35
-rw-r--r--omx/gstomx_base_sink.c619
-rw-r--r--omx/gstomx_base_sink.h21
-rw-r--r--omx/gstomx_base_src.c586
-rw-r--r--omx/gstomx_base_src.h15
-rw-r--r--omx/gstomx_base_videodec.c319
-rw-r--r--omx/gstomx_base_videodec.h13
-rw-r--r--omx/gstomx_base_videoenc.c346
-rw-r--r--omx/gstomx_base_videoenc.h15
-rw-r--r--omx/gstomx_dummy.c64
-rw-r--r--omx/gstomx_dummy.h7
-rw-r--r--omx/gstomx_filereadersrc.c200
-rw-r--r--omx/gstomx_filereadersrc.h9
-rw-r--r--omx/gstomx_g711dec.c180
-rw-r--r--omx/gstomx_g711dec.h7
-rw-r--r--omx/gstomx_g711enc.c195
-rw-r--r--omx/gstomx_g711enc.h7
-rw-r--r--omx/gstomx_g729dec.c124
-rw-r--r--omx/gstomx_g729dec.h7
-rw-r--r--omx/gstomx_g729enc.c262
-rw-r--r--omx/gstomx_g729enc.h9
-rw-r--r--omx/gstomx_h263dec.c62
-rw-r--r--omx/gstomx_h263dec.h7
-rw-r--r--omx/gstomx_h263enc.c117
-rw-r--r--omx/gstomx_h263enc.h7
-rw-r--r--omx/gstomx_h264dec.c60
-rw-r--r--omx/gstomx_h264dec.h7
-rw-r--r--omx/gstomx_h264enc.c113
-rw-r--r--omx/gstomx_h264enc.h7
-rw-r--r--omx/gstomx_ilbcdec.c155
-rw-r--r--omx/gstomx_ilbcdec.h7
-rw-r--r--omx/gstomx_ilbcenc.c155
-rw-r--r--omx/gstomx_ilbcenc.h7
-rw-r--r--omx/gstomx_interface.c19
-rw-r--r--omx/gstomx_interface.h5
-rw-r--r--omx/gstomx_jpegenc.c421
-rw-r--r--omx/gstomx_jpegenc.h13
-rw-r--r--omx/gstomx_mp2dec.c88
-rw-r--r--omx/gstomx_mp2dec.h7
-rw-r--r--omx/gstomx_mp3dec.c88
-rw-r--r--omx/gstomx_mp3dec.h7
-rw-r--r--omx/gstomx_mpeg4dec.c99
-rw-r--r--omx/gstomx_mpeg4dec.h7
-rw-r--r--omx/gstomx_mpeg4enc.c121
-rw-r--r--omx/gstomx_mpeg4enc.h7
-rw-r--r--omx/gstomx_util.c1297
-rw-r--r--omx/gstomx_util.h138
-rw-r--r--omx/gstomx_videosink.c411
-rw-r--r--omx/gstomx_videosink.h13
-rw-r--r--omx/gstomx_volume.c169
-rw-r--r--omx/gstomx_volume.h7
-rw-r--r--omx/gstomx_vorbisdec.c85
-rw-r--r--omx/gstomx_vorbisdec.h7
-rw-r--r--omx/gstomx_wmvdec.c60
-rw-r--r--omx/gstomx_wmvdec.h7
-rw-r--r--tests/check_async_queue.c488
-rw-r--r--tests/check_gstomx.c243
-rw-r--r--tests/check_libomxil.c242
-rw-r--r--tests/standalone/core.c482
-rw-r--r--util/async_queue.c155
-rw-r--r--util/async_queue.h26
-rw-r--r--util/sem.c45
-rw-r--r--util/sem.h12
86 files changed, 5862 insertions, 6614 deletions
diff --git a/omx/gstomx.c b/omx/gstomx.c
index 6c6a659..8b375c0 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -69,133 +69,124 @@ 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,
+ gst_omx_dummy_get_type,
+ gst_omx_mpeg4dec_get_type,
+ gst_omx_h264dec_get_type,
+ gst_omx_h263dec_get_type,
+ gst_omx_wmvdec_get_type,
+ gst_omx_mpeg4enc_get_type,
+ gst_omx_h264enc_get_type,
+ gst_omx_h263enc_get_type,
+ gst_omx_vorbisdec_get_type, gst_omx_mp3dec_get_type,
#ifdef EXPERIMENTAL
- gst_omx_mp2dec_get_type,
- gst_omx_amrnbdec_get_type,
- gst_omx_amrnbenc_get_type,
- gst_omx_amrwbdec_get_type,
- gst_omx_amrwbenc_get_type,
- gst_omx_aacdec_get_type,
- gst_omx_aacenc_get_type,
- gst_omx_adpcmdec_get_type,
- gst_omx_adpcmenc_get_type,
- gst_omx_g711dec_get_type,
- gst_omx_g711enc_get_type,
- gst_omx_g729dec_get_type,
- gst_omx_g729enc_get_type,
- gst_omx_ilbcdec_get_type,
- gst_omx_ilbcenc_get_type,
- gst_omx_jpegenc_get_type,
+ gst_omx_mp2dec_get_type,
+ gst_omx_amrnbdec_get_type,
+ gst_omx_amrnbenc_get_type,
+ gst_omx_amrwbdec_get_type,
+ gst_omx_amrwbenc_get_type,
+ gst_omx_aacdec_get_type,
+ gst_omx_aacenc_get_type,
+ gst_omx_adpcmdec_get_type,
+ gst_omx_adpcmenc_get_type,
+ gst_omx_g711dec_get_type,
+ gst_omx_g711enc_get_type,
+ gst_omx_g729dec_get_type,
+ gst_omx_g729enc_get_type,
+ gst_omx_ilbcdec_get_type,
+ gst_omx_ilbcenc_get_type, gst_omx_jpegenc_get_type,
#endif /* EXPERIMENTAL */
- gst_omx_audiosink_get_type,
+ gst_omx_audiosink_get_type,
#ifdef EXPERIMENTAL
- gst_omx_videosink_get_type,
- gst_omx_filereadersrc_get_type,
+ gst_omx_videosink_get_type, gst_omx_filereadersrc_get_type,
#endif /* EXPERIMENTAL */
- gst_omx_volume_get_type,
-};
+gst_omx_volume_get_type,};
static gchar *
get_config_path (void)
{
- gchar *path;
- const gchar *const *dirs;
- int i;
-
- path = g_strdup (g_getenv ("OMX_CONFIG"));
-
- if (path)
- return path;
-
- dirs = g_get_system_config_dirs ();
- for (i = 0; dirs[i]; i++)
- {
- path = g_build_filename (dirs[i], "gstreamer-0.10", "gst-openmax.conf", NULL);
- if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
- return path;
- g_free (path);
- }
+ gchar *path;
+ const gchar *const *dirs;
+ int i;
+
+ path = g_strdup (g_getenv ("OMX_CONFIG"));
+
+ if (path)
+ return path;
- return g_build_filename (g_get_user_config_dir (),
- "gst-openmax.conf", NULL);
+ dirs = g_get_system_config_dirs ();
+ for (i = 0; dirs[i]; i++) {
+ path =
+ g_build_filename (dirs[i], "gstreamer-0.10", "gst-openmax.conf", NULL);
+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
+ return path;
+ g_free (path);
+ }
+
+ return g_build_filename (g_get_user_config_dir (), "gst-openmax.conf", NULL);
}
static void
-fetch_element_table (GstPlugin *plugin)
+fetch_element_table (GstPlugin * plugin)
{
- gchar *path;
- gchar *config, *s;
- GstStructure *tmp, *element;
+ gchar *path;
+ gchar *config, *s;
+ GstStructure *tmp, *element;
- element_table = gst_plugin_get_cache_data (plugin);
+ element_table = gst_plugin_get_cache_data (plugin);
- if (element_table)
- return;
+ if (element_table)
+ return;
- path = get_config_path ();
+ path = get_config_path ();
- if (!g_file_get_contents (path, &config, NULL, NULL))
- {
- g_warning ("could not find config file '%s'.. using defaults!", path);
- config = (gchar *) default_config;
- }
+ if (!g_file_get_contents (path, &config, NULL, NULL)) {
+ g_warning ("could not find config file '%s'.. using defaults!", path);
+ config = (gchar *) default_config;
+ }
- gst_plugin_add_dependency_simple (plugin, "ONX_CONFIG", path, NULL,
- GST_PLUGIN_DEPENDENCY_FLAG_NONE);
+ gst_plugin_add_dependency_simple (plugin, "ONX_CONFIG", path, NULL,
+ GST_PLUGIN_DEPENDENCY_FLAG_NONE);
- g_free (path);
+ g_free (path);
- GST_DEBUG ("parsing config:\n%s", config);
+ GST_DEBUG ("parsing config:\n%s", config);
- tmp = gst_structure_empty_new ("element_table");
+ tmp = gst_structure_empty_new ("element_table");
- s = config;
+ s = config;
- while ((element = gst_structure_from_string (s, &s)))
- {
- const gchar *element_name = gst_structure_get_name (element);
- gst_structure_set (tmp,
- element_name, GST_TYPE_STRUCTURE, element, NULL);
- }
+ while ((element = gst_structure_from_string (s, &s))) {
+ const gchar *element_name = gst_structure_get_name (element);
+ gst_structure_set (tmp, element_name, GST_TYPE_STRUCTURE, element, NULL);
+ }
- if (config != default_config)
- g_free (config);
+ if (config != default_config)
+ g_free (config);
- GST_DEBUG ("element_table=%" GST_PTR_FORMAT, tmp);
+ GST_DEBUG ("element_table=%" GST_PTR_FORMAT, tmp);
- gst_plugin_set_cache_data (plugin, tmp);
+ gst_plugin_set_cache_data (plugin, tmp);
- element_table = tmp;
+ element_table = tmp;
}
static GstStructure *
-get_element_entry (const gchar *element_name)
+get_element_entry (const gchar * element_name)
{
- GstStructure *element;
+ GstStructure *element;
- if (!gst_structure_get ((GstStructure *) element_table, element_name,
- GST_TYPE_STRUCTURE, &element, NULL))
- {
- element = NULL;
- }
+ if (!gst_structure_get ((GstStructure *) element_table, element_name,
+ GST_TYPE_STRUCTURE, &element, NULL)) {
+ element = NULL;
+ }
- /* This assert should never fail, because plugin elements are registered
- * based on the entries in this table. Someone would have to manually
- * override the type qdata for this to fail.
- */
- g_assert (element);
+ /* 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;
+ return element;
}
/* register a new dynamic sub-class with the name 'type_name'.. this gives us
@@ -204,194 +195,180 @@ get_element_entry (const gchar *element_name)
* and/or component names
*/
static GType
-create_subtype (GType parent_type, const gchar *type_name)
+create_subtype (GType parent_type, const gchar * type_name)
{
- GTypeQuery q;
- GTypeInfo i = {0,0,0,0,0,0,0,0,0,0};
+ GTypeQuery q;
+ GTypeInfo i = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- if (!type_name)
- return 0;
+ if (!type_name)
+ return 0;
- g_type_query (parent_type, &q);
+ g_type_query (parent_type, &q);
- i.class_size = q.class_size;
- i.instance_size = q.instance_size;
+ i.class_size = q.class_size;
+ i.instance_size = q.instance_size;
- return g_type_register_static (parent_type, type_name, &i, 0);
+ return g_type_register_static (parent_type, type_name, &i, 0);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- guint i, cnt;
-
- GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
- GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
-
- element_name_quark = g_quark_from_static_string ("element-name");
-
- /*
- * First, call all the _get_type() functions to ensure the types are
- * registered.
- */
- for (i = 0; i < G_N_ELEMENTS (get_type); i++)
- get_type[i] ();
-
- fetch_element_table (plugin);
-
- g_omx_init ();
-
- cnt = gst_structure_n_fields (element_table);
- for (i = 0; i < cnt; i++)
- {
- const gchar *element_name = gst_structure_nth_field_name (element_table, i);
- GstStructure *element = get_element_entry (element_name);
- const gchar *type_name, *parent_type_name;
- const gchar *component_name, *component_role, *library_name;
- GType type;
- gint rank;
-
- GST_DEBUG ("element_name=%s, element=%" GST_PTR_FORMAT, element_name, element);
-
- parent_type_name = gst_structure_get_string (element, "parent-type");
- type_name = gst_structure_get_string (element, "type");
- component_name = gst_structure_get_string (element, "component-name");
- component_role = gst_structure_get_string (element, "component-role");
- library_name = gst_structure_get_string (element, "library-name");
-
- if (!type_name || !component_name || !library_name)
- {
- g_warning ("malformed config file: missing required fields for %s",
- element_name);
- return FALSE;
- }
-
- if (parent_type_name)
- {
- type = g_type_from_name (parent_type_name);
- if (type)
- {
- type = create_subtype (type, type_name);
- }
- else
- {
- g_warning ("malformed config file: invalid parent-type '%s' for %s",
- parent_type_name, element_name);
- return FALSE;
- }
- }
- else
- {
- type = g_type_from_name (type_name);
- }
-
- if (!type)
- {
- g_warning ("malformed config file: invalid type '%s' for %s",
- type_name, element_name);
- return FALSE;
- }
-
- g_type_set_qdata (type, element_name_quark, (gpointer) element_name);
-
- if (!gst_structure_get_int (element, "rank", &rank))
- {
- /* use default rank: */
- rank = GST_RANK_NONE;
- }
-
- if (!gst_element_register (plugin, element_name, rank, type))
- {
- g_warning ("failed registering '%s'", element_name);
- return FALSE;
- }
+ guint i, cnt;
+
+ GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
+ GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0,
+ "gst-openmax utility");
+
+ element_name_quark = g_quark_from_static_string ("element-name");
+
+ /*
+ * First, call all the _get_type() functions to ensure the types are
+ * registered.
+ */
+ for (i = 0; i < G_N_ELEMENTS (get_type); i++)
+ get_type[i] ();
+
+ fetch_element_table (plugin);
+
+ g_omx_init ();
+
+ cnt = gst_structure_n_fields (element_table);
+ for (i = 0; i < cnt; i++) {
+ const gchar *element_name = gst_structure_nth_field_name (element_table, i);
+ GstStructure *element = get_element_entry (element_name);
+ const gchar *type_name, *parent_type_name;
+ const gchar *component_name, *component_role, *library_name;
+ GType type;
+ gint rank;
+
+ GST_DEBUG ("element_name=%s, element=%" GST_PTR_FORMAT, element_name,
+ element);
+
+ parent_type_name = gst_structure_get_string (element, "parent-type");
+ type_name = gst_structure_get_string (element, "type");
+ component_name = gst_structure_get_string (element, "component-name");
+ component_role = gst_structure_get_string (element, "component-role");
+ library_name = gst_structure_get_string (element, "library-name");
+
+ if (!type_name || !component_name || !library_name) {
+ g_warning ("malformed config file: missing required fields for %s",
+ element_name);
+ return FALSE;
}
- return TRUE;
+ if (parent_type_name) {
+ type = g_type_from_name (parent_type_name);
+ if (type) {
+ type = create_subtype (type, type_name);
+ } else {
+ g_warning ("malformed config file: invalid parent-type '%s' for %s",
+ parent_type_name, element_name);
+ return FALSE;
+ }
+ } else {
+ type = g_type_from_name (type_name);
+ }
+
+ if (!type) {
+ g_warning ("malformed config file: invalid type '%s' for %s",
+ type_name, element_name);
+ return FALSE;
+ }
+
+ g_type_set_qdata (type, element_name_quark, (gpointer) element_name);
+
+ if (!gst_structure_get_int (element, "rank", &rank)) {
+ /* use default rank: */
+ rank = GST_RANK_NONE;
+ }
+
+ if (!gst_element_register (plugin, element_name, rank, type)) {
+ g_warning ("failed registering '%s'", element_name);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
}
gboolean
-gstomx_get_component_info (void *core,
- GType type)
+gstomx_get_component_info (void *core, GType type)
{
- GOmxCore *rcore = core;
- const gchar *element_name;
- GstStructure *element;
- const gchar *str;
+ GOmxCore *rcore = core;
+ const gchar *element_name;
+ GstStructure *element;
+ const gchar *str;
- element_name = g_type_get_qdata (type, element_name_quark);
- element = get_element_entry (element_name);
+ element_name = g_type_get_qdata (type, element_name_quark);
+ element = get_element_entry (element_name);
- if (!element)
- return FALSE;
+ if (!element)
+ return FALSE;
- str = gst_structure_get_string (element, "library-name");
- rcore->library_name = g_strdup (str);
+ str = gst_structure_get_string (element, "library-name");
+ rcore->library_name = g_strdup (str);
- str = gst_structure_get_string (element, "component-name");
- rcore->component_name = g_strdup (str);
+ str = gst_structure_get_string (element, "component-name");
+ rcore->component_name = g_strdup (str);
- str = gst_structure_get_string (element, "component-role");
- rcore->component_role = g_strdup (str);
+ str = gst_structure_get_string (element, "component-role");
+ rcore->component_role = g_strdup (str);
- return TRUE;
+ return TRUE;
}
void *
gstomx_core_new (void *object, GType type)
{
- GOmxCore *core = g_omx_core_new (object);
- gstomx_get_component_info (core, type);
- g_omx_core_init (core);
- return core;
+ GOmxCore *core = g_omx_core_new (object);
+ gstomx_get_component_info (core, type);
+ g_omx_core_init (core);
+ return core;
}
void
-gstomx_install_property_helper (GObjectClass *gobject_class)
+gstomx_install_property_helper (GObjectClass * gobject_class)
{
- g_object_class_install_property (gobject_class, ARG_COMPONENT_NAME,
- g_param_spec_string ("component-name", "Component name",
- "Name of the OpenMAX IL component to use",
- NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_COMPONENT_NAME,
+ g_param_spec_string ("component-name", "Component name",
+ "Name of the OpenMAX IL component to use",
+ NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, ARG_COMPONENT_ROLE,
- g_param_spec_string ("component-role", "Component role",
- "Role of the OpenMAX IL component",
- NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_COMPONENT_ROLE,
+ g_param_spec_string ("component-role", "Component role",
+ "Role of the OpenMAX IL component",
+ NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, ARG_LIBRARY_NAME,
- g_param_spec_string ("library-name", "Library name",
- "Name of the OpenMAX IL implementation library to use",
- NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_LIBRARY_NAME,
+ g_param_spec_string ("library-name", "Library name",
+ "Name of the OpenMAX IL implementation library to use",
+ NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}
gboolean
-gstomx_get_property_helper (void *core, guint prop_id, GValue *value)
+gstomx_get_property_helper (void *core, guint prop_id, GValue * value)
{
- GOmxCore *gomx = core;
- switch (prop_id)
- {
- case ARG_COMPONENT_NAME:
- g_value_set_string (value, gomx->component_name);
- return TRUE;
- case ARG_COMPONENT_ROLE:
- g_value_set_string (value, gomx->component_role);
- return TRUE;
- case ARG_LIBRARY_NAME:
- g_value_set_string (value, gomx->library_name);
- return TRUE;
- default:
- return FALSE;
- }
+ GOmxCore *gomx = core;
+ switch (prop_id) {
+ case ARG_COMPONENT_NAME:
+ g_value_set_string (value, gomx->component_name);
+ return TRUE;
+ case ARG_COMPONENT_ROLE:
+ g_value_set_string (value, gomx->component_role);
+ return TRUE;
+ case ARG_LIBRARY_NAME:
+ g_value_set_string (value, gomx->library_name);
+ return TRUE;
+ default:
+ return FALSE;
+ }
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "omx",
- "OpenMAX IL",
- plugin_init,
- PACKAGE_VERSION,
- GST_LICENSE,
- GST_PACKAGE_NAME,
- GST_PACKAGE_ORIGIN)
+ GST_VERSION_MINOR,
+ "omx",
+ "OpenMAX IL",
+ plugin_init,
+ PACKAGE_VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/omx/gstomx.h b/omx/gstomx.h
index d294acb..37027ec 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -24,28 +24,24 @@
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
+G_BEGIN_DECLS GST_DEBUG_CATEGORY_EXTERN (gstomx_debug);
GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
#define GST_CAT_DEFAULT gstomx_debug
enum
{
- GSTOMX_ARG_0,
- ARG_COMPONENT_NAME,
- ARG_COMPONENT_ROLE,
- ARG_LIBRARY_NAME,
- GSTOMX_NUM_COMMON_PROP
+ GSTOMX_ARG_0,
+ ARG_COMPONENT_NAME,
+ ARG_COMPONENT_ROLE,
+ ARG_LIBRARY_NAME,
+ GSTOMX_NUM_COMMON_PROP
};
-gboolean gstomx_get_component_info (void *core,
- GType type);
+gboolean gstomx_get_component_info (void *core, GType type);
void *gstomx_core_new (void *object, GType type);
-void gstomx_install_property_helper (GObjectClass *gobject_class);
-gboolean gstomx_get_property_helper (void *core, guint prop_id, GValue *value);
+void gstomx_install_property_helper (GObjectClass * gobject_class);
+gboolean gstomx_get_property_helper (void *core, guint prop_id, GValue * value);
G_END_DECLS
-
#endif /* GSTOMX_H */
diff --git a/omx/gstomx_aacdec.c b/omx/gstomx_aacdec.c
index ddad4ca..ec06de3 100644
--- a/omx/gstomx_aacdec.c
+++ b/omx/gstomx_aacdec.c
@@ -22,141 +22,133 @@
#include "gstomx_aacdec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxAacDec, gst_omx_aacdec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAacDec, gst_omx_aacdec, GstOmxBaseAudioDec,
+ GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", GST_TYPE_INT_RANGE, 1, 6,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "channels", GST_TYPE_INT_RANGE, 1, 6, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("audio/mpeg",
- "mpegversion", G_TYPE_INT, 4,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "channels", GST_TYPE_INT_RANGE, 1, 6,
- NULL);
+ struc = gst_structure_new ("audio/mpeg",
+ "mpegversion", G_TYPE_INT, 4,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "channels", GST_TYPE_INT_RANGE, 1, 6, NULL);
- {
- GValue list;
- GValue val;
+ {
+ GValue list;
+ GValue val;
- list.g_type = val.g_type = 0;
+ list.g_type = val.g_type = 0;
- g_value_init (&list, GST_TYPE_LIST);
- g_value_init (&val, G_TYPE_INT);
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, G_TYPE_INT);
- g_value_set_int (&val, 2);
- gst_value_list_append_value (&list, &val);
+ g_value_set_int (&val, 2);
+ gst_value_list_append_value (&list, &val);
- g_value_set_int (&val, 4);
- gst_value_list_append_value (&list, &val);
+ g_value_set_int (&val, 4);
+ gst_value_list_append_value (&list, &val);
- gst_structure_set_value (struc, "mpegversion", &list);
+ gst_structure_set_value (struc, "mpegversion", &list);
- g_value_unset (&val);
- g_value_unset (&list);
- }
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL AAC audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in AAC format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL AAC audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in AAC format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- {
- const GValue *codec_data;
- GstBuffer *buffer;
+ {
+ const GValue *codec_data;
+ GstBuffer *buffer;
- codec_data = gst_structure_get_value (structure, "codec_data");
- if (codec_data)
- {
- buffer = gst_value_get_buffer (codec_data);
- omx_base->codec_data = buffer;
- gst_buffer_ref (buffer);
- }
+ codec_data = gst_structure_get_value (structure, "codec_data");
+ if (codec_data) {
+ buffer = gst_value_get_buffer (codec_data);
+ omx_base->codec_data = buffer;
+ gst_buffer_ref (buffer);
}
+ }
- return gst_pad_set_caps (pad, caps);
+ return gst_pad_set_caps (pad, caps);
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_aacdec.h b/omx/gstomx_aacdec.h
index 1b431fd..43e1c0b 100644
--- a/omx/gstomx_aacdec.h
+++ b/omx/gstomx_aacdec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_AACDEC(obj) (GstOmxAacDec *) (obj)
#define GST_OMX_AACDEC_TYPE (gst_omx_aacdec_get_type ())
-
typedef struct GstOmxAacDec GstOmxAacDec;
typedef struct GstOmxAacDecClass GstOmxAacDecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxAacDecClass GstOmxAacDecClass;
struct GstOmxAacDec
{
- GstOmxBaseAudioDec omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxAacDecClass
{
- GstOmxBaseAudioDecClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_aacdec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_AACDEC_H */
diff --git a/omx/gstomx_aacenc.c b/omx/gstomx_aacenc.c
index e038791..da741a7 100644
--- a/omx/gstomx_aacenc.c
+++ b/omx/gstomx_aacenc.c
@@ -25,388 +25,382 @@
enum
{
- ARG_0,
- ARG_BITRATE,
- ARG_PROFILE,
- ARG_OUTPUT_FORMAT,
+ ARG_0,
+ ARG_BITRATE,
+ ARG_PROFILE,
+ ARG_OUTPUT_FORMAT,
};
#define DEFAULT_BITRATE 64000
#define DEFAULT_PROFILE OMX_AUDIO_AACObjectLC
#define DEFAULT_OUTPUT_FORMAT OMX_AUDIO_AACStreamFormatRAW
-GSTOMX_BOILERPLATE (GstOmxAacEnc, gst_omx_aacenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+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
gst_omx_aacenc_profile_get_type (void)
{
- static GType gst_omx_aacenc_profile_type = 0;
-
- if (!gst_omx_aacenc_profile_type) {
- static GEnumValue gst_omx_aacenc_profile[] = {
- {OMX_AUDIO_AACObjectLC, "Low Complexity", "LC"},
- {OMX_AUDIO_AACObjectMain, "Main", "Main"},
- {OMX_AUDIO_AACObjectSSR, "Scalable Sample Rate", "SSR"},
- {OMX_AUDIO_AACObjectLTP, "Long Term Prediction", "LTP"},
- {OMX_AUDIO_AACObjectHE, "High Efficiency with SBR (HE-AAC v1)", "HE"},
- {OMX_AUDIO_AACObjectScalable, "Scalable", "Scalable"},
- {OMX_AUDIO_AACObjectERLC, "ER AAC Low Complexity object (Error Resilient AAC-LC)", "ERLC"},
- {OMX_AUDIO_AACObjectLD, "AAC Low Delay object (Error Resilient)", "LD"},
- {OMX_AUDIO_AACObjectHE_PS, "High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS)", "HE_PS"},
- {0, NULL, NULL},
- };
-
- gst_omx_aacenc_profile_type = g_enum_register_static ("GstOmxAacencProfile",
- gst_omx_aacenc_profile);
- }
-
- return gst_omx_aacenc_profile_type;
+ static GType gst_omx_aacenc_profile_type = 0;
+
+ if (!gst_omx_aacenc_profile_type) {
+ static GEnumValue gst_omx_aacenc_profile[] = {
+ {OMX_AUDIO_AACObjectLC, "Low Complexity", "LC"},
+ {OMX_AUDIO_AACObjectMain, "Main", "Main"},
+ {OMX_AUDIO_AACObjectSSR, "Scalable Sample Rate", "SSR"},
+ {OMX_AUDIO_AACObjectLTP, "Long Term Prediction", "LTP"},
+ {OMX_AUDIO_AACObjectHE, "High Efficiency with SBR (HE-AAC v1)", "HE"},
+ {OMX_AUDIO_AACObjectScalable, "Scalable", "Scalable"},
+ {OMX_AUDIO_AACObjectERLC,
+ "ER AAC Low Complexity object (Error Resilient AAC-LC)", "ERLC"},
+ {OMX_AUDIO_AACObjectLD, "AAC Low Delay object (Error Resilient)", "LD"},
+ {OMX_AUDIO_AACObjectHE_PS,
+ "High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS)",
+ "HE_PS"},
+ {0, NULL, NULL},
+ };
+
+ gst_omx_aacenc_profile_type = g_enum_register_static ("GstOmxAacencProfile",
+ gst_omx_aacenc_profile);
+ }
+
+ return gst_omx_aacenc_profile_type;
}
#define GST_TYPE_OMX_AACENC_OUTPUT_FORMAT (gst_omx_aacenc_output_format_get_type ())
static GType
gst_omx_aacenc_output_format_get_type (void)
{
- static GType gst_omx_aacenc_output_format_type = 0;
-
- if (!gst_omx_aacenc_output_format_type) {
- static GEnumValue gst_omx_aacenc_output_format[] = {
- {OMX_AUDIO_AACStreamFormatMP2ADTS, "Audio Data Transport Stream 2 format", "MP2ADTS"},
- {OMX_AUDIO_AACStreamFormatMP4ADTS, "Audio Data Transport Stream 4 format", "MP4ADTS"},
- {OMX_AUDIO_AACStreamFormatMP4LOAS, "Low Overhead Audio Stream format", "MP4LOAS"},
- {OMX_AUDIO_AACStreamFormatMP4LATM, "Low overhead Audio Transport Multiplex", "MP4LATM"},
- {OMX_AUDIO_AACStreamFormatADIF, "Audio Data Interchange Format", "ADIF"},
- {OMX_AUDIO_AACStreamFormatMP4FF, "AAC inside MPEG-4/ISO File Format", "MP4FF"},
- {OMX_AUDIO_AACStreamFormatRAW, "AAC Raw Format", "RAW"},
- {0, NULL, NULL},
- };
-
- gst_omx_aacenc_output_format_type = g_enum_register_static ("GstOmxAacencOutputFormat",
- gst_omx_aacenc_output_format);
- }
-
- return gst_omx_aacenc_output_format_type;
+ static GType gst_omx_aacenc_output_format_type = 0;
+
+ if (!gst_omx_aacenc_output_format_type) {
+ static GEnumValue gst_omx_aacenc_output_format[] = {
+ {OMX_AUDIO_AACStreamFormatMP2ADTS, "Audio Data Transport Stream 2 format",
+ "MP2ADTS"},
+ {OMX_AUDIO_AACStreamFormatMP4ADTS, "Audio Data Transport Stream 4 format",
+ "MP4ADTS"},
+ {OMX_AUDIO_AACStreamFormatMP4LOAS, "Low Overhead Audio Stream format",
+ "MP4LOAS"},
+ {OMX_AUDIO_AACStreamFormatMP4LATM,
+ "Low overhead Audio Transport Multiplex", "MP4LATM"},
+ {OMX_AUDIO_AACStreamFormatADIF, "Audio Data Interchange Format", "ADIF"},
+ {OMX_AUDIO_AACStreamFormatMP4FF, "AAC inside MPEG-4/ISO File Format",
+ "MP4FF"},
+ {OMX_AUDIO_AACStreamFormatRAW, "AAC Raw Format", "RAW"},
+ {0, NULL, NULL},
+ };
+
+ gst_omx_aacenc_output_format_type =
+ g_enum_register_static ("GstOmxAacencOutputFormat",
+ gst_omx_aacenc_output_format);
+ }
+
+ return gst_omx_aacenc_output_format_type;
}
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- GstStructure *struc;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("audio/mpeg",
- "mpegversion", G_TYPE_INT, 4,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "channels", GST_TYPE_INT_RANGE, 1, 6,
- NULL);
+ struc = gst_structure_new ("audio/mpeg",
+ "mpegversion", G_TYPE_INT, 4,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "channels", GST_TYPE_INT_RANGE, 1, 6, NULL);
- {
- GValue list;
- GValue val;
+ {
+ GValue list;
+ GValue val;
- list.g_type = val.g_type = 0;
+ list.g_type = val.g_type = 0;
- g_value_init (&list, GST_TYPE_LIST);
- g_value_init (&val, G_TYPE_INT);
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, G_TYPE_INT);
- g_value_set_int (&val, 2);
- gst_value_list_append_value (&list, &val);
+ g_value_set_int (&val, 2);
+ gst_value_list_append_value (&list, &val);
- g_value_set_int (&val, 4);
- gst_value_list_append_value (&list, &val);
+ g_value_set_int (&val, 4);
+ gst_value_list_append_value (&list, &val);
- gst_structure_set_value (struc, "mpegversion", &list);
+ gst_structure_set_value (struc, "mpegversion", &list);
- g_value_unset (&val);
- g_value_unset (&list);
- }
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", GST_TYPE_INT_RANGE, 1, 6,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "channels", GST_TYPE_INT_RANGE, 1, 6, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL AAC audio encoder",
- "Codec/Encoder/Audio",
- "Encodes audio in AAC format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL AAC audio encoder",
+ "Codec/Encoder/Audio",
+ "Encodes audio in AAC format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxAacEnc *self;
-
- self = GST_OMX_AACENC (obj);
-
- switch (prop_id)
- {
- case ARG_BITRATE:
- self->bitrate = g_value_get_uint (value);
- break;
- case ARG_PROFILE:
- self->profile = g_value_get_enum (value);
- break;
- case ARG_OUTPUT_FORMAT:
- self->output_format = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxAacEnc *self;
+
+ self = GST_OMX_AACENC (obj);
+
+ switch (prop_id) {
+ case ARG_BITRATE:
+ self->bitrate = g_value_get_uint (value);
+ break;
+ case ARG_PROFILE:
+ self->profile = g_value_get_enum (value);
+ break;
+ case ARG_OUTPUT_FORMAT:
+ self->output_format = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxAacEnc *self;
+ GstOmxAacEnc *self;
- self = GST_OMX_AACENC (obj);
+ self = GST_OMX_AACENC (obj);
- switch (prop_id)
- {
- case ARG_BITRATE:
+ switch (prop_id) {
+ case ARG_BITRATE:
/** @todo propagate this to OpenMAX when processing. */
- g_value_set_uint (value, self->bitrate);
- break;
- case ARG_PROFILE:
- g_value_set_enum (value, self->profile);
- break;
- case ARG_OUTPUT_FORMAT:
- g_value_set_enum (value, self->output_format);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ g_value_set_uint (value, self->bitrate);
+ break;
+ case ARG_PROFILE:
+ g_value_set_enum (value, self->profile);
+ break;
+ case ARG_OUTPUT_FORMAT:
+ g_value_set_enum (value, self->output_format);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (g_class);
-
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
-
- g_object_class_install_property (gobject_class, ARG_BITRATE,
- g_param_spec_uint ("bitrate", "Bit-rate",
- "Encoding bit-rate",
- 0, G_MAXUINT, DEFAULT_BITRATE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, ARG_PROFILE,
- g_param_spec_enum ("profile", "Enocding profile",
- "OMX_AUDIO_AACPROFILETYPE of output",
- GST_TYPE_OMX_AACENC_PROFILE,
- DEFAULT_PROFILE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, ARG_OUTPUT_FORMAT,
- g_param_spec_enum ("output-format", "Output format",
- "OMX_AUDIO_AACSTREAMFORMATTYPE of output",
- GST_TYPE_OMX_AACENC_OUTPUT_FORMAT,
- DEFAULT_OUTPUT_FORMAT,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (g_class);
+
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
+
+ g_object_class_install_property (gobject_class, ARG_BITRATE,
+ g_param_spec_uint ("bitrate", "Bit-rate",
+ "Encoding bit-rate",
+ 0, G_MAXUINT, DEFAULT_BITRATE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_PROFILE,
+ g_param_spec_enum ("profile", "Enocding profile",
+ "OMX_AUDIO_AACPROFILETYPE of output",
+ GST_TYPE_OMX_AACENC_PROFILE,
+ DEFAULT_PROFILE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, ARG_OUTPUT_FORMAT,
+ g_param_spec_enum ("output-format", "Output format",
+ "OMX_AUDIO_AACSTREAMFORMATTYPE of output",
+ GST_TYPE_OMX_AACENC_OUTPUT_FORMAT,
+ DEFAULT_OUTPUT_FORMAT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- gint rate = 0;
- gint channels = 0;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ gint rate = 0;
+ gint channels = 0;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
- gst_structure_get_int (structure, "channels", &channels);
+ gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_int (structure, "channels", &channels);
- /* Input port configuration. */
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ /* Input port configuration. */
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- param.nSamplingRate = rate;
- param.nChannels = channels;
+ param.nSamplingRate = rate;
+ param.nChannels = channels;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ }
- {
- GstCaps *src_caps;
+ {
+ GstCaps *src_caps;
- src_caps = gst_caps_new_simple ("audio/mpeg",
- "mpegversion", G_TYPE_INT, 4,
- "rate", G_TYPE_INT, rate,
- "channels", G_TYPE_INT, channels,
- NULL);
- GST_INFO_OBJECT (omx_base, "src caps are: %" GST_PTR_FORMAT, src_caps);
+ src_caps = gst_caps_new_simple ("audio/mpeg",
+ "mpegversion", G_TYPE_INT, 4,
+ "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL);
+ GST_INFO_OBJECT (omx_base, "src caps are: %" GST_PTR_FORMAT, src_caps);
- gst_pad_set_caps (omx_base->srcpad, src_caps);
+ gst_pad_set_caps (omx_base->srcpad, src_caps);
- gst_caps_unref (src_caps);
- }
+ gst_caps_unref (src_caps);
+ }
- return gst_pad_set_caps (pad, caps);
+ return gst_pad_set_caps (pad, caps);
}
static void
-omx_setup (GstOmxBaseFilter *omx_base)
+omx_setup (GstOmxBaseFilter * omx_base)
{
- GstOmxAacEnc *self;
- GOmxCore *gomx;
+ GstOmxAacEnc *self;
+ GOmxCore *gomx;
- self = GST_OMX_AACENC (omx_base);
- gomx = (GOmxCore *) omx_base->gomx;
+ self = GST_OMX_AACENC (omx_base);
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "begin");
+ GST_INFO_OBJECT (omx_base, "begin");
- {
- OMX_AUDIO_PARAM_AACPROFILETYPE param;
+ {
+ OMX_AUDIO_PARAM_AACPROFILETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- /* Output port configuration. */
- {
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioAac, &param);
+ /* Output port configuration. */
+ {
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioAac, &param);
- GST_DEBUG_OBJECT (omx_base, "setting bitrate: %i", self->bitrate);
- param.nBitRate = self->bitrate;
+ GST_DEBUG_OBJECT (omx_base, "setting bitrate: %i", self->bitrate);
+ param.nBitRate = self->bitrate;
- GST_DEBUG_OBJECT (omx_base, "setting profile: %i", self->profile);
- param.eAACProfile = self->profile;
+ GST_DEBUG_OBJECT (omx_base, "setting profile: %i", self->profile);
+ param.eAACProfile = self->profile;
- GST_DEBUG_OBJECT (omx_base, "setting output format: %i",
- self->output_format);
- param.eAACStreamFormat = self->output_format;
+ GST_DEBUG_OBJECT (omx_base, "setting output format: %i",
+ self->output_format);
+ param.eAACStreamFormat = self->output_format;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioAac, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioAac, &param);
}
+ }
- /* some workarounds. */
+ /* some workarounds. */
#if 0
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm,
+ &param);
- rate = param.nSamplingRate;
- channels = param.nChannels;
- }
+ rate = param.nSamplingRate;
+ channels = param.nChannels;
+ }
- {
- OMX_AUDIO_PARAM_AACPROFILETYPE param;
+ {
+ OMX_AUDIO_PARAM_AACPROFILETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac,
+ &param);
- param.nSampleRate = rate;
- param.nChannels = channels;
+ param.nSampleRate = rate;
+ param.nChannels = channels;
- OMX_SetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac, &param);
- }
+ OMX_SetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac,
+ &param);
+ }
#endif
- GST_INFO_OBJECT (omx_base, "end");
+ GST_INFO_OBJECT (omx_base, "end");
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
- GstOmxAacEnc *self;
+ GstOmxBaseFilter *omx_base;
+ GstOmxAacEnc *self;
- omx_base = GST_OMX_BASE_FILTER (instance);
- self = GST_OMX_AACENC (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
+ self = GST_OMX_AACENC (instance);
- omx_base->omx_setup = omx_setup;
+ omx_base->omx_setup = omx_setup;
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
- self->bitrate = DEFAULT_BITRATE;
- self->profile = DEFAULT_PROFILE;
- self->output_format = DEFAULT_OUTPUT_FORMAT;
+ self->bitrate = DEFAULT_BITRATE;
+ self->profile = DEFAULT_PROFILE;
+ self->output_format = DEFAULT_OUTPUT_FORMAT;
}
diff --git a/omx/gstomx_aacenc.h b/omx/gstomx_aacenc.h
index 5501e7d..2e5b567 100644
--- a/omx/gstomx_aacenc.h
+++ b/omx/gstomx_aacenc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_AACENC(obj) (GstOmxAacEnc *) (obj)
#define GST_OMX_AACENC_TYPE (gst_omx_aacenc_get_type ())
-
typedef struct GstOmxAacEnc GstOmxAacEnc;
typedef struct GstOmxAacEncClass GstOmxAacEncClass;
@@ -36,19 +34,18 @@ typedef struct GstOmxAacEncClass GstOmxAacEncClass;
struct GstOmxAacEnc
{
- GstOmxBaseFilter omx_base;
- guint bitrate;
- gint profile;
- gint output_format;
+ GstOmxBaseFilter omx_base;
+ guint bitrate;
+ gint profile;
+ gint output_format;
};
struct GstOmxAacEncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_aacenc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_AACENC_H */
diff --git a/omx/gstomx_adpcmdec.c b/omx/gstomx_adpcmdec.c
index 6969937..6b39881 100644
--- a/omx/gstomx_adpcmdec.c
+++ b/omx/gstomx_adpcmdec.c
@@ -24,140 +24,130 @@
#include "gstomx.h"
/* should this class extend GstOmxBaseAudioDec? */
-GSTOMX_BOILERPLATE (GstOmxAdpcmDec, gst_omx_adpcmdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAdpcmDec, gst_omx_adpcmdec, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("audio/x-adpcm",
- "layout", G_TYPE_STRING, "dvi",
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ caps = gst_caps_new_simple ("audio/x-adpcm",
+ "layout", G_TYPE_STRING, "dvi",
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000, "channels", G_TYPE_INT, 1, NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL ADPCM audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in ADPCM format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL ADPCM audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in ADPCM format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- gint rate = 0;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ gint rate = 0;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_int (structure, "rate", &rate);
- /* Input port configuration. */
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ /* Input port configuration. */
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- param.nSamplingRate = rate;
+ param.nSamplingRate = rate;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- }
-
- /* set caps on the srcpad */
- {
- GstCaps *tmp_caps;
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ }
- tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
- tmp_caps = gst_caps_make_writable (tmp_caps);
- gst_caps_truncate (tmp_caps);
+ /* set caps on the srcpad */
+ {
+ GstCaps *tmp_caps;
- gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
+ tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
+ tmp_caps = gst_caps_make_writable (tmp_caps);
+ gst_caps_truncate (tmp_caps);
- if (gst_caps_is_fixed (tmp_caps))
- {
- GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
- gst_pad_set_caps (omx_base->srcpad, tmp_caps);
- }
+ gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
- gst_caps_unref (tmp_caps);
+ if (gst_caps_is_fixed (tmp_caps)) {
+ GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
+ gst_pad_set_caps (omx_base->srcpad, tmp_caps);
}
- return gst_pad_set_caps (pad, caps);
+ gst_caps_unref (tmp_caps);
+ }
+
+ return gst_pad_set_caps (pad, caps);
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_adpcmdec.h b/omx/gstomx_adpcmdec.h
index 48246a9..1af4f04 100644
--- a/omx/gstomx_adpcmdec.h
+++ b/omx/gstomx_adpcmdec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_ADPCMDEC(obj) (GstOmxAdpcmDec *) (obj)
#define GST_OMX_ADPCMDEC_TYPE (gst_omx_adpcmdec_get_type ())
-
typedef struct GstOmxAdpcmDec GstOmxAdpcmDec;
typedef struct GstOmxAdpcmDecClass GstOmxAdpcmDecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxAdpcmDecClass GstOmxAdpcmDecClass;
struct GstOmxAdpcmDec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxAdpcmDecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_adpcmdec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_ADPCMDEC_H */
diff --git a/omx/gstomx_adpcmenc.c b/omx/gstomx_adpcmenc.c
index 4e82f56..55d6c93 100644
--- a/omx/gstomx_adpcmenc.c
+++ b/omx/gstomx_adpcmenc.c
@@ -23,201 +23,188 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxAdpcmEnc, gst_omx_adpcmenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAdpcmEnc, gst_omx_adpcmenc, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("audio/x-adpcm",
- "layout", G_TYPE_STRING, "dvi",
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ caps = gst_caps_new_simple ("audio/x-adpcm",
+ "layout", G_TYPE_STRING, "dvi",
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000, "channels", G_TYPE_INT, 1, NULL);
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL ADPCM audio encoder",
- "Codec/Encoder/Audio",
- "Encodes audio in ADPCM format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL ADPCM audio encoder",
+ "Codec/Encoder/Audio",
+ "Encodes audio in ADPCM format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseFilter *omx_base;
- guint rate;
+ GstOmxBaseFilter *omx_base;
+ guint rate;
- omx_base = core->object;
+ omx_base = core->object;
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_AUDIO_PARAM_ADPCMTYPE param;
+ {
+ OMX_AUDIO_PARAM_ADPCMTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAdpcm, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAdpcm,
+ &param);
- rate = param.nSampleRate;
- }
+ rate = param.nSampleRate;
+ }
- {
- GstCaps *new_caps;
+ {
+ GstCaps *new_caps;
- new_caps = gst_caps_new_simple ("audio/x-adpcm",
- "layout", G_TYPE_STRING, "dvi",
- "rate", G_TYPE_INT, rate,
- "channels", G_TYPE_INT, 1,
- NULL);
+ new_caps = gst_caps_new_simple ("audio/x-adpcm",
+ "layout", G_TYPE_STRING, "dvi",
+ "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, 1, NULL);
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstCaps *peer_caps;
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- gint rate = 0;
- gboolean ret = TRUE;
+ GstCaps *peer_caps;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ gint rate = 0;
+ gboolean ret = TRUE;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- peer_caps = gst_pad_peer_get_caps (omx_base->srcpad);
+ peer_caps = gst_pad_peer_get_caps (omx_base->srcpad);
- g_return_val_if_fail (peer_caps, FALSE);
+ g_return_val_if_fail (peer_caps, FALSE);
- GST_INFO_OBJECT (omx_base, "setcaps (sink): peercaps: %" GST_PTR_FORMAT, peer_caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): peercaps: %" GST_PTR_FORMAT,
+ peer_caps);
- if (gst_caps_get_size (peer_caps) >= 1)
- {
- structure = gst_caps_get_structure (peer_caps, 0);
+ if (gst_caps_get_size (peer_caps) >= 1) {
+ structure = gst_caps_get_structure (peer_caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
- }
- else
- {
- structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "rate", &rate);
+ } else {
+ structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
- }
+ gst_structure_get_int (structure, "rate", &rate);
+ }
- /* Input port configuration. */
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ /* Input port configuration. */
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- param.nSamplingRate = rate;
+ param.nSamplingRate = rate;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ }
- /* set caps on the srcpad */
- {
- GstCaps *tmp_caps;
- GstStructure *tmp_structure;
+ /* set caps on the srcpad */
+ {
+ GstCaps *tmp_caps;
+ GstStructure *tmp_structure;
- tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
- tmp_caps = gst_caps_make_writable (tmp_caps);
- gst_caps_truncate (tmp_caps);
+ tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
+ tmp_caps = gst_caps_make_writable (tmp_caps);
+ gst_caps_truncate (tmp_caps);
- tmp_structure = gst_caps_get_structure (tmp_caps, 0);
- gst_structure_fixate_field_nearest_int (tmp_structure, "rate", rate);
- gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
+ tmp_structure = gst_caps_get_structure (tmp_caps, 0);
+ gst_structure_fixate_field_nearest_int (tmp_structure, "rate", rate);
+ gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
- if (gst_caps_is_fixed (tmp_caps))
- {
- GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
- gst_pad_set_caps (omx_base->srcpad, tmp_caps);
- }
-
- gst_caps_unref (tmp_caps);
+ if (gst_caps_is_fixed (tmp_caps)) {
+ GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
+ gst_pad_set_caps (omx_base->srcpad, tmp_caps);
}
- ret = gst_pad_set_caps (pad, caps);
+ gst_caps_unref (tmp_caps);
+ }
+
+ ret = gst_pad_set_caps (pad, caps);
- gst_caps_unref (peer_caps);
+ gst_caps_unref (peer_caps);
- return ret;
+ return ret;
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_adpcmenc.h b/omx/gstomx_adpcmenc.h
index 6262081..2191798 100644
--- a/omx/gstomx_adpcmenc.h
+++ b/omx/gstomx_adpcmenc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_ADPCMENC(obj) (GstOmxAdpcmEnc *) (obj)
#define GST_OMX_ADPCMENC_TYPE (gst_omx_adpcmenc_get_type ())
-
typedef struct GstOmxAdpcmEnc GstOmxAdpcmEnc;
typedef struct GstOmxAdpcmEncClass GstOmxAdpcmEncClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxAdpcmEncClass GstOmxAdpcmEncClass;
struct GstOmxAdpcmEnc
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxAdpcmEncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_adpcmenc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_ADPCMENC_H */
diff --git a/omx/gstomx_amrnbdec.c b/omx/gstomx_amrnbdec.c
index 7b8f707..99fa45a 100644
--- a/omx/gstomx_amrnbdec.c
+++ b/omx/gstomx_amrnbdec.c
@@ -22,80 +22,72 @@
#include "gstomx_amrnbdec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxAmrNbDec, gst_omx_amrnbdec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAmrNbDec, gst_omx_amrnbdec, GstOmxBaseAudioDec,
+ GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("audio/AMR",
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ caps = gst_caps_new_simple ("audio/AMR",
+ "rate", G_TYPE_INT, 8000, "channels", G_TYPE_INT, 1, NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL AMR-NB audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in AMR-NB format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL AMR-NB audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in AMR-NB format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
}
diff --git a/omx/gstomx_amrnbdec.h b/omx/gstomx_amrnbdec.h
index 781e4ed..f5cc1a0 100644
--- a/omx/gstomx_amrnbdec.h
+++ b/omx/gstomx_amrnbdec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_AMRNBDEC(obj) (GstOmxAmrNbDec *) (obj)
#define GST_OMX_AMRNBDEC_TYPE (gst_omx_amrnbdec_get_type ())
-
typedef struct GstOmxAmrNbDec GstOmxAmrNbDec;
typedef struct GstOmxAmrNbDecClass GstOmxAmrNbDecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxAmrNbDecClass GstOmxAmrNbDecClass;
struct GstOmxAmrNbDec
{
- GstOmxBaseAudioDec omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxAmrNbDecClass
{
- GstOmxBaseAudioDecClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_amrnbdec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_AMRNBDEC_H */
diff --git a/omx/gstomx_amrnbenc.c b/omx/gstomx_amrnbenc.c
index 8e61716..491165d 100644
--- a/omx/gstomx_amrnbenc.c
+++ b/omx/gstomx_amrnbenc.c
@@ -25,229 +25,212 @@
enum
{
- ARG_0,
- ARG_BITRATE,
+ ARG_0,
+ ARG_BITRATE,
};
#define DEFAULT_BITRATE 64000
-GSTOMX_BOILERPLATE (GstOmxAmrNbEnc, gst_omx_amrnbenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAmrNbEnc, gst_omx_amrnbenc, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("audio/AMR",
- "channels", G_TYPE_INT, 1,
- "rate", G_TYPE_INT, 8000,
- NULL);
+ caps = gst_caps_new_simple ("audio/AMR",
+ "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL AMR-NB audio encoder",
- "Codec/Encoder/Audio",
- "Encodes audio in AMR-NB format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL AMR-NB audio encoder",
+ "Codec/Encoder/Audio",
+ "Encodes audio in AMR-NB format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxAmrNbEnc *self;
-
- self = GST_OMX_AMRNBENC (obj);
-
- switch (prop_id)
- {
- case ARG_BITRATE:
- self->bitrate = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxAmrNbEnc *self;
+
+ self = GST_OMX_AMRNBENC (obj);
+
+ switch (prop_id) {
+ case ARG_BITRATE:
+ self->bitrate = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxAmrNbEnc *self;
+ GstOmxAmrNbEnc *self;
- self = GST_OMX_AMRNBENC (obj);
+ self = GST_OMX_AMRNBENC (obj);
- switch (prop_id)
- {
- case ARG_BITRATE:
+ switch (prop_id) {
+ case ARG_BITRATE:
/** @todo propagate this to OpenMAX when processing. */
- g_value_set_uint (value, self->bitrate);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ g_value_set_uint (value, self->bitrate);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
- gobject_class = G_OBJECT_CLASS (g_class);
+ gobject_class = G_OBJECT_CLASS (g_class);
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
- g_object_class_install_property (gobject_class, ARG_BITRATE,
- g_param_spec_uint ("bitrate", "Bit-rate",
- "Encoding bit-rate",
- 0, G_MAXUINT, DEFAULT_BITRATE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ g_object_class_install_property (gobject_class, ARG_BITRATE,
+ g_param_spec_uint ("bitrate", "Bit-rate",
+ "Encoding bit-rate",
+ 0, G_MAXUINT, DEFAULT_BITRATE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseFilter *omx_base;
- guint channels;
+ GstOmxBaseFilter *omx_base;
+ guint channels;
- omx_base = core->object;
+ omx_base = core->object;
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_AUDIO_PARAM_AMRTYPE param;
+ {
+ OMX_AUDIO_PARAM_AMRTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr,
+ &param);
- channels = param.nChannels;
- }
+ channels = param.nChannels;
+ }
- {
- GstCaps *new_caps;
+ {
+ GstCaps *new_caps;
- new_caps = gst_caps_new_simple ("audio/AMR",
- "channels", G_TYPE_INT, channels,
- "rate", G_TYPE_INT, 8000,
- NULL);
+ new_caps = gst_caps_new_simple ("audio/AMR",
+ "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, 8000, NULL);
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- gint rate = 0;
- gint channels = 0;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ gint rate = 0;
+ gint channels = 0;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
- gst_structure_get_int (structure, "channels", &channels);
+ gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_int (structure, "channels", &channels);
- /* Input port configuration. */
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ /* Input port configuration. */
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- param.nSamplingRate = rate;
- param.nChannels = channels;
+ param.nSamplingRate = rate;
+ param.nChannels = channels;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ }
- return gst_pad_set_caps (pad, caps);
+ return gst_pad_set_caps (pad, caps);
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
- GstOmxAmrNbEnc *self;
+ GstOmxBaseFilter *omx_base;
+ GstOmxAmrNbEnc *self;
- omx_base = GST_OMX_BASE_FILTER (instance);
- self = GST_OMX_AMRNBENC (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
+ self = GST_OMX_AMRNBENC (instance);
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
- self->bitrate = DEFAULT_BITRATE;
+ self->bitrate = DEFAULT_BITRATE;
}
diff --git a/omx/gstomx_amrnbenc.h b/omx/gstomx_amrnbenc.h
index dff1318..200c3e0 100644
--- a/omx/gstomx_amrnbenc.h
+++ b/omx/gstomx_amrnbenc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_AMRNBENC(obj) (GstOmxAmrNbEnc *) (obj)
#define GST_OMX_AMRNBENC_TYPE (gst_omx_amrnbenc_get_type ())
-
typedef struct GstOmxAmrNbEnc GstOmxAmrNbEnc;
typedef struct GstOmxAmrNbEncClass GstOmxAmrNbEncClass;
@@ -36,17 +34,16 @@ typedef struct GstOmxAmrNbEncClass GstOmxAmrNbEncClass;
struct GstOmxAmrNbEnc
{
- GstOmxBaseFilter omx_base;
- guint bitrate;
+ GstOmxBaseFilter omx_base;
+ guint bitrate;
};
struct GstOmxAmrNbEncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_amrnbenc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_AMRNBENC_H */
diff --git a/omx/gstomx_amrwbdec.c b/omx/gstomx_amrwbdec.c
index 67d7b0f..e94827d 100644
--- a/omx/gstomx_amrwbdec.c
+++ b/omx/gstomx_amrwbdec.c
@@ -22,80 +22,72 @@
#include "gstomx_amrwbdec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxAmrWbDec, gst_omx_amrwbdec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAmrWbDec, gst_omx_amrwbdec, GstOmxBaseAudioDec,
+ GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 16000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 16000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("audio/AMR-WB",
- "rate", G_TYPE_INT, 16000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ caps = gst_caps_new_simple ("audio/AMR-WB",
+ "rate", G_TYPE_INT, 16000, "channels", G_TYPE_INT, 1, NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL AMR-WB audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in AMR-WB format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL AMR-WB audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in AMR-WB format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
}
diff --git a/omx/gstomx_amrwbdec.h b/omx/gstomx_amrwbdec.h
index 61870b8..4528fe6 100644
--- a/omx/gstomx_amrwbdec.h
+++ b/omx/gstomx_amrwbdec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_AMRWBDEC(obj) (GstOmxAmrWbDec *) (obj)
#define GST_OMX_AMRWBDEC_TYPE (gst_omx_amrwbdec_get_type ())
-
typedef struct GstOmxAmrWbDec GstOmxAmrWbDec;
typedef struct GstOmxAmrWbDecClass GstOmxAmrWbDecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxAmrWbDecClass GstOmxAmrWbDecClass;
struct GstOmxAmrWbDec
{
- GstOmxBaseAudioDec omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxAmrWbDecClass
{
- GstOmxBaseAudioDecClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_amrwbdec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_AMRWBDEC_H */
diff --git a/omx/gstomx_amrwbenc.c b/omx/gstomx_amrwbenc.c
index 7eaef10..2aad99f 100644
--- a/omx/gstomx_amrwbenc.c
+++ b/omx/gstomx_amrwbenc.c
@@ -25,229 +25,212 @@
enum
{
- ARG_0,
- ARG_BITRATE,
+ ARG_0,
+ ARG_BITRATE,
};
#define DEFAULT_BITRATE 64000
-GSTOMX_BOILERPLATE (GstOmxAmrWbEnc, gst_omx_amrwbenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAmrWbEnc, gst_omx_amrwbenc, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("audio/AMR-WB",
- "channels", G_TYPE_INT, 1,
- "rate", G_TYPE_INT, 16000,
- NULL);
+ caps = gst_caps_new_simple ("audio/AMR-WB",
+ "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 16000, NULL);
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 16000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 16000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL AMR-WB audio encoder",
- "Codec/Encoder/Audio",
- "Encodes audio in AMR-WB format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL AMR-WB audio encoder",
+ "Codec/Encoder/Audio",
+ "Encodes audio in AMR-WB format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxAmrWbEnc *self;
-
- self = GST_OMX_AMRWBENC (obj);
-
- switch (prop_id)
- {
- case ARG_BITRATE:
- self->bitrate = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxAmrWbEnc *self;
+
+ self = GST_OMX_AMRWBENC (obj);
+
+ switch (prop_id) {
+ case ARG_BITRATE:
+ self->bitrate = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxAmrWbEnc *self;
+ GstOmxAmrWbEnc *self;
- self = GST_OMX_AMRWBENC (obj);
+ self = GST_OMX_AMRWBENC (obj);
- switch (prop_id)
- {
- case ARG_BITRATE:
+ switch (prop_id) {
+ case ARG_BITRATE:
/** @todo propagate this to OpenMAX when processing. */
- g_value_set_uint (value, self->bitrate);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ g_value_set_uint (value, self->bitrate);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
- gobject_class = G_OBJECT_CLASS (g_class);
+ gobject_class = G_OBJECT_CLASS (g_class);
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
- g_object_class_install_property (gobject_class, ARG_BITRATE,
- g_param_spec_uint ("bitrate", "Bit-rate",
- "Encoding bit-rate",
- 0, G_MAXUINT, DEFAULT_BITRATE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ g_object_class_install_property (gobject_class, ARG_BITRATE,
+ g_param_spec_uint ("bitrate", "Bit-rate",
+ "Encoding bit-rate",
+ 0, G_MAXUINT, DEFAULT_BITRATE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseFilter *omx_base;
- guint channels;
+ GstOmxBaseFilter *omx_base;
+ guint channels;
- omx_base = core->object;
+ omx_base = core->object;
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_AUDIO_PARAM_AMRTYPE param;
+ {
+ OMX_AUDIO_PARAM_AMRTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr,
+ &param);
- channels = param.nChannels;
- }
+ channels = param.nChannels;
+ }
- {
- GstCaps *new_caps;
+ {
+ GstCaps *new_caps;
- new_caps = gst_caps_new_simple ("audio/AMR-WB",
- "channels", G_TYPE_INT, channels,
- "rate", G_TYPE_INT, 16000,
- NULL);
+ new_caps = gst_caps_new_simple ("audio/AMR-WB",
+ "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, 16000, NULL);
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- gint rate = 0;
- gint channels = 0;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ gint rate = 0;
+ gint channels = 0;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
- gst_structure_get_int (structure, "channels", &channels);
+ gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_int (structure, "channels", &channels);
- /* Input port configuration. */
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ /* Input port configuration. */
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- param.nSamplingRate = rate;
- param.nChannels = channels;
+ param.nSamplingRate = rate;
+ param.nChannels = channels;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ }
- return gst_pad_set_caps (pad, caps);
+ return gst_pad_set_caps (pad, caps);
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
- GstOmxAmrWbEnc *self;
+ GstOmxBaseFilter *omx_base;
+ GstOmxAmrWbEnc *self;
- omx_base = GST_OMX_BASE_FILTER (instance);
- self = GST_OMX_AMRWBENC (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
+ self = GST_OMX_AMRWBENC (instance);
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
- self->bitrate = DEFAULT_BITRATE;
+ self->bitrate = DEFAULT_BITRATE;
}
diff --git a/omx/gstomx_amrwbenc.h b/omx/gstomx_amrwbenc.h
index 616998b..d804ba2 100644
--- a/omx/gstomx_amrwbenc.h
+++ b/omx/gstomx_amrwbenc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_AMRWBENC(obj) (GstOmxAmrWbEnc *) (obj)
#define GST_OMX_AMRWBENC_TYPE (gst_omx_amrwbenc_get_type ())
-
typedef struct GstOmxAmrWbEnc GstOmxAmrWbEnc;
typedef struct GstOmxAmrWbEncClass GstOmxAmrWbEncClass;
@@ -36,17 +34,16 @@ typedef struct GstOmxAmrWbEncClass GstOmxAmrWbEncClass;
struct GstOmxAmrWbEnc
{
- GstOmxBaseFilter omx_base;
- guint bitrate;
+ GstOmxBaseFilter omx_base;
+ guint bitrate;
};
struct GstOmxAmrWbEncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_amrwbenc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_AMRWBENC_H */
diff --git a/omx/gstomx_audiosink.c b/omx/gstomx_audiosink.c
index 3974034..bc6d6ef 100644
--- a/omx/gstomx_audiosink.c
+++ b/omx/gstomx_audiosink.c
@@ -22,122 +22,117 @@
#include "gstomx_audiosink.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxAudioSink, gst_omx_audiosink, GstOmxBaseSink, GST_OMX_BASE_SINK_TYPE);
+GSTOMX_BOILERPLATE (GstOmxAudioSink, gst_omx_audiosink, GstOmxBaseSink,
+ GST_OMX_BASE_SINK_TYPE);
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", GST_TYPE_INT_RANGE, 8, 32,
- "depth", GST_TYPE_INT_RANGE, 8, 32,
- "rate", GST_TYPE_INT_RANGE, 8000, 48000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", GST_TYPE_INT_RANGE, 1, 8,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", GST_TYPE_INT_RANGE, 8, 32,
+ "depth", GST_TYPE_INT_RANGE, 8, 32,
+ "rate", GST_TYPE_INT_RANGE, 8000, 48000,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "channels", GST_TYPE_INT_RANGE, 1, 8, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL audiosink element",
- "Sink/Audio",
- "Renders audio",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL audiosink element",
+ "Sink/Audio", "Renders audio", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static gboolean
-setcaps (GstBaseSink *gst_sink,
- GstCaps *caps)
+setcaps (GstBaseSink * gst_sink, GstCaps * caps)
{
- GstOmxBaseSink *self;
- GOmxCore *gomx;
+ GstOmxBaseSink *self;
+ GOmxCore *gomx;
- self = GST_OMX_BASE_SINK (gst_sink);
- gomx = (GOmxCore *) self->gomx;
+ self = GST_OMX_BASE_SINK (gst_sink);
+ gomx = (GOmxCore *) self->gomx;
- GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ {
+ GstStructure *structure;
+ gint channels;
+ gint width;
+ gint rate;
+ gboolean is_signed;
+ gboolean is_bigendian;
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ gst_structure_get_int (structure, "channels", &channels);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_boolean (structure, "signed", &is_signed);
{
- GstStructure *structure;
- gint channels;
- gint width;
- gint rate;
- gboolean is_signed;
- gboolean is_bigendian;
-
- structure = gst_caps_get_structure (caps, 0);
-
- gst_structure_get_int (structure, "channels", &channels);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "rate", &rate);
- gst_structure_get_boolean (structure, "signed", &is_signed);
- {
- gint endianness;
- gst_structure_get_int (structure, "endianness", &endianness);
- is_bigendian = (endianness == 1234) ? FALSE : TRUE;
- }
-
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = self->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
-
- param.nChannels = channels;
- param.eNumData = is_signed ? OMX_NumericalDataSigned : OMX_NumericalDataUnsigned;
- param.eEndian = is_bigendian ? OMX_EndianBig : OMX_EndianLittle;
- param.nBitPerSample = width;
- param.nSamplingRate = rate;
-
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- }
+ gint endianness;
+ gst_structure_get_int (structure, "endianness", &endianness);
+ is_bigendian = (endianness == 1234) ? FALSE : TRUE;
+ }
+
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = self->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+
+ param.nChannels = channels;
+ param.eNumData =
+ is_signed ? OMX_NumericalDataSigned : OMX_NumericalDataUnsigned;
+ param.eEndian = is_bigendian ? OMX_EndianBig : OMX_EndianLittle;
+ param.nBitPerSample = width;
+ param.nSamplingRate = rate;
+
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
}
+ }
- return TRUE;
+ return TRUE;
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GstBaseSinkClass *gst_base_sink_class;
+ GstBaseSinkClass *gst_base_sink_class;
- gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
+ gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
- gst_base_sink_class->set_caps = setcaps;
+ gst_base_sink_class->set_caps = setcaps;
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseSink *omx_base;
+ GstOmxBaseSink *omx_base;
- omx_base = GST_OMX_BASE_SINK (instance);
+ omx_base = GST_OMX_BASE_SINK (instance);
- GST_DEBUG_OBJECT (omx_base, "start");
+ GST_DEBUG_OBJECT (omx_base, "start");
}
diff --git a/omx/gstomx_audiosink.h b/omx/gstomx_audiosink.h
index 6b19b06..1054028 100644
--- a/omx/gstomx_audiosink.h
+++ b/omx/gstomx_audiosink.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_AUDIOSINK(obj) (GstOmxAudioSink *) (obj)
#define GST_OMX_AUDIOSINK_TYPE (gst_omx_audiosink_get_type ())
-
typedef struct GstOmxAudioSink GstOmxAudioSink;
typedef struct GstOmxAudioSinkClass GstOmxAudioSinkClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxAudioSinkClass GstOmxAudioSinkClass;
struct GstOmxAudioSink
{
- GstOmxBaseSink omx_base;
+ GstOmxBaseSink omx_base;
};
struct GstOmxAudioSinkClass
{
- GstOmxBaseSinkClass parent_class;
+ GstOmxBaseSinkClass parent_class;
};
GType gst_omx_audiosink_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_AUDIOSINK_H */
diff --git a/omx/gstomx_base_audiodec.c b/omx/gstomx_base_audiodec.c
index 25f19cb..6f94b33 100644
--- a/omx/gstomx_base_audiodec.c
+++ b/omx/gstomx_base_audiodec.c
@@ -22,7 +22,8 @@
#include "gstomx_base_audiodec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxBaseAudioDec, gst_omx_base_audiodec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxBaseAudioDec, gst_omx_base_audiodec, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static void
type_base_init (gpointer g_class)
@@ -30,66 +31,63 @@ type_base_init (gpointer g_class)
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
+ GstOmxBaseFilter *omx_base;
+ guint rate;
+ guint channels;
- omx_base = core->object;
+ omx_base = core->object;
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm,
+ &param);
- rate = param.nSamplingRate;
- channels = param.nChannels;
- if (rate == 0)
- {
+ rate = param.nSamplingRate;
+ channels = param.nChannels;
+ if (rate == 0) {
/** @todo: this shouldn't happen. */
- GST_WARNING_OBJECT (omx_base, "Bad samplerate");
- rate = 44100;
- }
- }
-
- {
- GstCaps *new_caps;
-
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, rate,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "channels", G_TYPE_INT, channels,
- NULL);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
+ GST_WARNING_OBJECT (omx_base, "Bad samplerate");
+ rate = 44100;
}
+ }
+
+ {
+ GstCaps *new_caps;
+
+ new_caps = gst_caps_new_simple ("audio/x-raw-int",
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, rate,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "channels", G_TYPE_INT, channels, NULL);
+
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- GST_DEBUG_OBJECT (omx_base, "start");
+ GST_DEBUG_OBJECT (omx_base, "start");
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_base_audiodec.h b/omx/gstomx_base_audiodec.h
index a5f924e..6d02781 100644
--- a/omx/gstomx_base_audiodec.h
+++ b/omx/gstomx_base_audiodec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_BASE_AUDIODEC(obj) (GstOmxBaseAudioDec *) (obj)
#define GST_OMX_BASE_AUDIODEC_TYPE (gst_omx_base_audiodec_get_type ())
-
typedef struct GstOmxBaseAudioDec GstOmxBaseAudioDec;
typedef struct GstOmxBaseAudioDecClass GstOmxBaseAudioDecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxBaseAudioDecClass GstOmxBaseAudioDecClass;
struct GstOmxBaseAudioDec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxBaseAudioDecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_base_audiodec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_BASE_AUDIODEC_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index fe8b8fe..54f7036 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -23,264 +23,240 @@
#include "gstomx.h"
#include "gstomx_interface.h"
-#include <string.h> /* for memcpy */
+#include <string.h> /* for memcpy */
enum
{
- ARG_USE_TIMESTAMPS = GSTOMX_NUM_COMMON_PROP,
- ARG_NUM_INPUT_BUFFERS,
- ARG_NUM_OUTPUT_BUFFERS,
+ ARG_USE_TIMESTAMPS = GSTOMX_NUM_COMMON_PROP,
+ ARG_NUM_INPUT_BUFFERS,
+ ARG_NUM_OUTPUT_BUFFERS,
};
static void init_interfaces (GType type);
-GSTOMX_BOILERPLATE_FULL (GstOmxBaseFilter, gst_omx_base_filter, GstElement, GST_TYPE_ELEMENT, init_interfaces);
+GSTOMX_BOILERPLATE_FULL (GstOmxBaseFilter, gst_omx_base_filter, GstElement,
+ GST_TYPE_ELEMENT, init_interfaces);
static inline void
-log_buffer (GstOmxBaseFilter *self,
- OMX_BUFFERHEADERTYPE *omx_buffer)
+log_buffer (GstOmxBaseFilter * self, OMX_BUFFERHEADERTYPE * omx_buffer)
{
- GST_DEBUG_OBJECT (self, "omx_buffer: "
- "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);
+ GST_DEBUG_OBJECT (self, "omx_buffer: "
+ "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);
}
static void
-setup_ports (GstOmxBaseFilter *self)
+setup_ports (GstOmxBaseFilter * self)
{
- /* Input port configuration. */
- g_omx_port_setup (self->in_port);
- gst_pad_set_element_private (self->sinkpad, self->in_port);
-
- /* Output port configuration. */
- g_omx_port_setup (self->out_port);
- gst_pad_set_element_private (self->srcpad, self->out_port);
-
- /* @todo: read from config file: */
- if (g_getenv ("OMX_ALLOCATE_ON"))
- {
- GST_DEBUG_OBJECT (self, "OMX_ALLOCATE_ON");
- self->in_port->omx_allocate = TRUE;
- self->out_port->omx_allocate = TRUE;
- self->share_input_buffer = FALSE;
- self->share_output_buffer = FALSE;
- }
- else if (g_getenv ("OMX_SHARE_HACK_ON"))
- {
- GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_ON");
- self->share_input_buffer = TRUE;
- self->share_output_buffer = TRUE;
- }
- else if (g_getenv ("OMX_SHARE_HACK_OFF"))
- {
- GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_OFF");
- self->share_input_buffer = FALSE;
- self->share_output_buffer = FALSE;
- }
- else
- {
- GST_DEBUG_OBJECT (self, "default sharing and allocation");
- }
-
- GST_DEBUG_OBJECT (self, "omx_allocate: in: %d, out: %d",
- self->in_port->omx_allocate, self->out_port->omx_allocate);
- GST_DEBUG_OBJECT (self, "share_buffer: in: %d, out: %d",
- self->share_input_buffer, self->share_output_buffer);
+ /* Input port configuration. */
+ g_omx_port_setup (self->in_port);
+ gst_pad_set_element_private (self->sinkpad, self->in_port);
+
+ /* Output port configuration. */
+ g_omx_port_setup (self->out_port);
+ gst_pad_set_element_private (self->srcpad, self->out_port);
+
+ /* @todo: read from config file: */
+ if (g_getenv ("OMX_ALLOCATE_ON")) {
+ GST_DEBUG_OBJECT (self, "OMX_ALLOCATE_ON");
+ self->in_port->omx_allocate = TRUE;
+ self->out_port->omx_allocate = TRUE;
+ self->share_input_buffer = FALSE;
+ self->share_output_buffer = FALSE;
+ } else if (g_getenv ("OMX_SHARE_HACK_ON")) {
+ GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_ON");
+ self->share_input_buffer = TRUE;
+ self->share_output_buffer = TRUE;
+ } else if (g_getenv ("OMX_SHARE_HACK_OFF")) {
+ GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_OFF");
+ self->share_input_buffer = FALSE;
+ self->share_output_buffer = FALSE;
+ } else {
+ GST_DEBUG_OBJECT (self, "default sharing and allocation");
+ }
+
+ GST_DEBUG_OBJECT (self, "omx_allocate: in: %d, out: %d",
+ self->in_port->omx_allocate, self->out_port->omx_allocate);
+ GST_DEBUG_OBJECT (self, "share_buffer: in: %d, out: %d",
+ self->share_input_buffer, self->share_output_buffer);
}
static GstStateChangeReturn
-change_state (GstElement *element,
- GstStateChange transition)
+change_state (GstElement * element, GstStateChange transition)
{
- GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
- GstOmxBaseFilter *self;
- GOmxCore *core;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GstOmxBaseFilter *self;
+ GOmxCore *core;
- self = GST_OMX_BASE_FILTER (element);
- core = self->gomx;
+ self = GST_OMX_BASE_FILTER (element);
+ core = self->gomx;
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- GST_INFO_OBJECT (self, "changing state %s - %s",
- gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
- gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
+ GST_INFO_OBJECT (self, "changing state %s - %s",
+ gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
+ gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
- switch (transition)
- {
- case GST_STATE_CHANGE_NULL_TO_READY:
- if (core->omx_state != OMX_StateLoaded)
- {
- ret = GST_STATE_CHANGE_FAILURE;
- goto leave;
- }
- break;
-
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-
- if (ret == GST_STATE_CHANGE_FAILURE)
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ if (core->omx_state != OMX_StateLoaded) {
+ ret = GST_STATE_CHANGE_FAILURE;
goto leave;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+ if (ret == GST_STATE_CHANGE_FAILURE)
+ goto leave;
+
+ switch (transition) {
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ g_mutex_lock (self->ready_lock);
+ if (self->ready) {
+ /* unlock */
+ g_omx_port_finish (self->in_port);
+ g_omx_port_finish (self->out_port);
+
+ g_omx_core_stop (core);
+ g_omx_core_unload (core);
+ self->ready = FALSE;
+ }
+ g_mutex_unlock (self->ready_lock);
+ if (core->omx_state != OMX_StateLoaded &&
+ core->omx_state != OMX_StateInvalid) {
+ ret = GST_STATE_CHANGE_FAILURE;
+ goto leave;
+ }
+ break;
- switch (transition)
- {
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- g_mutex_lock (self->ready_lock);
- if (self->ready)
- {
- /* unlock */
- g_omx_port_finish (self->in_port);
- g_omx_port_finish (self->out_port);
-
- g_omx_core_stop (core);
- g_omx_core_unload (core);
- self->ready = FALSE;
- }
- g_mutex_unlock (self->ready_lock);
- if (core->omx_state != OMX_StateLoaded &&
- core->omx_state != OMX_StateInvalid)
- {
- ret = GST_STATE_CHANGE_FAILURE;
- goto leave;
- }
- break;
-
- default:
- break;
- }
+ default:
+ break;
+ }
leave:
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return ret;
+ return ret;
}
static void
-finalize (GObject *obj)
+finalize (GObject * obj)
{
- GstOmxBaseFilter *self;
+ GstOmxBaseFilter *self;
- self = GST_OMX_BASE_FILTER (obj);
+ self = GST_OMX_BASE_FILTER (obj);
- if (self->codec_data)
- {
- gst_buffer_unref (self->codec_data);
- self->codec_data = NULL;
- }
+ if (self->codec_data) {
+ gst_buffer_unref (self->codec_data);
+ self->codec_data = NULL;
+ }
- g_omx_core_free (self->gomx);
+ g_omx_core_free (self->gomx);
- g_mutex_free (self->ready_lock);
+ g_mutex_free (self->ready_lock);
- G_OBJECT_CLASS (parent_class)->finalize (obj);
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxBaseFilter *self;
+ GstOmxBaseFilter *self;
- self = GST_OMX_BASE_FILTER (obj);
+ self = GST_OMX_BASE_FILTER (obj);
- switch (prop_id)
+ switch (prop_id) {
+ case ARG_USE_TIMESTAMPS:
+ self->use_timestamps = g_value_get_boolean (value);
+ break;
+ case ARG_NUM_INPUT_BUFFERS:
+ case ARG_NUM_OUTPUT_BUFFERS:
{
- case ARG_USE_TIMESTAMPS:
- self->use_timestamps = g_value_get_boolean (value);
- break;
- case ARG_NUM_INPUT_BUFFERS:
- case ARG_NUM_OUTPUT_BUFFERS:
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
- OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
- OMX_U32 nBufferCountActual;
- GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
- self->in_port : self->out_port;
-
- if (G_UNLIKELY (!omx_handle))
- {
- GST_WARNING_OBJECT (self, "no component");
- break;
- }
-
- nBufferCountActual = g_value_get_uint (value);
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = port->port_index;
- OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
-
- if (nBufferCountActual < param.nBufferCountMin)
- {
- GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
- nBufferCountActual, param.nBufferCountMin);
- return;
- }
-
- param.nBufferCountActual = nBufferCountActual;
-
- OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ OMX_U32 nBufferCountActual;
+ GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
+ self->in_port : self->out_port;
+
+ if (G_UNLIKELY (!omx_handle)) {
+ GST_WARNING_OBJECT (self, "no component");
+ break;
+ }
+
+ nBufferCountActual = g_value_get_uint (value);
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
+
+ if (nBufferCountActual < param.nBufferCountMin) {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
+
+ param.nBufferCountActual = nBufferCountActual;
+
+ OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
}
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxBaseFilter *self;
+ GstOmxBaseFilter *self;
- self = GST_OMX_BASE_FILTER (obj);
+ self = GST_OMX_BASE_FILTER (obj);
- if (gstomx_get_property_helper (self->gomx, prop_id, value))
- return;
+ if (gstomx_get_property_helper (self->gomx, prop_id, value))
+ return;
- switch (prop_id)
+ switch (prop_id) {
+ case ARG_USE_TIMESTAMPS:
+ g_value_set_boolean (value, self->use_timestamps);
+ break;
+ case ARG_NUM_INPUT_BUFFERS:
+ case ARG_NUM_OUTPUT_BUFFERS:
{
- case ARG_USE_TIMESTAMPS:
- g_value_set_boolean (value, self->use_timestamps);
- break;
- case ARG_NUM_INPUT_BUFFERS:
- case ARG_NUM_OUTPUT_BUFFERS:
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
- OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
- GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
- self->in_port : self->out_port;
-
- if (G_UNLIKELY (!omx_handle))
- {
- GST_WARNING_OBJECT (self, "no component");
- g_value_set_uint (value, 0);
- break;
- }
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = port->port_index;
- OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
-
- g_value_set_uint (value, param.nBufferCountActual);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ GOmxPort *port = (prop_id == ARG_NUM_INPUT_BUFFERS) ?
+ self->in_port : self->out_port;
+
+ if (G_UNLIKELY (!omx_handle)) {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ break;
+ }
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
+
+ g_value_set_uint (value, param.nBufferCountActual);
}
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
@@ -289,713 +265,641 @@ type_base_init (gpointer g_class)
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = G_OBJECT_CLASS (g_class);
- gstelement_class = GST_ELEMENT_CLASS (g_class);
-
- gobject_class->finalize = finalize;
- gstelement_class->change_state = change_state;
-
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
-
- gstomx_install_property_helper (gobject_class);
-
- g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
- g_param_spec_boolean ("use-timestamps", "Use timestamps",
- "Whether or not to use timestamps",
- TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
- g_param_spec_uint ("input-buffers", "Input buffers",
- "The number of OMX input buffers",
- 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
- g_param_spec_uint ("output-buffers", "Output buffers",
- "The number of OMX output buffers",
- 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = G_OBJECT_CLASS (g_class);
+ gstelement_class = GST_ELEMENT_CLASS (g_class);
+
+ gobject_class->finalize = finalize;
+ gstelement_class->change_state = change_state;
+
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
+
+ gstomx_install_property_helper (gobject_class);
+
+ g_object_class_install_property (gobject_class, ARG_USE_TIMESTAMPS,
+ g_param_spec_boolean ("use-timestamps", "Use timestamps",
+ "Whether or not to use timestamps",
+ TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
+ g_param_spec_uint ("input-buffers", "Input buffers",
+ "The number of OMX input buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
+ g_param_spec_uint ("output-buffers", "Output buffers",
+ "The number of OMX output buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static inline GstFlowReturn
-push_buffer (GstOmxBaseFilter *self,
- GstBuffer *buf)
+push_buffer (GstOmxBaseFilter * self, GstBuffer * buf)
{
- GstFlowReturn ret;
+ GstFlowReturn ret;
/** @todo check if tainted */
- GST_LOG_OBJECT (self, "begin");
- ret = gst_pad_push (self->srcpad, buf);
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "begin");
+ ret = gst_pad_push (self->srcpad, buf);
+ GST_LOG_OBJECT (self, "end");
- return ret;
+ return ret;
}
static void
output_loop (gpointer data)
{
- GstPad *pad;
- GOmxCore *gomx;
- GOmxPort *out_port;
- GstOmxBaseFilter *self;
- GstFlowReturn ret = GST_FLOW_OK;
+ GstPad *pad;
+ GOmxCore *gomx;
+ GOmxPort *out_port;
+ GstOmxBaseFilter *self;
+ GstFlowReturn ret = GST_FLOW_OK;
- pad = data;
- self = GST_OMX_BASE_FILTER (gst_pad_get_parent (pad));
- gomx = self->gomx;
+ pad = data;
+ self = GST_OMX_BASE_FILTER (gst_pad_get_parent (pad));
+ gomx = self->gomx;
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- /* do not bother if we have been setup to bail out */
- if ((ret = g_atomic_int_get (&self->last_pad_push_return)) != GST_FLOW_OK)
- goto leave;
+ /* do not bother if we have been setup to bail out */
+ if ((ret = g_atomic_int_get (&self->last_pad_push_return)) != GST_FLOW_OK)
+ goto leave;
- if (!self->ready)
- {
- g_error ("not ready");
- return;
- }
+ if (!self->ready) {
+ g_error ("not ready");
+ return;
+ }
- out_port = self->out_port;
+ out_port = self->out_port;
- if (G_LIKELY (out_port->enabled))
- {
- OMX_BUFFERHEADERTYPE *omx_buffer = NULL;
+ if (G_LIKELY (out_port->enabled)) {
+ OMX_BUFFERHEADERTYPE *omx_buffer = NULL;
- GST_LOG_OBJECT (self, "request buffer");
- omx_buffer = g_omx_port_request_buffer (out_port);
+ GST_LOG_OBJECT (self, "request buffer");
+ omx_buffer = g_omx_port_request_buffer (out_port);
- GST_LOG_OBJECT (self, "omx_buffer: %p", omx_buffer);
+ GST_LOG_OBJECT (self, "omx_buffer: %p", omx_buffer);
- if (G_UNLIKELY (!omx_buffer))
- {
- GST_WARNING_OBJECT (self, "null buffer: leaving");
- ret = GST_FLOW_WRONG_STATE;
- goto leave;
- }
+ if (G_UNLIKELY (!omx_buffer)) {
+ GST_WARNING_OBJECT (self, "null buffer: leaving");
+ ret = GST_FLOW_WRONG_STATE;
+ goto leave;
+ }
- log_buffer (self, omx_buffer);
+ log_buffer (self, omx_buffer);
- if (G_LIKELY (omx_buffer->nFilledLen > 0))
- {
- GstBuffer *buf;
+ if (G_LIKELY (omx_buffer->nFilledLen > 0)) {
+ GstBuffer *buf;
#if 1
/** @todo remove this check */
- if (G_LIKELY (self->in_port->enabled))
- {
- GstCaps *caps = NULL;
+ if (G_LIKELY (self->in_port->enabled)) {
+ GstCaps *caps = NULL;
- caps = gst_pad_get_negotiated_caps (self->srcpad);
+ caps = gst_pad_get_negotiated_caps (self->srcpad);
- if (!caps)
- {
+ if (!caps) {
/** @todo We shouldn't be doing this. */
- GST_WARNING_OBJECT (self, "faking settings changed notification");
- if (gomx->settings_changed_cb)
- gomx->settings_changed_cb (gomx);
- }
- else
- {
- GST_LOG_OBJECT (self, "caps already fixed: %" GST_PTR_FORMAT, caps);
- gst_caps_unref (caps);
- }
- }
+ GST_WARNING_OBJECT (self, "faking settings changed notification");
+ if (gomx->settings_changed_cb)
+ gomx->settings_changed_cb (gomx);
+ } else {
+ GST_LOG_OBJECT (self, "caps already fixed: %" GST_PTR_FORMAT, caps);
+ gst_caps_unref (caps);
+ }
+ }
#endif
- /* buf is always null when the output buffer pointer isn't shared. */
- buf = omx_buffer->pAppPrivate;
+ /* buf is always null when the output buffer pointer isn't shared. */
+ buf = omx_buffer->pAppPrivate;
/** @todo we need to move all the caps handling to one single
* place, in the output loop probably. */
- if (G_UNLIKELY (omx_buffer->nFlags & 0x80))
- {
- GstCaps *caps = NULL;
- GstStructure *structure;
- GValue value = {0, {{0}}};
-
- caps = gst_pad_get_negotiated_caps (self->srcpad);
- caps = gst_caps_make_writable (caps);
- structure = gst_caps_get_structure (caps, 0);
-
- g_value_init (&value, GST_TYPE_BUFFER);
- buf = gst_buffer_new_and_alloc (omx_buffer->nFilledLen);
- memcpy (GST_BUFFER_DATA (buf), omx_buffer->pBuffer + omx_buffer->nOffset, omx_buffer->nFilledLen);
- gst_value_set_buffer (&value, buf);
- gst_buffer_unref (buf);
- gst_structure_set_value (structure, "codec_data", &value);
- g_value_unset (&value);
-
- gst_pad_set_caps (self->srcpad, caps);
+ if (G_UNLIKELY (omx_buffer->nFlags & 0x80)) {
+ GstCaps *caps = NULL;
+ GstStructure *structure;
+ GValue value = { 0, {{0}
}
- else if (buf && !(omx_buffer->nFlags & OMX_BUFFERFLAG_EOS))
- {
- GST_BUFFER_SIZE (buf) = omx_buffer->nFilledLen;
- if (self->use_timestamps)
- {
- GST_BUFFER_TIMESTAMP (buf) = gst_util_uint64_scale_int (omx_buffer->nTimeStamp,
- GST_SECOND,
- OMX_TICKS_PER_SECOND);
- }
-
- omx_buffer->pAppPrivate = NULL;
- omx_buffer->pBuffer = NULL;
-
- ret = push_buffer (self, buf);
-
- gst_buffer_unref (buf);
- }
- else
- {
- /* This is only meant for the first OpenMAX buffers,
- * which need to be pre-allocated. */
- /* Also for the very last one. */
- ret = gst_pad_alloc_buffer_and_set_caps (self->srcpad,
- GST_BUFFER_OFFSET_NONE,
- omx_buffer->nFilledLen,
- GST_PAD_CAPS (self->srcpad),
- &buf);
-
- if (G_LIKELY (buf))
- {
- memcpy (GST_BUFFER_DATA (buf), omx_buffer->pBuffer + omx_buffer->nOffset, omx_buffer->nFilledLen);
- if (self->use_timestamps)
- {
- GST_BUFFER_TIMESTAMP (buf) = gst_util_uint64_scale_int (omx_buffer->nTimeStamp,
- GST_SECOND,
- OMX_TICKS_PER_SECOND);
- }
-
- if (self->share_output_buffer)
- {
- GST_WARNING_OBJECT (self, "couldn't zero-copy");
- /* If pAppPrivate is NULL, it means it was a dummy
- * allocation, free it. */
- if (!omx_buffer->pAppPrivate)
- {
- g_free (omx_buffer->pBuffer);
- omx_buffer->pBuffer = NULL;
- }
- }
-
- ret = push_buffer (self, buf);
- }
- else
- {
- GST_WARNING_OBJECT (self, "couldn't allocate buffer of size %lu",
- omx_buffer->nFilledLen);
- }
- }
- }
- else
- {
- GST_WARNING_OBJECT (self, "empty buffer");
+ };
+
+ caps = gst_pad_get_negotiated_caps (self->srcpad);
+ caps = gst_caps_make_writable (caps);
+ structure = gst_caps_get_structure (caps, 0);
+
+ g_value_init (&value, GST_TYPE_BUFFER);
+ buf = gst_buffer_new_and_alloc (omx_buffer->nFilledLen);
+ memcpy (GST_BUFFER_DATA (buf),
+ omx_buffer->pBuffer + omx_buffer->nOffset, omx_buffer->nFilledLen);
+ gst_value_set_buffer (&value, buf);
+ gst_buffer_unref (buf);
+ gst_structure_set_value (structure, "codec_data", &value);
+ g_value_unset (&value);
+
+ gst_pad_set_caps (self->srcpad, caps);
+ } else if (buf && !(omx_buffer->nFlags & OMX_BUFFERFLAG_EOS)) {
+ GST_BUFFER_SIZE (buf) = omx_buffer->nFilledLen;
+ if (self->use_timestamps) {
+ GST_BUFFER_TIMESTAMP (buf) =
+ gst_util_uint64_scale_int (omx_buffer->nTimeStamp, GST_SECOND,
+ OMX_TICKS_PER_SECOND);
}
- if (self->share_output_buffer &&
- !omx_buffer->pBuffer &&
- omx_buffer->nOffset == 0)
- {
- GstBuffer *buf;
- GstFlowReturn result;
-
- GST_LOG_OBJECT (self, "allocate buffer");
- result = gst_pad_alloc_buffer_and_set_caps (self->srcpad,
- GST_BUFFER_OFFSET_NONE,
- omx_buffer->nAllocLen,
- GST_PAD_CAPS (self->srcpad),
- &buf);
-
- if (G_LIKELY (result == GST_FLOW_OK))
- {
- gst_buffer_ref (buf);
- omx_buffer->pAppPrivate = buf;
-
- omx_buffer->pBuffer = GST_BUFFER_DATA (buf);
- omx_buffer->nAllocLen = GST_BUFFER_SIZE (buf);
- }
- else
- {
- GST_WARNING_OBJECT (self, "could not pad allocate buffer, using malloc");
- omx_buffer->pBuffer = g_malloc (omx_buffer->nAllocLen);
+ omx_buffer->pAppPrivate = NULL;
+ omx_buffer->pBuffer = NULL;
+
+ ret = push_buffer (self, buf);
+
+ gst_buffer_unref (buf);
+ } else {
+ /* This is only meant for the first OpenMAX buffers,
+ * which need to be pre-allocated. */
+ /* Also for the very last one. */
+ ret = gst_pad_alloc_buffer_and_set_caps (self->srcpad,
+ GST_BUFFER_OFFSET_NONE,
+ omx_buffer->nFilledLen, GST_PAD_CAPS (self->srcpad), &buf);
+
+ if (G_LIKELY (buf)) {
+ memcpy (GST_BUFFER_DATA (buf),
+ omx_buffer->pBuffer + omx_buffer->nOffset,
+ omx_buffer->nFilledLen);
+ if (self->use_timestamps) {
+ GST_BUFFER_TIMESTAMP (buf) =
+ gst_util_uint64_scale_int (omx_buffer->nTimeStamp, GST_SECOND,
+ OMX_TICKS_PER_SECOND);
+ }
+
+ if (self->share_output_buffer) {
+ GST_WARNING_OBJECT (self, "couldn't zero-copy");
+ /* If pAppPrivate is NULL, it means it was a dummy
+ * allocation, free it. */
+ if (!omx_buffer->pAppPrivate) {
+ g_free (omx_buffer->pBuffer);
+ omx_buffer->pBuffer = NULL;
}
- }
+ }
- if (self->share_output_buffer &&
- !omx_buffer->pBuffer)
- {
- GST_ERROR_OBJECT (self, "no input buffer to share");
+ ret = push_buffer (self, buf);
+ } else {
+ GST_WARNING_OBJECT (self, "couldn't allocate buffer of size %lu",
+ omx_buffer->nFilledLen);
}
+ }
+ } else {
+ GST_WARNING_OBJECT (self, "empty buffer");
+ }
- if (G_UNLIKELY (omx_buffer->nFlags & OMX_BUFFERFLAG_EOS))
- {
- GST_DEBUG_OBJECT (self, "got eos");
- gst_pad_push_event (self->srcpad, gst_event_new_eos ());
- omx_buffer->nFlags &= ~OMX_BUFFERFLAG_EOS;
- ret = GST_FLOW_UNEXPECTED;
- }
+ if (self->share_output_buffer &&
+ !omx_buffer->pBuffer && omx_buffer->nOffset == 0) {
+ GstBuffer *buf;
+ GstFlowReturn result;
+
+ GST_LOG_OBJECT (self, "allocate buffer");
+ result = gst_pad_alloc_buffer_and_set_caps (self->srcpad,
+ GST_BUFFER_OFFSET_NONE,
+ omx_buffer->nAllocLen, GST_PAD_CAPS (self->srcpad), &buf);
+
+ if (G_LIKELY (result == GST_FLOW_OK)) {
+ gst_buffer_ref (buf);
+ omx_buffer->pAppPrivate = buf;
+
+ omx_buffer->pBuffer = GST_BUFFER_DATA (buf);
+ omx_buffer->nAllocLen = GST_BUFFER_SIZE (buf);
+ } else {
+ GST_WARNING_OBJECT (self,
+ "could not pad allocate buffer, using malloc");
+ omx_buffer->pBuffer = g_malloc (omx_buffer->nAllocLen);
+ }
+ }
- omx_buffer->nFilledLen = 0;
- GST_LOG_OBJECT (self, "release_buffer");
- g_omx_port_release_buffer (out_port, omx_buffer);
+ if (self->share_output_buffer && !omx_buffer->pBuffer) {
+ GST_ERROR_OBJECT (self, "no input buffer to share");
+ }
+
+ if (G_UNLIKELY (omx_buffer->nFlags & OMX_BUFFERFLAG_EOS)) {
+ GST_DEBUG_OBJECT (self, "got eos");
+ gst_pad_push_event (self->srcpad, gst_event_new_eos ());
+ omx_buffer->nFlags &= ~OMX_BUFFERFLAG_EOS;
+ ret = GST_FLOW_UNEXPECTED;
}
+ omx_buffer->nFilledLen = 0;
+ GST_LOG_OBJECT (self, "release_buffer");
+ g_omx_port_release_buffer (out_port, omx_buffer);
+ }
+
leave:
- self->last_pad_push_return = ret;
+ self->last_pad_push_return = ret;
- if (gomx->omx_error != OMX_ErrorNone)
- ret = GST_FLOW_ERROR;
+ if (gomx->omx_error != OMX_ErrorNone)
+ ret = GST_FLOW_ERROR;
- if (ret != GST_FLOW_OK)
- {
- GST_INFO_OBJECT (self, "pause task, reason: %s",
- gst_flow_get_name (ret));
- gst_pad_pause_task (self->srcpad);
- }
+ if (ret != GST_FLOW_OK) {
+ GST_INFO_OBJECT (self, "pause task, reason: %s", gst_flow_get_name (ret));
+ gst_pad_pause_task (self->srcpad);
+ }
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- gst_object_unref (self);
+ gst_object_unref (self);
}
static GstFlowReturn
-pad_chain (GstPad *pad,
- GstBuffer *buf)
+pad_chain (GstPad * pad, GstBuffer * buf)
{
- GOmxCore *gomx;
- GOmxPort *in_port;
- GstOmxBaseFilter *self;
- GstFlowReturn ret = GST_FLOW_OK;
+ GOmxCore *gomx;
+ GOmxPort *in_port;
+ GstOmxBaseFilter *self;
+ GstFlowReturn ret = GST_FLOW_OK;
- self = GST_OMX_BASE_FILTER (GST_OBJECT_PARENT (pad));
+ self = GST_OMX_BASE_FILTER (GST_OBJECT_PARENT (pad));
- gomx = self->gomx;
+ gomx = self->gomx;
- GST_LOG_OBJECT (self, "begin");
- GST_LOG_OBJECT (self, "gst_buffer: size=%u", GST_BUFFER_SIZE (buf));
+ GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "gst_buffer: size=%u", GST_BUFFER_SIZE (buf));
- GST_LOG_OBJECT (self, "state: %d", gomx->omx_state);
+ GST_LOG_OBJECT (self, "state: %d", gomx->omx_state);
- if (G_UNLIKELY (gomx->omx_state == OMX_StateLoaded))
- {
- g_mutex_lock (self->ready_lock);
+ if (G_UNLIKELY (gomx->omx_state == OMX_StateLoaded)) {
+ g_mutex_lock (self->ready_lock);
- GST_INFO_OBJECT (self, "omx: prepare");
+ GST_INFO_OBJECT (self, "omx: prepare");
/** @todo this should probably go after doing preparations. */
- if (self->omx_setup)
- {
- self->omx_setup (self);
- }
+ if (self->omx_setup) {
+ self->omx_setup (self);
+ }
- setup_ports (self);
+ setup_ports (self);
- g_omx_core_prepare (self->gomx);
+ g_omx_core_prepare (self->gomx);
- if (gomx->omx_state == OMX_StateIdle)
- {
- self->ready = TRUE;
- gst_pad_start_task (self->srcpad, output_loop, self->srcpad);
- }
+ if (gomx->omx_state == OMX_StateIdle) {
+ self->ready = TRUE;
+ gst_pad_start_task (self->srcpad, output_loop, self->srcpad);
+ }
- g_mutex_unlock (self->ready_lock);
+ g_mutex_unlock (self->ready_lock);
- if (gomx->omx_state != OMX_StateIdle)
- goto out_flushing;
- }
+ if (gomx->omx_state != OMX_StateIdle)
+ goto out_flushing;
+ }
- in_port = self->in_port;
+ in_port = self->in_port;
- if (G_LIKELY (in_port->enabled))
- {
- guint buffer_offset = 0;
+ if (G_LIKELY (in_port->enabled)) {
+ guint buffer_offset = 0;
- if (G_UNLIKELY (gomx->omx_state == OMX_StateIdle))
- {
- GST_INFO_OBJECT (self, "omx: play");
- g_omx_core_start (gomx);
+ if (G_UNLIKELY (gomx->omx_state == OMX_StateIdle)) {
+ GST_INFO_OBJECT (self, "omx: play");
+ g_omx_core_start (gomx);
- if (gomx->omx_state != OMX_StateExecuting)
- goto out_flushing;
+ if (gomx->omx_state != OMX_StateExecuting)
+ goto out_flushing;
- /* send buffer with codec data flag */
+ /* send buffer with codec data flag */
/** @todo move to util */
- if (self->codec_data)
- {
- OMX_BUFFERHEADERTYPE *omx_buffer;
+ if (self->codec_data) {
+ OMX_BUFFERHEADERTYPE *omx_buffer;
- GST_LOG_OBJECT (self, "request buffer");
- omx_buffer = g_omx_port_request_buffer (in_port);
+ GST_LOG_OBJECT (self, "request buffer");
+ omx_buffer = g_omx_port_request_buffer (in_port);
- if (G_LIKELY (omx_buffer))
- {
- omx_buffer->nFlags |= 0x00000080; /* codec data flag */
+ if (G_LIKELY (omx_buffer)) {
+ omx_buffer->nFlags |= 0x00000080; /* codec data flag */
- omx_buffer->nFilledLen = GST_BUFFER_SIZE (self->codec_data);
- memcpy (omx_buffer->pBuffer + omx_buffer->nOffset, GST_BUFFER_DATA (self->codec_data), omx_buffer->nFilledLen);
+ omx_buffer->nFilledLen = GST_BUFFER_SIZE (self->codec_data);
+ memcpy (omx_buffer->pBuffer + omx_buffer->nOffset,
+ GST_BUFFER_DATA (self->codec_data), omx_buffer->nFilledLen);
- GST_LOG_OBJECT (self, "release_buffer");
- g_omx_port_release_buffer (in_port, omx_buffer);
- }
- }
+ GST_LOG_OBJECT (self, "release_buffer");
+ g_omx_port_release_buffer (in_port, omx_buffer);
}
+ }
+ }
- if (G_UNLIKELY (gomx->omx_state != OMX_StateExecuting))
- {
- GST_ERROR_OBJECT (self, "Whoa! very wrong");
- }
+ if (G_UNLIKELY (gomx->omx_state != OMX_StateExecuting)) {
+ GST_ERROR_OBJECT (self, "Whoa! very wrong");
+ }
- while (G_LIKELY (buffer_offset < GST_BUFFER_SIZE (buf)))
- {
- OMX_BUFFERHEADERTYPE *omx_buffer;
+ while (G_LIKELY (buffer_offset < GST_BUFFER_SIZE (buf))) {
+ OMX_BUFFERHEADERTYPE *omx_buffer;
- if (self->last_pad_push_return != GST_FLOW_OK ||
- !(gomx->omx_state == OMX_StateExecuting ||
- gomx->omx_state == OMX_StatePause))
- {
- goto out_flushing;
- }
+ if (self->last_pad_push_return != GST_FLOW_OK ||
+ !(gomx->omx_state == OMX_StateExecuting ||
+ gomx->omx_state == OMX_StatePause)) {
+ goto out_flushing;
+ }
- GST_LOG_OBJECT (self, "request buffer");
- omx_buffer = g_omx_port_request_buffer (in_port);
-
- GST_LOG_OBJECT (self, "omx_buffer: %p", omx_buffer);
-
- if (G_LIKELY (omx_buffer))
- {
- log_buffer (self, omx_buffer);
-
- if (omx_buffer->nOffset == 0 &&
- self->share_input_buffer)
- {
- {
- GstBuffer *old_buf;
- old_buf = omx_buffer->pAppPrivate;
-
- if (old_buf)
- {
- gst_buffer_unref (old_buf);
- }
- else if (omx_buffer->pBuffer)
- {
- g_free (omx_buffer->pBuffer);
- }
- }
-
- omx_buffer->pBuffer = GST_BUFFER_DATA (buf);
- omx_buffer->nAllocLen = GST_BUFFER_SIZE (buf);
- omx_buffer->nFilledLen = GST_BUFFER_SIZE (buf);
- omx_buffer->pAppPrivate = buf;
- }
- else
- {
- omx_buffer->nFilledLen = MIN (GST_BUFFER_SIZE (buf) - buffer_offset,
- omx_buffer->nAllocLen - omx_buffer->nOffset);
- memcpy (omx_buffer->pBuffer + omx_buffer->nOffset, GST_BUFFER_DATA (buf) + buffer_offset, omx_buffer->nFilledLen);
- }
-
- if (self->use_timestamps)
- {
- GstClockTime timestamp_offset = 0;
-
- if (buffer_offset && GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE)
- {
- timestamp_offset = gst_util_uint64_scale_int (buffer_offset,
- GST_BUFFER_DURATION (buf),
- GST_BUFFER_SIZE (buf));
- }
-
- omx_buffer->nTimeStamp = gst_util_uint64_scale_int (GST_BUFFER_TIMESTAMP (buf) + timestamp_offset,
- OMX_TICKS_PER_SECOND,
- GST_SECOND);
- }
-
- buffer_offset += omx_buffer->nFilledLen;
-
- GST_LOG_OBJECT (self, "release_buffer");
- /** @todo untaint buffer */
- g_omx_port_release_buffer (in_port, omx_buffer);
- }
- else
- {
- GST_WARNING_OBJECT (self, "null buffer");
- ret = GST_FLOW_WRONG_STATE;
- goto out_flushing;
+ GST_LOG_OBJECT (self, "request buffer");
+ omx_buffer = g_omx_port_request_buffer (in_port);
+
+ GST_LOG_OBJECT (self, "omx_buffer: %p", omx_buffer);
+
+ if (G_LIKELY (omx_buffer)) {
+ log_buffer (self, omx_buffer);
+
+ if (omx_buffer->nOffset == 0 && self->share_input_buffer) {
+ {
+ GstBuffer *old_buf;
+ old_buf = omx_buffer->pAppPrivate;
+
+ if (old_buf) {
+ gst_buffer_unref (old_buf);
+ } else if (omx_buffer->pBuffer) {
+ g_free (omx_buffer->pBuffer);
}
+ }
+
+ omx_buffer->pBuffer = GST_BUFFER_DATA (buf);
+ omx_buffer->nAllocLen = GST_BUFFER_SIZE (buf);
+ omx_buffer->nFilledLen = GST_BUFFER_SIZE (buf);
+ omx_buffer->pAppPrivate = buf;
+ } else {
+ omx_buffer->nFilledLen = MIN (GST_BUFFER_SIZE (buf) - buffer_offset,
+ omx_buffer->nAllocLen - omx_buffer->nOffset);
+ memcpy (omx_buffer->pBuffer + omx_buffer->nOffset,
+ GST_BUFFER_DATA (buf) + buffer_offset, omx_buffer->nFilledLen);
}
- }
- else
- {
- GST_WARNING_OBJECT (self, "done");
- ret = GST_FLOW_UNEXPECTED;
- }
- if (!self->share_input_buffer)
- {
- gst_buffer_unref (buf);
+ if (self->use_timestamps) {
+ GstClockTime timestamp_offset = 0;
+
+ if (buffer_offset && GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE) {
+ timestamp_offset = gst_util_uint64_scale_int (buffer_offset,
+ GST_BUFFER_DURATION (buf), GST_BUFFER_SIZE (buf));
+ }
+
+ omx_buffer->nTimeStamp =
+ gst_util_uint64_scale_int (GST_BUFFER_TIMESTAMP (buf) +
+ timestamp_offset, OMX_TICKS_PER_SECOND, GST_SECOND);
+ }
+
+ buffer_offset += omx_buffer->nFilledLen;
+
+ GST_LOG_OBJECT (self, "release_buffer");
+ /** @todo untaint buffer */
+ g_omx_port_release_buffer (in_port, omx_buffer);
+ } else {
+ GST_WARNING_OBJECT (self, "null buffer");
+ ret = GST_FLOW_WRONG_STATE;
+ goto out_flushing;
+ }
}
+ } else {
+ GST_WARNING_OBJECT (self, "done");
+ ret = GST_FLOW_UNEXPECTED;
+ }
+
+ if (!self->share_input_buffer) {
+ gst_buffer_unref (buf);
+ }
leave:
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return ret;
+ return ret;
- /* special conditions */
+ /* special conditions */
out_flushing:
- {
- const gchar *error_msg = NULL;
-
- if (gomx->omx_error)
- {
- error_msg = "Error from OpenMAX component";
- }
- else if (gomx->omx_state != OMX_StateExecuting &&
- gomx->omx_state != OMX_StatePause)
- {
- error_msg = "OpenMAX component in wrong state";
- }
+ {
+ const gchar *error_msg = NULL;
+
+ if (gomx->omx_error) {
+ error_msg = "Error from OpenMAX component";
+ } else if (gomx->omx_state != OMX_StateExecuting &&
+ gomx->omx_state != OMX_StatePause) {
+ error_msg = "OpenMAX component in wrong state";
+ }
- if (error_msg)
- {
- GST_ELEMENT_ERROR (self, STREAM, FAILED, (NULL), ("%s", error_msg));
- ret = GST_FLOW_ERROR;
- }
+ if (error_msg) {
+ GST_ELEMENT_ERROR (self, STREAM, FAILED, (NULL), ("%s", error_msg));
+ ret = GST_FLOW_ERROR;
+ }
- gst_buffer_unref (buf);
+ gst_buffer_unref (buf);
- goto leave;
- }
+ goto leave;
+ }
}
static gboolean
-pad_event (GstPad *pad,
- GstEvent *event)
+pad_event (GstPad * pad, GstEvent * event)
{
- GstOmxBaseFilter *self;
- GOmxCore *gomx;
- GOmxPort *in_port;
- gboolean ret = TRUE;
-
- self = GST_OMX_BASE_FILTER (GST_OBJECT_PARENT (pad));
- gomx = self->gomx;
- in_port = self->in_port;
-
- GST_LOG_OBJECT (self, "begin");
+ GstOmxBaseFilter *self;
+ GOmxCore *gomx;
+ GOmxPort *in_port;
+ gboolean ret = TRUE;
+
+ self = GST_OMX_BASE_FILTER (GST_OBJECT_PARENT (pad));
+ gomx = self->gomx;
+ in_port = self->in_port;
+
+ GST_LOG_OBJECT (self, "begin");
+
+ GST_INFO_OBJECT (self, "event: %s", GST_EVENT_TYPE_NAME (event));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ /* if we are init'ed, and there is a running loop; then
+ * if we get a buffer to inform it of EOS, let it handle the rest
+ * in any other case, we send EOS */
+ if (self->ready && self->last_pad_push_return == GST_FLOW_OK) {
+ /* send buffer with eos flag */
+ /** @todo move to util */
+ {
+ OMX_BUFFERHEADERTYPE *omx_buffer;
- GST_INFO_OBJECT (self, "event: %s", GST_EVENT_TYPE_NAME (event));
+ GST_LOG_OBJECT (self, "request buffer");
+ omx_buffer = g_omx_port_request_buffer (in_port);
- switch (GST_EVENT_TYPE (event))
- {
- case GST_EVENT_EOS:
- /* if we are init'ed, and there is a running loop; then
- * if we get a buffer to inform it of EOS, let it handle the rest
- * in any other case, we send EOS */
- if (self->ready && self->last_pad_push_return == GST_FLOW_OK)
- {
- /* send buffer with eos flag */
- /** @todo move to util */
- {
- OMX_BUFFERHEADERTYPE *omx_buffer;
-
- GST_LOG_OBJECT (self, "request buffer");
- omx_buffer = g_omx_port_request_buffer (in_port);
-
- if (G_LIKELY (omx_buffer))
- {
- omx_buffer->nFlags |= OMX_BUFFERFLAG_EOS;
-
- GST_LOG_OBJECT (self, "release_buffer");
- /* foo_buffer_untaint (omx_buffer); */
- g_omx_port_release_buffer (in_port, omx_buffer);
- /* loop handles EOS, eat it here */
- gst_event_unref (event);
- break;
- }
- }
- }
+ if (G_LIKELY (omx_buffer)) {
+ omx_buffer->nFlags |= OMX_BUFFERFLAG_EOS;
- /* we tried, but it's up to us here */
- ret = gst_pad_push_event (self->srcpad, event);
+ GST_LOG_OBJECT (self, "release_buffer");
+ /* foo_buffer_untaint (omx_buffer); */
+ g_omx_port_release_buffer (in_port, omx_buffer);
+ /* loop handles EOS, eat it here */
+ gst_event_unref (event);
break;
+ }
+ }
+ }
- case GST_EVENT_FLUSH_START:
- gst_pad_push_event (self->srcpad, event);
- self->last_pad_push_return = GST_FLOW_WRONG_STATE;
+ /* we tried, but it's up to us here */
+ ret = gst_pad_push_event (self->srcpad, event);
+ break;
- g_omx_core_flush_start (gomx);
+ case GST_EVENT_FLUSH_START:
+ gst_pad_push_event (self->srcpad, event);
+ self->last_pad_push_return = GST_FLOW_WRONG_STATE;
- gst_pad_pause_task (self->srcpad);
+ g_omx_core_flush_start (gomx);
- ret = TRUE;
- break;
+ gst_pad_pause_task (self->srcpad);
- case GST_EVENT_FLUSH_STOP:
- gst_pad_push_event (self->srcpad, event);
- self->last_pad_push_return = GST_FLOW_OK;
+ ret = TRUE;
+ break;
- g_omx_core_flush_stop (gomx);
+ case GST_EVENT_FLUSH_STOP:
+ gst_pad_push_event (self->srcpad, event);
+ self->last_pad_push_return = GST_FLOW_OK;
- if (self->ready)
- gst_pad_start_task (self->srcpad, output_loop, self->srcpad);
+ g_omx_core_flush_stop (gomx);
- ret = TRUE;
- break;
+ if (self->ready)
+ gst_pad_start_task (self->srcpad, output_loop, self->srcpad);
- case GST_EVENT_NEWSEGMENT:
- ret = gst_pad_push_event (self->srcpad, event);
- break;
+ ret = TRUE;
+ break;
- default:
- ret = gst_pad_push_event (self->srcpad, event);
- break;
- }
+ case GST_EVENT_NEWSEGMENT:
+ ret = gst_pad_push_event (self->srcpad, event);
+ break;
- GST_LOG_OBJECT (self, "end");
+ default:
+ ret = gst_pad_push_event (self->srcpad, event);
+ break;
+ }
- return ret;
+ GST_LOG_OBJECT (self, "end");
+
+ return ret;
}
static gboolean
-activate_push (GstPad *pad,
- gboolean active)
+activate_push (GstPad * pad, gboolean active)
{
- gboolean result = TRUE;
- GstOmxBaseFilter *self;
+ gboolean result = TRUE;
+ GstOmxBaseFilter *self;
- self = GST_OMX_BASE_FILTER (gst_pad_get_parent (pad));
+ self = GST_OMX_BASE_FILTER (gst_pad_get_parent (pad));
- if (active)
- {
- GST_DEBUG_OBJECT (self, "activate");
- /* task may carry on */
- g_atomic_int_set (&self->last_pad_push_return, GST_FLOW_OK);
+ if (active) {
+ GST_DEBUG_OBJECT (self, "activate");
+ /* task may carry on */
+ g_atomic_int_set (&self->last_pad_push_return, GST_FLOW_OK);
- /* we do not start the task yet if the pad is not connected */
- if (gst_pad_is_linked (pad))
- {
- if (self->ready)
- {
+ /* we do not start the task yet if the pad is not connected */
+ if (gst_pad_is_linked (pad)) {
+ if (self->ready) {
/** @todo link callback function also needed */
- g_omx_port_resume (self->in_port);
- g_omx_port_resume (self->out_port);
+ g_omx_port_resume (self->in_port);
+ g_omx_port_resume (self->out_port);
- result = gst_pad_start_task (pad, output_loop, pad);
- }
- }
+ result = gst_pad_start_task (pad, output_loop, pad);
+ }
}
- else
- {
- GST_DEBUG_OBJECT (self, "deactivate");
+ } else {
+ GST_DEBUG_OBJECT (self, "deactivate");
- /* persuade task to bail out */
- g_atomic_int_set (&self->last_pad_push_return, GST_FLOW_WRONG_STATE);
+ /* persuade task to bail out */
+ g_atomic_int_set (&self->last_pad_push_return, GST_FLOW_WRONG_STATE);
- if (self->ready)
- {
+ if (self->ready) {
/** @todo disable this until we properly reinitialize the buffers. */
#if 0
- /* flush all buffers */
- OMX_SendCommand (self->gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
+ /* flush all buffers */
+ OMX_SendCommand (self->gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
#endif
- /* unlock loops */
- g_omx_port_pause (self->in_port);
- g_omx_port_pause (self->out_port);
- }
-
- /* make sure streaming finishes */
- result = gst_pad_stop_task (pad);
+ /* unlock loops */
+ g_omx_port_pause (self->in_port);
+ g_omx_port_pause (self->out_port);
}
- gst_object_unref (self);
+ /* make sure streaming finishes */
+ result = gst_pad_stop_task (pad);
+ }
+
+ gst_object_unref (self);
- return result;
+ return result;
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *self;
- GstElementClass *element_class;
+ GstOmxBaseFilter *self;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- self = GST_OMX_BASE_FILTER (instance);
+ self = GST_OMX_BASE_FILTER (instance);
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- self->use_timestamps = TRUE;
+ self->use_timestamps = TRUE;
- self->gomx = gstomx_core_new (self, G_TYPE_FROM_CLASS (g_class));
- self->in_port = g_omx_core_new_port (self->gomx, 0);
- self->out_port = g_omx_core_new_port (self->gomx, 1);
+ self->gomx = gstomx_core_new (self, G_TYPE_FROM_CLASS (g_class));
+ self->in_port = g_omx_core_new_port (self->gomx, 0);
+ self->out_port = g_omx_core_new_port (self->gomx, 1);
- self->ready_lock = g_mutex_new ();
+ self->ready_lock = g_mutex_new ();
- self->sinkpad =
- gst_pad_new_from_template (gst_element_class_get_pad_template (element_class, "sink"), "sink");
+ self->sinkpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template
+ (element_class, "sink"), "sink");
- gst_pad_set_chain_function (self->sinkpad, pad_chain);
- gst_pad_set_event_function (self->sinkpad, pad_event);
+ gst_pad_set_chain_function (self->sinkpad, pad_chain);
+ gst_pad_set_event_function (self->sinkpad, pad_event);
- self->srcpad =
- gst_pad_new_from_template (gst_element_class_get_pad_template (element_class, "src"), "src");
+ self->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template
+ (element_class, "src"), "src");
- gst_pad_set_activatepush_function (self->srcpad, activate_push);
+ gst_pad_set_activatepush_function (self->srcpad, activate_push);
- gst_pad_use_fixed_caps (self->srcpad);
+ gst_pad_use_fixed_caps (self->srcpad);
- gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
- gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
+ gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
}
static void
-omx_interface_init (GstImplementsInterfaceClass *klass)
+omx_interface_init (GstImplementsInterfaceClass * klass)
{
}
static gboolean
-interface_supported (GstImplementsInterface *iface,
- GType type)
+interface_supported (GstImplementsInterface * iface, GType type)
{
- g_assert (type == GST_TYPE_OMX);
- return TRUE;
+ g_assert (type == GST_TYPE_OMX);
+ return TRUE;
}
static void
-interface_init (GstImplementsInterfaceClass *klass)
+interface_init (GstImplementsInterfaceClass * klass)
{
- klass->supported = interface_supported;
+ klass->supported = interface_supported;
}
static void
init_interfaces (GType type)
{
- GInterfaceInfo *iface_info;
- GInterfaceInfo *omx_info;
+ GInterfaceInfo *iface_info;
+ GInterfaceInfo *omx_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);
+ g_type_add_interface_static (type, GST_TYPE_OMX, omx_info);
+ g_free (omx_info);
}
diff --git a/omx/gstomx_base_filter.h b/omx/gstomx_base_filter.h
index 99b5d72..76040aa 100644
--- a/omx/gstomx_base_filter.h
+++ b/omx/gstomx_base_filter.h
@@ -25,49 +25,46 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_BASE_FILTER(obj) (GstOmxBaseFilter *) (obj)
#define GST_OMX_BASE_FILTER_TYPE (gst_omx_base_filter_get_type ())
#define GST_OMX_BASE_FILTER_CLASS(obj) (GstOmxBaseFilterClass *) (obj)
-
typedef struct GstOmxBaseFilter GstOmxBaseFilter;
typedef struct GstOmxBaseFilterClass GstOmxBaseFilterClass;
-typedef void (*GstOmxBaseFilterCb) (GstOmxBaseFilter *self);
+typedef void (*GstOmxBaseFilterCb) (GstOmxBaseFilter * self);
#include "gstomx_util.h"
#include <async_queue.h>
struct GstOmxBaseFilter
{
- GstElement element;
+ GstElement element;
- GstPad *sinkpad;
- GstPad *srcpad;
+ GstPad *sinkpad;
+ GstPad *srcpad;
- GOmxCore *gomx;
- GOmxPort *in_port;
- GOmxPort *out_port;
+ GOmxCore *gomx;
+ GOmxPort *in_port;
+ GOmxPort *out_port;
- gboolean use_timestamps; /** @todo remove; timestamps should always be used */
- gboolean ready;
- GMutex *ready_lock;
+ gboolean use_timestamps; /** @todo remove; timestamps should always be used */
+ gboolean ready;
+ GMutex *ready_lock;
- GstOmxBaseFilterCb omx_setup;
- GstFlowReturn last_pad_push_return;
- GstBuffer *codec_data;
+ GstOmxBaseFilterCb omx_setup;
+ GstFlowReturn last_pad_push_return;
+ GstBuffer *codec_data;
/** @todo these are hacks, OpenMAX IL spec should be revised. */
- gboolean share_input_buffer;
- gboolean share_output_buffer;
+ gboolean share_input_buffer;
+ gboolean share_output_buffer;
};
struct GstOmxBaseFilterClass
{
- GstElementClass parent_class;
+ GstElementClass parent_class;
};
GType gst_omx_base_filter_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_BASE_FILTER_H */
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 66e32d6..9c2d40b 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -26,337 +26,309 @@
#include "gstomx.h"
#include "gstomx_interface.h"
-#include <string.h> /* for memcpy */
+#include <string.h> /* for memcpy */
enum
{
- ARG_NUM_INPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
+ ARG_NUM_INPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
};
static gboolean share_input_buffer;
-static inline gboolean omx_init (GstOmxBaseSink *self);
+static inline gboolean omx_init (GstOmxBaseSink * self);
static void init_interfaces (GType type);
-GSTOMX_BOILERPLATE_FULL (GstOmxBaseSink, gst_omx_base_sink, GstBaseSink, GST_TYPE_BASE_SINK, init_interfaces);
+GSTOMX_BOILERPLATE_FULL (GstOmxBaseSink, gst_omx_base_sink, GstBaseSink,
+ GST_TYPE_BASE_SINK, init_interfaces);
static void
-setup_ports (GstOmxBaseSink *self)
+setup_ports (GstOmxBaseSink * self)
{
- /* Input port configuration. */
- g_omx_port_setup (self->in_port);
- gst_pad_set_element_private (self->sinkpad, self->in_port);
+ /* Input port configuration. */
+ g_omx_port_setup (self->in_port);
+ gst_pad_set_element_private (self->sinkpad, self->in_port);
}
static GstStateChangeReturn
-change_state (GstElement *element,
- GstStateChange transition)
+change_state (GstElement * element, GstStateChange transition)
{
- GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
- GstOmxBaseSink *self;
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GstOmxBaseSink *self;
- self = GST_OMX_BASE_SINK (element);
+ self = GST_OMX_BASE_SINK (element);
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- GST_INFO_OBJECT (self, "changing state %s - %s",
- gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
- gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
+ GST_INFO_OBJECT (self, "changing state %s - %s",
+ gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
+ gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
- switch (transition)
- {
- case GST_STATE_CHANGE_NULL_TO_READY:
- if (!self->initialized)
- {
- if (!omx_init (self))
- return GST_PAD_LINK_REFUSED;
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ if (!self->initialized) {
+ if (!omx_init (self))
+ return GST_PAD_LINK_REFUSED;
- self->initialized = TRUE;
- }
+ self->initialized = TRUE;
+ }
- g_omx_core_prepare (self->gomx);
- break;
+ g_omx_core_prepare (self->gomx);
+ break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- g_omx_core_start (self->gomx);
- break;
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ g_omx_core_start (self->gomx);
+ break;
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- g_omx_port_finish (self->in_port);
- break;
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ g_omx_port_finish (self->in_port);
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (ret == GST_STATE_CHANGE_FAILURE)
- goto leave;
+ if (ret == GST_STATE_CHANGE_FAILURE)
+ goto leave;
- switch (transition)
- {
- case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
- g_omx_port_pause (self->in_port);
- break;
+ switch (transition) {
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+ g_omx_port_pause (self->in_port);
+ break;
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- g_omx_core_stop (self->gomx);
- break;
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ g_omx_core_stop (self->gomx);
+ break;
- case GST_STATE_CHANGE_READY_TO_NULL:
- g_omx_core_unload (self->gomx);
- break;
+ case GST_STATE_CHANGE_READY_TO_NULL:
+ g_omx_core_unload (self->gomx);
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
leave:
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return ret;
+ return ret;
}
static void
-finalize (GObject *obj)
+finalize (GObject * obj)
{
- GstOmxBaseSink *self;
+ GstOmxBaseSink *self;
- self = GST_OMX_BASE_SINK (obj);
+ self = GST_OMX_BASE_SINK (obj);
- g_omx_core_free (self->gomx);
+ g_omx_core_free (self->gomx);
- G_OBJECT_CLASS (parent_class)->finalize (obj);
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
}
static GstFlowReturn
-render (GstBaseSink *gst_base,
- GstBuffer *buf)
+render (GstBaseSink * gst_base, GstBuffer * buf)
{
- GOmxCore *gomx;
- GOmxPort *in_port;
- GstOmxBaseSink *self;
- GstFlowReturn ret = GST_FLOW_OK;
+ GOmxCore *gomx;
+ GOmxPort *in_port;
+ GstOmxBaseSink *self;
+ GstFlowReturn ret = GST_FLOW_OK;
- self = GST_OMX_BASE_SINK (gst_base);
+ self = GST_OMX_BASE_SINK (gst_base);
- gomx = self->gomx;
+ gomx = self->gomx;
- GST_LOG_OBJECT (self, "begin");
- GST_LOG_OBJECT (self, "gst_buffer: size=%u", GST_BUFFER_SIZE (buf));
+ GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "gst_buffer: size=%u", GST_BUFFER_SIZE (buf));
- GST_LOG_OBJECT (self, "state: %d", gomx->omx_state);
+ GST_LOG_OBJECT (self, "state: %d", gomx->omx_state);
- in_port = self->in_port;
+ in_port = self->in_port;
- if (G_LIKELY (in_port->enabled))
- {
- guint buffer_offset = 0;
-
- while (G_LIKELY (buffer_offset < GST_BUFFER_SIZE (buf)))
- {
- OMX_BUFFERHEADERTYPE *omx_buffer;
-
- GST_LOG_OBJECT (self, "request_buffer");
- omx_buffer = g_omx_port_request_buffer (in_port);
-
- if (G_LIKELY (omx_buffer))
- {
- GST_DEBUG_OBJECT (self, "omx_buffer: 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);
-
- if (omx_buffer->nOffset == 0 &&
- share_input_buffer)
- {
- {
- GstBuffer *old_buf;
- old_buf = omx_buffer->pAppPrivate;
-
- if (old_buf)
- {
- gst_buffer_unref (old_buf);
- }
- else if (omx_buffer->pBuffer)
- {
- g_free (omx_buffer->pBuffer);
- }
- }
-
- /* We are going to use this. */
- gst_buffer_ref (buf);
-
- omx_buffer->pBuffer = GST_BUFFER_DATA (buf);
- omx_buffer->nAllocLen = GST_BUFFER_SIZE (buf);
- omx_buffer->nFilledLen = GST_BUFFER_SIZE (buf);
- omx_buffer->pAppPrivate = buf;
- }
- else
- {
- omx_buffer->nFilledLen = MIN (GST_BUFFER_SIZE (buf) - buffer_offset,
- omx_buffer->nAllocLen - omx_buffer->nOffset);
- memcpy (omx_buffer->pBuffer + omx_buffer->nOffset, GST_BUFFER_DATA (buf) + buffer_offset, omx_buffer->nFilledLen);
- }
-
- GST_LOG_OBJECT (self, "release_buffer");
- g_omx_port_release_buffer (in_port, omx_buffer);
-
- buffer_offset += omx_buffer->nFilledLen;
- }
- else
- {
- GST_WARNING_OBJECT (self, "null buffer");
- ret = GST_FLOW_UNEXPECTED;
- break;
+ if (G_LIKELY (in_port->enabled)) {
+ guint buffer_offset = 0;
+
+ while (G_LIKELY (buffer_offset < GST_BUFFER_SIZE (buf))) {
+ OMX_BUFFERHEADERTYPE *omx_buffer;
+
+ GST_LOG_OBJECT (self, "request_buffer");
+ omx_buffer = g_omx_port_request_buffer (in_port);
+
+ if (G_LIKELY (omx_buffer)) {
+ GST_DEBUG_OBJECT (self,
+ "omx_buffer: 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);
+
+ if (omx_buffer->nOffset == 0 && share_input_buffer) {
+ {
+ GstBuffer *old_buf;
+ old_buf = omx_buffer->pAppPrivate;
+
+ if (old_buf) {
+ gst_buffer_unref (old_buf);
+ } else if (omx_buffer->pBuffer) {
+ g_free (omx_buffer->pBuffer);
}
+ }
+
+ /* We are going to use this. */
+ gst_buffer_ref (buf);
+
+ omx_buffer->pBuffer = GST_BUFFER_DATA (buf);
+ omx_buffer->nAllocLen = GST_BUFFER_SIZE (buf);
+ omx_buffer->nFilledLen = GST_BUFFER_SIZE (buf);
+ omx_buffer->pAppPrivate = buf;
+ } else {
+ omx_buffer->nFilledLen = MIN (GST_BUFFER_SIZE (buf) - buffer_offset,
+ omx_buffer->nAllocLen - omx_buffer->nOffset);
+ memcpy (omx_buffer->pBuffer + omx_buffer->nOffset,
+ GST_BUFFER_DATA (buf) + buffer_offset, omx_buffer->nFilledLen);
}
- }
- else
- {
- GST_WARNING_OBJECT (self, "done");
+
+ GST_LOG_OBJECT (self, "release_buffer");
+ g_omx_port_release_buffer (in_port, omx_buffer);
+
+ buffer_offset += omx_buffer->nFilledLen;
+ } else {
+ GST_WARNING_OBJECT (self, "null buffer");
ret = GST_FLOW_UNEXPECTED;
+ break;
+ }
}
+ } else {
+ GST_WARNING_OBJECT (self, "done");
+ ret = GST_FLOW_UNEXPECTED;
+ }
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return ret;
+ return ret;
}
static gboolean
-handle_event (GstBaseSink *gst_base,
- GstEvent *event)
+handle_event (GstBaseSink * gst_base, GstEvent * event)
{
- GstOmxBaseSink *self;
- GOmxCore *gomx;
- GOmxPort *in_port;
+ GstOmxBaseSink *self;
+ GOmxCore *gomx;
+ GOmxPort *in_port;
- self = GST_OMX_BASE_SINK (gst_base);
- gomx = self->gomx;
- in_port = self->in_port;
+ self = GST_OMX_BASE_SINK (gst_base);
+ gomx = self->gomx;
+ in_port = self->in_port;
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- GST_DEBUG_OBJECT (self, "event: %s", GST_EVENT_TYPE_NAME (event));
+ GST_DEBUG_OBJECT (self, "event: %s", GST_EVENT_TYPE_NAME (event));
- switch (GST_EVENT_TYPE (event))
- {
- case GST_EVENT_EOS:
- /* Close the inpurt port. */
- g_omx_core_set_done (gomx);
- break;
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ /* Close the inpurt port. */
+ g_omx_core_set_done (gomx);
+ break;
- case GST_EVENT_FLUSH_START:
- /* unlock loops */
- g_omx_port_pause (in_port);
+ case GST_EVENT_FLUSH_START:
+ /* unlock loops */
+ g_omx_port_pause (in_port);
- /* flush all buffers */
- OMX_SendCommand (gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
- break;
+ /* flush all buffers */
+ OMX_SendCommand (gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
+ break;
- case GST_EVENT_FLUSH_STOP:
- g_sem_down (gomx->flush_sem);
+ case GST_EVENT_FLUSH_STOP:
+ g_sem_down (gomx->flush_sem);
- g_omx_port_resume (in_port);
- break;
+ g_omx_port_resume (in_port);
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return TRUE;
+ return TRUE;
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxBaseSink *self;
+ GstOmxBaseSink *self;
- self = GST_OMX_BASE_SINK (obj);
+ self = GST_OMX_BASE_SINK (obj);
- switch (prop_id)
+ switch (prop_id) {
+ case ARG_NUM_INPUT_BUFFERS:
{
- case ARG_NUM_INPUT_BUFFERS:
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
- OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
- OMX_U32 nBufferCountActual;
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ OMX_U32 nBufferCountActual;
- if (G_UNLIKELY (!omx_handle))
- {
- GST_WARNING_OBJECT (self, "no component");
- break;
- }
+ if (G_UNLIKELY (!omx_handle)) {
+ GST_WARNING_OBJECT (self, "no component");
+ break;
+ }
- nBufferCountActual = g_value_get_uint (value);
+ nBufferCountActual = g_value_get_uint (value);
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = self->in_port->port_index;
- OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
+ param.nPortIndex = self->in_port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
- if (nBufferCountActual < param.nBufferCountMin)
- {
- GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
- nBufferCountActual, param.nBufferCountMin);
- return;
- }
+ if (nBufferCountActual < param.nBufferCountMin) {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
- param.nBufferCountActual = nBufferCountActual;
+ param.nBufferCountActual = nBufferCountActual;
- OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
+ OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
}
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxBaseSink *self;
+ GstOmxBaseSink *self;
- self = GST_OMX_BASE_SINK (obj);
+ self = GST_OMX_BASE_SINK (obj);
- if (gstomx_get_property_helper (self->gomx, prop_id, value))
- return;
+ if (gstomx_get_property_helper (self->gomx, prop_id, value))
+ return;
- switch (prop_id)
+ switch (prop_id) {
+ case ARG_NUM_INPUT_BUFFERS:
{
- case ARG_NUM_INPUT_BUFFERS:
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
- OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
- if (G_UNLIKELY (!omx_handle))
- {
- GST_WARNING_OBJECT (self, "no component");
- g_value_set_uint (value, 0);
- break;
- }
+ if (G_UNLIKELY (!omx_handle)) {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ break;
+ }
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = self->in_port->port_index;
- OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
+ param.nPortIndex = self->in_port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
- g_value_set_uint (value, param.nBufferCountActual);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
+ g_value_set_uint (value, param.nBufferCountActual);
}
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
@@ -365,169 +337,160 @@ type_base_init (gpointer g_class)
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
- GstBaseSinkClass *gst_base_sink_class;
- GstElementClass *gstelement_class;
+ GObjectClass *gobject_class;
+ GstBaseSinkClass *gst_base_sink_class;
+ GstElementClass *gstelement_class;
- gobject_class = G_OBJECT_CLASS (g_class);
- gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
- gstelement_class = GST_ELEMENT_CLASS (g_class);
+ gobject_class = G_OBJECT_CLASS (g_class);
+ gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
+ gstelement_class = GST_ELEMENT_CLASS (g_class);
- gobject_class->finalize = finalize;
+ gobject_class->finalize = finalize;
- gstelement_class->change_state = change_state;
+ gstelement_class->change_state = change_state;
- gst_base_sink_class->event = handle_event;
- gst_base_sink_class->preroll = render;
- gst_base_sink_class->render = render;
+ gst_base_sink_class->event = handle_event;
+ gst_base_sink_class->preroll = render;
+ gst_base_sink_class->render = render;
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
- gstomx_install_property_helper (gobject_class);
+ gstomx_install_property_helper (gobject_class);
- g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
- g_param_spec_uint ("input-buffers", "Input buffers",
- "The number of OMX input buffers",
- 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ g_object_class_install_property (gobject_class, ARG_NUM_INPUT_BUFFERS,
+ g_param_spec_uint ("input-buffers", "Input buffers",
+ "The number of OMX input buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static gboolean
-activate_push (GstPad *pad,
- gboolean active)
+activate_push (GstPad * pad, gboolean active)
{
- gboolean result = TRUE;
- GstOmxBaseSink *self;
+ gboolean result = TRUE;
+ GstOmxBaseSink *self;
- self = GST_OMX_BASE_SINK (gst_pad_get_parent (pad));
+ self = GST_OMX_BASE_SINK (gst_pad_get_parent (pad));
- if (active)
- {
- GST_DEBUG_OBJECT (self, "activate");
+ if (active) {
+ GST_DEBUG_OBJECT (self, "activate");
- /* we do not start the task yet if the pad is not connected */
- if (gst_pad_is_linked (pad))
- {
+ /* we do not start the task yet if the pad is not connected */
+ if (gst_pad_is_linked (pad)) {
/** @todo link callback function also needed */
- g_omx_port_resume (self->in_port);
- }
+ g_omx_port_resume (self->in_port);
}
- else
- {
- GST_DEBUG_OBJECT (self, "deactivate");
+ } else {
+ GST_DEBUG_OBJECT (self, "deactivate");
/** @todo disable this until we properly reinitialize the buffers. */
#if 0
- /* flush all buffers */
- OMX_SendCommand (self->gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
+ /* flush all buffers */
+ OMX_SendCommand (self->gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
#endif
- /* unlock loops */
- g_omx_port_pause (self->in_port);
- }
+ /* unlock loops */
+ g_omx_port_pause (self->in_port);
+ }
- gst_object_unref (self);
+ gst_object_unref (self);
- if (result)
- result = self->base_activatepush (pad, active);
+ if (result)
+ result = self->base_activatepush (pad, active);
- return result;
+ return result;
}
static inline gboolean
-omx_init (GstOmxBaseSink *self)
+omx_init (GstOmxBaseSink * self)
{
- if (self->gomx->omx_error)
- return FALSE;
+ if (self->gomx->omx_error)
+ return FALSE;
- setup_ports (self);
+ setup_ports (self);
- return TRUE;
+ return TRUE;
}
static GstPadLinkReturn
-pad_sink_link (GstPad *pad,
- GstPad *peer)
+pad_sink_link (GstPad * pad, GstPad * peer)
{
- GstOmxBaseSink *self;
+ GstOmxBaseSink *self;
- self = GST_OMX_BASE_SINK (GST_OBJECT_PARENT (pad));
+ self = GST_OMX_BASE_SINK (GST_OBJECT_PARENT (pad));
- GST_INFO_OBJECT (self, "link");
+ GST_INFO_OBJECT (self, "link");
- if (!self->initialized)
- {
- if (!omx_init (self))
- return GST_PAD_LINK_REFUSED;
- self->initialized = TRUE;
- }
+ if (!self->initialized) {
+ if (!omx_init (self))
+ return GST_PAD_LINK_REFUSED;
+ self->initialized = TRUE;
+ }
- return GST_PAD_LINK_OK;
+ return GST_PAD_LINK_OK;
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseSink *self;
+ GstOmxBaseSink *self;
- self = GST_OMX_BASE_SINK (instance);
+ self = GST_OMX_BASE_SINK (instance);
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- self->gomx = gstomx_core_new (self, G_TYPE_FROM_CLASS (g_class));
- self->in_port = g_omx_core_new_port (self->gomx, 0);
+ self->gomx = gstomx_core_new (self, G_TYPE_FROM_CLASS (g_class));
+ self->in_port = g_omx_core_new_port (self->gomx, 0);
- {
- GstPad *sinkpad;
- self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
- self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
- gst_pad_set_activatepush_function (sinkpad, activate_push);
- gst_pad_set_link_function (sinkpad, pad_sink_link);
- }
+ {
+ GstPad *sinkpad;
+ self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
+ self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
+ gst_pad_set_activatepush_function (sinkpad, activate_push);
+ gst_pad_set_link_function (sinkpad, pad_sink_link);
+ }
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
}
static void
-omx_interface_init (GstImplementsInterfaceClass *klass)
+omx_interface_init (GstImplementsInterfaceClass * klass)
{
}
static gboolean
-interface_supported (GstImplementsInterface *iface,
- GType type)
+interface_supported (GstImplementsInterface * iface, GType type)
{
- g_assert (type == GST_TYPE_OMX);
- return TRUE;
+ g_assert (type == GST_TYPE_OMX);
+ return TRUE;
}
static void
-interface_init (GstImplementsInterfaceClass *klass)
+interface_init (GstImplementsInterfaceClass * klass)
{
- klass->supported = interface_supported;
+ klass->supported = interface_supported;
}
+
static void
init_interfaces (GType type)
{
- GInterfaceInfo *iface_info;
- GInterfaceInfo *omx_info;
+ GInterfaceInfo *iface_info;
+ GInterfaceInfo *omx_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);
+ g_type_add_interface_static (type, GST_TYPE_OMX, omx_info);
+ g_free (omx_info);
}
diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
index 589c441..ad5db49 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -26,38 +26,35 @@
#include <gst/base/gstbasesink.h>
G_BEGIN_DECLS
-
#define GST_OMX_BASE_SINK(obj) (GstOmxBaseSink *) (obj)
#define GST_OMX_BASE_SINK_TYPE (gst_omx_base_sink_get_type ())
#define GST_OMX_BASE_SINK_CLASS(obj) (GstOmxBaseSinkClass *) (obj)
-
typedef struct GstOmxBaseSink GstOmxBaseSink;
typedef struct GstOmxBaseSinkClass GstOmxBaseSinkClass;
-typedef void (*GstOmxBaseSinkCb) (GstOmxBaseSink *self);
+typedef void (*GstOmxBaseSinkCb) (GstOmxBaseSink * self);
#include <gstomx_util.h>
struct GstOmxBaseSink
{
- GstBaseSink element;
+ GstBaseSink element;
- GstPad *sinkpad;
+ GstPad *sinkpad;
- GOmxCore *gomx;
- GOmxPort *in_port;
+ GOmxCore *gomx;
+ GOmxPort *in_port;
- gboolean ready;
- GstPadActivateModeFunction base_activatepush;
- gboolean initialized;
+ gboolean ready;
+ GstPadActivateModeFunction base_activatepush;
+ gboolean initialized;
};
struct GstOmxBaseSinkClass
{
- GstBaseSinkClass parent_class;
+ GstBaseSinkClass parent_class;
};
GType gst_omx_base_sink_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_BASE_SINK_H */
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index 37b29f9..b83a52d 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -22,402 +22,362 @@
#include "gstomx_base_src.h"
#include "gstomx.h"
-#include <string.h> /* for memcpy */
+#include <string.h> /* for memcpy */
enum
{
- ARG_NUM_OUTPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
+ ARG_NUM_OUTPUT_BUFFERS = GSTOMX_NUM_COMMON_PROP,
};
-GSTOMX_BOILERPLATE (GstOmxBaseSrc, gst_omx_base_src, GstBaseSrc, GST_TYPE_BASE_SRC);
+GSTOMX_BOILERPLATE (GstOmxBaseSrc, gst_omx_base_src, GstBaseSrc,
+ GST_TYPE_BASE_SRC);
static void
-setup_ports (GstOmxBaseSrc *self)
+setup_ports (GstOmxBaseSrc * self)
{
- /* Input port configuration. */
- g_omx_port_setup (self->out_port);
+ /* Input port configuration. */
+ g_omx_port_setup (self->out_port);
- if (self->setup_ports)
- {
- self->setup_ports (self);
- }
+ if (self->setup_ports) {
+ self->setup_ports (self);
+ }
}
static gboolean
-start (GstBaseSrc *gst_base)
+start (GstBaseSrc * gst_base)
{
- GstOmxBaseSrc *self;
+ GstOmxBaseSrc *self;
- self = GST_OMX_BASE_SRC (gst_base);
+ self = GST_OMX_BASE_SRC (gst_base);
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- if (self->gomx->omx_error)
- return GST_STATE_CHANGE_FAILURE;
+ if (self->gomx->omx_error)
+ return GST_STATE_CHANGE_FAILURE;
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return TRUE;
+ return TRUE;
}
static gboolean
-stop (GstBaseSrc *gst_base)
+stop (GstBaseSrc * gst_base)
{
- GstOmxBaseSrc *self;
+ GstOmxBaseSrc *self;
- self = GST_OMX_BASE_SRC (gst_base);
+ self = GST_OMX_BASE_SRC (gst_base);
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- g_omx_core_stop (self->gomx);
- g_omx_core_unload (self->gomx);
+ g_omx_core_stop (self->gomx);
+ g_omx_core_unload (self->gomx);
- if (self->gomx->omx_error)
- return GST_STATE_CHANGE_FAILURE;
+ if (self->gomx->omx_error)
+ return GST_STATE_CHANGE_FAILURE;
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return TRUE;
+ return TRUE;
}
static void
-finalize (GObject *obj)
+finalize (GObject * obj)
{
- GstOmxBaseSrc *self;
+ GstOmxBaseSrc *self;
- self = GST_OMX_BASE_SRC (obj);
+ self = GST_OMX_BASE_SRC (obj);
- g_omx_core_free (self->gomx);
+ g_omx_core_free (self->gomx);
- G_OBJECT_CLASS (parent_class)->finalize (obj);
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
}
static GstFlowReturn
-create (GstBaseSrc *gst_base,
- guint64 offset,
- guint length,
- GstBuffer **ret_buf)
+create (GstBaseSrc * gst_base,
+ guint64 offset, guint length, GstBuffer ** ret_buf)
{
- GOmxCore *gomx;
- GOmxPort *out_port;
- GstOmxBaseSrc *self;
- GstFlowReturn ret = GST_FLOW_OK;
+ GOmxCore *gomx;
+ GOmxPort *out_port;
+ GstOmxBaseSrc *self;
+ GstFlowReturn ret = GST_FLOW_OK;
- self = GST_OMX_BASE_SRC (gst_base);
+ self = GST_OMX_BASE_SRC (gst_base);
- gomx = self->gomx;
+ gomx = self->gomx;
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- GST_LOG_OBJECT (self, "state: %d", gomx->omx_state);
+ GST_LOG_OBJECT (self, "state: %d", gomx->omx_state);
- if (gomx->omx_state == OMX_StateLoaded)
- {
- GST_INFO_OBJECT (self, "omx: prepare");
+ if (gomx->omx_state == OMX_StateLoaded) {
+ GST_INFO_OBJECT (self, "omx: prepare");
- setup_ports (self);
- g_omx_core_prepare (self->gomx);
+ setup_ports (self);
+ g_omx_core_prepare (self->gomx);
+ }
+
+ out_port = self->out_port;
+
+ while (out_port->enabled) {
+ switch (gomx->omx_state) {
+ case OMX_StateIdle:
+ {
+ GST_INFO_OBJECT (self, "omx: play");
+ g_omx_core_start (gomx);
+ }
+ break;
+ default:
+ break;
}
- out_port = self->out_port;
+ switch (gomx->omx_state) {
+ case OMX_StateExecuting:
+ /* OK */
+ break;
+ default:
+ GST_ERROR_OBJECT (self, "Whoa! very wrong");
+ break;
+ }
- while (out_port->enabled)
{
- switch (gomx->omx_state)
- {
- case OMX_StateIdle:
- {
- GST_INFO_OBJECT (self, "omx: play");
- g_omx_core_start (gomx);
- }
- break;
- default:
- break;
- }
+ OMX_BUFFERHEADERTYPE *omx_buffer;
- switch (gomx->omx_state)
- {
- case OMX_StateExecuting:
- /* OK */
- break;
- default:
- GST_ERROR_OBJECT (self, "Whoa! very wrong");
- break;
- }
+ GST_LOG_OBJECT (self, "request_buffer");
+ omx_buffer = g_omx_port_request_buffer (out_port);
- {
- OMX_BUFFERHEADERTYPE *omx_buffer;
+ if (omx_buffer) {
+ GST_DEBUG_OBJECT (self, "omx_buffer: size=%lu, len=%lu, offset=%lu",
+ omx_buffer->nAllocLen, omx_buffer->nFilledLen, omx_buffer->nOffset);
- GST_LOG_OBJECT (self, "request_buffer");
- omx_buffer = g_omx_port_request_buffer (out_port);
+ if (omx_buffer->nFlags & OMX_BUFFERFLAG_EOS) {
+ GST_INFO_OBJECT (self, "got eos");
+ g_omx_core_set_done (gomx);
+ break;
+ }
- if (omx_buffer)
- {
- GST_DEBUG_OBJECT (self, "omx_buffer: size=%lu, len=%lu, offset=%lu",
- omx_buffer->nAllocLen, omx_buffer->nFilledLen, omx_buffer->nOffset);
+ if (omx_buffer->nFilledLen > 0) {
+ GstBuffer *buf;
- if (omx_buffer->nFlags & OMX_BUFFERFLAG_EOS)
- {
- GST_INFO_OBJECT (self, "got eos");
- g_omx_core_set_done (gomx);
- break;
- }
+ if (out_port->enabled) {
+ GstCaps *caps = NULL;
- if (omx_buffer->nFilledLen > 0)
- {
- GstBuffer *buf;
+ caps = gst_pad_get_negotiated_caps (gst_base->srcpad);
- if (out_port->enabled)
- {
- GstCaps *caps = NULL;
+ if (!caps) {
+ /** @todo We shouldn't be doing this. */
+ GST_WARNING_OBJECT (self, "somebody didn't do his work");
+ gomx->settings_changed_cb (gomx);
+ } else {
+ GST_LOG_OBJECT (self, "caps already fixed");
+ gst_caps_unref (caps);
+ }
+ }
- caps = gst_pad_get_negotiated_caps (gst_base->srcpad);
+ buf = omx_buffer->pAppPrivate;
- if (!caps)
- {
- /** @todo We shouldn't be doing this. */
- GST_WARNING_OBJECT (self, "somebody didn't do his work");
- gomx->settings_changed_cb (gomx);
- }
- else
- {
- GST_LOG_OBJECT (self, "caps already fixed");
- gst_caps_unref (caps);
- }
- }
-
- buf = omx_buffer->pAppPrivate;
-
- if (buf && !(omx_buffer->nFlags & OMX_BUFFERFLAG_EOS))
- {
- GST_BUFFER_SIZE (buf) = omx_buffer->nFilledLen;
+ if (buf && !(omx_buffer->nFlags & OMX_BUFFERFLAG_EOS)) {
+ GST_BUFFER_SIZE (buf) = omx_buffer->nFilledLen;
#if 0
- if (self->use_timestamps)
- {
- GST_BUFFER_TIMESTAMP (buf) = omx_buffer->nTimeStamp * (GST_SECOND / OMX_TICKS_PER_SECOND);
- }
+ if (self->use_timestamps) {
+ GST_BUFFER_TIMESTAMP (buf) =
+ omx_buffer->nTimeStamp * (GST_SECOND / OMX_TICKS_PER_SECOND);
+ }
#endif
- omx_buffer->pAppPrivate = NULL;
- omx_buffer->pBuffer = NULL;
- omx_buffer->nFilledLen = 0;
-
- *ret_buf = buf;
-
- gst_buffer_unref (buf);
- }
- else
- {
- /* This is only meant for the first OpenMAX buffers,
- * which need to be pre-allocated. */
- /* Also for the very last one. */
- gst_pad_alloc_buffer_and_set_caps (gst_base->srcpad,
- GST_BUFFER_OFFSET_NONE,
- omx_buffer->nFilledLen,
- GST_PAD_CAPS (gst_base->srcpad),
- &buf);
-
- if (buf)
- {
- GST_WARNING_OBJECT (self, "couldn't zero-copy");
- memcpy (GST_BUFFER_DATA (buf), omx_buffer->pBuffer + omx_buffer->nOffset, omx_buffer->nFilledLen);
+ omx_buffer->pAppPrivate = NULL;
+ omx_buffer->pBuffer = NULL;
+ omx_buffer->nFilledLen = 0;
+
+ *ret_buf = buf;
+
+ gst_buffer_unref (buf);
+ } else {
+ /* This is only meant for the first OpenMAX buffers,
+ * which need to be pre-allocated. */
+ /* Also for the very last one. */
+ gst_pad_alloc_buffer_and_set_caps (gst_base->srcpad,
+ GST_BUFFER_OFFSET_NONE,
+ omx_buffer->nFilledLen, GST_PAD_CAPS (gst_base->srcpad), &buf);
+
+ if (buf) {
+ GST_WARNING_OBJECT (self, "couldn't zero-copy");
+ memcpy (GST_BUFFER_DATA (buf),
+ omx_buffer->pBuffer + omx_buffer->nOffset,
+ omx_buffer->nFilledLen);
#if 0
- if (self->use_timestamps)
- {
- GST_BUFFER_TIMESTAMP (buf) = omx_buffer->nTimeStamp * (GST_SECOND / OMX_TICKS_PER_SECOND);
- }
+ if (self->use_timestamps) {
+ GST_BUFFER_TIMESTAMP (buf) =
+ omx_buffer->nTimeStamp * (GST_SECOND /
+ OMX_TICKS_PER_SECOND);
+ }
#endif
- omx_buffer->nFilledLen = 0;
- g_free (omx_buffer->pBuffer);
- omx_buffer->pBuffer = NULL;
-
- *ret_buf = buf;
- }
- else
- {
- GST_ERROR_OBJECT (self, "whoa!");
- }
- }
-
- if (!omx_buffer->pBuffer)
- {
- GstBuffer *new_buf;
- GstFlowReturn result;
-
- GST_LOG_OBJECT (self, "allocate buffer");
- result = gst_pad_alloc_buffer_and_set_caps (gst_base->srcpad,
- GST_BUFFER_OFFSET_NONE,
- omx_buffer->nAllocLen,
- GST_PAD_CAPS (gst_base->srcpad),
- &new_buf);
-
- if (result == GST_FLOW_OK)
- {
- gst_buffer_ref (new_buf);
- omx_buffer->pAppPrivate = new_buf;
-
- omx_buffer->pBuffer = GST_BUFFER_DATA (new_buf);
- omx_buffer->nAllocLen = GST_BUFFER_SIZE (new_buf);
- }
- else
- {
- GST_WARNING_OBJECT (self, "could not allocate buffer");
- omx_buffer->pBuffer = g_malloc (omx_buffer->nAllocLen);
- }
- }
-
- GST_LOG_OBJECT (self, "release_buffer");
- g_omx_port_release_buffer (out_port, omx_buffer);
- break;
- }
- else
- {
- GST_WARNING_OBJECT (self, "empty buffer");
- GST_LOG_OBJECT (self, "release_buffer");
- g_omx_port_release_buffer (out_port, omx_buffer);
- continue;
- }
+ omx_buffer->nFilledLen = 0;
+ g_free (omx_buffer->pBuffer);
+ omx_buffer->pBuffer = NULL;
+
+ *ret_buf = buf;
+ } else {
+ GST_ERROR_OBJECT (self, "whoa!");
}
- else
- {
- GST_WARNING_OBJECT (self, "null buffer");
- /* ret = GST_FLOW_ERROR; */
- break;
+ }
+
+ if (!omx_buffer->pBuffer) {
+ GstBuffer *new_buf;
+ GstFlowReturn result;
+
+ GST_LOG_OBJECT (self, "allocate buffer");
+ result = gst_pad_alloc_buffer_and_set_caps (gst_base->srcpad,
+ GST_BUFFER_OFFSET_NONE,
+ omx_buffer->nAllocLen,
+ GST_PAD_CAPS (gst_base->srcpad), &new_buf);
+
+ if (result == GST_FLOW_OK) {
+ gst_buffer_ref (new_buf);
+ omx_buffer->pAppPrivate = new_buf;
+
+ omx_buffer->pBuffer = GST_BUFFER_DATA (new_buf);
+ omx_buffer->nAllocLen = GST_BUFFER_SIZE (new_buf);
+ } else {
+ GST_WARNING_OBJECT (self, "could not allocate buffer");
+ omx_buffer->pBuffer = g_malloc (omx_buffer->nAllocLen);
}
+ }
+
+ GST_LOG_OBJECT (self, "release_buffer");
+ g_omx_port_release_buffer (out_port, omx_buffer);
+ break;
+ } else {
+ GST_WARNING_OBJECT (self, "empty buffer");
+ GST_LOG_OBJECT (self, "release_buffer");
+ g_omx_port_release_buffer (out_port, omx_buffer);
+ continue;
}
+ } else {
+ GST_WARNING_OBJECT (self, "null buffer");
+ /* ret = GST_FLOW_ERROR; */
+ break;
+ }
}
+ }
- if (!out_port->enabled)
- {
- GST_WARNING_OBJECT (self, "done");
- ret = GST_FLOW_UNEXPECTED;
- }
+ if (!out_port->enabled) {
+ GST_WARNING_OBJECT (self, "done");
+ ret = GST_FLOW_UNEXPECTED;
+ }
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return ret;
+ return ret;
}
static gboolean
-handle_event (GstBaseSrc *gst_base,
- GstEvent *event)
+handle_event (GstBaseSrc * gst_base, GstEvent * event)
{
- GstOmxBaseSrc *self;
+ GstOmxBaseSrc *self;
- self = GST_OMX_BASE_SRC (gst_base);
+ self = GST_OMX_BASE_SRC (gst_base);
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- GST_DEBUG_OBJECT (self, "event: %s", GST_EVENT_TYPE_NAME (event));
+ GST_DEBUG_OBJECT (self, "event: %s", GST_EVENT_TYPE_NAME (event));
- switch (GST_EVENT_TYPE (event))
- {
- case GST_EVENT_EOS:
- /* Close the output port. */
- g_omx_core_set_done (self->gomx);
- break;
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ /* Close the output port. */
+ g_omx_core_set_done (self->gomx);
+ break;
- case GST_EVENT_NEWSEGMENT:
- break;
+ case GST_EVENT_NEWSEGMENT:
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
- return TRUE;
+ return TRUE;
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxBaseSrc *self;
+ GstOmxBaseSrc *self;
- self = GST_OMX_BASE_SRC (obj);
+ self = GST_OMX_BASE_SRC (obj);
- switch (prop_id)
+ switch (prop_id) {
+ case ARG_NUM_OUTPUT_BUFFERS:
{
- case ARG_NUM_OUTPUT_BUFFERS:
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
- OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
- OMX_U32 nBufferCountActual;
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ OMX_U32 nBufferCountActual;
- if (G_UNLIKELY (omx_handle))
- {
- GST_WARNING_OBJECT (self, "no component");
- break;
- }
+ if (G_UNLIKELY (omx_handle)) {
+ GST_WARNING_OBJECT (self, "no component");
+ break;
+ }
- nBufferCountActual = g_value_get_uint (value);
+ nBufferCountActual = g_value_get_uint (value);
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = self->out_port->port_index;
- OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
+ param.nPortIndex = self->out_port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
- if (nBufferCountActual < param.nBufferCountMin)
- {
- GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
- nBufferCountActual, param.nBufferCountMin);
- return;
- }
+ if (nBufferCountActual < param.nBufferCountMin) {
+ GST_ERROR_OBJECT (self, "buffer count %lu is less than minimum %lu",
+ nBufferCountActual, param.nBufferCountMin);
+ return;
+ }
- param.nBufferCountActual = nBufferCountActual;
+ param.nBufferCountActual = nBufferCountActual;
- OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
+ OMX_SetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
}
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxBaseSrc *self;
+ GstOmxBaseSrc *self;
- self = GST_OMX_BASE_SRC (obj);
+ self = GST_OMX_BASE_SRC (obj);
- if (gstomx_get_property_helper (self->gomx, prop_id, value))
- return;
+ if (gstomx_get_property_helper (self->gomx, prop_id, value))
+ return;
- switch (prop_id)
+ switch (prop_id) {
+ case ARG_NUM_OUTPUT_BUFFERS:
{
- case ARG_NUM_OUTPUT_BUFFERS:
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
- OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ OMX_HANDLETYPE omx_handle = self->gomx->omx_handle;
- if (G_UNLIKELY (!omx_handle))
- {
- GST_WARNING_OBJECT (self, "no component");
- g_value_set_uint (value, 0);
- break;
- }
+ if (G_UNLIKELY (!omx_handle)) {
+ GST_WARNING_OBJECT (self, "no component");
+ g_value_set_uint (value, 0);
+ break;
+ }
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = self->out_port->port_index;
- OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
+ param.nPortIndex = self->out_port->port_index;
+ OMX_GetParameter (omx_handle, OMX_IndexParamPortDefinition, &param);
- g_value_set_uint (value, param.nBufferCountActual);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
+ g_value_set_uint (value, param.nBufferCountActual);
}
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
@@ -426,48 +386,46 @@ type_base_init (gpointer g_class)
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
- GstBaseSrcClass *gst_base_src_class;
+ GObjectClass *gobject_class;
+ GstBaseSrcClass *gst_base_src_class;
- gobject_class = G_OBJECT_CLASS (g_class);
- gst_base_src_class = GST_BASE_SRC_CLASS (g_class);
+ gobject_class = G_OBJECT_CLASS (g_class);
+ gst_base_src_class = GST_BASE_SRC_CLASS (g_class);
- gobject_class->finalize = finalize;
+ gobject_class->finalize = finalize;
- gst_base_src_class->start = start;
- gst_base_src_class->stop = stop;
- gst_base_src_class->event = handle_event;
- gst_base_src_class->create = create;
+ gst_base_src_class->start = start;
+ gst_base_src_class->stop = stop;
+ gst_base_src_class->event = handle_event;
+ gst_base_src_class->create = create;
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
- gstomx_install_property_helper (gobject_class);
+ gstomx_install_property_helper (gobject_class);
- g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
- g_param_spec_uint ("output-buffers", "Output buffers",
- "The number of OMX output buffers",
- 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ g_object_class_install_property (gobject_class, ARG_NUM_OUTPUT_BUFFERS,
+ g_param_spec_uint ("output-buffers", "Output buffers",
+ "The number of OMX output buffers",
+ 1, 10, 4, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseSrc *self;
+ GstOmxBaseSrc *self;
- self = GST_OMX_BASE_SRC (instance);
+ self = GST_OMX_BASE_SRC (instance);
- GST_LOG_OBJECT (self, "begin");
+ GST_LOG_OBJECT (self, "begin");
- self->gomx = gstomx_core_new (self, G_TYPE_FROM_CLASS (g_class));
- self->out_port = g_omx_core_new_port (self->gomx, 1);
+ self->gomx = gstomx_core_new (self, G_TYPE_FROM_CLASS (g_class));
+ self->out_port = g_omx_core_new_port (self->gomx, 1);
- GST_LOG_OBJECT (self, "end");
+ GST_LOG_OBJECT (self, "end");
}
diff --git a/omx/gstomx_base_src.h b/omx/gstomx_base_src.h
index adab894..11d5c30 100644
--- a/omx/gstomx_base_src.h
+++ b/omx/gstomx_base_src.h
@@ -26,34 +26,31 @@
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
-
#define GST_OMX_BASE_SRC(obj) (GstOmxBaseSrc *) (obj)
#define GST_OMX_BASE_SRC_TYPE (gst_omx_base_src_get_type ())
#define GST_OMX_BASE_SRC_CLASS(obj) (GstOmxBaseSrcClass *) (obj)
-
typedef struct GstOmxBaseSrc GstOmxBaseSrc;
typedef struct GstOmxBaseSrcClass GstOmxBaseSrcClass;
-typedef void (*GstOmxBaseSrcCb) (GstOmxBaseSrc *self);
+typedef void (*GstOmxBaseSrcCb) (GstOmxBaseSrc * self);
#include <gstomx_util.h>
struct GstOmxBaseSrc
{
- GstBaseSrc element;
+ GstBaseSrc element;
- GOmxCore *gomx;
- GOmxPort *out_port;
+ GOmxCore *gomx;
+ GOmxPort *out_port;
- GstOmxBaseSrcCb setup_ports;
+ GstOmxBaseSrcCb setup_ports;
};
struct GstOmxBaseSrcClass
{
- GstBaseSrcClass parent_class;
+ GstBaseSrcClass parent_class;
};
GType gst_omx_base_src_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_BASE_SRC_H */
diff --git a/omx/gstomx_base_videodec.c b/omx/gstomx_base_videodec.c
index 56b79d1..de36899 100644
--- a/omx/gstomx_base_videodec.c
+++ b/omx/gstomx_base_videodec.c
@@ -22,245 +22,238 @@
#include "gstomx_base_videodec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxBaseVideoDec, gst_omx_base_videodec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxBaseVideoDec, gst_omx_base_videodec, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/x-raw-yuv",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-raw-yuv",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- {
- GValue list;
- GValue val;
+ {
+ GValue list;
+ GValue val;
- list.g_type = val.g_type = 0;
+ list.g_type = val.g_type = 0;
- g_value_init (&list, GST_TYPE_LIST);
- g_value_init (&val, GST_TYPE_FOURCC);
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, GST_TYPE_FOURCC);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
+ gst_value_list_append_value (&list, &val);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
+ gst_value_list_append_value (&list, &val);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
+ gst_value_list_append_value (&list, &val);
- gst_structure_set_value (struc, "format", &list);
+ gst_structure_set_value (struc, "format", &list);
- g_value_unset (&val);
- g_value_unset (&list);
- }
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseFilter *omx_base;
- GstOmxBaseVideoDec *self;
- guint width;
- guint height;
- guint32 format = 0;
+ GstOmxBaseFilter *omx_base;
+ GstOmxBaseVideoDec *self;
+ guint width;
+ guint height;
+ guint32 format = 0;
- omx_base = core->object;
- self = GST_OMX_BASE_VIDEODEC (omx_base);
+ omx_base = core->object;
+ self = GST_OMX_BASE_VIDEODEC (omx_base);
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
-
- width = param.format.video.nFrameWidth;
- height = param.format.video.nFrameHeight;
- switch (param.format.video.eColorFormat)
- {
- case OMX_COLOR_FormatYUV420PackedPlanar:
- format = GST_MAKE_FOURCC ('I', '4', '2', '0'); break;
- case OMX_COLOR_FormatYCbYCr:
- format = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'); break;
- case OMX_COLOR_FormatCbYCrY:
- format = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'); break;
- default:
- break;
- }
- }
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- {
- GstCaps *new_caps;
- GstStructure *struc;
-
- new_caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/x-raw-yuv",
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "format", GST_TYPE_FOURCC, format,
- NULL);
-
- if (self->framerate_denom != 0)
- gst_structure_set (struc, "framerate", GST_TYPE_FRACTION,
- self->framerate_num, self->framerate_denom,
- NULL);
- else
- /* FIXME this is a workaround for xvimagesink */
- gst_structure_set (struc, "framerate", GST_TYPE_FRACTION,
- 0, 1, NULL);
-
- gst_caps_append_structure (new_caps, struc);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition,
+ &param);
+
+ width = param.format.video.nFrameWidth;
+ height = param.format.video.nFrameHeight;
+ switch (param.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420PackedPlanar:
+ format = GST_MAKE_FOURCC ('I', '4', '2', '0');
+ break;
+ case OMX_COLOR_FormatYCbYCr:
+ format = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
+ break;
+ case OMX_COLOR_FormatCbYCrY:
+ format = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
+ break;
+ default:
+ break;
}
+ }
+
+ {
+ GstCaps *new_caps;
+ GstStructure *struc;
+
+ new_caps = gst_caps_new_empty ();
+ struc = gst_structure_new ("video/x-raw-yuv",
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height, "format", GST_TYPE_FOURCC, format, NULL);
+
+ if (self->framerate_denom != 0)
+ gst_structure_set (struc, "framerate", GST_TYPE_FRACTION,
+ self->framerate_num, self->framerate_denom, NULL);
+ else
+ /* FIXME this is a workaround for xvimagesink */
+ gst_structure_set (struc, "framerate", GST_TYPE_FRACTION, 0, 1, NULL);
+
+ gst_caps_append_structure (new_caps, struc);
+
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseVideoDec *self;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- OMX_PARAM_PORTDEFINITIONTYPE param;
- gint width = 0;
- gint height = 0;
+ GstStructure *structure;
+ GstOmxBaseVideoDec *self;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ gint width = 0;
+ gint height = 0;
- self = GST_OMX_BASE_VIDEODEC (GST_PAD_PARENT (pad));
- omx_base = GST_OMX_BASE_FILTER (self);
+ self = GST_OMX_BASE_VIDEODEC (GST_PAD_PARENT (pad));
+ omx_base = GST_OMX_BASE_FILTER (self);
- gomx = (GOmxCore *) omx_base->gomx;
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
- {
- const GValue *framerate = NULL;
- framerate = gst_structure_get_value (structure, "framerate");
- if (framerate)
- {
- self->framerate_num = gst_value_get_fraction_numerator (framerate);
- self->framerate_denom = gst_value_get_fraction_denominator (framerate);
- }
+ {
+ const GValue *framerate = NULL;
+ framerate = gst_structure_get_value (structure, "framerate");
+ if (framerate) {
+ self->framerate_num = gst_value_get_fraction_numerator (framerate);
+ self->framerate_denom = gst_value_get_fraction_denominator (framerate);
}
+ }
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- {
- const GValue *codec_data;
- GstBuffer *buffer;
-
- codec_data = gst_structure_get_value (structure, "codec_data");
- if (codec_data)
- {
- buffer = gst_value_get_buffer (codec_data);
- omx_base->codec_data = buffer;
- gst_buffer_ref (buffer);
- }
+ {
+ const GValue *codec_data;
+ GstBuffer *buffer;
+
+ codec_data = gst_structure_get_value (structure, "codec_data");
+ if (codec_data) {
+ buffer = gst_value_get_buffer (codec_data);
+ omx_base->codec_data = buffer;
+ gst_buffer_ref (buffer);
}
+ }
- /* Input port configuration. */
- {
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+ /* Input port configuration. */
+ {
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- param.format.video.nFrameWidth = width;
- param.format.video.nFrameHeight = height;
+ param.format.video.nFrameWidth = width;
+ param.format.video.nFrameHeight = height;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+ }
- return gst_pad_set_caps (pad, caps);
+ return gst_pad_set_caps (pad, caps);
}
static void
-omx_setup (GstOmxBaseFilter *omx_base)
+omx_setup (GstOmxBaseFilter * omx_base)
{
- GstOmxBaseVideoDec *self;
- GOmxCore *gomx;
+ GstOmxBaseVideoDec *self;
+ GOmxCore *gomx;
- self = GST_OMX_BASE_VIDEODEC (omx_base);
- gomx = (GOmxCore *) omx_base->gomx;
+ self = GST_OMX_BASE_VIDEODEC (omx_base);
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "begin");
+ GST_INFO_OBJECT (omx_base, "begin");
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- /* Input port configuration. */
- {
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+ /* Input port configuration. */
+ {
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- param.format.video.eCompressionFormat = self->compression_format;
+ param.format.video.eCompressionFormat = self->compression_format;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
}
+ }
- GST_INFO_OBJECT (omx_base, "end");
+ GST_INFO_OBJECT (omx_base, "end");
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- omx_base->omx_setup = omx_setup;
+ omx_base->omx_setup = omx_setup;
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_base_videodec.h b/omx/gstomx_base_videodec.h
index 436d33f..e45df75 100644
--- a/omx/gstomx_base_videodec.h
+++ b/omx/gstomx_base_videodec.h
@@ -25,11 +25,9 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_BASE_VIDEODEC(obj) (GstOmxBaseVideoDec *) (obj)
#define GST_OMX_BASE_VIDEODEC_TYPE (gst_omx_base_videodec_get_type ())
#define GST_OMX_BASE_VIDEODEC_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GST_OMX_BASE_VIDEODEC_TYPE, GstOmxBaseVideoDecClass))
-
typedef struct GstOmxBaseVideoDec GstOmxBaseVideoDec;
typedef struct GstOmxBaseVideoDecClass GstOmxBaseVideoDecClass;
@@ -37,20 +35,19 @@ typedef struct GstOmxBaseVideoDecClass GstOmxBaseVideoDecClass;
struct GstOmxBaseVideoDec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
- OMX_VIDEO_CODINGTYPE compression_format;
- gint framerate_num;
- gint framerate_denom;
+ OMX_VIDEO_CODINGTYPE compression_format;
+ gint framerate_num;
+ gint framerate_denom;
};
struct GstOmxBaseVideoDecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_base_videodec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_BASE_VIDEODEC_H */
diff --git a/omx/gstomx_base_videoenc.c b/omx/gstomx_base_videoenc.c
index f469494..87a4f1b 100644
--- a/omx/gstomx_base_videoenc.c
+++ b/omx/gstomx_base_videoenc.c
@@ -22,271 +22,255 @@
#include "gstomx_base_videoenc.h"
#include "gstomx.h"
-#include <string.h> /* for strcmp */
+#include <string.h> /* for strcmp */
enum
{
- ARG_0,
- ARG_BITRATE,
+ ARG_0,
+ ARG_BITRATE,
};
#define DEFAULT_BITRATE 0
-GSTOMX_BOILERPLATE (GstOmxBaseVideoEnc, gst_omx_base_videoenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxBaseVideoEnc, gst_omx_base_videoenc, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/x-raw-yuv",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-raw-yuv",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- {
- GValue list;
- GValue val;
+ {
+ GValue list;
+ GValue val;
- list.g_type = val.g_type = 0;
+ list.g_type = val.g_type = 0;
- g_value_init (&list, GST_TYPE_LIST);
- g_value_init (&val, GST_TYPE_FOURCC);
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, GST_TYPE_FOURCC);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
+ gst_value_list_append_value (&list, &val);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
+ gst_value_list_append_value (&list, &val);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
+ gst_value_list_append_value (&list, &val);
- gst_structure_set_value (struc, "format", &list);
+ gst_structure_set_value (struc, "format", &list);
- g_value_unset (&val);
- g_value_unset (&list);
- }
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxBaseVideoEnc *self;
-
- self = GST_OMX_BASE_VIDEOENC (obj);
-
- switch (prop_id)
- {
- case ARG_BITRATE:
- self->bitrate = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxBaseVideoEnc *self;
+
+ self = GST_OMX_BASE_VIDEOENC (obj);
+
+ switch (prop_id) {
+ case ARG_BITRATE:
+ self->bitrate = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxBaseVideoEnc *self;
+ GstOmxBaseVideoEnc *self;
- self = GST_OMX_BASE_VIDEOENC (obj);
+ self = GST_OMX_BASE_VIDEOENC (obj);
- switch (prop_id)
- {
- case ARG_BITRATE:
+ switch (prop_id) {
+ case ARG_BITRATE:
/** @todo propagate this to OpenMAX when processing. */
- g_value_set_uint (value, self->bitrate);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ g_value_set_uint (value, self->bitrate);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
- gobject_class = G_OBJECT_CLASS (g_class);
+ gobject_class = G_OBJECT_CLASS (g_class);
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
-
- g_object_class_install_property (gobject_class, ARG_BITRATE,
- g_param_spec_uint ("bitrate", "Bit-rate",
- "Encoding bit-rate",
- 0, G_MAXUINT, DEFAULT_BITRATE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
+
+ g_object_class_install_property (gobject_class, ARG_BITRATE,
+ g_param_spec_uint ("bitrate", "Bit-rate",
+ "Encoding bit-rate",
+ 0, G_MAXUINT, DEFAULT_BITRATE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseVideoEnc *self;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- OMX_COLOR_FORMATTYPE color_format = OMX_COLOR_FormatUnused;
- gint width = 0;
- gint height = 0;
- const GValue *framerate = NULL;
+ GstStructure *structure;
+ GstOmxBaseVideoEnc *self;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ OMX_COLOR_FORMATTYPE color_format = OMX_COLOR_FormatUnused;
+ gint width = 0;
+ gint height = 0;
+ const GValue *framerate = NULL;
- self = GST_OMX_BASE_VIDEOENC (GST_PAD_PARENT (pad));
- omx_base = GST_OMX_BASE_FILTER (self);
- gomx = (GOmxCore *) omx_base->gomx;
+ self = GST_OMX_BASE_VIDEOENC (GST_PAD_PARENT (pad));
+ omx_base = GST_OMX_BASE_FILTER (self);
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
- if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0)
- {
- guint32 fourcc;
-
- framerate = gst_structure_get_value (structure, "framerate");
- if (framerate)
- {
- self->framerate_num = gst_value_get_fraction_numerator (framerate);
- self->framerate_denom = gst_value_get_fraction_denominator (framerate);
- }
-
- if (gst_structure_get_fourcc (structure, "format", &fourcc))
- {
- switch (fourcc)
- {
- case GST_MAKE_FOURCC ('I', '4', '2', '0'):
- color_format = OMX_COLOR_FormatYUV420PackedPlanar;
- break;
- case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
- color_format = OMX_COLOR_FormatYCbYCr;
- break;
- case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
- color_format = OMX_COLOR_FormatCbYCrY;
- break;
- }
- }
+ if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
+ guint32 fourcc;
+
+ framerate = gst_structure_get_value (structure, "framerate");
+ if (framerate) {
+ self->framerate_num = gst_value_get_fraction_numerator (framerate);
+ self->framerate_denom = gst_value_get_fraction_denominator (framerate);
+ }
+
+ if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
+ switch (fourcc) {
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ color_format = OMX_COLOR_FormatYUV420PackedPlanar;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ color_format = OMX_COLOR_FormatYCbYCr;
+ break;
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+ color_format = OMX_COLOR_FormatCbYCrY;
+ break;
+ }
}
+ }
+
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+
+ G_OMX_INIT_PARAM (param);
+ /* Input port configuration. */
{
- OMX_PARAM_PORTDEFINITIONTYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- /* Input port configuration. */
- {
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
-
- param.format.video.nFrameWidth = width;
- param.format.video.nFrameHeight = height;
- param.format.video.eColorFormat = color_format;
- if (framerate)
- {
- /* convert to Q.16 */
- param.format.video.xFramerate =
- (gst_value_get_fraction_numerator (framerate) << 16) /
- gst_value_get_fraction_denominator (framerate);
- }
-
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- }
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+
+ param.format.video.nFrameWidth = width;
+ param.format.video.nFrameHeight = height;
+ param.format.video.eColorFormat = color_format;
+ if (framerate) {
+ /* convert to Q.16 */
+ param.format.video.xFramerate =
+ (gst_value_get_fraction_numerator (framerate) << 16) /
+ gst_value_get_fraction_denominator (framerate);
+ }
+
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
}
+ }
- return gst_pad_set_caps (pad, caps);
+ return gst_pad_set_caps (pad, caps);
}
static void
-omx_setup (GstOmxBaseFilter *omx_base)
+omx_setup (GstOmxBaseFilter * omx_base)
{
- GstOmxBaseVideoEnc *self;
- GOmxCore *gomx;
+ GstOmxBaseVideoEnc *self;
+ GOmxCore *gomx;
- self = GST_OMX_BASE_VIDEOENC (omx_base);
- gomx = (GOmxCore *) omx_base->gomx;
+ self = GST_OMX_BASE_VIDEOENC (omx_base);
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "begin");
+ GST_INFO_OBJECT (omx_base, "begin");
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- /* Output port configuration. */
- {
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+ /* Output port configuration. */
+ {
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- param.format.video.eCompressionFormat = self->compression_format;
+ param.format.video.eCompressionFormat = self->compression_format;
- if (self->bitrate != 0)
- param.format.video.nBitrate = self->bitrate;
+ if (self->bitrate != 0)
+ param.format.video.nBitrate = self->bitrate;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
}
+ }
- GST_INFO_OBJECT (omx_base, "end");
+ GST_INFO_OBJECT (omx_base, "end");
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
- GstOmxBaseVideoEnc *self;
+ GstOmxBaseFilter *omx_base;
+ GstOmxBaseVideoEnc *self;
- omx_base = GST_OMX_BASE_FILTER (instance);
- self = GST_OMX_BASE_VIDEOENC (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
+ self = GST_OMX_BASE_VIDEOENC (instance);
- omx_base->omx_setup = omx_setup;
+ omx_base->omx_setup = omx_setup;
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
- self->bitrate = DEFAULT_BITRATE;
+ self->bitrate = DEFAULT_BITRATE;
}
diff --git a/omx/gstomx_base_videoenc.h b/omx/gstomx_base_videoenc.h
index 9ddcd25..96a1b07 100644
--- a/omx/gstomx_base_videoenc.h
+++ b/omx/gstomx_base_videoenc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_BASE_VIDEOENC(obj) (GstOmxBaseVideoEnc *) (obj)
#define GST_OMX_BASE_VIDEOENC_TYPE (gst_omx_base_videoenc_get_type ())
-
typedef struct GstOmxBaseVideoEnc GstOmxBaseVideoEnc;
typedef struct GstOmxBaseVideoEncClass GstOmxBaseVideoEncClass;
@@ -36,21 +34,20 @@ typedef struct GstOmxBaseVideoEncClass GstOmxBaseVideoEncClass;
struct GstOmxBaseVideoEnc
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
- OMX_VIDEO_CODINGTYPE compression_format;
- guint bitrate;
- gint framerate_num;
- gint framerate_denom;
+ OMX_VIDEO_CODINGTYPE compression_format;
+ guint bitrate;
+ gint framerate_num;
+ gint framerate_denom;
};
struct GstOmxBaseVideoEncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_base_videoenc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_BASE_VIDEOENC_H */
diff --git a/omx/gstomx_dummy.c b/omx/gstomx_dummy.c
index cc43c28..9dbd744 100644
--- a/omx/gstomx_dummy.c
+++ b/omx/gstomx_dummy.c
@@ -23,75 +23,69 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxDummy, gst_omx_dummy, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxDummy, gst_omx_dummy, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_any ();
+ caps = gst_caps_new_any ();
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_any ();
+ caps = gst_caps_new_any ();
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL dummy element",
- "None",
- "Does nothing",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL dummy element", "None", "Does nothing", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- GST_DEBUG_OBJECT (omx_base, "start");
+ GST_DEBUG_OBJECT (omx_base, "start");
}
diff --git a/omx/gstomx_dummy.h b/omx/gstomx_dummy.h
index bd8df97..e8c824f 100644
--- a/omx/gstomx_dummy.h
+++ b/omx/gstomx_dummy.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_DUMMY(obj) (GstOmxDummy *) (obj)
#define GST_OMX_DUMMY_TYPE (gst_omx_dummy_get_type ())
-
typedef struct GstOmxDummy GstOmxDummy;
typedef struct GstOmxDummyClass GstOmxDummyClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxDummyClass GstOmxDummyClass;
struct GstOmxDummy
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxDummyClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_dummy_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_DUMMY_H */
diff --git a/omx/gstomx_filereadersrc.c b/omx/gstomx_filereadersrc.c
index 76a17fa..3c63ceb 100644
--- a/omx/gstomx_filereadersrc.c
+++ b/omx/gstomx_filereadersrc.c
@@ -25,173 +25,161 @@
enum
{
- ARG_0,
- ARG_FILE_NAME,
+ ARG_0,
+ ARG_FILE_NAME,
};
-GSTOMX_BOILERPLATE (GstOmxFilereaderSrc, gst_omx_filereadersrc, GstOmxBaseSrc, GST_OMX_BASE_SRC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxFilereaderSrc, gst_omx_filereadersrc, GstOmxBaseSrc,
+ GST_OMX_BASE_SRC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_any ();
+ caps = gst_caps_new_any ();
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL filereader src element",
- "None",
- "Does nothing",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL filereader src element",
+ "None", "Does nothing", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static gboolean
-setcaps (GstBaseSrc *gst_src,
- GstCaps *caps)
+setcaps (GstBaseSrc * gst_src, GstCaps * caps)
{
- GstOmxBaseSrc *self;
+ GstOmxBaseSrc *self;
- self = GST_OMX_BASE_SRC (gst_src);
+ self = GST_OMX_BASE_SRC (gst_src);
- GST_INFO_OBJECT (self, "setcaps (src): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (self, "setcaps (src): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
- return TRUE;
+ return TRUE;
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseSrc *omx_base;
+ GstOmxBaseSrc *omx_base;
- omx_base = core->object;
+ omx_base = core->object;
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
/** @todo properly set the capabilities */
}
static void
-setup_ports (GstOmxBaseSrc *base_src)
+setup_ports (GstOmxBaseSrc * base_src)
{
- GOmxCore *gomx;
- GstOmxFilereaderSrc *self;
-
- self = GST_OMX_FILEREADERSRC (base_src);
- gomx = base_src->gomx;
-
- /* This is specific for Bellagio. */
- {
- OMX_INDEXTYPE index;
- OMX_GetExtensionIndex (gomx->omx_handle, "OMX.ST.index.param.filereader.inputfilename", &index);
- OMX_SetParameter (gomx->omx_handle, index, self->file_name);
- }
+ GOmxCore *gomx;
+ GstOmxFilereaderSrc *self;
+
+ self = GST_OMX_FILEREADERSRC (base_src);
+ gomx = base_src->gomx;
+
+ /* This is specific for Bellagio. */
+ {
+ OMX_INDEXTYPE index;
+ OMX_GetExtensionIndex (gomx->omx_handle,
+ "OMX.ST.index.param.filereader.inputfilename", &index);
+ OMX_SetParameter (gomx->omx_handle, index, self->file_name);
+ }
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxFilereaderSrc *self;
-
- self = GST_OMX_FILEREADERSRC (obj);
-
- switch (prop_id)
- {
- case ARG_FILE_NAME:
- if (self->file_name)
- {
- g_free (self->file_name);
- }
- self->file_name = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxFilereaderSrc *self;
+
+ self = GST_OMX_FILEREADERSRC (obj);
+
+ switch (prop_id) {
+ case ARG_FILE_NAME:
+ if (self->file_name) {
+ g_free (self->file_name);
+ }
+ self->file_name = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxFilereaderSrc *self;
-
- self = GST_OMX_FILEREADERSRC (obj);
-
- switch (prop_id)
- {
- case ARG_FILE_NAME:
- g_value_set_string (value, self->file_name);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxFilereaderSrc *self;
+
+ self = GST_OMX_FILEREADERSRC (obj);
+
+ switch (prop_id) {
+ case ARG_FILE_NAME:
+ g_value_set_string (value, self->file_name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GstBaseSrcClass *gst_base_src_class;
- GObjectClass *gobject_class;
+ GstBaseSrcClass *gst_base_src_class;
+ GObjectClass *gobject_class;
- gst_base_src_class = GST_BASE_SRC_CLASS (g_class);
- gobject_class = G_OBJECT_CLASS (g_class);
+ gst_base_src_class = GST_BASE_SRC_CLASS (g_class);
+ gobject_class = G_OBJECT_CLASS (g_class);
- gst_base_src_class->set_caps = setcaps;
+ gst_base_src_class->set_caps = setcaps;
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
- g_object_class_install_property (gobject_class, ARG_FILE_NAME,
- g_param_spec_string ("file-name", "File name",
- "The input filename to use",
- NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ g_object_class_install_property (gobject_class, ARG_FILE_NAME,
+ g_param_spec_string ("file-name", "File name",
+ "The input filename to use",
+ NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseSrc *omx_base;
+ GstOmxBaseSrc *omx_base;
- omx_base = GST_OMX_BASE_SRC (instance);
+ omx_base = GST_OMX_BASE_SRC (instance);
- GST_DEBUG_OBJECT (omx_base, "begin");
+ GST_DEBUG_OBJECT (omx_base, "begin");
- omx_base->setup_ports = setup_ports;
+ omx_base->setup_ports = setup_ports;
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
- GST_DEBUG_OBJECT (omx_base, "end");
+ GST_DEBUG_OBJECT (omx_base, "end");
}
diff --git a/omx/gstomx_filereadersrc.h b/omx/gstomx_filereadersrc.h
index 80224a1..47d4e80 100644
--- a/omx/gstomx_filereadersrc.h
+++ b/omx/gstomx_filereadersrc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_FILEREADERSRC(obj) (GstOmxFilereaderSrc *) (obj)
#define GST_OMX_FILEREADERSRC_TYPE (gst_omx_filereadersrc_get_type ())
-
typedef struct GstOmxFilereaderSrc GstOmxFilereaderSrc;
typedef struct GstOmxFilereaderSrcClass GstOmxFilereaderSrcClass;
@@ -36,18 +34,17 @@ typedef struct GstOmxFilereaderSrcClass GstOmxFilereaderSrcClass;
struct GstOmxFilereaderSrc
{
- GstOmxBaseSrc omx_base;
+ GstOmxBaseSrc omx_base;
- char *file_name; /**< The input file name. */
+ char *file_name; /**< The input file name. */
};
struct GstOmxFilereaderSrcClass
{
- GstOmxBaseSrcClass parent_class;
+ GstOmxBaseSrcClass parent_class;
};
GType gst_omx_filereadersrc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_FILEREADERSRC_H */
diff --git a/omx/gstomx_g711dec.c b/omx/gstomx_g711dec.c
index 87a1123..25f97f0 100644
--- a/omx/gstomx_g711dec.c
+++ b/omx/gstomx_g711dec.c
@@ -23,160 +23,148 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for strcmp */
+#include <string.h> /* for strcmp */
/* should this class extend GstOmxBaseAudioDec? */
-GSTOMX_BOILERPLATE (GstOmxG711Dec, gst_omx_g711dec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxG711Dec, gst_omx_g711dec, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("audio/x-alaw",
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ struc = gst_structure_new ("audio/x-alaw",
+ "rate", G_TYPE_INT, 8000, "channels", G_TYPE_INT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- struc = gst_structure_new ("audio/x-mulaw",
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ struc = gst_structure_new ("audio/x-mulaw",
+ "rate", G_TYPE_INT, 8000, "channels", G_TYPE_INT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL G.711 audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in G.711 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL G.711 audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in G.711 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- const gchar *mode;
- gboolean ret = TRUE;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ const gchar *mode;
+ gboolean ret = TRUE;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- mode = gst_structure_get_name (structure);
+ mode = gst_structure_get_name (structure);
- /* Output port configuration. */
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ /* Output port configuration. */
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- if (strcmp (mode, "audio/x-alaw") == 0)
- param.ePCMMode = OMX_AUDIO_PCMModeALaw;
- else if (strcmp (mode, "audio/x-mulaw") == 0)
- param.ePCMMode = OMX_AUDIO_PCMModeMULaw;
+ if (strcmp (mode, "audio/x-alaw") == 0)
+ param.ePCMMode = OMX_AUDIO_PCMModeALaw;
+ else if (strcmp (mode, "audio/x-mulaw") == 0)
+ param.ePCMMode = OMX_AUDIO_PCMModeMULaw;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- }
-
- /* set caps on the srcpad */
- {
- GstCaps *tmp_caps;
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ }
- tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
- tmp_caps = gst_caps_make_writable (tmp_caps);
- gst_caps_truncate (tmp_caps);
+ /* set caps on the srcpad */
+ {
+ GstCaps *tmp_caps;
- gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
+ tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
+ tmp_caps = gst_caps_make_writable (tmp_caps);
+ gst_caps_truncate (tmp_caps);
- if (gst_caps_is_fixed (tmp_caps))
- {
- GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
- gst_pad_set_caps (omx_base->srcpad, tmp_caps);
- }
+ gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
- gst_caps_unref (tmp_caps);
+ if (gst_caps_is_fixed (tmp_caps)) {
+ GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
+ gst_pad_set_caps (omx_base->srcpad, tmp_caps);
}
- ret = gst_pad_set_caps (pad, caps);
+ gst_caps_unref (tmp_caps);
+ }
+
+ ret = gst_pad_set_caps (pad, caps);
- return ret;
+ return ret;
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_g711dec.h b/omx/gstomx_g711dec.h
index 209e617..7e5cdf4 100644
--- a/omx/gstomx_g711dec.h
+++ b/omx/gstomx_g711dec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_G711DEC(obj) (GstOmxG711Dec *) (obj)
#define GST_OMX_G711DEC_TYPE (gst_omx_g711dec_get_type ())
-
typedef struct GstOmxG711Dec GstOmxG711Dec;
typedef struct GstOmxG711DecClass GstOmxG711DecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxG711DecClass GstOmxG711DecClass;
struct GstOmxG711Dec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxG711DecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_g711dec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_G711DEC_H */
diff --git a/omx/gstomx_g711enc.c b/omx/gstomx_g711enc.c
index 550e435..c1aab07 100644
--- a/omx/gstomx_g711enc.c
+++ b/omx/gstomx_g711enc.c
@@ -23,173 +23,162 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-#include <string.h> /* for strcmp */
+#include <string.h> /* for strcmp */
-GSTOMX_BOILERPLATE (GstOmxG711Enc, gst_omx_g711enc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxG711Enc, gst_omx_g711enc, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("audio/x-alaw",
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ struc = gst_structure_new ("audio/x-alaw",
+ "rate", G_TYPE_INT, 8000, "channels", G_TYPE_INT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- struc = gst_structure_new ("audio/x-mulaw",
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ struc = gst_structure_new ("audio/x-mulaw",
+ "rate", G_TYPE_INT, 8000, "channels", G_TYPE_INT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL G.711 audio encoder",
- "Codec/Encoder/Audio",
- "Encodes audio in G.711 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL G.711 audio encoder",
+ "Codec/Encoder/Audio",
+ "Encodes audio in G.711 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstCaps *peer_caps;
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
- const gchar *mode;
- gboolean ret = TRUE;
+ GstCaps *peer_caps;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
+ GOmxCore *gomx;
+ const gchar *mode;
+ gboolean ret = TRUE;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- peer_caps = gst_pad_peer_get_caps (omx_base->srcpad);
+ peer_caps = gst_pad_peer_get_caps (omx_base->srcpad);
- g_return_val_if_fail (peer_caps, FALSE);
+ g_return_val_if_fail (peer_caps, FALSE);
- GST_INFO_OBJECT (omx_base, "setcaps (sink): peercaps: %" GST_PTR_FORMAT, peer_caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): peercaps: %" GST_PTR_FORMAT,
+ peer_caps);
- if (gst_caps_get_size (peer_caps) == 0)
- goto leave;
+ if (gst_caps_get_size (peer_caps) == 0)
+ goto leave;
- structure = gst_caps_get_structure (peer_caps, 0);
+ structure = gst_caps_get_structure (peer_caps, 0);
- mode = gst_structure_get_name (structure);
+ mode = gst_structure_get_name (structure);
- /* Output port configuration. */
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ /* Output port configuration. */
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- if (strcmp (mode, "audio/x-alaw") == 0)
- param.ePCMMode = OMX_AUDIO_PCMModeALaw;
- else if (strcmp (mode, "audio/x-mulaw") == 0)
- param.ePCMMode = OMX_AUDIO_PCMModeMULaw;
+ if (strcmp (mode, "audio/x-alaw") == 0)
+ param.ePCMMode = OMX_AUDIO_PCMModeALaw;
+ else if (strcmp (mode, "audio/x-mulaw") == 0)
+ param.ePCMMode = OMX_AUDIO_PCMModeMULaw;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ }
leave:
- /* set caps on the srcpad */
- {
- GstCaps *tmp_caps;
-
- tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
- tmp_caps = gst_caps_make_writable (tmp_caps);
- gst_caps_truncate (tmp_caps);
+ /* set caps on the srcpad */
+ {
+ GstCaps *tmp_caps;
- gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
+ tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
+ tmp_caps = gst_caps_make_writable (tmp_caps);
+ gst_caps_truncate (tmp_caps);
- if (gst_caps_is_fixed (tmp_caps))
- {
- GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
- gst_pad_set_caps (omx_base->srcpad, tmp_caps);
- }
+ gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
- gst_caps_unref (tmp_caps);
+ if (gst_caps_is_fixed (tmp_caps)) {
+ GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
+ gst_pad_set_caps (omx_base->srcpad, tmp_caps);
}
- ret = gst_pad_set_caps (pad, caps);
+ gst_caps_unref (tmp_caps);
+ }
+
+ ret = gst_pad_set_caps (pad, caps);
- gst_caps_unref (peer_caps);
+ gst_caps_unref (peer_caps);
- return ret;
+ return ret;
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_g711enc.h b/omx/gstomx_g711enc.h
index 1678b4b..aa24ed2 100644
--- a/omx/gstomx_g711enc.h
+++ b/omx/gstomx_g711enc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_G711ENC(obj) (GstOmxG711Enc *) (obj)
#define GST_OMX_G711ENC_TYPE (gst_omx_g711enc_get_type ())
-
typedef struct GstOmxG711Enc GstOmxG711Enc;
typedef struct GstOmxG711EncClass GstOmxG711EncClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxG711EncClass GstOmxG711EncClass;
struct GstOmxG711Enc
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxG711EncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_g711enc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_G711ENC_H */
diff --git a/omx/gstomx_g729dec.c b/omx/gstomx_g729dec.c
index 917ea2f..e80310f 100644
--- a/omx/gstomx_g729dec.c
+++ b/omx/gstomx_g729dec.c
@@ -22,117 +22,107 @@
#include "gstomx_g729dec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxG729Dec, gst_omx_g729dec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxG729Dec, gst_omx_g729dec, GstOmxBaseAudioDec,
+ GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("audio/G729",
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ struc = gst_structure_new ("audio/G729",
+ "rate", G_TYPE_INT, 8000, "channels", G_TYPE_INT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL G.729 audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in G.729 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL G.729 audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in G.729 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
/* should we be overriding the settings_changed_cb from parent class like this?? */
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = core->object;
+ omx_base = core->object;
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- GstCaps *new_caps;
+ {
+ GstCaps *new_caps;
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
+ new_caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_g729dec.h b/omx/gstomx_g729dec.h
index 49e525f..680815c 100644
--- a/omx/gstomx_g729dec.h
+++ b/omx/gstomx_g729dec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_G729DEC(obj) (GstOmxG729Dec *) (obj)
#define GST_OMX_G729DEC_TYPE (gst_omx_g729dec_get_type ())
-
typedef struct GstOmxG729Dec GstOmxG729Dec;
typedef struct GstOmxG729DecClass GstOmxG729DecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxG729DecClass GstOmxG729DecClass;
struct GstOmxG729Dec
{
- GstOmxBaseAudioDec omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxG729DecClass
{
- GstOmxBaseAudioDecClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_g729dec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_G729DEC_H */
diff --git a/omx/gstomx_g729enc.c b/omx/gstomx_g729enc.c
index 64d93f7..c589749 100644
--- a/omx/gstomx_g729enc.c
+++ b/omx/gstomx_g729enc.c
@@ -27,223 +27,207 @@
enum
{
- ARG_0,
- ARG_DTX,
+ ARG_0,
+ ARG_DTX,
};
-GSTOMX_BOILERPLATE (GstOmxG729Enc, gst_omx_g729enc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxG729Enc, gst_omx_g729enc, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("audio/G729",
- "rate", G_TYPE_INT, 8000,
- "channels", G_TYPE_INT, 1,
- NULL);
+ struc = gst_structure_new ("audio/G729",
+ "rate", G_TYPE_INT, 8000, "channels", G_TYPE_INT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL G.729 audio encoder",
- "Codec/Encoder/Audio",
- "Encodes audio in G.729 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL G.729 audio encoder",
+ "Codec/Encoder/Audio",
+ "Encodes audio in G.729 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxG729Enc *self;
-
- self = GST_OMX_G729ENC (obj);
-
- switch (prop_id)
- {
- case ARG_DTX:
- self->dtx = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxG729Enc *self;
+
+ self = GST_OMX_G729ENC (obj);
+
+ switch (prop_id) {
+ case ARG_DTX:
+ self->dtx = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxG729Enc *self;
+ GstOmxG729Enc *self;
- self = GST_OMX_G729ENC (obj);
+ self = GST_OMX_G729ENC (obj);
- switch (prop_id)
- {
- case ARG_DTX:
+ switch (prop_id) {
+ case ARG_DTX:
/** @todo propagate this to OpenMAX when processing. */
- g_value_set_boolean (value, self->dtx);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ g_value_set_boolean (value, self->dtx);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
- gobject_class = G_OBJECT_CLASS (g_class);
+ gobject_class = G_OBJECT_CLASS (g_class);
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
- g_object_class_install_property (gobject_class, ARG_DTX,
- g_param_spec_boolean ("dtx", "DTX",
- "Enable DTX",
- DEFAULT_DTX, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ g_object_class_install_property (gobject_class, ARG_DTX,
+ g_param_spec_boolean ("dtx", "DTX",
+ "Enable DTX",
+ DEFAULT_DTX, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstOmxBaseFilter *omx_base;
- gboolean ret = TRUE;
+ GstOmxBaseFilter *omx_base;
+ gboolean ret = TRUE;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- if (!caps || gst_caps_get_size (caps) == 0)
- goto refuse_caps;
+ if (!caps || gst_caps_get_size (caps) == 0)
+ goto refuse_caps;
- /* some extreme checking */
- if (!gst_pad_accept_caps (pad, caps))
- goto refuse_caps;
+ /* some extreme checking */
+ if (!gst_pad_accept_caps (pad, caps))
+ goto refuse_caps;
- /* set caps on the srcpad */
- {
- GstCaps *tmp_caps;
+ /* set caps on the srcpad */
+ {
+ GstCaps *tmp_caps;
- /* src template are fixed caps */
- tmp_caps = generate_src_template ();
+ /* src template are fixed caps */
+ tmp_caps = generate_src_template ();
- ret = gst_pad_set_caps (omx_base->srcpad, tmp_caps);
- gst_caps_unref (tmp_caps);
- }
+ ret = gst_pad_set_caps (omx_base->srcpad, tmp_caps);
+ gst_caps_unref (tmp_caps);
+ }
- return ret;
+ return ret;
- /* ERRORS */
+ /* ERRORS */
refuse_caps:
- {
- GST_WARNING_OBJECT (omx_base, "refused caps %" GST_PTR_FORMAT, caps);
- return FALSE;
- }
+ {
+ GST_WARNING_OBJECT (omx_base, "refused caps %" GST_PTR_FORMAT, caps);
+ return FALSE;
+ }
}
static void
-omx_setup (GstOmxBaseFilter *omx_base)
+omx_setup (GstOmxBaseFilter * omx_base)
{
- GstOmxG729Enc *self;
- GOmxCore *gomx;
+ GstOmxG729Enc *self;
+ GOmxCore *gomx;
- self = GST_OMX_G729ENC (omx_base);
- gomx = omx_base->gomx;
+ self = GST_OMX_G729ENC (omx_base);
+ gomx = omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "begin");
+ GST_INFO_OBJECT (omx_base, "begin");
- {
- OMX_AUDIO_PARAM_G729TYPE param;
+ {
+ OMX_AUDIO_PARAM_G729TYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, &param);
- param.bDTX = self->dtx;
+ param.bDTX = self->dtx;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, &param);
+ }
- GST_INFO_OBJECT (omx_base, "end");
+ GST_INFO_OBJECT (omx_base, "end");
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
- GstOmxG729Enc *self;
+ GstOmxBaseFilter *omx_base;
+ GstOmxG729Enc *self;
- omx_base = GST_OMX_BASE_FILTER (instance);
- self = GST_OMX_G729ENC (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
+ self = GST_OMX_G729ENC (instance);
- omx_base->omx_setup = omx_setup;
+ omx_base->omx_setup = omx_setup;
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
- self->dtx = DEFAULT_DTX;
+ self->dtx = DEFAULT_DTX;
}
diff --git a/omx/gstomx_g729enc.h b/omx/gstomx_g729enc.h
index 5e7a411..9667b96 100644
--- a/omx/gstomx_g729enc.h
+++ b/omx/gstomx_g729enc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_G729ENC(obj) (GstOmxG729Enc *) (obj)
#define GST_OMX_G729ENC_TYPE (gst_omx_g729enc_get_type ())
-
typedef struct GstOmxG729Enc GstOmxG729Enc;
typedef struct GstOmxG729EncClass GstOmxG729EncClass;
@@ -36,17 +34,16 @@ typedef struct GstOmxG729EncClass GstOmxG729EncClass;
struct GstOmxG729Enc
{
- GstOmxBaseFilter omx_base;
- gboolean dtx;
+ GstOmxBaseFilter omx_base;
+ gboolean dtx;
};
struct GstOmxG729EncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_g729enc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_G729ENC_H */
diff --git a/omx/gstomx_h263dec.c b/omx/gstomx_h263dec.c
index 6c1e1d1..4cd5e38 100644
--- a/omx/gstomx_h263dec.c
+++ b/omx/gstomx_h263dec.c
@@ -22,65 +22,61 @@
#include "gstomx_h263dec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxH263Dec, gst_omx_h263dec, GstOmxBaseVideoDec, GST_OMX_BASE_VIDEODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxH263Dec, gst_omx_h263dec, GstOmxBaseVideoDec,
+ GST_OMX_BASE_VIDEODEC_TYPE);
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/x-h263",
- "variant", G_TYPE_STRING, "itu",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-h263",
+ "variant", G_TYPE_STRING, "itu",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL H.263 video decoder",
- "Codec/Decoder/Video",
- "Decodes video in H.263 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL H.263 video decoder",
+ "Codec/Decoder/Video",
+ "Decodes video in H.263 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseVideoDec *omx_base;
+ GstOmxBaseVideoDec *omx_base;
- omx_base = GST_OMX_BASE_VIDEODEC (instance);
+ omx_base = GST_OMX_BASE_VIDEODEC (instance);
- omx_base->compression_format = OMX_VIDEO_CodingH263;
+ omx_base->compression_format = OMX_VIDEO_CodingH263;
}
diff --git a/omx/gstomx_h263dec.h b/omx/gstomx_h263dec.h
index b99369f..018824c 100644
--- a/omx/gstomx_h263dec.h
+++ b/omx/gstomx_h263dec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_H263DEC(obj) (GstOmxH263Dec *) (obj)
#define GST_OMX_H263DEC_TYPE (gst_omx_h263dec_get_type ())
-
typedef struct GstOmxH263Dec GstOmxH263Dec;
typedef struct GstOmxH263DecClass GstOmxH263DecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxH263DecClass GstOmxH263DecClass;
struct GstOmxH263Dec
{
- GstOmxBaseVideoDec omx_base;
+ GstOmxBaseVideoDec omx_base;
};
struct GstOmxH263DecClass
{
- GstOmxBaseVideoDecClass parent_class;
+ GstOmxBaseVideoDecClass parent_class;
};
GType gst_omx_h263dec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_H263DEC_H */
diff --git a/omx/gstomx_h263enc.c b/omx/gstomx_h263enc.c
index 4ec12b7..71c5361 100644
--- a/omx/gstomx_h263enc.c
+++ b/omx/gstomx_h263enc.c
@@ -22,105 +22,100 @@
#include "gstomx_h263enc.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxH263Enc, gst_omx_h263enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxH263Enc, gst_omx_h263enc, GstOmxBaseVideoEnc,
+ GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("video/x-h263",
- "variant", G_TYPE_STRING, "itu",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ caps = gst_caps_new_simple ("video/x-h263",
+ "variant", G_TYPE_STRING, "itu",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL H.263 video encoder",
- "Codec/Encoder/Video",
- "Encodes video in H.263 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL H.263 video encoder",
+ "Codec/Encoder/Video",
+ "Encodes video in H.263 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseVideoEnc *omx_base;
- GstOmxBaseFilter *omx_base_filter;
- guint width;
- guint height;
+ GstOmxBaseVideoEnc *omx_base;
+ GstOmxBaseFilter *omx_base_filter;
+ guint width;
+ guint height;
- omx_base_filter = core->object;
- omx_base = GST_OMX_BASE_VIDEOENC (omx_base_filter);
+ omx_base_filter = core->object;
+ omx_base = GST_OMX_BASE_VIDEOENC (omx_base_filter);
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base_filter->out_port->port_index;
- OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+ param.nPortIndex = omx_base_filter->out_port->port_index;
+ OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
- width = param.format.video.nFrameWidth;
- height = param.format.video.nFrameHeight;
- }
+ width = param.format.video.nFrameWidth;
+ height = param.format.video.nFrameHeight;
+ }
- {
- GstCaps *new_caps;
+ {
+ GstCaps *new_caps;
- new_caps = gst_caps_new_simple ("video/x-h263",
- "variant", G_TYPE_STRING, "itu",
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", GST_TYPE_FRACTION,
- omx_base->framerate_num, omx_base->framerate_denom,
- NULL);
+ new_caps = gst_caps_new_simple ("video/x-h263",
+ "variant", G_TYPE_STRING, "itu",
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ "framerate", GST_TYPE_FRACTION,
+ omx_base->framerate_num, omx_base->framerate_denom, NULL);
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base_filter->srcpad, new_caps);
- }
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base_filter->srcpad, new_caps);
+ }
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base_filter;
- GstOmxBaseVideoEnc *omx_base;
+ GstOmxBaseFilter *omx_base_filter;
+ GstOmxBaseVideoEnc *omx_base;
- omx_base_filter = GST_OMX_BASE_FILTER (instance);
- omx_base = GST_OMX_BASE_VIDEOENC (instance);
+ omx_base_filter = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_VIDEOENC (instance);
- omx_base->compression_format = OMX_VIDEO_CodingH263;
+ omx_base->compression_format = OMX_VIDEO_CodingH263;
- omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_h263enc.h b/omx/gstomx_h263enc.h
index 1201132..18eaaa7 100644
--- a/omx/gstomx_h263enc.h
+++ b/omx/gstomx_h263enc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_H263ENC(obj) (GstOmxH263Enc *) (obj)
#define GST_OMX_H263ENC_TYPE (gst_omx_h263enc_get_type ())
-
typedef struct GstOmxH263Enc GstOmxH263Enc;
typedef struct GstOmxH263EncClass GstOmxH263EncClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxH263EncClass GstOmxH263EncClass;
struct GstOmxH263Enc
{
- GstOmxBaseVideoEnc omx_base;
+ GstOmxBaseVideoEnc omx_base;
};
struct GstOmxH263EncClass
{
- GstOmxBaseVideoEncClass parent_class;
+ GstOmxBaseVideoEncClass parent_class;
};
GType gst_omx_h263enc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_H263ENC_H */
diff --git a/omx/gstomx_h264dec.c b/omx/gstomx_h264dec.c
index 7815f98..167d9d3 100644
--- a/omx/gstomx_h264dec.c
+++ b/omx/gstomx_h264dec.c
@@ -22,64 +22,60 @@
#include "gstomx_h264dec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxH264Dec, gst_omx_h264dec, GstOmxBaseVideoDec, GST_OMX_BASE_VIDEODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxH264Dec, gst_omx_h264dec, GstOmxBaseVideoDec,
+ GST_OMX_BASE_VIDEODEC_TYPE);
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/x-h264",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-h264",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL H.264/AVC video decoder",
- "Codec/Decoder/Video",
- "Decodes video in H.264/AVC format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL H.264/AVC video decoder",
+ "Codec/Decoder/Video",
+ "Decodes video in H.264/AVC format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseVideoDec *omx_base;
+ GstOmxBaseVideoDec *omx_base;
- omx_base = GST_OMX_BASE_VIDEODEC (instance);
+ omx_base = GST_OMX_BASE_VIDEODEC (instance);
- omx_base->compression_format = OMX_VIDEO_CodingAVC;
+ omx_base->compression_format = OMX_VIDEO_CodingAVC;
}
diff --git a/omx/gstomx_h264dec.h b/omx/gstomx_h264dec.h
index 81527e9..8a771ac 100644
--- a/omx/gstomx_h264dec.h
+++ b/omx/gstomx_h264dec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_H264DEC(obj) (GstOmxH264Dec *) (obj)
#define GST_OMX_H264DEC_TYPE (gst_omx_h264dec_get_type ())
-
typedef struct GstOmxH264Dec GstOmxH264Dec;
typedef struct GstOmxH264DecClass GstOmxH264DecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxH264DecClass GstOmxH264DecClass;
struct GstOmxH264Dec
{
- GstOmxBaseVideoDec omx_base;
+ GstOmxBaseVideoDec omx_base;
};
struct GstOmxH264DecClass
{
- GstOmxBaseVideoDecClass parent_class;
+ GstOmxBaseVideoDecClass parent_class;
};
GType gst_omx_h264dec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_H264DEC_H */
diff --git a/omx/gstomx_h264enc.c b/omx/gstomx_h264enc.c
index adf4c9a..86585ca 100644
--- a/omx/gstomx_h264enc.c
+++ b/omx/gstomx_h264enc.c
@@ -22,103 +22,98 @@
#include "gstomx_h264enc.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxH264Enc, gst_omx_h264enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxH264Enc, gst_omx_h264enc, GstOmxBaseVideoEnc,
+ GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("video/x-h264",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ caps = gst_caps_new_simple ("video/x-h264",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL H.264/AVC video encoder",
- "Codec/Encoder/Video",
- "Encodes video in H.264/AVC format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL H.264/AVC video encoder",
+ "Codec/Encoder/Video",
+ "Encodes video in H.264/AVC format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseVideoEnc *omx_base;
- GstOmxBaseFilter *omx_base_filter;
- guint width;
- guint height;
+ GstOmxBaseVideoEnc *omx_base;
+ GstOmxBaseFilter *omx_base_filter;
+ guint width;
+ guint height;
- omx_base_filter = core->object;
- omx_base = GST_OMX_BASE_VIDEOENC (omx_base_filter);
+ omx_base_filter = core->object;
+ omx_base = GST_OMX_BASE_VIDEOENC (omx_base_filter);
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base_filter->out_port->port_index;
- OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+ param.nPortIndex = omx_base_filter->out_port->port_index;
+ OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
- width = param.format.video.nFrameWidth;
- height = param.format.video.nFrameHeight;
- }
+ width = param.format.video.nFrameWidth;
+ height = param.format.video.nFrameHeight;
+ }
- {
- GstCaps *new_caps;
+ {
+ GstCaps *new_caps;
- new_caps = gst_caps_new_simple ("video/x-h264",
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", GST_TYPE_FRACTION,
- omx_base->framerate_num, omx_base->framerate_denom,
- NULL);
+ new_caps = gst_caps_new_simple ("video/x-h264",
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ "framerate", GST_TYPE_FRACTION,
+ omx_base->framerate_num, omx_base->framerate_denom, NULL);
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base_filter->srcpad, new_caps);
- }
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base_filter->srcpad, new_caps);
+ }
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base_filter;
- GstOmxBaseVideoEnc *omx_base;
+ GstOmxBaseFilter *omx_base_filter;
+ GstOmxBaseVideoEnc *omx_base;
- omx_base_filter = GST_OMX_BASE_FILTER (instance);
- omx_base = GST_OMX_BASE_VIDEOENC (instance);
+ omx_base_filter = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_VIDEOENC (instance);
- omx_base->compression_format = OMX_VIDEO_CodingAVC;
+ omx_base->compression_format = OMX_VIDEO_CodingAVC;
- omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_h264enc.h b/omx/gstomx_h264enc.h
index 4cf7100..05258a5 100644
--- a/omx/gstomx_h264enc.h
+++ b/omx/gstomx_h264enc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_H264ENC(obj) (GstOmxH264Enc *) (obj)
#define GST_OMX_H264ENC_TYPE (gst_omx_h264enc_get_type ())
-
typedef struct GstOmxH264Enc GstOmxH264Enc;
typedef struct GstOmxH264EncClass GstOmxH264EncClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxH264EncClass GstOmxH264EncClass;
struct GstOmxH264Enc
{
- GstOmxBaseVideoEnc omx_base;
+ GstOmxBaseVideoEnc omx_base;
};
struct GstOmxH264EncClass
{
- GstOmxBaseVideoEncClass parent_class;
+ GstOmxBaseVideoEncClass parent_class;
};
GType gst_omx_h264enc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_H264ENC_H */
diff --git a/omx/gstomx_ilbcdec.c b/omx/gstomx_ilbcdec.c
index 69ce9ad..580d658 100644
--- a/omx/gstomx_ilbcdec.c
+++ b/omx/gstomx_ilbcdec.c
@@ -24,141 +24,132 @@
#include "gstomx.h"
/* should this class extend GstOmxBaseAudioDec? */
-GSTOMX_BOILERPLATE (GstOmxIlbcDec, gst_omx_ilbcdec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxIlbcDec, gst_omx_ilbcdec, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("audio/x-iLBC",
- NULL);
+ struc = gst_structure_new ("audio/x-iLBC", NULL);
- {
- GValue list;
- GValue val;
+ {
+ GValue list;
+ GValue val;
- list.g_type = val.g_type = 0;
+ list.g_type = val.g_type = 0;
- g_value_init (&list, GST_TYPE_LIST);
- g_value_init (&val, G_TYPE_INT);
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, G_TYPE_INT);
- g_value_set_int (&val, 20);
- gst_value_list_append_value (&list, &val);
+ g_value_set_int (&val, 20);
+ gst_value_list_append_value (&list, &val);
- g_value_set_int (&val, 30);
- gst_value_list_append_value (&list, &val);
+ g_value_set_int (&val, 30);
+ gst_value_list_append_value (&list, &val);
- gst_structure_set_value (struc, "mode", &list);
+ gst_structure_set_value (struc, "mode", &list);
- g_value_unset (&val);
- g_value_unset (&list);
- }
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL iLBC audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in iLBC format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL iLBC audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in iLBC format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstOmxBaseFilter *omx_base;
-
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ GstOmxBaseFilter *omx_base;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- /* set caps on the srcpad */
- {
- GstCaps *tmp_caps;
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
- tmp_caps = gst_caps_make_writable (tmp_caps);
- gst_caps_truncate (tmp_caps);
+ /* set caps on the srcpad */
+ {
+ GstCaps *tmp_caps;
- gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
+ tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
+ tmp_caps = gst_caps_make_writable (tmp_caps);
+ gst_caps_truncate (tmp_caps);
- if (gst_caps_is_fixed (tmp_caps))
- {
- GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
- gst_pad_set_caps (omx_base->srcpad, tmp_caps);
- }
+ gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
- gst_caps_unref (tmp_caps);
+ if (gst_caps_is_fixed (tmp_caps)) {
+ GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
+ gst_pad_set_caps (omx_base->srcpad, tmp_caps);
}
- return gst_pad_set_caps (pad, caps);
+ gst_caps_unref (tmp_caps);
+ }
+
+ return gst_pad_set_caps (pad, caps);
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_ilbcdec.h b/omx/gstomx_ilbcdec.h
index fcf4da2..d83ccfd 100644
--- a/omx/gstomx_ilbcdec.h
+++ b/omx/gstomx_ilbcdec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_ILBCDEC(obj) (GstOmxIlbcDec *) (obj)
#define GST_OMX_ILBCDEC_TYPE (gst_omx_ilbcdec_get_type ())
-
typedef struct GstOmxIlbcDec GstOmxIlbcDec;
typedef struct GstOmxIlbcDecClass GstOmxIlbcDecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxIlbcDecClass GstOmxIlbcDecClass;
struct GstOmxIlbcDec
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxIlbcDecClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_ilbcdec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_ILBCDEC_H */
diff --git a/omx/gstomx_ilbcenc.c b/omx/gstomx_ilbcenc.c
index 5ecfbf7..b7bf6af 100644
--- a/omx/gstomx_ilbcenc.c
+++ b/omx/gstomx_ilbcenc.c
@@ -23,141 +23,132 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxIlbcEnc, gst_omx_ilbcenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxIlbcEnc, gst_omx_ilbcenc, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("audio/x-iLBC",
- NULL);
+ struc = gst_structure_new ("audio/x-iLBC", NULL);
- {
- GValue list;
- GValue val;
+ {
+ GValue list;
+ GValue val;
- list.g_type = val.g_type = 0;
+ list.g_type = val.g_type = 0;
- g_value_init (&list, GST_TYPE_LIST);
- g_value_init (&val, G_TYPE_INT);
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, G_TYPE_INT);
- g_value_set_int (&val, 20);
- gst_value_list_append_value (&list, &val);
+ g_value_set_int (&val, 20);
+ gst_value_list_append_value (&list, &val);
- g_value_set_int (&val, 30);
- gst_value_list_append_value (&list, &val);
+ g_value_set_int (&val, 30);
+ gst_value_list_append_value (&list, &val);
- gst_structure_set_value (struc, "mode", &list);
+ gst_structure_set_value (struc, "mode", &list);
- g_value_unset (&val);
- g_value_unset (&list);
- }
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", G_TYPE_INT, 1,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 8000,
+ "signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL iLBC audio encoder",
- "Codec/Encoder/Audio",
- "Encodes audio in iLBC format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL iLBC audio encoder",
+ "Codec/Encoder/Audio",
+ "Encodes audio in iLBC format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstOmxBaseFilter *omx_base;
-
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ GstOmxBaseFilter *omx_base;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- /* set caps on the srcpad */
- {
- GstCaps *tmp_caps;
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
- tmp_caps = gst_caps_make_writable (tmp_caps);
- gst_caps_truncate (tmp_caps);
+ /* set caps on the srcpad */
+ {
+ GstCaps *tmp_caps;
- gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
+ tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
+ tmp_caps = gst_caps_make_writable (tmp_caps);
+ gst_caps_truncate (tmp_caps);
- if (gst_caps_is_fixed (tmp_caps))
- {
- GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
- gst_pad_set_caps (omx_base->srcpad, tmp_caps);
- }
+ gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
- gst_caps_unref (tmp_caps);
+ if (gst_caps_is_fixed (tmp_caps)) {
+ GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
+ gst_pad_set_caps (omx_base->srcpad, tmp_caps);
}
- return gst_pad_set_caps (pad, caps);
+ gst_caps_unref (tmp_caps);
+ }
+
+ return gst_pad_set_caps (pad, caps);
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
}
diff --git a/omx/gstomx_ilbcenc.h b/omx/gstomx_ilbcenc.h
index 114e803..78e498d 100644
--- a/omx/gstomx_ilbcenc.h
+++ b/omx/gstomx_ilbcenc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_ILBCENC(obj) (GstOmxIlbcEnc *) (obj)
#define GST_OMX_ILBCENC_TYPE (gst_omx_ilbcenc_get_type ())
-
typedef struct GstOmxIlbcEnc GstOmxIlbcEnc;
typedef struct GstOmxIlbcEncClass GstOmxIlbcEncClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxIlbcEncClass GstOmxIlbcEncClass;
struct GstOmxIlbcEnc
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxIlbcEncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_ilbcenc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_ILBCENC_H */
diff --git a/omx/gstomx_interface.c b/omx/gstomx_interface.c
index f7828e7..75a04a3 100644
--- a/omx/gstomx_interface.c
+++ b/omx/gstomx_interface.c
@@ -24,19 +24,18 @@
GType
gst_omx_get_type (void)
{
- static GType type = 0;
+ static GType type = 0;
- if (G_UNLIKELY (type == 0))
- {
- GTypeInfo *type_info;
+ if (G_UNLIKELY (type == 0)) {
+ GTypeInfo *type_info;
- type_info = g_new0 (GTypeInfo, 1);
+ type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = sizeof (GstOmxClass);
+ type_info->class_size = sizeof (GstOmxClass);
- type = g_type_register_static (G_TYPE_INTERFACE, "GstOmx", type_info, 0);
- g_type_interface_add_prerequisite (type, GST_TYPE_IMPLEMENTS_INTERFACE);
- }
+ type = g_type_register_static (G_TYPE_INTERFACE, "GstOmx", type_info, 0);
+ g_type_interface_add_prerequisite (type, GST_TYPE_IMPLEMENTS_INTERFACE);
+ }
- return type;
+ return type;
}
diff --git a/omx/gstomx_interface.h b/omx/gstomx_interface.h
index 5804e84..896c9e1 100644
--- a/omx/gstomx_interface.h
+++ b/omx/gstomx_interface.h
@@ -25,21 +25,18 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_OMX (gst_omx_get_type ())
#define GST_OMX(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_OMX, GstOmx))
#define GST_IS_OMX(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_OMX))
-
typedef struct GstOmx GstOmx;
typedef struct GstOmxClass
{
- GTypeInterface klass;
+ GTypeInterface klass;
} GstOmxClass;
GType gst_omx_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_INTERFACE_H */
diff --git a/omx/gstomx_jpegenc.c b/omx/gstomx_jpegenc.c
index 0ca4f8e..3e83f03 100644
--- a/omx/gstomx_jpegenc.c
+++ b/omx/gstomx_jpegenc.c
@@ -28,333 +28,314 @@
enum
{
- ARG_0,
- ARG_QUALITY,
+ ARG_0,
+ ARG_QUALITY,
};
#define DEFAULT_QUALITY 90
-GSTOMX_BOILERPLATE (GstOmxJpegEnc, gst_omx_jpegenc, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxJpegEnc, gst_omx_jpegenc, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("image/jpeg",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ caps = gst_caps_new_simple ("image/jpeg",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- return caps;
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/x-raw-yuv",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-raw-yuv",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- {
- GValue list = { 0 };
- GValue val = { 0 };
+ {
+ GValue list = { 0 };
+ GValue val = { 0 };
- g_value_init (&list, GST_TYPE_LIST);
- g_value_init (&val, GST_TYPE_FOURCC);
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, GST_TYPE_FOURCC);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
+ gst_value_list_append_value (&list, &val);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
+ gst_value_list_append_value (&list, &val);
- gst_structure_set_value (struc, "format", &list);
+ gst_structure_set_value (struc, "format", &list);
- g_value_unset (&val);
- g_value_unset (&list);
- }
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL JPEG image encoder",
- "Codec/Encoder/Image",
- "Encodes image in JPEG format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL JPEG image encoder",
+ "Codec/Encoder/Image",
+ "Encodes image in JPEG format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-set_property (GObject *obj,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+set_property (GObject * obj,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxJpegEnc *self;
-
- self = GST_OMX_JPEGENC (obj);
-
- switch (prop_id)
- {
- case ARG_QUALITY:
- self->quality = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxJpegEnc *self;
+
+ self = GST_OMX_JPEGENC (obj);
+
+ switch (prop_id) {
+ case ARG_QUALITY:
+ self->quality = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-get_property (GObject *obj,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstOmxJpegEnc *self;
-
- self = GST_OMX_JPEGENC (obj);
-
- switch (prop_id)
- {
- case ARG_QUALITY:
- g_value_set_uint (value, self->quality);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
- break;
- }
+ GstOmxJpegEnc *self;
+
+ self = GST_OMX_JPEGENC (obj);
+
+ switch (prop_id) {
+ case ARG_QUALITY:
+ g_value_set_uint (value, self->quality);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
- gobject_class = G_OBJECT_CLASS (g_class);
+ gobject_class = G_OBJECT_CLASS (g_class);
- /* Properties stuff */
- {
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
-
- g_object_class_install_property (gobject_class, ARG_QUALITY,
- g_param_spec_uint ("quality", "Quality of image",
- "Set the quality from 0 to 100",
- 0, 100, DEFAULT_QUALITY,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ /* Properties stuff */
+ {
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
+
+ g_object_class_install_property (gobject_class, ARG_QUALITY,
+ g_param_spec_uint ("quality", "Quality of image",
+ "Set the quality from 0 to 100",
+ 0, 100, DEFAULT_QUALITY,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseFilter *omx_base;
- GstOmxJpegEnc *self;
- guint width;
- guint height;
+ GstOmxBaseFilter *omx_base;
+ GstOmxJpegEnc *self;
+ guint width;
+ guint height;
- omx_base = core->object;
- self = GST_OMX_JPEGENC (omx_base);
+ omx_base = core->object;
+ self = GST_OMX_JPEGENC (omx_base);
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition,
+ &param);
- width = param.format.image.nFrameWidth;
- height = param.format.image.nFrameHeight;
- }
+ width = param.format.image.nFrameWidth;
+ height = param.format.image.nFrameHeight;
+ }
- {
- GstCaps *new_caps;
+ {
+ GstCaps *new_caps;
- new_caps = gst_caps_new_simple ("image/jpeg",
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", GST_TYPE_FRACTION,
- self->framerate_num, self->framerate_denom,
- NULL);
+ new_caps = gst_caps_new_simple ("image/jpeg",
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ "framerate", GST_TYPE_FRACTION,
+ self->framerate_num, self->framerate_denom, NULL);
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
}
static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
+sink_setcaps (GstPad * pad, GstCaps * caps)
{
- GstStructure *structure;
- GstOmxBaseFilter *omx_base;
- GstOmxJpegEnc *self;
- GOmxCore *gomx;
- OMX_COLOR_FORMATTYPE color_format = OMX_COLOR_FormatYUV420PackedPlanar;
- gint width = 0;
- gint height = 0;
+ GstStructure *structure;
+ GstOmxBaseFilter *omx_base;
+ GstOmxJpegEnc *self;
+ GOmxCore *gomx;
+ OMX_COLOR_FORMATTYPE color_format = OMX_COLOR_FormatYUV420PackedPlanar;
+ gint width = 0;
+ gint height = 0;
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- self = GST_OMX_JPEGENC (omx_base);
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ self = GST_OMX_JPEGENC (omx_base);
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
- if (!gst_structure_get_fraction (structure, "framerate",
- &self->framerate_num,
- &self->framerate_denom))
- {
- self->framerate_num = 0;
- self->framerate_denom = 1;
+ if (!gst_structure_get_fraction (structure, "framerate",
+ &self->framerate_num, &self->framerate_denom)) {
+ self->framerate_num = 0;
+ self->framerate_denom = 1;
+ }
+
+ if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
+ guint32 fourcc;
+
+ if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
+ switch (fourcc) {
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ color_format = OMX_COLOR_FormatYUV420PackedPlanar;
+ break;
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+ color_format = OMX_COLOR_FormatCbYCrY;
+ break;
+ }
}
+ }
- if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0)
- {
- guint32 fourcc;
-
- if (gst_structure_get_fourcc (structure, "format", &fourcc))
- {
- switch (fourcc)
- {
- case GST_MAKE_FOURCC ('I', '4', '2', '0'):
- color_format = OMX_COLOR_FormatYUV420PackedPlanar;
- break;
- case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
- color_format = OMX_COLOR_FormatCbYCrY;
- break;
- }
- }
- }
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
+ G_OMX_INIT_PARAM (param);
- G_OMX_INIT_PARAM (param);
-
- /* Input port configuration. */
- {
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+ /* Input port configuration. */
+ {
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- param.format.image.nFrameWidth = width;
- param.format.image.nFrameHeight = height;
- param.format.image.eColorFormat = color_format;
+ param.format.image.nFrameWidth = width;
+ param.format.image.nFrameHeight = height;
+ param.format.image.eColorFormat = color_format;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
}
+ }
- return gst_pad_set_caps (pad, caps);
+ return gst_pad_set_caps (pad, caps);
}
static void
-omx_setup (GstOmxBaseFilter *omx_base)
+omx_setup (GstOmxBaseFilter * omx_base)
{
- GstOmxJpegEnc *self;
- GOmxCore *gomx;
+ GstOmxJpegEnc *self;
+ GOmxCore *gomx;
- self = GST_OMX_JPEGENC (omx_base);
- gomx = (GOmxCore *) omx_base->gomx;
+ self = GST_OMX_JPEGENC (omx_base);
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "begin");
+ GST_INFO_OBJECT (omx_base, "begin");
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- /* Output port configuration. */
- {
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+ /* Output port configuration. */
+ {
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- param.format.image.eCompressionFormat = OMX_IMAGE_CodingJPEG;
+ param.format.image.eCompressionFormat = OMX_IMAGE_CodingJPEG;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
}
+ }
- {
- OMX_IMAGE_PARAM_QFACTORTYPE param;
+ {
+ OMX_IMAGE_PARAM_QFACTORTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nQFactor = self->quality;
- param.nPortIndex = omx_base->out_port->port_index;
+ param.nQFactor = self->quality;
+ param.nPortIndex = omx_base->out_port->port_index;
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamQFactor, &param);
- }
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamQFactor, &param);
+ }
- GST_INFO_OBJECT (omx_base, "end");
+ GST_INFO_OBJECT (omx_base, "end");
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
- GstOmxJpegEnc *self;
+ GstOmxBaseFilter *omx_base;
+ GstOmxJpegEnc *self;
- omx_base = GST_OMX_BASE_FILTER (instance);
- self = GST_OMX_JPEGENC (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
+ self = GST_OMX_JPEGENC (instance);
- omx_base->omx_setup = omx_setup;
+ omx_base->omx_setup = omx_setup;
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
- gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
+ gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
- self->framerate_num = 0;
- self->framerate_denom = 1;
- self->quality = DEFAULT_QUALITY;
+ self->framerate_num = 0;
+ self->framerate_denom = 1;
+ self->quality = DEFAULT_QUALITY;
}
diff --git a/omx/gstomx_jpegenc.h b/omx/gstomx_jpegenc.h
index b14a0d0..be3a3e1 100644
--- a/omx/gstomx_jpegenc.h
+++ b/omx/gstomx_jpegenc.h
@@ -27,10 +27,8 @@
#include <config.h>
G_BEGIN_DECLS
-
#define GST_OMX_JPEGENC(obj) (GstOmxJpegEnc *) (obj)
#define GST_OMX_JPEGENC_TYPE (gst_omx_jpegenc_get_type ())
-
typedef struct GstOmxJpegEnc GstOmxJpegEnc;
typedef struct GstOmxJpegEncClass GstOmxJpegEncClass;
@@ -38,20 +36,19 @@ typedef struct GstOmxJpegEncClass GstOmxJpegEncClass;
struct GstOmxJpegEnc
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
- gint framerate_num;
- gint framerate_denom;
- guint quality;
+ gint framerate_num;
+ gint framerate_denom;
+ guint quality;
};
struct GstOmxJpegEncClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_jpegenc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_JPEGENC_H */
diff --git a/omx/gstomx_mp2dec.c b/omx/gstomx_mp2dec.c
index 9168d98..0211f08 100644
--- a/omx/gstomx_mp2dec.c
+++ b/omx/gstomx_mp2dec.c
@@ -23,83 +23,77 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxMp2Dec, gst_omx_mp2dec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxMp2Dec, gst_omx_mp2dec, GstOmxBaseAudioDec,
+ GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", GST_TYPE_INT_RANGE, 1, 2,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("audio/mpeg",
- "mpegversion", G_TYPE_INT, 1,
- "layer", G_TYPE_INT, 2,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "channels", GST_TYPE_INT_RANGE, 1, 2,
- "parsed", G_TYPE_BOOLEAN, TRUE,
- NULL);
+ caps = gst_caps_new_simple ("audio/mpeg",
+ "mpegversion", G_TYPE_INT, 1,
+ "layer", G_TYPE_INT, 2,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "channels", GST_TYPE_INT_RANGE, 1, 2,
+ "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL MP2 audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in MP2 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL MP2 audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in MP2 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
}
diff --git a/omx/gstomx_mp2dec.h b/omx/gstomx_mp2dec.h
index c6c517e..c744245 100644
--- a/omx/gstomx_mp2dec.h
+++ b/omx/gstomx_mp2dec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_MP2DEC(obj) (GstOmxMp2Dec *) (obj)
#define GST_OMX_MP2DEC_TYPE (gst_omx_mp2dec_get_type ())
-
typedef struct GstOmxMp2Dec GstOmxMp2Dec;
typedef struct GstOmxMp2DecClass GstOmxMp2DecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxMp2DecClass GstOmxMp2DecClass;
struct GstOmxMp2Dec
{
- GstOmxBaseAudioDec omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxMp2DecClass
{
- GstOmxBaseAudioDecClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_mp2dec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_MP2DEC_H */
diff --git a/omx/gstomx_mp3dec.c b/omx/gstomx_mp3dec.c
index 19c217d..a617771 100644
--- a/omx/gstomx_mp3dec.c
+++ b/omx/gstomx_mp3dec.c
@@ -22,83 +22,77 @@
#include "gstomx_mp3dec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxMp3Dec, gst_omx_mp3dec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxMp3Dec, gst_omx_mp3dec, GstOmxBaseAudioDec,
+ GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", GST_TYPE_INT_RANGE, 1, 2,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("audio/mpeg",
- "mpegversion", G_TYPE_INT, 1,
- "layer", G_TYPE_INT, 3,
- "rate", GST_TYPE_INT_RANGE, 8000, 48000,
- "channels", GST_TYPE_INT_RANGE, 1, 8,
- "parsed", G_TYPE_BOOLEAN, TRUE,
- NULL);
+ caps = gst_caps_new_simple ("audio/mpeg",
+ "mpegversion", G_TYPE_INT, 1,
+ "layer", G_TYPE_INT, 3,
+ "rate", GST_TYPE_INT_RANGE, 8000, 48000,
+ "channels", GST_TYPE_INT_RANGE, 1, 8,
+ "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL MP3 audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in MP3 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL MP3 audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in MP3 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
}
diff --git a/omx/gstomx_mp3dec.h b/omx/gstomx_mp3dec.h
index c0a7d78..f88481a 100644
--- a/omx/gstomx_mp3dec.h
+++ b/omx/gstomx_mp3dec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_MP3DEC(obj) (GstOmxMp3Dec *) (obj)
#define GST_OMX_MP3DEC_TYPE (gst_omx_mp3dec_get_type ())
-
typedef struct GstOmxMp3Dec GstOmxMp3Dec;
typedef struct GstOmxMp3DecClass GstOmxMp3DecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxMp3DecClass GstOmxMp3DecClass;
struct GstOmxMp3Dec
{
- GstOmxBaseAudioDec omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxMp3DecClass
{
- GstOmxBaseAudioDecClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_mp3dec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_MP3DEC_H */
diff --git a/omx/gstomx_mpeg4dec.c b/omx/gstomx_mpeg4dec.c
index 59b04a9..f112ecb 100644
--- a/omx/gstomx_mpeg4dec.c
+++ b/omx/gstomx_mpeg4dec.c
@@ -22,91 +22,84 @@
#include "gstomx_mpeg4dec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxMpeg4Dec, gst_omx_mpeg4dec, GstOmxBaseVideoDec, GST_OMX_BASE_VIDEODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxMpeg4Dec, gst_omx_mpeg4dec, GstOmxBaseVideoDec,
+ GST_OMX_BASE_VIDEODEC_TYPE);
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/mpeg",
- "mpegversion", G_TYPE_INT, 4,
- "systemstream", G_TYPE_BOOLEAN, FALSE,
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/mpeg",
+ "mpegversion", G_TYPE_INT, 4,
+ "systemstream", G_TYPE_BOOLEAN, FALSE,
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- struc = gst_structure_new ("video/x-divx",
- "divxversion", GST_TYPE_INT_RANGE, 4, 5,
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-divx",
+ "divxversion", GST_TYPE_INT_RANGE, 4, 5,
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- struc = gst_structure_new ("video/x-xvid",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-xvid",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- struc = gst_structure_new ("video/x-3ivx",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-3ivx",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL MPEG-4 video decoder",
- "Codec/Decoder/Video",
- "Decodes video in MPEG-4 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL MPEG-4 video decoder",
+ "Codec/Decoder/Video",
+ "Decodes video in MPEG-4 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseVideoDec *omx_base;
+ GstOmxBaseVideoDec *omx_base;
- omx_base = GST_OMX_BASE_VIDEODEC (instance);
+ omx_base = GST_OMX_BASE_VIDEODEC (instance);
- omx_base->compression_format = OMX_VIDEO_CodingMPEG4;
+ omx_base->compression_format = OMX_VIDEO_CodingMPEG4;
}
diff --git a/omx/gstomx_mpeg4dec.h b/omx/gstomx_mpeg4dec.h
index ed35ac0..1b5cce8 100644
--- a/omx/gstomx_mpeg4dec.h
+++ b/omx/gstomx_mpeg4dec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_MPEG4DEC(obj) (GstOmxMpeg4Dec *) (obj)
#define GST_OMX_MPEG4DEC_TYPE (gst_omx_mpeg4dec_get_type ())
-
typedef struct GstOmxMpeg4Dec GstOmxMpeg4Dec;
typedef struct GstOmxMpeg4DecClass GstOmxMpeg4DecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxMpeg4DecClass GstOmxMpeg4DecClass;
struct GstOmxMpeg4Dec
{
- GstOmxBaseVideoDec omx_base;
+ GstOmxBaseVideoDec omx_base;
};
struct GstOmxMpeg4DecClass
{
- GstOmxBaseVideoDecClass parent_class;
+ GstOmxBaseVideoDecClass parent_class;
};
GType gst_omx_mpeg4dec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_MPEG4DEC_H */
diff --git a/omx/gstomx_mpeg4enc.c b/omx/gstomx_mpeg4enc.c
index b715fc2..ca6d4ed 100644
--- a/omx/gstomx_mpeg4enc.c
+++ b/omx/gstomx_mpeg4enc.c
@@ -22,107 +22,102 @@
#include "gstomx_mpeg4enc.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxMpeg4Enc, gst_omx_mpeg4enc, GstOmxBaseVideoEnc, GST_OMX_BASE_VIDEOENC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxMpeg4Enc, gst_omx_mpeg4enc, GstOmxBaseVideoEnc,
+ GST_OMX_BASE_VIDEOENC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
+ GstCaps *caps;
- caps = gst_caps_new_simple ("video/mpeg",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- "mpegversion", G_TYPE_INT, 4,
- "systemstream", G_TYPE_BOOLEAN, FALSE,
- NULL);
+ caps = gst_caps_new_simple ("video/mpeg",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
+ "mpegversion", G_TYPE_INT, 4,
+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL MPEG-4 video encoder",
- "Codec/Encoder/Video",
- "Encodes video in MPEG-4 format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL MPEG-4 video encoder",
+ "Codec/Encoder/Video",
+ "Encodes video in MPEG-4 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseVideoEnc *omx_base;
- GstOmxBaseFilter *omx_base_filter;
- guint width;
- guint height;
+ GstOmxBaseVideoEnc *omx_base;
+ GstOmxBaseFilter *omx_base_filter;
+ guint width;
+ guint height;
- omx_base_filter = core->object;
- omx_base = GST_OMX_BASE_VIDEOENC (omx_base_filter);
+ omx_base_filter = core->object;
+ omx_base = GST_OMX_BASE_VIDEOENC (omx_base_filter);
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base_filter->out_port->port_index;
- OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+ param.nPortIndex = omx_base_filter->out_port->port_index;
+ OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
- width = param.format.video.nFrameWidth;
- height = param.format.video.nFrameHeight;
- }
+ width = param.format.video.nFrameWidth;
+ height = param.format.video.nFrameHeight;
+ }
- {
- GstCaps *new_caps;
+ {
+ GstCaps *new_caps;
- new_caps = gst_caps_new_simple ("video/mpeg",
- "mpegversion", G_TYPE_INT, 4,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", GST_TYPE_FRACTION,
- omx_base->framerate_num, omx_base->framerate_denom,
- "systemstream", G_TYPE_BOOLEAN, FALSE,
- NULL);
+ new_caps = gst_caps_new_simple ("video/mpeg",
+ "mpegversion", G_TYPE_INT, 4,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ "framerate", GST_TYPE_FRACTION,
+ omx_base->framerate_num, omx_base->framerate_denom,
+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base_filter->srcpad, new_caps);
- }
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base_filter->srcpad, new_caps);
+ }
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base_filter;
- GstOmxBaseVideoEnc *omx_base;
+ GstOmxBaseFilter *omx_base_filter;
+ GstOmxBaseVideoEnc *omx_base;
- omx_base_filter = GST_OMX_BASE_FILTER (instance);
- omx_base = GST_OMX_BASE_VIDEOENC (instance);
+ omx_base_filter = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_VIDEOENC (instance);
- omx_base->compression_format = OMX_VIDEO_CodingMPEG4;
+ omx_base->compression_format = OMX_VIDEO_CodingMPEG4;
- omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base_filter->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_mpeg4enc.h b/omx/gstomx_mpeg4enc.h
index 9fab0b4..da904e0 100644
--- a/omx/gstomx_mpeg4enc.h
+++ b/omx/gstomx_mpeg4enc.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_MPEG4ENC(obj) (GstOmxMpeg4Enc *) (obj)
#define GST_OMX_MPEG4ENC_TYPE (gst_omx_mpeg4enc_get_type ())
-
typedef struct GstOmxMpeg4Enc GstOmxMpeg4Enc;
typedef struct GstOmxMpeg4EncClass GstOmxMpeg4EncClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxMpeg4EncClass GstOmxMpeg4EncClass;
struct GstOmxMpeg4Enc
{
- GstOmxBaseVideoEnc omx_base;
+ GstOmxBaseVideoEnc omx_base;
};
struct GstOmxMpeg4EncClass
{
- GstOmxBaseVideoEncClass parent_class;
+ GstOmxBaseVideoEncClass parent_class;
};
GType gst_omx_mpeg4enc_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_MPEG4ENC_H */
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 283c32d..423e441 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -31,65 +31,49 @@ GST_DEBUG_CATEGORY (gstomx_util_debug);
* Forward declarations
*/
-static inline void
-change_state (GOmxCore *core,
- OMX_STATETYPE state);
+static inline void change_state (GOmxCore * core, OMX_STATETYPE state);
-static inline void
-wait_for_state (GOmxCore *core,
- OMX_STATETYPE state);
+static inline void wait_for_state (GOmxCore * core, OMX_STATETYPE state);
static inline void
-in_port_cb (GOmxPort *port,
- OMX_BUFFERHEADERTYPE *omx_buffer);
+in_port_cb (GOmxPort * port, OMX_BUFFERHEADERTYPE * omx_buffer);
static inline void
-out_port_cb (GOmxPort *port,
- OMX_BUFFERHEADERTYPE *omx_buffer);
+out_port_cb (GOmxPort * port, OMX_BUFFERHEADERTYPE * omx_buffer);
static inline void
-got_buffer (GOmxCore *core,
- GOmxPort *port,
- OMX_BUFFERHEADERTYPE *omx_buffer);
+got_buffer (GOmxCore * core,
+ GOmxPort * port, OMX_BUFFERHEADERTYPE * omx_buffer);
static OMX_ERRORTYPE
EventHandler (OMX_HANDLETYPE omx_handle,
- OMX_PTR app_data,
- OMX_EVENTTYPE event,
- OMX_U32 data_1,
- OMX_U32 data_2,
- OMX_PTR event_data);
+ OMX_PTR app_data,
+ OMX_EVENTTYPE event, OMX_U32 data_1, OMX_U32 data_2, OMX_PTR event_data);
static OMX_ERRORTYPE
EmptyBufferDone (OMX_HANDLETYPE omx_handle,
- OMX_PTR app_data,
- OMX_BUFFERHEADERTYPE *omx_buffer);
+ OMX_PTR app_data, OMX_BUFFERHEADERTYPE * omx_buffer);
static OMX_ERRORTYPE
FillBufferDone (OMX_HANDLETYPE omx_handle,
- OMX_PTR app_data,
- OMX_BUFFERHEADERTYPE *omx_buffer);
+ OMX_PTR app_data, OMX_BUFFERHEADERTYPE * omx_buffer);
-static inline const char *
-omx_state_to_str (OMX_STATETYPE omx_state);
+static inline const char *omx_state_to_str (OMX_STATETYPE omx_state);
-static inline const char *
-omx_error_to_str (OMX_ERRORTYPE omx_error);
+static inline const char *omx_error_to_str (OMX_ERRORTYPE omx_error);
-static inline GOmxPort * get_port (GOmxCore *core, guint index);
+static inline GOmxPort *get_port (GOmxCore * core, guint index);
-static void core_deinit (GOmxCore *core);
+static void core_deinit (GOmxCore * core);
-static inline void
-port_free_buffers (GOmxPort *port);
+static inline void port_free_buffers (GOmxPort * port);
-static inline void
-port_allocate_buffers (GOmxPort *port);
+static inline void port_allocate_buffers (GOmxPort * port);
-static inline void
-port_start_buffers (GOmxPort *port);
+static inline void port_start_buffers (GOmxPort * port);
-static OMX_CALLBACKTYPE callbacks = { EventHandler, EmptyBufferDone, FillBufferDone };
+static OMX_CALLBACKTYPE callbacks =
+ { EventHandler, EmptyBufferDone, FillBufferDone };
/* protect implementations hash_table */
static GMutex *imp_mutex;
@@ -101,168 +85,153 @@ static gboolean initialized;
*/
static void
-g_ptr_array_clear (GPtrArray *array)
+g_ptr_array_clear (GPtrArray * array)
{
- guint index;
- for (index = 0; index < array->len; index++)
- array->pdata[index] = NULL;
+ guint index;
+ for (index = 0; index < array->len; index++)
+ array->pdata[index] = NULL;
}
static void
-g_ptr_array_insert (GPtrArray *array,
- guint index,
- gpointer data)
+g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
{
- if (index + 1 > array->len)
- {
- g_ptr_array_set_size (array, index + 1);
- }
+ if (index + 1 > array->len) {
+ g_ptr_array_set_size (array, index + 1);
+ }
- array->pdata[index] = data;
+ array->pdata[index] = data;
}
-typedef void (*GOmxPortFunc) (GOmxPort *port);
+typedef void (*GOmxPortFunc) (GOmxPort * port);
static inline void
-core_for_each_port (GOmxCore *core,
- GOmxPortFunc func)
+core_for_each_port (GOmxCore * core, GOmxPortFunc func)
{
- guint index;
+ guint index;
- for (index = 0; index < core->ports->len; index++)
- {
- GOmxPort *port;
+ for (index = 0; index < core->ports->len; index++) {
+ GOmxPort *port;
- port = get_port (core, index);
+ port = get_port (core, index);
- if (port)
- func (port);
- }
+ if (port)
+ func (port);
+ }
}
/*
* Main
*/
-static GOmxImp *imp_new (const gchar *name);
-static void imp_free (GOmxImp *imp);
+static GOmxImp *imp_new (const gchar * name);
+static void imp_free (GOmxImp * imp);
static GOmxImp *
-imp_new (const gchar *name)
+imp_new (const gchar * name)
{
- GOmxImp *imp;
+ GOmxImp *imp;
- imp = g_new0 (GOmxImp, 1);
+ imp = g_new0 (GOmxImp, 1);
- /* Load the OpenMAX IL symbols */
- {
- void *handle;
-
- GST_DEBUG ("loading: %s", name);
+ /* Load the OpenMAX IL symbols */
+ {
+ void *handle;
- imp->dl_handle = handle = dlopen (name, RTLD_LAZY);
+ GST_DEBUG ("loading: %s", name);
- GST_DEBUG ("dlopen(%s) -> %p", name, handle);
+ imp->dl_handle = handle = dlopen (name, RTLD_LAZY);
- if (!handle)
- {
- g_warning ("%s\n", dlerror ());
- g_free (imp);
- return NULL;
- }
+ GST_DEBUG ("dlopen(%s) -> %p", name, handle);
- imp->mutex = g_mutex_new ();
- imp->sym_table.init = dlsym (handle, "OMX_Init");
- imp->sym_table.deinit = dlsym (handle, "OMX_Deinit");
- imp->sym_table.get_handle = dlsym (handle, "OMX_GetHandle");
- imp->sym_table.free_handle = dlsym (handle, "OMX_FreeHandle");
+ if (!handle) {
+ g_warning ("%s\n", dlerror ());
+ g_free (imp);
+ return NULL;
}
- return imp;
+ imp->mutex = g_mutex_new ();
+ imp->sym_table.init = dlsym (handle, "OMX_Init");
+ imp->sym_table.deinit = dlsym (handle, "OMX_Deinit");
+ imp->sym_table.get_handle = dlsym (handle, "OMX_GetHandle");
+ imp->sym_table.free_handle = dlsym (handle, "OMX_FreeHandle");
+ }
+
+ return imp;
}
static void
-imp_free (GOmxImp *imp)
+imp_free (GOmxImp * imp)
{
- if (imp->dl_handle)
- {
- dlclose (imp->dl_handle);
- }
- g_mutex_free (imp->mutex);
- g_free (imp);
+ if (imp->dl_handle) {
+ dlclose (imp->dl_handle);
+ }
+ g_mutex_free (imp->mutex);
+ g_free (imp);
}
static inline GOmxImp *
-request_imp (const gchar *name)
+request_imp (const gchar * name)
{
- GOmxImp *imp = NULL;
-
- g_mutex_lock (imp_mutex);
- imp = g_hash_table_lookup (implementations, name);
- if (!imp)
- {
- imp = imp_new (name);
- if (imp)
- g_hash_table_insert (implementations, g_strdup (name), imp);
- }
- g_mutex_unlock (imp_mutex);
-
- if (!imp)
- return NULL;
+ GOmxImp *imp = NULL;
+
+ g_mutex_lock (imp_mutex);
+ imp = g_hash_table_lookup (implementations, name);
+ if (!imp) {
+ imp = imp_new (name);
+ if (imp)
+ g_hash_table_insert (implementations, g_strdup (name), imp);
+ }
+ g_mutex_unlock (imp_mutex);
+
+ if (!imp)
+ return NULL;
- g_mutex_lock (imp->mutex);
- if (imp->client_count == 0)
- {
- OMX_ERRORTYPE omx_error;
- omx_error = imp->sym_table.init ();
- if (omx_error)
- {
- g_mutex_unlock (imp->mutex);
- return NULL;
- }
+ g_mutex_lock (imp->mutex);
+ if (imp->client_count == 0) {
+ OMX_ERRORTYPE omx_error;
+ omx_error = imp->sym_table.init ();
+ if (omx_error) {
+ g_mutex_unlock (imp->mutex);
+ return NULL;
}
- imp->client_count++;
- g_mutex_unlock (imp->mutex);
+ }
+ imp->client_count++;
+ g_mutex_unlock (imp->mutex);
- return imp;
+ return imp;
}
static inline void
-release_imp (GOmxImp *imp)
+release_imp (GOmxImp * imp)
{
- g_mutex_lock (imp->mutex);
- imp->client_count--;
- if (imp->client_count == 0)
- {
- imp->sym_table.deinit ();
- }
- g_mutex_unlock (imp->mutex);
+ g_mutex_lock (imp->mutex);
+ imp->client_count--;
+ if (imp->client_count == 0) {
+ imp->sym_table.deinit ();
+ }
+ g_mutex_unlock (imp->mutex);
}
void
g_omx_init (void)
{
- if (!initialized)
- {
- /* safe as plugin_init is safe */
- imp_mutex = g_mutex_new ();
- implementations = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- (GDestroyNotify) imp_free);
- initialized = TRUE;
- }
+ if (!initialized) {
+ /* safe as plugin_init is safe */
+ imp_mutex = g_mutex_new ();
+ implementations = g_hash_table_new_full (g_str_hash,
+ g_str_equal, g_free, (GDestroyNotify) imp_free);
+ initialized = TRUE;
+ }
}
void
g_omx_deinit (void)
{
- if (initialized)
- {
- g_hash_table_destroy (implementations);
- g_mutex_free (imp_mutex);
- initialized = FALSE;
- }
+ if (initialized) {
+ g_hash_table_destroy (implementations);
+ g_mutex_free (imp_mutex);
+ initialized = FALSE;
+ }
}
/*
@@ -272,224 +241,211 @@ g_omx_deinit (void)
GOmxCore *
g_omx_core_new (void *object)
{
- GOmxCore *core;
+ GOmxCore *core;
- core = g_new0 (GOmxCore, 1);
+ core = g_new0 (GOmxCore, 1);
- core->object = object;
- core->ports = g_ptr_array_new ();
+ core->object = object;
+ core->ports = g_ptr_array_new ();
- core->omx_state_condition = g_cond_new ();
- core->omx_state_mutex = g_mutex_new ();
+ core->omx_state_condition = g_cond_new ();
+ core->omx_state_mutex = g_mutex_new ();
- core->done_sem = g_sem_new ();
- core->flush_sem = g_sem_new ();
- core->port_sem = g_sem_new ();
+ core->done_sem = g_sem_new ();
+ core->flush_sem = g_sem_new ();
+ core->port_sem = g_sem_new ();
- core->omx_state = OMX_StateInvalid;
+ core->omx_state = OMX_StateInvalid;
- return core;
+ return core;
}
void
-g_omx_core_free (GOmxCore *core)
+g_omx_core_free (GOmxCore * core)
{
- core_deinit (core);
+ core_deinit (core);
- g_sem_free (core->port_sem);
- g_sem_free (core->flush_sem);
- g_sem_free (core->done_sem);
+ g_sem_free (core->port_sem);
+ g_sem_free (core->flush_sem);
+ g_sem_free (core->done_sem);
- g_mutex_free (core->omx_state_mutex);
- g_cond_free (core->omx_state_condition);
+ g_mutex_free (core->omx_state_mutex);
+ g_cond_free (core->omx_state_condition);
- g_ptr_array_free (core->ports, TRUE);
+ g_ptr_array_free (core->ports, TRUE);
- g_free (core);
+ g_free (core);
}
void
-g_omx_core_init (GOmxCore *core)
+g_omx_core_init (GOmxCore * core)
{
- GST_DEBUG_OBJECT (core->object, "loading: %s %s (%s)",
- core->component_name,
- core->component_role ? core->component_role : "",
- core->library_name);
+ GST_DEBUG_OBJECT (core->object, "loading: %s %s (%s)",
+ core->component_name,
+ core->component_role ? core->component_role : "", core->library_name);
- core->imp = request_imp (core->library_name);
+ core->imp = request_imp (core->library_name);
- if (!core->imp)
- return;
+ if (!core->imp)
+ return;
- core->omx_error = core->imp->sym_table.get_handle (&core->omx_handle,
- (char *) core->component_name,
- core,
- &callbacks);
+ core->omx_error = core->imp->sym_table.get_handle (&core->omx_handle,
+ (char *) core->component_name, core, &callbacks);
- GST_DEBUG_OBJECT (core->object, "OMX_GetHandle(&%p) -> %d",
- core->omx_handle, core->omx_error);
+ GST_DEBUG_OBJECT (core->object, "OMX_GetHandle(&%p) -> %d",
+ core->omx_handle, core->omx_error);
- if (!core->omx_error)
- {
- core->omx_state = OMX_StateLoaded;
+ if (!core->omx_error) {
+ core->omx_state = OMX_StateLoaded;
- if (core->component_role)
- {
- OMX_PARAM_COMPONENTROLETYPE param;
+ if (core->component_role) {
+ OMX_PARAM_COMPONENTROLETYPE param;
- GST_DEBUG_OBJECT (core->object, "setting component role: %s",
- core->component_role);
+ GST_DEBUG_OBJECT (core->object, "setting component role: %s",
+ core->component_role);
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- strncpy ((char *) param.cRole, core->component_role, OMX_MAX_STRINGNAME_SIZE);
+ strncpy ((char *) param.cRole, core->component_role,
+ OMX_MAX_STRINGNAME_SIZE);
- OMX_SetParameter (core->omx_handle, OMX_IndexParamStandardComponentRole, &param);
- }
+ OMX_SetParameter (core->omx_handle, OMX_IndexParamStandardComponentRole,
+ &param);
}
+ }
}
static void
-core_deinit (GOmxCore *core)
+core_deinit (GOmxCore * core)
{
- if (!core->imp)
- return;
-
- if (core->omx_state == OMX_StateLoaded ||
- core->omx_state == OMX_StateInvalid)
- {
- if (core->omx_handle)
- {
- core->omx_error = core->imp->sym_table.free_handle (core->omx_handle);
- GST_DEBUG_OBJECT (core->object, "OMX_FreeHandle(%p) -> %d",
- core->omx_handle, core->omx_error);
- }
- }
- else
- {
- GST_WARNING_OBJECT (core->object, "Incorrect state: %s",
- omx_state_to_str (core->omx_state));
+ if (!core->imp)
+ return;
+
+ if (core->omx_state == OMX_StateLoaded || core->omx_state == OMX_StateInvalid) {
+ if (core->omx_handle) {
+ core->omx_error = core->imp->sym_table.free_handle (core->omx_handle);
+ GST_DEBUG_OBJECT (core->object, "OMX_FreeHandle(%p) -> %d",
+ core->omx_handle, core->omx_error);
}
+ } else {
+ GST_WARNING_OBJECT (core->object, "Incorrect state: %s",
+ omx_state_to_str (core->omx_state));
+ }
- g_free (core->library_name);
- g_free (core->component_name);
- g_free (core->component_role);
+ g_free (core->library_name);
+ g_free (core->component_name);
+ g_free (core->component_role);
- release_imp (core->imp);
- core->imp = NULL;
+ release_imp (core->imp);
+ core->imp = NULL;
}
void
-g_omx_core_prepare (GOmxCore *core)
+g_omx_core_prepare (GOmxCore * core)
{
- change_state (core, OMX_StateIdle);
+ change_state (core, OMX_StateIdle);
- /* Allocate buffers. */
- core_for_each_port (core, port_allocate_buffers);
+ /* Allocate buffers. */
+ core_for_each_port (core, port_allocate_buffers);
- wait_for_state (core, OMX_StateIdle);
+ wait_for_state (core, OMX_StateIdle);
}
void
-g_omx_core_start (GOmxCore *core)
+g_omx_core_start (GOmxCore * core)
{
- change_state (core, OMX_StateExecuting);
- wait_for_state (core, OMX_StateExecuting);
+ change_state (core, OMX_StateExecuting);
+ wait_for_state (core, OMX_StateExecuting);
- if (core->omx_state == OMX_StateExecuting)
- core_for_each_port (core, port_start_buffers);
+ if (core->omx_state == OMX_StateExecuting)
+ core_for_each_port (core, port_start_buffers);
}
void
-g_omx_core_stop (GOmxCore *core)
+g_omx_core_stop (GOmxCore * core)
{
- if (core->omx_state == OMX_StateExecuting ||
- core->omx_state == OMX_StatePause)
- {
- change_state (core, OMX_StateIdle);
- wait_for_state (core, OMX_StateIdle);
- }
+ if (core->omx_state == OMX_StateExecuting ||
+ core->omx_state == OMX_StatePause) {
+ change_state (core, OMX_StateIdle);
+ wait_for_state (core, OMX_StateIdle);
+ }
}
void
-g_omx_core_pause (GOmxCore *core)
+g_omx_core_pause (GOmxCore * core)
{
- change_state (core, OMX_StatePause);
- wait_for_state (core, OMX_StatePause);
+ change_state (core, OMX_StatePause);
+ wait_for_state (core, OMX_StatePause);
}
void
-g_omx_core_unload (GOmxCore *core)
+g_omx_core_unload (GOmxCore * core)
{
- if (core->omx_state == OMX_StateIdle ||
- core->omx_state == OMX_StateWaitForResources ||
- core->omx_state == OMX_StateInvalid)
- {
- if (core->omx_state != OMX_StateInvalid)
- change_state (core, OMX_StateLoaded);
+ if (core->omx_state == OMX_StateIdle ||
+ core->omx_state == OMX_StateWaitForResources ||
+ core->omx_state == OMX_StateInvalid) {
+ if (core->omx_state != OMX_StateInvalid)
+ change_state (core, OMX_StateLoaded);
- core_for_each_port (core, port_free_buffers);
+ core_for_each_port (core, port_free_buffers);
- if (core->omx_state != OMX_StateInvalid)
- wait_for_state (core, OMX_StateLoaded);
- }
+ if (core->omx_state != OMX_StateInvalid)
+ wait_for_state (core, OMX_StateLoaded);
+ }
- core_for_each_port (core, g_omx_port_free);
- g_ptr_array_clear (core->ports);
+ core_for_each_port (core, g_omx_port_free);
+ g_ptr_array_clear (core->ports);
}
static inline GOmxPort *
-get_port (GOmxCore *core, guint index)
+get_port (GOmxCore * core, guint index)
{
- if (G_LIKELY (index < core->ports->len))
- {
- return g_ptr_array_index (core->ports, index);
- }
+ if (G_LIKELY (index < core->ports->len)) {
+ return g_ptr_array_index (core->ports, index);
+ }
- return NULL;
+ return NULL;
}
GOmxPort *
-g_omx_core_new_port (GOmxCore *core,
- guint index)
+g_omx_core_new_port (GOmxCore * core, guint index)
{
- GOmxPort *port = get_port (core, index);
+ GOmxPort *port = get_port (core, index);
- if (port)
- {
- GST_WARNING_OBJECT (core->object, "port %d already exists", index);
- return port;
- }
+ if (port) {
+ GST_WARNING_OBJECT (core->object, "port %d already exists", index);
+ return port;
+ }
- port = g_omx_port_new (core, index);
- g_ptr_array_insert (core->ports, index, port);
+ port = g_omx_port_new (core, index);
+ g_ptr_array_insert (core->ports, index, port);
- return port;
+ return port;
}
void
-g_omx_core_set_done (GOmxCore *core)
+g_omx_core_set_done (GOmxCore * core)
{
- g_sem_up (core->done_sem);
+ g_sem_up (core->done_sem);
}
void
-g_omx_core_wait_for_done (GOmxCore *core)
+g_omx_core_wait_for_done (GOmxCore * core)
{
- g_sem_down (core->done_sem);
+ g_sem_down (core->done_sem);
}
void
-g_omx_core_flush_start (GOmxCore *core)
+g_omx_core_flush_start (GOmxCore * core)
{
- core_for_each_port (core, g_omx_port_pause);
+ core_for_each_port (core, g_omx_port_pause);
}
void
-g_omx_core_flush_stop (GOmxCore *core)
+g_omx_core_flush_stop (GOmxCore * core)
{
- core_for_each_port (core, g_omx_port_flush);
- core_for_each_port (core, g_omx_port_resume);
+ core_for_each_port (core, g_omx_port_flush);
+ core_for_each_port (core, g_omx_port_resume);
}
/*
@@ -501,249 +457,232 @@ g_omx_core_flush_stop (GOmxCore *core)
* instead use g_omx_core_new_port())
*/
GOmxPort *
-g_omx_port_new (GOmxCore *core, guint index)
+g_omx_port_new (GOmxCore * core, guint index)
{
- GOmxPort *port;
- port = g_new0 (GOmxPort, 1);
+ GOmxPort *port;
+ port = g_new0 (GOmxPort, 1);
- port->core = core;
- port->port_index = index;
- port->num_buffers = 0;
- port->buffer_size = 0;
- port->buffers = NULL;
+ port->core = core;
+ port->port_index = index;
+ port->num_buffers = 0;
+ port->buffer_size = 0;
+ port->buffers = NULL;
- port->enabled = TRUE;
- port->queue = async_queue_new ();
- port->mutex = g_mutex_new ();
+ port->enabled = TRUE;
+ port->queue = async_queue_new ();
+ port->mutex = g_mutex_new ();
- return port;
+ return port;
}
void
-g_omx_port_free (GOmxPort *port)
+g_omx_port_free (GOmxPort * port)
{
- g_mutex_free (port->mutex);
- async_queue_free (port->queue);
+ g_mutex_free (port->mutex);
+ async_queue_free (port->queue);
- g_free (port->buffers);
- g_free (port);
+ g_free (port->buffers);
+ g_free (port);
}
void
-g_omx_port_setup (GOmxPort *port)
+g_omx_port_setup (GOmxPort * port)
{
- GOmxPortType type = -1;
- OMX_PARAM_PORTDEFINITIONTYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = port->port_index;
- OMX_GetParameter (port->core->omx_handle, OMX_IndexParamPortDefinition, &param);
-
- switch (param.eDir)
- {
- case OMX_DirInput:
- type = GOMX_PORT_INPUT;
- break;
- case OMX_DirOutput:
- type = GOMX_PORT_OUTPUT;
- break;
- default:
- break;
- }
-
- port->type = type;
+ GOmxPortType type = -1;
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+
+ G_OMX_INIT_PARAM (param);
+
+ param.nPortIndex = port->port_index;
+ OMX_GetParameter (port->core->omx_handle, OMX_IndexParamPortDefinition,
+ &param);
+
+ switch (param.eDir) {
+ case OMX_DirInput:
+ type = GOMX_PORT_INPUT;
+ break;
+ case OMX_DirOutput:
+ type = GOMX_PORT_OUTPUT;
+ break;
+ default:
+ break;
+ }
+
+ port->type = type;
/** @todo should it be nBufferCountMin? */
- port->num_buffers = param.nBufferCountActual;
- port->buffer_size = param.nBufferSize;
+ port->num_buffers = param.nBufferCountActual;
+ port->buffer_size = param.nBufferSize;
- GST_DEBUG_OBJECT (port->core->object,
- "type=%d, num_buffers=%d, buffer_size=%ld, port_index=%d",
- port->type, port->num_buffers, port->buffer_size, port->port_index);
+ GST_DEBUG_OBJECT (port->core->object,
+ "type=%d, num_buffers=%d, buffer_size=%ld, port_index=%d",
+ port->type, port->num_buffers, port->buffer_size, port->port_index);
- g_free (port->buffers);
- port->buffers = g_new0 (OMX_BUFFERHEADERTYPE *, port->num_buffers);
+ g_free (port->buffers);
+ port->buffers = g_new0 (OMX_BUFFERHEADERTYPE *, port->num_buffers);
}
static void
-port_allocate_buffers (GOmxPort *port)
+port_allocate_buffers (GOmxPort * port)
{
- guint i;
- gsize size;
-
- size = port->buffer_size;
-
- for (i = 0; i < port->num_buffers; i++)
- {
- if (port->omx_allocate)
- {
- GST_DEBUG_OBJECT (port->core->object, "%d: OMX_AllocateBuffer(), size=%"G_GSIZE_FORMAT, i, size);
- OMX_AllocateBuffer (port->core->omx_handle,
- &port->buffers[i],
- port->port_index,
- NULL,
- size);
- }
- else
- {
- gpointer buffer_data;
- buffer_data = g_malloc (size);
- GST_DEBUG_OBJECT (port->core->object, "%d: OMX_UseBuffer(), size=%"G_GSIZE_FORMAT, i, size);
- OMX_UseBuffer (port->core->omx_handle,
- &port->buffers[i],
- port->port_index,
- NULL,
- size,
- buffer_data);
- }
+ guint i;
+ gsize size;
+
+ size = port->buffer_size;
+
+ for (i = 0; i < port->num_buffers; i++) {
+ if (port->omx_allocate) {
+ GST_DEBUG_OBJECT (port->core->object,
+ "%d: OMX_AllocateBuffer(), size=%" G_GSIZE_FORMAT, i, size);
+ OMX_AllocateBuffer (port->core->omx_handle, &port->buffers[i],
+ port->port_index, NULL, size);
+ } else {
+ gpointer buffer_data;
+ buffer_data = g_malloc (size);
+ GST_DEBUG_OBJECT (port->core->object,
+ "%d: OMX_UseBuffer(), size=%" G_GSIZE_FORMAT, i, size);
+ OMX_UseBuffer (port->core->omx_handle, &port->buffers[i],
+ port->port_index, NULL, size, buffer_data);
}
+ }
}
static void
-port_free_buffers (GOmxPort *port)
+port_free_buffers (GOmxPort * port)
{
- guint i;
+ guint i;
- for (i = 0; i < port->num_buffers; i++)
- {
- OMX_BUFFERHEADERTYPE *omx_buffer;
+ for (i = 0; i < port->num_buffers; i++) {
+ OMX_BUFFERHEADERTYPE *omx_buffer;
- omx_buffer = port->buffers[i];
+ omx_buffer = port->buffers[i];
- if (omx_buffer)
- {
+ if (omx_buffer) {
#if 0
/** @todo how shall we free that buffer? */
- if (!port->omx_allocate)
- {
- g_free (omx_buffer->pBuffer);
- omx_buffer->pBuffer = NULL;
- }
+ if (!port->omx_allocate) {
+ g_free (omx_buffer->pBuffer);
+ omx_buffer->pBuffer = NULL;
+ }
#endif
- OMX_FreeBuffer (port->core->omx_handle, port->port_index, omx_buffer);
- port->buffers[i] = NULL;
- }
+ OMX_FreeBuffer (port->core->omx_handle, port->port_index, omx_buffer);
+ port->buffers[i] = NULL;
}
+ }
}
static void
-port_start_buffers (GOmxPort *port)
+port_start_buffers (GOmxPort * port)
{
- guint i;
+ guint i;
- for (i = 0; i < port->num_buffers; i++)
- {
- OMX_BUFFERHEADERTYPE *omx_buffer;
+ for (i = 0; i < port->num_buffers; i++) {
+ OMX_BUFFERHEADERTYPE *omx_buffer;
- omx_buffer = port->buffers[i];
+ omx_buffer = port->buffers[i];
- /* If it's an input port we will need to fill the buffer, so put it in
- * the queue, otherwise send to omx for processing (fill it up). */
- if (port->type == GOMX_PORT_INPUT)
- got_buffer (port->core, port, omx_buffer);
- else
- g_omx_port_release_buffer (port, omx_buffer);
- }
+ /* If it's an input port we will need to fill the buffer, so put it in
+ * the queue, otherwise send to omx for processing (fill it up). */
+ if (port->type == GOMX_PORT_INPUT)
+ got_buffer (port->core, port, omx_buffer);
+ else
+ g_omx_port_release_buffer (port, omx_buffer);
+ }
}
void
-g_omx_port_push_buffer (GOmxPort *port,
- OMX_BUFFERHEADERTYPE *omx_buffer)
+g_omx_port_push_buffer (GOmxPort * port, OMX_BUFFERHEADERTYPE * omx_buffer)
{
- async_queue_push (port->queue, omx_buffer);
+ async_queue_push (port->queue, omx_buffer);
}
OMX_BUFFERHEADERTYPE *
-g_omx_port_request_buffer (GOmxPort *port)
+g_omx_port_request_buffer (GOmxPort * port)
{
- return async_queue_pop (port->queue);
+ return async_queue_pop (port->queue);
}
void
-g_omx_port_release_buffer (GOmxPort *port,
- OMX_BUFFERHEADERTYPE *omx_buffer)
+g_omx_port_release_buffer (GOmxPort * port, OMX_BUFFERHEADERTYPE * omx_buffer)
{
- switch (port->type)
- {
- case GOMX_PORT_INPUT:
- OMX_EmptyThisBuffer (port->core->omx_handle, omx_buffer);
- break;
- case GOMX_PORT_OUTPUT:
- OMX_FillThisBuffer (port->core->omx_handle, omx_buffer);
- break;
- default:
- break;
- }
+ switch (port->type) {
+ case GOMX_PORT_INPUT:
+ OMX_EmptyThisBuffer (port->core->omx_handle, omx_buffer);
+ break;
+ case GOMX_PORT_OUTPUT:
+ OMX_FillThisBuffer (port->core->omx_handle, omx_buffer);
+ break;
+ default:
+ break;
+ }
}
void
-g_omx_port_resume (GOmxPort *port)
+g_omx_port_resume (GOmxPort * port)
{
- async_queue_enable (port->queue);
+ async_queue_enable (port->queue);
}
void
-g_omx_port_pause (GOmxPort *port)
+g_omx_port_pause (GOmxPort * port)
{
- async_queue_disable (port->queue);
+ async_queue_disable (port->queue);
}
void
-g_omx_port_flush (GOmxPort *port)
+g_omx_port_flush (GOmxPort * port)
{
- if (port->type == GOMX_PORT_OUTPUT)
- {
- OMX_BUFFERHEADERTYPE *omx_buffer;
- while ((omx_buffer = async_queue_pop_forced (port->queue)))
- {
- omx_buffer->nFilledLen = 0;
- g_omx_port_release_buffer (port, omx_buffer);
- }
- }
- else
- {
- OMX_SendCommand (port->core->omx_handle, OMX_CommandFlush, port->port_index, NULL);
- g_sem_down (port->core->flush_sem);
+ if (port->type == GOMX_PORT_OUTPUT) {
+ OMX_BUFFERHEADERTYPE *omx_buffer;
+ while ((omx_buffer = async_queue_pop_forced (port->queue))) {
+ omx_buffer->nFilledLen = 0;
+ g_omx_port_release_buffer (port, omx_buffer);
}
+ } else {
+ OMX_SendCommand (port->core->omx_handle, OMX_CommandFlush, port->port_index,
+ NULL);
+ g_sem_down (port->core->flush_sem);
+ }
}
void
-g_omx_port_enable (GOmxPort *port)
+g_omx_port_enable (GOmxPort * port)
{
- GOmxCore *core;
+ GOmxCore *core;
- core = port->core;
+ core = port->core;
- OMX_SendCommand (core->omx_handle, OMX_CommandPortEnable, port->port_index, NULL);
- port_allocate_buffers (port);
- if (core->omx_state != OMX_StateLoaded)
- port_start_buffers (port);
- g_omx_port_resume (port);
+ OMX_SendCommand (core->omx_handle, OMX_CommandPortEnable, port->port_index,
+ NULL);
+ port_allocate_buffers (port);
+ if (core->omx_state != OMX_StateLoaded)
+ port_start_buffers (port);
+ g_omx_port_resume (port);
- g_sem_down (core->port_sem);
+ g_sem_down (core->port_sem);
}
void
-g_omx_port_disable (GOmxPort *port)
+g_omx_port_disable (GOmxPort * port)
{
- GOmxCore *core;
+ GOmxCore *core;
- core = port->core;
+ core = port->core;
- OMX_SendCommand (core->omx_handle, OMX_CommandPortDisable, port->port_index, NULL);
- g_omx_port_pause (port);
- g_omx_port_flush (port);
- port_free_buffers (port);
+ OMX_SendCommand (core->omx_handle, OMX_CommandPortDisable, port->port_index,
+ NULL);
+ g_omx_port_pause (port);
+ g_omx_port_flush (port);
+ port_free_buffers (port);
- g_sem_down (core->port_sem);
+ g_sem_down (core->port_sem);
}
void
-g_omx_port_finish (GOmxPort *port)
+g_omx_port_finish (GOmxPort * port)
{
- port->enabled = FALSE;
- async_queue_disable (port->queue);
+ port->enabled = FALSE;
+ async_queue_disable (port->queue);
}
/*
@@ -751,64 +690,60 @@ g_omx_port_finish (GOmxPort *port)
*/
static inline void
-change_state (GOmxCore *core,
- OMX_STATETYPE state)
+change_state (GOmxCore * core, OMX_STATETYPE state)
{
- GST_DEBUG_OBJECT (core->object, "state=%d", state);
- OMX_SendCommand (core->omx_handle, OMX_CommandStateSet, state, NULL);
+ GST_DEBUG_OBJECT (core->object, "state=%d", state);
+ OMX_SendCommand (core->omx_handle, OMX_CommandStateSet, state, NULL);
}
static inline void
-complete_change_state (GOmxCore *core,
- OMX_STATETYPE state)
+complete_change_state (GOmxCore * core, OMX_STATETYPE state)
{
- g_mutex_lock (core->omx_state_mutex);
+ g_mutex_lock (core->omx_state_mutex);
- core->omx_state = state;
- g_cond_signal (core->omx_state_condition);
- GST_DEBUG_OBJECT (core->object, "state=%d", state);
+ core->omx_state = state;
+ g_cond_signal (core->omx_state_condition);
+ GST_DEBUG_OBJECT (core->object, "state=%d", state);
- g_mutex_unlock (core->omx_state_mutex);
+ g_mutex_unlock (core->omx_state_mutex);
}
static inline void
-wait_for_state (GOmxCore *core,
- OMX_STATETYPE state)
+wait_for_state (GOmxCore * core, OMX_STATETYPE state)
{
- GTimeVal tv;
- gboolean signaled;
+ GTimeVal tv;
+ gboolean signaled;
- g_mutex_lock (core->omx_state_mutex);
+ g_mutex_lock (core->omx_state_mutex);
- if (core->omx_error != OMX_ErrorNone)
- goto leave;
+ if (core->omx_error != OMX_ErrorNone)
+ goto leave;
- g_get_current_time (&tv);
- g_time_val_add (&tv, 15 * G_USEC_PER_SEC);
+ g_get_current_time (&tv);
+ g_time_val_add (&tv, 15 * G_USEC_PER_SEC);
- /* try once */
- if (core->omx_state != state)
- {
- signaled = g_cond_timed_wait (core->omx_state_condition, core->omx_state_mutex, &tv);
+ /* try once */
+ if (core->omx_state != state) {
+ signaled =
+ g_cond_timed_wait (core->omx_state_condition, core->omx_state_mutex,
+ &tv);
- if (!signaled)
- {
- GST_ERROR_OBJECT (core->object, "timed out switching from '%s' to '%s'",
- omx_state_to_str(core->omx_state), omx_state_to_str(state));
- }
+ if (!signaled) {
+ GST_ERROR_OBJECT (core->object, "timed out switching from '%s' to '%s'",
+ omx_state_to_str (core->omx_state), omx_state_to_str (state));
}
+ }
- if (core->omx_error != OMX_ErrorNone)
- goto leave;
+ if (core->omx_error != OMX_ErrorNone)
+ goto leave;
- if (core->omx_state != state)
- {
- GST_ERROR_OBJECT (core->object, "wrong state received: state=%d, expected=%d",
- core->omx_state, state);
- }
+ if (core->omx_state != state) {
+ GST_ERROR_OBJECT (core->object,
+ "wrong state received: state=%d, expected=%d", core->omx_state, state);
+ }
leave:
- g_mutex_unlock (core->omx_state_mutex);
+ g_mutex_unlock (core->omx_state_mutex);
}
/*
@@ -816,59 +751,51 @@ leave:
*/
static inline void
-in_port_cb (GOmxPort *port,
- OMX_BUFFERHEADERTYPE *omx_buffer)
+in_port_cb (GOmxPort * port, OMX_BUFFERHEADERTYPE * omx_buffer)
{
/** @todo remove this */
- if (!port->enabled)
- return;
+ if (!port->enabled)
+ return;
}
static inline void
-out_port_cb (GOmxPort *port,
- OMX_BUFFERHEADERTYPE *omx_buffer)
+out_port_cb (GOmxPort * port, OMX_BUFFERHEADERTYPE * omx_buffer)
{
/** @todo remove this */
- if (!port->enabled)
- return;
+ if (!port->enabled)
+ return;
#if 0
- if (omx_buffer->nFlags & OMX_BUFFERFLAG_EOS)
- {
- g_omx_port_set_done (port);
- return;
- }
+ if (omx_buffer->nFlags & OMX_BUFFERFLAG_EOS) {
+ g_omx_port_set_done (port);
+ return;
+ }
#endif
}
static inline void
-got_buffer (GOmxCore *core,
- GOmxPort *port,
- OMX_BUFFERHEADERTYPE *omx_buffer)
+got_buffer (GOmxCore * core, GOmxPort * port, OMX_BUFFERHEADERTYPE * omx_buffer)
{
- if (G_UNLIKELY (!omx_buffer))
- {
- return;
- }
-
- if (G_LIKELY (port))
- {
- g_omx_port_push_buffer (port, omx_buffer);
-
- switch (port->type)
- {
- case GOMX_PORT_INPUT:
- in_port_cb (port, omx_buffer);
- break;
- case GOMX_PORT_OUTPUT:
- out_port_cb (port, omx_buffer);
- break;
- default:
- break;
- }
+ if (G_UNLIKELY (!omx_buffer)) {
+ return;
+ }
+
+ if (G_LIKELY (port)) {
+ g_omx_port_push_buffer (port, omx_buffer);
+
+ switch (port->type) {
+ case GOMX_PORT_INPUT:
+ in_port_cb (port, omx_buffer);
+ break;
+ case GOMX_PORT_OUTPUT:
+ out_port_cb (port, omx_buffer);
+ break;
+ default:
+ break;
}
+ }
}
/*
@@ -877,257 +804,259 @@ got_buffer (GOmxCore *core,
static OMX_ERRORTYPE
EventHandler (OMX_HANDLETYPE omx_handle,
- OMX_PTR app_data,
- OMX_EVENTTYPE event,
- OMX_U32 data_1,
- OMX_U32 data_2,
- OMX_PTR event_data)
+ OMX_PTR app_data,
+ OMX_EVENTTYPE event, OMX_U32 data_1, OMX_U32 data_2, OMX_PTR event_data)
{
- GOmxCore *core;
+ GOmxCore *core;
- core = (GOmxCore *) app_data;
+ core = (GOmxCore *) app_data;
- switch (event)
+ switch (event) {
+ case OMX_EventCmdComplete:
{
- case OMX_EventCmdComplete:
- {
- OMX_COMMANDTYPE cmd;
-
- cmd = (OMX_COMMANDTYPE) data_1;
-
- GST_DEBUG_OBJECT (core->object, "OMX_EventCmdComplete: %d", cmd);
-
- switch (cmd)
- {
- case OMX_CommandStateSet:
- complete_change_state (core, data_2);
- break;
- case OMX_CommandFlush:
- g_sem_up (core->flush_sem);
- break;
- case OMX_CommandPortDisable:
- case OMX_CommandPortEnable:
- g_sem_up (core->port_sem);
- default:
- break;
- }
- break;
- }
- case OMX_EventBufferFlag:
- {
- GST_DEBUG_OBJECT (core->object, "OMX_EventBufferFlag");
- if (data_2 & OMX_BUFFERFLAG_EOS)
- {
- g_omx_core_set_done (core);
- }
- break;
- }
- case OMX_EventPortSettingsChanged:
- {
- GST_DEBUG_OBJECT (core->object, "OMX_EventPortSettingsChanged");
- /** @todo only on the relevant port. */
- if (core->settings_changed_cb)
- {
- core->settings_changed_cb (core);
- }
- break;
- }
- case OMX_EventError:
- {
- core->omx_error = data_1;
- GST_ERROR_OBJECT (core->object, "unrecoverable error: %s (0x%lx)",
- omx_error_to_str (data_1), data_1);
- /* component might leave us waiting for buffers, unblock */
- g_omx_core_flush_start (core);
- /* unlock wait_for_state */
- g_mutex_lock (core->omx_state_mutex);
- g_cond_signal (core->omx_state_condition);
- g_mutex_unlock (core->omx_state_mutex);
- break;
- }
+ OMX_COMMANDTYPE cmd;
+
+ cmd = (OMX_COMMANDTYPE) data_1;
+
+ GST_DEBUG_OBJECT (core->object, "OMX_EventCmdComplete: %d", cmd);
+
+ switch (cmd) {
+ case OMX_CommandStateSet:
+ complete_change_state (core, data_2);
+ break;
+ case OMX_CommandFlush:
+ g_sem_up (core->flush_sem);
+ break;
+ case OMX_CommandPortDisable:
+ case OMX_CommandPortEnable:
+ g_sem_up (core->port_sem);
default:
- break;
+ break;
+ }
+ break;
}
+ case OMX_EventBufferFlag:
+ {
+ GST_DEBUG_OBJECT (core->object, "OMX_EventBufferFlag");
+ if (data_2 & OMX_BUFFERFLAG_EOS) {
+ g_omx_core_set_done (core);
+ }
+ break;
+ }
+ case OMX_EventPortSettingsChanged:
+ {
+ GST_DEBUG_OBJECT (core->object, "OMX_EventPortSettingsChanged");
+ /** @todo only on the relevant port. */
+ if (core->settings_changed_cb) {
+ core->settings_changed_cb (core);
+ }
+ break;
+ }
+ case OMX_EventError:
+ {
+ core->omx_error = data_1;
+ GST_ERROR_OBJECT (core->object, "unrecoverable error: %s (0x%lx)",
+ omx_error_to_str (data_1), data_1);
+ /* component might leave us waiting for buffers, unblock */
+ g_omx_core_flush_start (core);
+ /* unlock wait_for_state */
+ g_mutex_lock (core->omx_state_mutex);
+ g_cond_signal (core->omx_state_condition);
+ g_mutex_unlock (core->omx_state_mutex);
+ break;
+ }
+ default:
+ break;
+ }
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static OMX_ERRORTYPE
EmptyBufferDone (OMX_HANDLETYPE omx_handle,
- OMX_PTR app_data,
- OMX_BUFFERHEADERTYPE *omx_buffer)
+ OMX_PTR app_data, OMX_BUFFERHEADERTYPE * omx_buffer)
{
- GOmxCore *core;
- GOmxPort *port;
+ GOmxCore *core;
+ GOmxPort *port;
- core = (GOmxCore*) app_data;
- port = get_port (core, omx_buffer->nInputPortIndex);
+ core = (GOmxCore *) app_data;
+ port = get_port (core, omx_buffer->nInputPortIndex);
- GST_CAT_LOG_OBJECT (gstomx_util_debug, core->object, "omx_buffer=%p", omx_buffer);
- got_buffer (core, port, omx_buffer);
+ GST_CAT_LOG_OBJECT (gstomx_util_debug, core->object, "omx_buffer=%p",
+ omx_buffer);
+ got_buffer (core, port, omx_buffer);
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static OMX_ERRORTYPE
FillBufferDone (OMX_HANDLETYPE omx_handle,
- OMX_PTR app_data,
- OMX_BUFFERHEADERTYPE *omx_buffer)
+ OMX_PTR app_data, OMX_BUFFERHEADERTYPE * omx_buffer)
{
- GOmxCore *core;
- GOmxPort *port;
+ GOmxCore *core;
+ GOmxPort *port;
- core = (GOmxCore *) app_data;
- port = get_port (core, omx_buffer->nOutputPortIndex);
+ core = (GOmxCore *) app_data;
+ port = get_port (core, omx_buffer->nOutputPortIndex);
- GST_CAT_LOG_OBJECT (gstomx_util_debug, core->object, "omx_buffer=%p", omx_buffer);
- got_buffer (core, port, omx_buffer);
+ GST_CAT_LOG_OBJECT (gstomx_util_debug, core->object, "omx_buffer=%p",
+ omx_buffer);
+ got_buffer (core, port, omx_buffer);
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static inline const char *
omx_state_to_str (OMX_STATETYPE omx_state)
{
- switch (omx_state)
- {
- case OMX_StateInvalid:
- return "invalid";
- case OMX_StateLoaded:
- return "loaded";
- case OMX_StateIdle:
- return "idle";
- case OMX_StateExecuting:
- return "executing";
- case OMX_StatePause:
- return "pause";
- case OMX_StateWaitForResources:
- return "wait for resources";
- default:
- return "unknown";
- }
+ switch (omx_state) {
+ case OMX_StateInvalid:
+ return "invalid";
+ case OMX_StateLoaded:
+ return "loaded";
+ case OMX_StateIdle:
+ return "idle";
+ case OMX_StateExecuting:
+ return "executing";
+ case OMX_StatePause:
+ return "pause";
+ case OMX_StateWaitForResources:
+ return "wait for resources";
+ default:
+ return "unknown";
+ }
}
static inline const char *
omx_error_to_str (OMX_ERRORTYPE omx_error)
{
- switch (omx_error)
- {
- case OMX_ErrorNone:
- return "None";
+ switch (omx_error) {
+ case OMX_ErrorNone:
+ return "None";
- case OMX_ErrorInsufficientResources:
- return "There were insufficient resources to perform the requested operation";
+ case OMX_ErrorInsufficientResources:
+ return
+ "There were insufficient resources to perform the requested operation";
- case OMX_ErrorUndefined:
- return "The cause of the error could not be determined";
+ case OMX_ErrorUndefined:
+ return "The cause of the error could not be determined";
- case OMX_ErrorInvalidComponentName:
- return "The component name string was not valid";
+ case OMX_ErrorInvalidComponentName:
+ return "The component name string was not valid";
- case OMX_ErrorComponentNotFound:
- return "No component with the specified name string was found";
+ case OMX_ErrorComponentNotFound:
+ return "No component with the specified name string was found";
- case OMX_ErrorInvalidComponent:
- return "The component specified did not have an entry point";
+ case OMX_ErrorInvalidComponent:
+ return "The component specified did not have an entry point";
- case OMX_ErrorBadParameter:
- return "One or more parameters were not valid";
+ case OMX_ErrorBadParameter:
+ return "One or more parameters were not valid";
- case OMX_ErrorNotImplemented:
- return "The requested function is not implemented";
+ case OMX_ErrorNotImplemented:
+ return "The requested function is not implemented";
- case OMX_ErrorUnderflow:
- return "The buffer was emptied before the next buffer was ready";
+ case OMX_ErrorUnderflow:
+ return "The buffer was emptied before the next buffer was ready";
- case OMX_ErrorOverflow:
- return "The buffer was not available when it was needed";
+ case OMX_ErrorOverflow:
+ return "The buffer was not available when it was needed";
- case OMX_ErrorHardware:
- return "The hardware failed to respond as expected";
+ case OMX_ErrorHardware:
+ return "The hardware failed to respond as expected";
- case OMX_ErrorInvalidState:
- return "The component is in invalid state";
+ case OMX_ErrorInvalidState:
+ return "The component is in invalid state";
- case OMX_ErrorStreamCorrupt:
- return "Stream is found to be corrupt";
+ case OMX_ErrorStreamCorrupt:
+ return "Stream is found to be corrupt";
- case OMX_ErrorPortsNotCompatible:
- return "Ports being connected are not compatible";
+ case OMX_ErrorPortsNotCompatible:
+ return "Ports being connected are not compatible";
- case OMX_ErrorResourcesLost:
- return "Resources allocated to an idle component have been lost";
+ case OMX_ErrorResourcesLost:
+ return "Resources allocated to an idle component have been lost";
- case OMX_ErrorNoMore:
- return "No more indices can be enumerated";
+ case OMX_ErrorNoMore:
+ return "No more indices can be enumerated";
- case OMX_ErrorVersionMismatch:
- return "The component detected a version mismatch";
+ case OMX_ErrorVersionMismatch:
+ return "The component detected a version mismatch";
- case OMX_ErrorNotReady:
- return "The component is not ready to return data at this time";
+ case OMX_ErrorNotReady:
+ return "The component is not ready to return data at this time";
- case OMX_ErrorTimeout:
- return "There was a timeout that occurred";
+ case OMX_ErrorTimeout:
+ return "There was a timeout that occurred";
- case OMX_ErrorSameState:
- return "This error occurs when trying to transition into the state you are already in";
+ case OMX_ErrorSameState:
+ return
+ "This error occurs when trying to transition into the state you are already in";
- case OMX_ErrorResourcesPreempted:
- return "Resources allocated to an executing or paused component have been preempted";
+ case OMX_ErrorResourcesPreempted:
+ return
+ "Resources allocated to an executing or paused component have been preempted";
- case OMX_ErrorPortUnresponsiveDuringAllocation:
- return "Waited an unusually long time for the supplier to allocate buffers";
+ case OMX_ErrorPortUnresponsiveDuringAllocation:
+ return
+ "Waited an unusually long time for the supplier to allocate buffers";
- case OMX_ErrorPortUnresponsiveDuringDeallocation:
- return "Waited an unusually long time for the supplier to de-allocate buffers";
+ case OMX_ErrorPortUnresponsiveDuringDeallocation:
+ return
+ "Waited an unusually long time for the supplier to de-allocate buffers";
- case OMX_ErrorPortUnresponsiveDuringStop:
- return "Waited an unusually long time for the non-supplier to return a buffer during stop";
+ case OMX_ErrorPortUnresponsiveDuringStop:
+ return
+ "Waited an unusually long time for the non-supplier to return a buffer during stop";
- case OMX_ErrorIncorrectStateTransition:
- return "Attempting a state transition that is not allowed";
+ case OMX_ErrorIncorrectStateTransition:
+ return "Attempting a state transition that is not allowed";
- case OMX_ErrorIncorrectStateOperation:
- return "Attempting a command that is not allowed during the present state";
+ case OMX_ErrorIncorrectStateOperation:
+ return
+ "Attempting a command that is not allowed during the present state";
- case OMX_ErrorUnsupportedSetting:
- return "The values encapsulated in the parameter or config structure are not supported";
+ case OMX_ErrorUnsupportedSetting:
+ return
+ "The values encapsulated in the parameter or config structure are not supported";
- case OMX_ErrorUnsupportedIndex:
- return "The parameter or config indicated by the given index is not supported";
+ case OMX_ErrorUnsupportedIndex:
+ return
+ "The parameter or config indicated by the given index is not supported";
- case OMX_ErrorBadPortIndex:
- return "The port index supplied is incorrect";
+ case OMX_ErrorBadPortIndex:
+ return "The port index supplied is incorrect";
- case OMX_ErrorPortUnpopulated:
- return "The port has lost one or more of its buffers and it thus unpopulated";
+ case OMX_ErrorPortUnpopulated:
+ return
+ "The port has lost one or more of its buffers and it thus unpopulated";
- case OMX_ErrorComponentSuspended:
- return "Component suspended due to temporary loss of resources";
+ case OMX_ErrorComponentSuspended:
+ return "Component suspended due to temporary loss of resources";
- case OMX_ErrorDynamicResourcesUnavailable:
- return "Component suspended due to an inability to acquire dynamic resources";
+ case OMX_ErrorDynamicResourcesUnavailable:
+ return
+ "Component suspended due to an inability to acquire dynamic resources";
- case OMX_ErrorMbErrorsInFrame:
- return "Frame generated macroblock error";
+ case OMX_ErrorMbErrorsInFrame:
+ return "Frame generated macroblock error";
- case OMX_ErrorFormatNotDetected:
- return "Cannot parse or determine the format of an input stream";
+ case OMX_ErrorFormatNotDetected:
+ return "Cannot parse or determine the format of an input stream";
- case OMX_ErrorContentPipeOpenFailed:
- return "The content open operation failed";
+ case OMX_ErrorContentPipeOpenFailed:
+ return "The content open operation failed";
- case OMX_ErrorContentPipeCreationFailed:
- return "The content creation operation failed";
+ case OMX_ErrorContentPipeCreationFailed:
+ return "The content creation operation failed";
- case OMX_ErrorSeperateTablesUsed:
- return "Separate table information is being used";
+ case OMX_ErrorSeperateTablesUsed:
+ return "Separate table information is being used";
- case OMX_ErrorTunnelingUnsupported:
- return "Tunneling is unsupported by the component";
+ case OMX_ErrorTunnelingUnsupported:
+ return "Tunneling is unsupported by the component";
- default:
- return "Unknown error";
- }
+ default:
+ return "Unknown error";
+ }
}
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index 68832d3..decc411 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -38,79 +38,77 @@ typedef struct GOmxImp GOmxImp;
typedef struct GOmxSymbolTable GOmxSymbolTable;
typedef enum GOmxPortType GOmxPortType;
-typedef void (*GOmxCb) (GOmxCore *core);
-typedef void (*GOmxPortCb) (GOmxPort *port);
+typedef void (*GOmxCb) (GOmxCore * core);
+typedef void (*GOmxPortCb) (GOmxPort * port);
/* Enums. */
enum GOmxPortType
{
- GOMX_PORT_INPUT,
- GOMX_PORT_OUTPUT
+ GOMX_PORT_INPUT,
+ GOMX_PORT_OUTPUT
};
/* Structures. */
struct GOmxSymbolTable
{
- OMX_ERRORTYPE (*init) (void);
- OMX_ERRORTYPE (*deinit) (void);
- OMX_ERRORTYPE (*get_handle) (OMX_HANDLETYPE *handle,
- OMX_STRING name,
- OMX_PTR data,
- OMX_CALLBACKTYPE *callbacks);
- OMX_ERRORTYPE (*free_handle) (OMX_HANDLETYPE handle);
+ OMX_ERRORTYPE (*init) (void);
+ OMX_ERRORTYPE (*deinit) (void);
+ OMX_ERRORTYPE (*get_handle) (OMX_HANDLETYPE * handle,
+ OMX_STRING name, OMX_PTR data, OMX_CALLBACKTYPE * callbacks);
+ OMX_ERRORTYPE (*free_handle) (OMX_HANDLETYPE handle);
};
struct GOmxImp
{
- guint client_count;
- void *dl_handle;
- GOmxSymbolTable sym_table;
- GMutex *mutex;
+ guint client_count;
+ void *dl_handle;
+ GOmxSymbolTable sym_table;
+ GMutex *mutex;
};
struct GOmxCore
{
- gpointer object; /**< GStreamer element. */
+ gpointer object; /**< GStreamer element. */
- OMX_HANDLETYPE omx_handle;
- OMX_ERRORTYPE omx_error;
+ OMX_HANDLETYPE omx_handle;
+ OMX_ERRORTYPE omx_error;
- OMX_STATETYPE omx_state;
- GCond *omx_state_condition;
- GMutex *omx_state_mutex;
+ OMX_STATETYPE omx_state;
+ GCond *omx_state_condition;
+ GMutex *omx_state_mutex;
- GPtrArray *ports;
+ GPtrArray *ports;
- GSem *done_sem;
- GSem *flush_sem;
- GSem *port_sem;
+ GSem *done_sem;
+ GSem *flush_sem;
+ GSem *port_sem;
- GOmxCb settings_changed_cb;
- GOmxImp *imp;
+ GOmxCb settings_changed_cb;
+ GOmxImp *imp;
- gboolean done;
+ gboolean done;
- gchar *library_name;
- gchar *component_name;
- gchar *component_role;
+ gchar *library_name;
+ gchar *component_name;
+ gchar *component_role;
};
struct GOmxPort
{
- GOmxCore *core;
- GOmxPortType type;
-
- guint num_buffers;
- gulong buffer_size;
- guint port_index;
- OMX_BUFFERHEADERTYPE **buffers;
-
- GMutex *mutex;
- gboolean enabled;
- gboolean omx_allocate; /**< Setup with OMX_AllocateBuffer rather than OMX_UseBuffer */
- AsyncQueue *queue;
+ GOmxCore *core;
+ GOmxPortType type;
+
+ guint num_buffers;
+ gulong buffer_size;
+ guint port_index;
+ OMX_BUFFERHEADERTYPE **buffers;
+
+ GMutex *mutex;
+ gboolean enabled;
+ gboolean omx_allocate; /**< Setup with OMX_AllocateBuffer rather than OMX_UseBuffer */
+ AsyncQueue *queue;
};
/* Functions. */
@@ -119,31 +117,33 @@ void g_omx_init (void);
void g_omx_deinit (void);
GOmxCore *g_omx_core_new (void *object);
-void g_omx_core_free (GOmxCore *core);
-void g_omx_core_init (GOmxCore *core);
-void g_omx_core_prepare (GOmxCore *core);
-void g_omx_core_start (GOmxCore *core);
-void g_omx_core_pause (GOmxCore *core);
-void g_omx_core_stop (GOmxCore *core);
-void g_omx_core_unload (GOmxCore *core);
-void g_omx_core_set_done (GOmxCore *core);
-void g_omx_core_wait_for_done (GOmxCore *core);
-void g_omx_core_flush_start (GOmxCore *core);
-void g_omx_core_flush_stop (GOmxCore *core);
-GOmxPort *g_omx_core_new_port (GOmxCore *core, guint index);
-
-GOmxPort *g_omx_port_new (GOmxCore *core, guint index);
-void g_omx_port_free (GOmxPort *port);
-void g_omx_port_setup (GOmxPort *port);
-void g_omx_port_push_buffer (GOmxPort *port, OMX_BUFFERHEADERTYPE *omx_buffer);
-OMX_BUFFERHEADERTYPE *g_omx_port_request_buffer (GOmxPort *port);
-void g_omx_port_release_buffer (GOmxPort *port, OMX_BUFFERHEADERTYPE *omx_buffer);
-void g_omx_port_resume (GOmxPort *port);
-void g_omx_port_pause (GOmxPort *port);
-void g_omx_port_flush (GOmxPort *port);
-void g_omx_port_enable (GOmxPort *port);
-void g_omx_port_disable (GOmxPort *port);
-void g_omx_port_finish (GOmxPort *port);
+void g_omx_core_free (GOmxCore * core);
+void g_omx_core_init (GOmxCore * core);
+void g_omx_core_prepare (GOmxCore * core);
+void g_omx_core_start (GOmxCore * core);
+void g_omx_core_pause (GOmxCore * core);
+void g_omx_core_stop (GOmxCore * core);
+void g_omx_core_unload (GOmxCore * core);
+void g_omx_core_set_done (GOmxCore * core);
+void g_omx_core_wait_for_done (GOmxCore * core);
+void g_omx_core_flush_start (GOmxCore * core);
+void g_omx_core_flush_stop (GOmxCore * core);
+GOmxPort *g_omx_core_new_port (GOmxCore * core, guint index);
+
+GOmxPort *g_omx_port_new (GOmxCore * core, guint index);
+void g_omx_port_free (GOmxPort * port);
+void g_omx_port_setup (GOmxPort * port);
+void g_omx_port_push_buffer (GOmxPort * port,
+ OMX_BUFFERHEADERTYPE * omx_buffer);
+OMX_BUFFERHEADERTYPE *g_omx_port_request_buffer (GOmxPort * port);
+void g_omx_port_release_buffer (GOmxPort * port,
+ OMX_BUFFERHEADERTYPE * omx_buffer);
+void g_omx_port_resume (GOmxPort * port);
+void g_omx_port_pause (GOmxPort * port);
+void g_omx_port_flush (GOmxPort * port);
+void g_omx_port_enable (GOmxPort * port);
+void g_omx_port_disable (GOmxPort * port);
+void g_omx_port_finish (GOmxPort * port);
/* Utility Macros */
@@ -194,7 +194,7 @@ GType type_as_function ## _get_type (void) \
GSTOMX_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
__GST_DO_NOTHING)
-#include <string.h> /* for memset */
+#include <string.h> /* for memset */
#define G_OMX_INIT_PARAM(param) G_STMT_START { \
memset (&(param), 0, sizeof ((param))); \
(param).nSize = sizeof (param); \
diff --git a/omx/gstomx_videosink.c b/omx/gstomx_videosink.c
index d6f6938..e58b8d3 100644
--- a/omx/gstomx_videosink.c
+++ b/omx/gstomx_videosink.c
@@ -23,295 +23,278 @@
#include "gstomx_base_sink.h"
#include "gstomx.h"
-#include <string.h> /* for strcmp */
+#include <string.h> /* for strcmp */
-GSTOMX_BOILERPLATE (GstOmxVideoSink, gst_omx_videosink, GstOmxBaseSink, GST_OMX_BASE_SINK_TYPE);
+GSTOMX_BOILERPLATE (GstOmxVideoSink, gst_omx_videosink, GstOmxBaseSink,
+ GST_OMX_BASE_SINK_TYPE);
enum
{
- ARG_0,
- ARG_X_SCALE,
- ARG_Y_SCALE,
- ARG_ROTATION,
+ ARG_0,
+ ARG_X_SCALE,
+ ARG_Y_SCALE,
+ ARG_ROTATION,
};
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/x-raw-yuv",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-raw-yuv",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- {
- GValue list;
- GValue val;
+ {
+ GValue list;
+ GValue val;
- list.g_type = val.g_type = 0;
+ list.g_type = val.g_type = 0;
- g_value_init (&list, GST_TYPE_LIST);
- g_value_init (&val, GST_TYPE_FOURCC);
+ g_value_init (&list, GST_TYPE_LIST);
+ g_value_init (&val, GST_TYPE_FOURCC);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
+ gst_value_list_append_value (&list, &val);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
+ gst_value_list_append_value (&list, &val);
- gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
- gst_value_list_append_value (&list, &val);
+ gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
+ gst_value_list_append_value (&list, &val);
- gst_structure_set_value (struc, "format", &list);
+ gst_structure_set_value (struc, "format", &list);
- g_value_unset (&val);
- g_value_unset (&list);
- }
+ g_value_unset (&val);
+ g_value_unset (&list);
+ }
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL videosink element",
- "Video/Sink",
- "Renders video",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL videosink element",
+ "Video/Sink", "Renders video", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static gboolean
-setcaps (GstBaseSink *gst_sink,
- GstCaps *caps)
+setcaps (GstBaseSink * gst_sink, GstCaps * caps)
{
- GstOmxBaseSink *omx_base;
- GstOmxVideoSink *self;
- GOmxCore *gomx;
+ GstOmxBaseSink *omx_base;
+ GstOmxVideoSink *self;
+ GOmxCore *gomx;
- omx_base = GST_OMX_BASE_SINK (gst_sink);
- self = GST_OMX_VIDEOSINK (gst_sink);
- gomx = (GOmxCore *) omx_base->gomx;
+ omx_base = GST_OMX_BASE_SINK (gst_sink);
+ self = GST_OMX_VIDEOSINK (gst_sink);
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
- {
- GstStructure *structure;
- const GValue *framerate = NULL;
- gint width;
- gint height;
- OMX_COLOR_FORMATTYPE color_format = OMX_COLOR_FormatUnused;
-
- structure = gst_caps_get_structure (caps, 0);
-
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
-
- if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0)
- {
- guint32 fourcc;
-
- framerate = gst_structure_get_value (structure, "framerate");
-
- if (gst_structure_get_fourcc (structure, "format", &fourcc))
- {
- switch (fourcc)
- {
- case GST_MAKE_FOURCC ('I', '4', '2', '0'):
- color_format = OMX_COLOR_FormatYUV420PackedPlanar;
- break;
- case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
- color_format = OMX_COLOR_FormatYCbYCr;
- break;
- case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
- color_format = OMX_COLOR_FormatCbYCrY;
- break;
- }
- }
- }
+ {
+ GstStructure *structure;
+ const GValue *framerate = NULL;
+ gint width;
+ gint height;
+ OMX_COLOR_FORMATTYPE color_format = OMX_COLOR_FormatUnused;
- {
- OMX_PARAM_PORTDEFINITIONTYPE param;
-
- G_OMX_INIT_PARAM (param);
-
- param.nPortIndex = omx_base->in_port->port_index;
- OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
-
- switch (color_format)
- {
- case OMX_COLOR_FormatYUV420PackedPlanar:
- param.nBufferSize = (width * height * 1.5);
- break;
- case OMX_COLOR_FormatYCbYCr:
- case OMX_COLOR_FormatCbYCrY:
- param.nBufferSize = (width * height * 2);
- break;
- default:
- break;
- }
-
- param.format.video.nFrameWidth = width;
- param.format.video.nFrameHeight = height;
- param.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
- param.format.video.eColorFormat = color_format;
- if (framerate)
- {
- /* convert to Q.16 */
- param.format.video.xFramerate =
- (gst_value_get_fraction_numerator (framerate) << 16) /
- gst_value_get_fraction_denominator (framerate);
- }
-
- OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- }
-
- {
- OMX_CONFIG_ROTATIONTYPE config;
+ structure = gst_caps_get_structure (caps, 0);
- G_OMX_INIT_PARAM (config);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
- config.nPortIndex = omx_base->in_port->port_index;
- OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
+ if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
+ guint32 fourcc;
- config.nRotation = self->rotation;
+ framerate = gst_structure_get_value (structure, "framerate");
- OMX_SetConfig (gomx->omx_handle, OMX_IndexConfigCommonRotate, &config);
+ if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
+ switch (fourcc) {
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ color_format = OMX_COLOR_FormatYUV420PackedPlanar;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ color_format = OMX_COLOR_FormatYCbYCr;
+ break;
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+ color_format = OMX_COLOR_FormatCbYCrY;
+ break;
}
+ }
+ }
- {
- OMX_CONFIG_SCALEFACTORTYPE config;
-
- G_OMX_INIT_PARAM (config);
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE param;
- config.nPortIndex = omx_base->in_port->port_index;
- OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
+ G_OMX_INIT_PARAM (param);
- config.xWidth = self->x_scale;
- config.xHeight = self->y_scale;
+ param.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
- OMX_SetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
- }
+ switch (color_format) {
+ case OMX_COLOR_FormatYUV420PackedPlanar:
+ param.nBufferSize = (width * height * 1.5);
+ break;
+ case OMX_COLOR_FormatYCbYCr:
+ case OMX_COLOR_FormatCbYCrY:
+ param.nBufferSize = (width * height * 2);
+ break;
+ default:
+ break;
+ }
+
+ param.format.video.nFrameWidth = width;
+ param.format.video.nFrameHeight = height;
+ param.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ param.format.video.eColorFormat = color_format;
+ if (framerate) {
+ /* convert to Q.16 */
+ param.format.video.xFramerate =
+ (gst_value_get_fraction_numerator (framerate) << 16) /
+ gst_value_get_fraction_denominator (framerate);
+ }
+
+ OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
}
- return TRUE;
-}
+ {
+ OMX_CONFIG_ROTATIONTYPE config;
-static void
-set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GstOmxVideoSink *self;
+ G_OMX_INIT_PARAM (config);
+
+ config.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
+
+ config.nRotation = self->rotation;
- self = GST_OMX_VIDEOSINK (object);
+ OMX_SetConfig (gomx->omx_handle, OMX_IndexConfigCommonRotate, &config);
+ }
- switch (prop_id)
{
- case ARG_X_SCALE:
- self->x_scale = g_value_get_uint (value);
- break;
- case ARG_Y_SCALE:
- self->y_scale = g_value_get_uint (value);
- break;
- case ARG_ROTATION:
- self->rotation = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ OMX_CONFIG_SCALEFACTORTYPE config;
+
+ G_OMX_INIT_PARAM (config);
+
+ config.nPortIndex = omx_base->in_port->port_index;
+ OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
+
+ config.xWidth = self->x_scale;
+ config.xHeight = self->y_scale;
+
+ OMX_SetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
}
+ }
+
+ return TRUE;
}
static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstOmxVideoSink *self;
-
- self = GST_OMX_VIDEOSINK (object);
+ GstOmxVideoSink *self;
+
+ self = GST_OMX_VIDEOSINK (object);
+
+ switch (prop_id) {
+ case ARG_X_SCALE:
+ self->x_scale = g_value_get_uint (value);
+ break;
+ case ARG_Y_SCALE:
+ self->y_scale = g_value_get_uint (value);
+ break;
+ case ARG_ROTATION:
+ self->rotation = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
- switch (prop_id)
- {
- case ARG_X_SCALE:
- g_value_set_uint (value, self->x_scale);
- break;
- case ARG_Y_SCALE:
- g_value_set_uint (value, self->y_scale);
- break;
- case ARG_ROTATION:
- g_value_set_uint (value, self->rotation);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+static void
+get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
+{
+ GstOmxVideoSink *self;
+
+ self = GST_OMX_VIDEOSINK (object);
+
+ switch (prop_id) {
+ case ARG_X_SCALE:
+ g_value_set_uint (value, self->x_scale);
+ break;
+ case ARG_Y_SCALE:
+ g_value_set_uint (value, self->y_scale);
+ break;
+ case ARG_ROTATION:
+ g_value_set_uint (value, self->rotation);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
- GstBaseSinkClass *gst_base_sink_class;
+ GObjectClass *gobject_class;
+ GstBaseSinkClass *gst_base_sink_class;
- gobject_class = (GObjectClass *) g_class;
- gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
+ gobject_class = (GObjectClass *) g_class;
+ gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
- gst_base_sink_class->set_caps = setcaps;
+ gst_base_sink_class->set_caps = setcaps;
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
- g_object_class_install_property (gobject_class, ARG_X_SCALE,
- g_param_spec_uint ("x-scale", "X Scale",
- "How much to scale the image in the X axis (100 means nothing)",
- 0, G_MAXUINT, 100, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_X_SCALE,
+ g_param_spec_uint ("x-scale", "X Scale",
+ "How much to scale the image in the X axis (100 means nothing)",
+ 0, G_MAXUINT, 100, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, ARG_Y_SCALE,
- g_param_spec_uint ("y-scale", "Y Scale",
- "How much to scale the image in the Y axis (100 means nothing)",
- 0, G_MAXUINT, 100, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_Y_SCALE,
+ g_param_spec_uint ("y-scale", "Y Scale",
+ "How much to scale the image in the Y axis (100 means nothing)",
+ 0, G_MAXUINT, 100, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, ARG_ROTATION,
- g_param_spec_uint ("rotation", "Rotation",
- "Rotation angle",
- 0, G_MAXUINT, 360, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, ARG_ROTATION,
+ g_param_spec_uint ("rotation", "Rotation",
+ "Rotation angle",
+ 0, G_MAXUINT, 360, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseSink *omx_base;
+ GstOmxBaseSink *omx_base;
- omx_base = GST_OMX_BASE_SINK (instance);
+ omx_base = GST_OMX_BASE_SINK (instance);
- GST_DEBUG_OBJECT (omx_base, "start");
+ GST_DEBUG_OBJECT (omx_base, "start");
}
diff --git a/omx/gstomx_videosink.h b/omx/gstomx_videosink.h
index e69057a..2f90b98 100644
--- a/omx/gstomx_videosink.h
+++ b/omx/gstomx_videosink.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_VIDEOSINK(obj) (GstOmxVideoSink *) (obj)
#define GST_OMX_VIDEOSINK_TYPE (gst_omx_videosink_get_type ())
-
typedef struct GstOmxVideoSink GstOmxVideoSink;
typedef struct GstOmxVideoSinkClass GstOmxVideoSinkClass;
@@ -36,19 +34,18 @@ typedef struct GstOmxVideoSinkClass GstOmxVideoSinkClass;
struct GstOmxVideoSink
{
- GstOmxBaseSink omx_base;
- guint x_scale;
- guint y_scale;
- guint rotation;
+ GstOmxBaseSink omx_base;
+ guint x_scale;
+ guint y_scale;
+ guint rotation;
};
struct GstOmxVideoSinkClass
{
- GstOmxBaseSinkClass parent_class;
+ GstOmxBaseSinkClass parent_class;
};
GType gst_omx_videosink_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_VIDEOSINK_H */
diff --git a/omx/gstomx_volume.c b/omx/gstomx_volume.c
index 6ca8cf0..2315060 100644
--- a/omx/gstomx_volume.c
+++ b/omx/gstomx_volume.c
@@ -24,137 +24,130 @@
#include "gstomx_base_filter.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxVolume, gst_omx_volume, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE);
+GSTOMX_BOILERPLATE (GstOmxVolume, gst_omx_volume, GstOmxBaseFilter,
+ GST_OMX_BASE_FILTER_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 8000, 48000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", GST_TYPE_INT_RANGE, 1, 8,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 8000, 48000,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "channels", GST_TYPE_INT_RANGE, 1, 8, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 8000, 48000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "channels", GST_TYPE_INT_RANGE, 1, 8,
- NULL);
-
- return caps;
+ GstCaps *caps;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 8000, 48000,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "channels", GST_TYPE_INT_RANGE, 1, 8, NULL);
+
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL Volume component",
- "Filter/Effect/Audio",
- "Changes the volume with OpenMAX IL",
- "Frederik Vernelen");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL Volume component",
+ "Filter/Effect/Audio",
+ "Changes the volume with OpenMAX IL", "Frederik Vernelen");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-settings_changed_cb (GOmxCore *core)
+settings_changed_cb (GOmxCore * core)
{
- GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
+ GstOmxBaseFilter *omx_base;
+ guint rate;
+ guint channels;
- omx_base = core->object;
+ omx_base = core->object;
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_DEBUG_OBJECT (omx_base, "settings changed");
- {
- OMX_AUDIO_PARAM_PCMMODETYPE param;
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
- G_OMX_INIT_PARAM (param);
+ G_OMX_INIT_PARAM (param);
- param.nPortIndex = omx_base->out_port->port_index;
- OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+ param.nPortIndex = omx_base->out_port->port_index;
+ OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm,
+ &param);
- rate = param.nSamplingRate;
- channels = param.nChannels;
- if (rate == 0)
- {
+ rate = param.nSamplingRate;
+ channels = param.nChannels;
+ if (rate == 0) {
/** @todo: this shouldn't happen. */
- GST_WARNING_OBJECT (omx_base, "Bad samplerate");
- rate = 44100;
- }
- }
-
- {
- GstCaps *new_caps;
-
- new_caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, rate,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "channels", G_TYPE_INT, channels,
- NULL);
-
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
+ GST_WARNING_OBJECT (omx_base, "Bad samplerate");
+ rate = 44100;
}
+ }
+
+ {
+ GstCaps *new_caps;
+
+ new_caps = gst_caps_new_simple ("audio/x-raw-int",
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, rate,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "channels", G_TYPE_INT, channels, NULL);
+
+ GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
+ gst_pad_set_caps (omx_base->srcpad, new_caps);
+ }
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- GST_DEBUG_OBJECT (omx_base, "start");
+ GST_DEBUG_OBJECT (omx_base, "start");
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
+ omx_base->gomx->settings_changed_cb = settings_changed_cb;
}
diff --git a/omx/gstomx_volume.h b/omx/gstomx_volume.h
index 0e21080..585af37 100644
--- a/omx/gstomx_volume.h
+++ b/omx/gstomx_volume.h
@@ -28,10 +28,8 @@
#include <config.h>
G_BEGIN_DECLS
-
#define GST_OMX_VOLUME(obj) (GstOmxVolume *) (obj)
#define GST_OMX_VOLUME_TYPE (gst_omx_volume_get_type ())
-
typedef struct GstOmxVolume GstOmxVolume;
typedef struct GstOmxVolumeClass GstOmxVolumeClass;
@@ -39,16 +37,15 @@ typedef struct GstOmxVolumeClass GstOmxVolumeClass;
struct GstOmxVolume
{
- GstOmxBaseFilter omx_base;
+ GstOmxBaseFilter omx_base;
};
struct GstOmxVolumeClass
{
- GstOmxBaseFilterClass parent_class;
+ GstOmxBaseFilterClass parent_class;
};
GType gst_omx_volume_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_VOLUME_H */
diff --git a/omx/gstomx_vorbisdec.c b/omx/gstomx_vorbisdec.c
index 51145f6..f14c1d8 100644
--- a/omx/gstomx_vorbisdec.c
+++ b/omx/gstomx_vorbisdec.c
@@ -22,85 +22,78 @@
#include "gstomx_vorbisdec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxVorbisDec, gst_omx_vorbisdec, GstOmxBaseAudioDec, GST_OMX_BASE_AUDIODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxVorbisDec, gst_omx_vorbisdec, GstOmxBaseAudioDec,
+ GST_OMX_BASE_AUDIODEC_TYPE);
static GstCaps *
generate_src_template (void)
{
- GstCaps *caps = NULL;
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "channels", GST_TYPE_INT_RANGE, 1, 256,
- NULL);
-
- return caps;
+ GstCaps *caps = NULL;
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16, "channels", GST_TYPE_INT_RANGE, 1, 256, NULL);
+
+ return caps;
}
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps = NULL;
+ GstCaps *caps = NULL;
- caps = gst_caps_new_simple ("application/ogg",
- NULL);
+ caps = gst_caps_new_simple ("application/ogg", NULL);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL Vorbis audio decoder",
- "Codec/Decoder/Audio",
- "Decodes audio in Vorbis format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL Vorbis audio decoder",
+ "Codec/Decoder/Audio",
+ "Decodes audio in Vorbis format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- generate_src_template ());
+ template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, generate_src_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseFilter *omx_base;
+ GstOmxBaseFilter *omx_base;
- omx_base = GST_OMX_BASE_FILTER (instance);
+ omx_base = GST_OMX_BASE_FILTER (instance);
- GST_DEBUG_OBJECT (omx_base, "start");
+ GST_DEBUG_OBJECT (omx_base, "start");
- omx_base->use_timestamps = FALSE;
+ omx_base->use_timestamps = FALSE;
}
diff --git a/omx/gstomx_vorbisdec.h b/omx/gstomx_vorbisdec.h
index c7737a3..d99686c 100644
--- a/omx/gstomx_vorbisdec.h
+++ b/omx/gstomx_vorbisdec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_VORBISDEC(obj) (GstOmxVorbisDec *) (obj)
#define GST_OMX_VORBISDEC_TYPE (gst_omx_vorbisdec_get_type ())
-
typedef struct GstOmxVorbisDec GstOmxVorbisDec;
typedef struct GstOmxVorbisDecClass GstOmxVorbisDecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxVorbisDecClass GstOmxVorbisDecClass;
struct GstOmxVorbisDec
{
- GstOmxBaseAudioDec omx_base;
+ GstOmxBaseAudioDec omx_base;
};
struct GstOmxVorbisDecClass
{
- GstOmxBaseAudioDecClass parent_class;
+ GstOmxBaseAudioDecClass parent_class;
};
GType gst_omx_vorbisdec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_VORBISDEC_H */
diff --git a/omx/gstomx_wmvdec.c b/omx/gstomx_wmvdec.c
index eb05a40..f99308f 100644
--- a/omx/gstomx_wmvdec.c
+++ b/omx/gstomx_wmvdec.c
@@ -22,64 +22,60 @@
#include "gstomx_wmvdec.h"
#include "gstomx.h"
-GSTOMX_BOILERPLATE (GstOmxWmvDec, gst_omx_wmvdec, GstOmxBaseVideoDec, GST_OMX_BASE_VIDEODEC_TYPE);
+GSTOMX_BOILERPLATE (GstOmxWmvDec, gst_omx_wmvdec, GstOmxBaseVideoDec,
+ GST_OMX_BASE_VIDEODEC_TYPE);
static GstCaps *
generate_sink_template (void)
{
- GstCaps *caps;
- GstStructure *struc;
+ GstCaps *caps;
+ GstStructure *struc;
- caps = gst_caps_new_empty ();
+ caps = gst_caps_new_empty ();
- struc = gst_structure_new ("video/x-wmv",
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- NULL);
+ struc = gst_structure_new ("video/x-wmv",
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096,
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
- gst_caps_append_structure (caps, struc);
+ gst_caps_append_structure (caps, struc);
- return caps;
+ return caps;
}
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
+ GstElementClass *element_class;
- element_class = GST_ELEMENT_CLASS (g_class);
+ element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_set_details_simple (element_class,
- "OpenMAX IL WMV video decoder",
- "Codec/Decoder/Video",
- "Decodes video in WMV format with OpenMAX IL",
- "Felipe Contreras");
+ gst_element_class_set_details_simple (element_class,
+ "OpenMAX IL WMV video decoder",
+ "Codec/Decoder/Video",
+ "Decodes video in WMV format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
+ {
+ GstPadTemplate *template;
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- generate_sink_template ());
+ template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, generate_sink_template ());
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class, template);
+ }
}
static void
-type_class_init (gpointer g_class,
- gpointer class_data)
+type_class_init (gpointer g_class, gpointer class_data)
{
}
static void
-type_instance_init (GTypeInstance *instance,
- gpointer g_class)
+type_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GstOmxBaseVideoDec *omx_base;
+ GstOmxBaseVideoDec *omx_base;
- omx_base = GST_OMX_BASE_VIDEODEC (instance);
+ omx_base = GST_OMX_BASE_VIDEODEC (instance);
- omx_base->compression_format = OMX_VIDEO_CodingWMV;
+ omx_base->compression_format = OMX_VIDEO_CodingWMV;
}
diff --git a/omx/gstomx_wmvdec.h b/omx/gstomx_wmvdec.h
index 663f00d..9bf93f5 100644
--- a/omx/gstomx_wmvdec.h
+++ b/omx/gstomx_wmvdec.h
@@ -25,10 +25,8 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_OMX_WMVDEC(obj) (GstOmxWmvDec *) (obj)
#define GST_OMX_WMVDEC_TYPE (gst_omx_wmvdec_get_type ())
-
typedef struct GstOmxWmvDec GstOmxWmvDec;
typedef struct GstOmxWmvDecClass GstOmxWmvDecClass;
@@ -36,16 +34,15 @@ typedef struct GstOmxWmvDecClass GstOmxWmvDecClass;
struct GstOmxWmvDec
{
- GstOmxBaseVideoDec omx_base;
+ GstOmxBaseVideoDec omx_base;
};
struct GstOmxWmvDecClass
{
- GstOmxBaseVideoDecClass parent_class;
+ GstOmxBaseVideoDecClass parent_class;
};
GType gst_omx_wmvdec_get_type (void);
G_END_DECLS
-
#endif /* GSTOMX_WMVDEC_H */
diff --git a/tests/check_async_queue.c b/tests/check_async_queue.c
index 2576035..51e94fe 100644
--- a/tests/check_async_queue.c
+++ b/tests/check_async_queue.c
@@ -30,389 +30,361 @@ typedef struct CustomData CustomData;
struct CustomData
{
- AsyncQueue *queue;
- GSem *push_sem;
- GSem *pop_sem;
- gboolean done;
+ AsyncQueue *queue;
+ GSem *push_sem;
+ GSem *pop_sem;
+ gboolean done;
};
static CustomData *
custom_data_new (void)
{
- CustomData *custom_data;
- custom_data = g_new0 (CustomData, 1);
- custom_data->queue = async_queue_new ();
- custom_data->push_sem = g_sem_new ();
- custom_data->pop_sem = g_sem_new ();
- return custom_data;
+ CustomData *custom_data;
+ custom_data = g_new0 (CustomData, 1);
+ custom_data->queue = async_queue_new ();
+ custom_data->push_sem = g_sem_new ();
+ custom_data->pop_sem = g_sem_new ();
+ return custom_data;
}
static void
-custom_data_free (CustomData *custom_data)
+custom_data_free (CustomData * custom_data)
{
- g_sem_free (custom_data->pop_sem);
- g_sem_free (custom_data->push_sem);
- async_queue_free (custom_data->queue);
- g_free (custom_data);
+ g_sem_free (custom_data->pop_sem);
+ g_sem_free (custom_data->push_sem);
+ async_queue_free (custom_data->queue);
+ g_free (custom_data);
}
START_TEST (test_async_queue_create)
{
- AsyncQueue *queue;
- queue = async_queue_new ();
- fail_if (!queue,
- "Construction failed");
- async_queue_free (queue);
+ AsyncQueue *queue;
+ queue = async_queue_new ();
+ fail_if (!queue, "Construction failed");
+ async_queue_free (queue);
}
-END_TEST
+END_TEST
START_TEST (test_async_queue_pop)
{
- AsyncQueue *queue;
- gpointer foo;
- gpointer tmp;
- queue = async_queue_new ();
- fail_if (!queue,
- "Construction failed");
- foo = GINT_TO_POINTER (1);
- async_queue_push (queue, foo);
- tmp = async_queue_pop (queue);
- fail_if (tmp != foo,
- "Pop failed");
- async_queue_free (queue);
+ AsyncQueue *queue;
+ gpointer foo;
+ gpointer tmp;
+ queue = async_queue_new ();
+ fail_if (!queue, "Construction failed");
+ foo = GINT_TO_POINTER (1);
+ async_queue_push (queue, foo);
+ tmp = async_queue_pop (queue);
+ fail_if (tmp != foo, "Pop failed");
+ async_queue_free (queue);
}
-END_TEST
+END_TEST
START_TEST (test_async_queue_process)
{
- AsyncQueue *queue;
- gpointer foo;
- guint i;
-
- queue = async_queue_new ();
- fail_if (!queue,
- "Construction failed");
-
- foo = GINT_TO_POINTER (1);
- for (i = 0; i < PROCESS_COUNT; i++, foo++)
- {
- async_queue_push (queue, foo);
- }
- foo = GINT_TO_POINTER (1);
- for (i = 0; i < PROCESS_COUNT; i++, foo++)
- {
- gpointer tmp;
- tmp = async_queue_pop (queue);
- fail_if (tmp != foo,
- "Pop failed");
- }
+ AsyncQueue *queue;
+ gpointer foo;
+ guint i;
+
+ queue = async_queue_new ();
+ fail_if (!queue, "Construction failed");
+
+ foo = GINT_TO_POINTER (1);
+ for (i = 0; i < PROCESS_COUNT; i++, foo++) {
+ async_queue_push (queue, foo);
+ }
+ foo = GINT_TO_POINTER (1);
+ for (i = 0; i < PROCESS_COUNT; i++, foo++) {
+ gpointer tmp;
+ tmp = async_queue_pop (queue);
+ fail_if (tmp != foo, "Pop failed");
+ }
- async_queue_free (queue);
+ async_queue_free (queue);
}
-END_TEST
-static gpointer
+END_TEST static gpointer
push_func (gpointer data)
{
- AsyncQueue *queue;
- gpointer foo;
- guint i;
-
- queue = data;
- foo = GINT_TO_POINTER (1);
- for (i = 0; i < PROCESS_COUNT; i++, foo++)
- {
- async_queue_push (queue, foo);
- }
+ AsyncQueue *queue;
+ gpointer foo;
+ guint i;
- return NULL;
+ queue = data;
+ foo = GINT_TO_POINTER (1);
+ for (i = 0; i < PROCESS_COUNT; i++, foo++) {
+ async_queue_push (queue, foo);
+ }
+
+ return NULL;
}
static gpointer
pop_func (gpointer data)
{
- AsyncQueue *queue;
- gpointer foo;
- guint i;
-
- queue = data;
- foo = GINT_TO_POINTER (1);
- for (i = 0; i < PROCESS_COUNT; i++, foo++)
- {
- gpointer tmp;
- tmp = async_queue_pop (queue);
- fail_if (tmp != foo,
- "Pop failed");
- }
+ AsyncQueue *queue;
+ gpointer foo;
+ guint i;
- return NULL;
+ queue = data;
+ foo = GINT_TO_POINTER (1);
+ for (i = 0; i < PROCESS_COUNT; i++, foo++) {
+ gpointer tmp;
+ tmp = async_queue_pop (queue);
+ fail_if (tmp != foo, "Pop failed");
+ }
+
+ return NULL;
}
START_TEST (test_async_queue_threads)
{
- AsyncQueue *queue;
- GThread *push_thread;
- GThread *pop_thread;
+ AsyncQueue *queue;
+ GThread *push_thread;
+ GThread *pop_thread;
- queue = async_queue_new ();
- fail_if (!queue,
- "Construction failed");
+ queue = async_queue_new ();
+ fail_if (!queue, "Construction failed");
- pop_thread = g_thread_create (pop_func, queue, TRUE, NULL);
- push_thread = g_thread_create (push_func, queue, TRUE, NULL);
+ pop_thread = g_thread_create (pop_func, queue, TRUE, NULL);
+ push_thread = g_thread_create (push_func, queue, TRUE, NULL);
- g_thread_join (pop_thread);
- g_thread_join (push_thread);
+ g_thread_join (pop_thread);
+ g_thread_join (push_thread);
- async_queue_free (queue);
+ async_queue_free (queue);
}
-END_TEST
-static gpointer
+END_TEST static gpointer
push_and_disable_func (gpointer data)
{
- AsyncQueue *queue;
- gpointer foo;
- guint i;
-
- queue = data;
- foo = GINT_TO_POINTER (1);
- for (i = 0; i < DISABLE_AT; i++, foo++)
- {
- async_queue_push (queue, foo);
- }
+ AsyncQueue *queue;
+ gpointer foo;
+ guint i;
- async_queue_disable (queue);
+ queue = data;
+ foo = GINT_TO_POINTER (1);
+ for (i = 0; i < DISABLE_AT; i++, foo++) {
+ async_queue_push (queue, foo);
+ }
- return NULL;
+ async_queue_disable (queue);
+
+ return NULL;
}
static gpointer
pop_with_disable_func (gpointer data)
{
- AsyncQueue *queue;
- gpointer foo;
- guint i;
- guint count = 0;
-
- queue = data;
- foo = GINT_TO_POINTER (1);
- for (i = 0; i < PROCESS_COUNT; i++, foo++)
- {
- gpointer tmp;
- tmp = async_queue_pop (queue);
- if (!tmp)
- continue;
- count++;
- fail_if (tmp != foo,
- "Pop failed");
- }
+ AsyncQueue *queue;
+ gpointer foo;
+ guint i;
+ guint count = 0;
+
+ queue = data;
+ foo = GINT_TO_POINTER (1);
+ for (i = 0; i < PROCESS_COUNT; i++, foo++) {
+ gpointer tmp;
+ tmp = async_queue_pop (queue);
+ if (!tmp)
+ continue;
+ count++;
+ fail_if (tmp != foo, "Pop failed");
+ }
- return GINT_TO_POINTER (count);
+ return GINT_TO_POINTER (count);
}
static gpointer
pop_stress (gpointer data)
{
- CustomData *custom_data;
- AsyncQueue *queue;
- guint i;
-
- custom_data = data;
- queue = custom_data->queue;
- while (!custom_data->done)
- {
- for (i = 0; i < 10; i++)
- {
- gpointer tmp;
- tmp = async_queue_pop (queue);
- if (!tmp)
- break;
- }
-
- g_sem_up (custom_data->pop_sem);
- g_sem_down (custom_data->push_sem);
+ CustomData *custom_data;
+ AsyncQueue *queue;
+ guint i;
+
+ custom_data = data;
+ queue = custom_data->queue;
+ while (!custom_data->done) {
+ for (i = 0; i < 10; i++) {
+ gpointer tmp;
+ tmp = async_queue_pop (queue);
+ if (!tmp)
+ break;
}
- return NULL;
+ g_sem_up (custom_data->pop_sem);
+ g_sem_down (custom_data->push_sem);
+ }
+
+ return NULL;
}
static gpointer
push_stress (gpointer data)
{
- CustomData *custom_data;
- AsyncQueue *queue;
- gpointer foo;
- guint i, j;
-
- custom_data = data;
- queue = custom_data->queue;
- foo = GINT_TO_POINTER (1);
- for (j = 0; j < 10; j++)
- {
- for (i = 0; i < 10; i++, foo++)
- {
- async_queue_push (queue, foo);
- }
+ CustomData *custom_data;
+ AsyncQueue *queue;
+ gpointer foo;
+ guint i, j;
+
+ custom_data = data;
+ queue = custom_data->queue;
+ foo = GINT_TO_POINTER (1);
+ for (j = 0; j < 10; j++) {
+ for (i = 0; i < 10; i++, foo++) {
+ async_queue_push (queue, foo);
+ }
- async_queue_disable (queue);
+ async_queue_disable (queue);
- g_sem_down (custom_data->pop_sem);
+ g_sem_down (custom_data->pop_sem);
#if 0
- if (queue->length)
- g_debug ("flusihng %i elements", queue->length);
+ if (queue->length)
+ g_debug ("flusihng %i elements", queue->length);
#endif
- async_queue_flush (queue);
+ async_queue_flush (queue);
- async_queue_enable (queue);
-
- g_sem_up (custom_data->push_sem);
- }
+ async_queue_enable (queue);
- custom_data->done = TRUE;
- async_queue_disable (queue);
g_sem_up (custom_data->push_sem);
+ }
+
+ custom_data->done = TRUE;
+ async_queue_disable (queue);
+ g_sem_up (custom_data->push_sem);
- return NULL;
+ return NULL;
}
START_TEST (test_async_queue_disable_simple)
{
- AsyncQueue *queue;
- GThread *pop_thread;
- guint count;
+ AsyncQueue *queue;
+ GThread *pop_thread;
+ guint count;
- queue = async_queue_new ();
- fail_if (!queue,
- "Construction failed");
+ queue = async_queue_new ();
+ fail_if (!queue, "Construction failed");
- pop_thread = g_thread_create (pop_with_disable_func, queue, TRUE, NULL);
+ pop_thread = g_thread_create (pop_with_disable_func, queue, TRUE, NULL);
- async_queue_disable (queue);
+ async_queue_disable (queue);
- count = GPOINTER_TO_INT (g_thread_join (pop_thread));
+ count = GPOINTER_TO_INT (g_thread_join (pop_thread));
- fail_if (count != 0,
- "Disable failed");
+ fail_if (count != 0, "Disable failed");
- async_queue_free (queue);
+ async_queue_free (queue);
}
-END_TEST
+END_TEST
START_TEST (test_async_queue_disable)
{
- AsyncQueue *queue;
- GThread *push_thread;
- GThread *pop_thread;
- guint count;
+ AsyncQueue *queue;
+ GThread *push_thread;
+ GThread *pop_thread;
+ guint count;
- queue = async_queue_new ();
- fail_if (!queue,
- "Construction failed");
+ queue = async_queue_new ();
+ fail_if (!queue, "Construction failed");
- pop_thread = g_thread_create (pop_with_disable_func, queue, TRUE, NULL);
- push_thread = g_thread_create (push_and_disable_func, queue, TRUE, NULL);
+ pop_thread = g_thread_create (pop_with_disable_func, queue, TRUE, NULL);
+ push_thread = g_thread_create (push_and_disable_func, queue, TRUE, NULL);
- count = GPOINTER_TO_INT (g_thread_join (pop_thread));
- g_thread_join (push_thread);
+ count = GPOINTER_TO_INT (g_thread_join (pop_thread));
+ g_thread_join (push_thread);
- fail_if (count > DISABLE_AT,
- "Disable failed");
+ fail_if (count > DISABLE_AT, "Disable failed");
- async_queue_free (queue);
+ async_queue_free (queue);
}
-END_TEST
+END_TEST
START_TEST (test_async_queue_enable)
{
- AsyncQueue *queue;
- GThread *push_thread;
- GThread *pop_thread;
- guint count;
+ AsyncQueue *queue;
+ GThread *push_thread;
+ GThread *pop_thread;
+ guint count;
- queue = async_queue_new ();
- fail_if (!queue,
- "Construction failed");
+ queue = async_queue_new ();
+ fail_if (!queue, "Construction failed");
- pop_thread = g_thread_create (pop_with_disable_func, queue, TRUE, NULL);
+ pop_thread = g_thread_create (pop_with_disable_func, queue, TRUE, NULL);
- async_queue_disable (queue);
+ async_queue_disable (queue);
- count = GPOINTER_TO_INT (g_thread_join (pop_thread));
+ count = GPOINTER_TO_INT (g_thread_join (pop_thread));
- fail_if (count != 0,
- "Disable failed");
+ fail_if (count != 0, "Disable failed");
- async_queue_enable (queue);
+ async_queue_enable (queue);
- pop_thread = g_thread_create (pop_with_disable_func, queue, TRUE, NULL);
- push_thread = g_thread_create (push_and_disable_func, queue, TRUE, NULL);
+ pop_thread = g_thread_create (pop_with_disable_func, queue, TRUE, NULL);
+ push_thread = g_thread_create (push_and_disable_func, queue, TRUE, NULL);
- count = GPOINTER_TO_INT (g_thread_join (pop_thread));
- g_thread_join (push_thread);
+ count = GPOINTER_TO_INT (g_thread_join (pop_thread));
+ g_thread_join (push_thread);
- fail_if (count > DISABLE_AT,
- "Disable failed");
+ fail_if (count > DISABLE_AT, "Disable failed");
- async_queue_free (queue);
+ async_queue_free (queue);
}
-END_TEST
+END_TEST
START_TEST (test_async_queue_stress)
{
- GThread *push_thread;
- GThread *pop_thread;
- CustomData *custom_data;
+ GThread *push_thread;
+ GThread *pop_thread;
+ CustomData *custom_data;
- custom_data = custom_data_new ();
+ custom_data = custom_data_new ();
- pop_thread = g_thread_create (pop_stress, custom_data, TRUE, NULL);
- push_thread = g_thread_create (push_stress, custom_data, TRUE, NULL);
+ pop_thread = g_thread_create (pop_stress, custom_data, TRUE, NULL);
+ push_thread = g_thread_create (push_stress, custom_data, TRUE, NULL);
- g_thread_join (pop_thread);
- g_thread_join (push_thread);
+ g_thread_join (pop_thread);
+ g_thread_join (push_thread);
- custom_data_free (custom_data);
+ custom_data_free (custom_data);
}
-END_TEST
-static Suite *
+END_TEST static Suite *
util_suite (void)
{
- Suite *s = suite_create ("util");
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
- /* Core test case */
- TCase *tc_core = tcase_create ("Core");
- tcase_add_test (tc_core, test_async_queue_create);
- tcase_add_test (tc_core, test_async_queue_pop);
- tcase_add_test (tc_core, test_async_queue_process);
- tcase_add_test (tc_core, test_async_queue_threads);
- tcase_add_test (tc_core, test_async_queue_disable_simple);
- tcase_add_test (tc_core, test_async_queue_disable);
- tcase_add_test (tc_core, test_async_queue_enable);
- tcase_add_test (tc_core, test_async_queue_stress);
- suite_add_tcase (s, tc_core);
-
- return s;
+ Suite *s = suite_create ("util");
+
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+
+ /* Core test case */
+ TCase *tc_core = tcase_create ("Core");
+ tcase_add_test (tc_core, test_async_queue_create);
+ tcase_add_test (tc_core, test_async_queue_pop);
+ tcase_add_test (tc_core, test_async_queue_process);
+ tcase_add_test (tc_core, test_async_queue_threads);
+ tcase_add_test (tc_core, test_async_queue_disable_simple);
+ tcase_add_test (tc_core, test_async_queue_disable);
+ tcase_add_test (tc_core, test_async_queue_enable);
+ tcase_add_test (tc_core, test_async_queue_stress);
+ suite_add_tcase (s, tc_core);
+
+ return s;
}
int
main (void)
{
- int number_failed;
- Suite *s;
- SRunner *sr;
+ int number_failed;
+ Suite *s;
+ SRunner *sr;
- s = util_suite ();
- sr = srunner_create (s);
- srunner_run_all (sr, CK_NORMAL);
- number_failed = srunner_ntests_failed (sr);
- srunner_free (sr);
+ s = util_suite ();
+ sr = srunner_create (s);
+ srunner_run_all (sr, CK_NORMAL);
+ number_failed = srunner_ntests_failed (sr);
+ srunner_free (sr);
- return (number_failed == 0) ? 0 : 1;
+ return (number_failed == 0) ? 0 : 1;
}
diff --git a/tests/check_gstomx.c b/tests/check_gstomx.c
index 0684f92..c51de6b 100644
--- a/tests/check_gstomx.c
+++ b/tests/check_gstomx.c
@@ -25,17 +25,15 @@
#define BUFFER_COUNT 0x100
#define FLUSH_AT 0x10
-static GstStaticPadTemplate sinktemplate =
-GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
-
-static GstStaticPadTemplate srctemplate =
-GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
+static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
/* some global vars, makes it easy as for the ones above */
static GMutex *eos_mutex;
@@ -46,146 +44,141 @@ static gboolean
test_sink_event (GstPad * pad, GstEvent * event)
{
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_EOS:
- g_mutex_lock (eos_mutex);
- eos_arrived = TRUE;
- g_cond_signal (eos_cond);
- g_mutex_unlock (eos_mutex);
- break;
- default:
- break;
- }
-
- return gst_pad_event_default (pad, event);
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ g_mutex_lock (eos_mutex);
+ eos_arrived = TRUE;
+ g_cond_signal (eos_cond);
+ g_mutex_unlock (eos_mutex);
+ break;
+ default:
+ break;
+ }
+
+ return gst_pad_event_default (pad, event);
}
static void
helper (gboolean flush)
{
- GstElement *filter;
- GstBus *bus;
- GstPad *mysrcpad;
- GstPad *mysinkpad;
-
- /* init */
- filter = gst_check_setup_element ("omx_dummy");
- mysrcpad = gst_check_setup_src_pad (filter, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (filter, &sinktemplate, NULL);
-
- gst_pad_set_active (mysrcpad, TRUE);
- gst_pad_set_active (mysinkpad, TRUE);
-
- /* need to know when we are eos */
- gst_pad_set_event_function (mysinkpad, test_sink_event);
-
- /* and notify the test run */
- eos_mutex = g_mutex_new ();
- eos_cond = g_cond_new ();
- eos_arrived = FALSE;
-
- /* start */
-
- fail_unless_equals_int (gst_element_set_state (filter, GST_STATE_PLAYING),
- GST_STATE_CHANGE_SUCCESS);
-
- bus = gst_bus_new ();
-
- gst_element_set_bus (filter, bus);
-
- /* send buffers in order*/
- {
- guint i;
- for (i = 0; i < BUFFER_COUNT; i++)
- {
- GstBuffer *inbuffer;
- inbuffer = gst_buffer_new_and_alloc (BUFFER_SIZE);
- GST_BUFFER_DATA(inbuffer)[0] = i;
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
-
- fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
-
- if (flush && i % FLUSH_AT == 0)
- {
- gst_pad_push_event (mysrcpad, gst_event_new_flush_start ());
- gst_pad_push_event (mysrcpad, gst_event_new_flush_stop ());
- i += FLUSH_AT;
- }
- }
- }
+ GstElement *filter;
+ GstBus *bus;
+ GstPad *mysrcpad;
+ GstPad *mysinkpad;
- {
- GstMessage *message;
+ /* init */
+ filter = gst_check_setup_element ("omx_dummy");
+ mysrcpad = gst_check_setup_src_pad (filter, &srctemplate, NULL);
+ mysinkpad = gst_check_setup_sink_pad (filter, &sinktemplate, NULL);
- /* make sure there's no error on the bus */
- message = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
- fail_if (message);
- }
+ gst_pad_set_active (mysrcpad, TRUE);
+ gst_pad_set_active (mysinkpad, TRUE);
- gst_pad_push_event (mysrcpad, gst_event_new_eos ());
- /* need to wait a bit to make sure src pad task digested all and sent eos */
- g_mutex_lock (eos_mutex);
- while (!eos_arrived)
- g_cond_wait (eos_cond, eos_mutex);
- g_mutex_unlock (eos_mutex);
-
- /* check the order of the buffers*/
- if (!flush)
- {
- GList *cur;
- guint i;
- for (cur = buffers, i = 0; cur; cur = g_list_next (cur), i++)
- {
- GstBuffer *buffer;
- buffer = cur->data;
- fail_unless (GST_BUFFER_DATA(buffer)[0] == i);
- }
- fail_unless (i == BUFFER_COUNT);
- }
+ /* need to know when we are eos */
+ gst_pad_set_event_function (mysinkpad, test_sink_event);
+
+ /* and notify the test run */
+ eos_mutex = g_mutex_new ();
+ eos_cond = g_cond_new ();
+ eos_arrived = FALSE;
+
+ /* start */
- /* cleanup */
- gst_bus_set_flushing (bus, TRUE);
- gst_element_set_bus (filter, NULL);
- gst_object_unref (GST_OBJECT (bus));
- gst_check_drop_buffers ();
+ fail_unless_equals_int (gst_element_set_state (filter, GST_STATE_PLAYING),
+ GST_STATE_CHANGE_SUCCESS);
- /* deinit */
- gst_element_set_state (filter, GST_STATE_NULL);
+ bus = gst_bus_new ();
- gst_pad_set_active (mysrcpad, FALSE);
- gst_pad_set_active (mysinkpad, FALSE);
- gst_check_teardown_src_pad (filter);
- gst_check_teardown_sink_pad (filter);
- gst_check_teardown_element (filter);
+ gst_element_set_bus (filter, bus);
- g_mutex_free (eos_mutex);
- g_cond_free (eos_cond);
+ /* send buffers in order */
+ {
+ guint i;
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ GstBuffer *inbuffer;
+ inbuffer = gst_buffer_new_and_alloc (BUFFER_SIZE);
+ GST_BUFFER_DATA (inbuffer)[0] = i;
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+
+ if (flush && i % FLUSH_AT == 0) {
+ gst_pad_push_event (mysrcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (mysrcpad, gst_event_new_flush_stop ());
+ i += FLUSH_AT;
+ }
+ }
+ }
+
+ {
+ GstMessage *message;
+
+ /* make sure there's no error on the bus */
+ message = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
+ fail_if (message);
+ }
+
+ gst_pad_push_event (mysrcpad, gst_event_new_eos ());
+ /* need to wait a bit to make sure src pad task digested all and sent eos */
+ g_mutex_lock (eos_mutex);
+ while (!eos_arrived)
+ g_cond_wait (eos_cond, eos_mutex);
+ g_mutex_unlock (eos_mutex);
+
+ /* check the order of the buffers */
+ if (!flush) {
+ GList *cur;
+ guint i;
+ for (cur = buffers, i = 0; cur; cur = g_list_next (cur), i++) {
+ GstBuffer *buffer;
+ buffer = cur->data;
+ fail_unless (GST_BUFFER_DATA (buffer)[0] == i);
+ }
+ fail_unless (i == BUFFER_COUNT);
+ }
+
+ /* cleanup */
+ gst_bus_set_flushing (bus, TRUE);
+ gst_element_set_bus (filter, NULL);
+ gst_object_unref (GST_OBJECT (bus));
+ gst_check_drop_buffers ();
+
+ /* deinit */
+ gst_element_set_state (filter, GST_STATE_NULL);
+
+ gst_pad_set_active (mysrcpad, FALSE);
+ gst_pad_set_active (mysinkpad, FALSE);
+ gst_check_teardown_src_pad (filter);
+ gst_check_teardown_sink_pad (filter);
+ gst_check_teardown_element (filter);
+
+ g_mutex_free (eos_mutex);
+ g_cond_free (eos_cond);
}
GST_START_TEST (test_flush)
{
- helper (TRUE);
+ helper (TRUE);
}
-GST_END_TEST
+GST_END_TEST
GST_START_TEST (test_basic)
{
- helper (FALSE);
+ helper (FALSE);
}
-GST_END_TEST
-static Suite *
+GST_END_TEST static Suite *
gstomx_suite (void)
{
- Suite *s = suite_create ("gstomx");
- TCase *tc_chain = tcase_create ("general");
+ Suite *s = suite_create ("gstomx");
+ TCase *tc_chain = tcase_create ("general");
- tcase_set_timeout (tc_chain, 10);
- tcase_add_test (tc_chain, test_basic);
- tcase_add_test (tc_chain, test_flush);
- suite_add_tcase (s, tc_chain);
+ tcase_set_timeout (tc_chain, 10);
+ tcase_add_test (tc_chain, test_basic);
+ tcase_add_test (tc_chain, test_flush);
+ suite_add_tcase (s, tc_chain);
- return s;
+ return s;
}
GST_CHECK_MAIN (gstomx);
diff --git a/tests/check_libomxil.c b/tests/check_libomxil.c
index 9c6550b..d75f914 100644
--- a/tests/check_libomxil.c
+++ b/tests/check_libomxil.c
@@ -30,221 +30,211 @@ static const char *lib_name;
static void *dl_handle;
static OMX_ERRORTYPE (*init) (void);
static OMX_ERRORTYPE (*deinit) (void);
-static OMX_ERRORTYPE (*get_handle) (OMX_HANDLETYPE *handle,
- OMX_STRING name,
- OMX_PTR data,
- OMX_CALLBACKTYPE *callbacks);
+static OMX_ERRORTYPE (*get_handle) (OMX_HANDLETYPE * handle,
+ OMX_STRING name, OMX_PTR data, OMX_CALLBACKTYPE * callbacks);
static OMX_ERRORTYPE (*free_handle) (OMX_HANDLETYPE handle);
typedef struct CustomData CustomData;
struct CustomData
{
- OMX_HANDLETYPE omx_handle;
- OMX_STATETYPE omx_state;
- GCond *omx_state_condition;
- GMutex *omx_state_mutex;
+ OMX_HANDLETYPE omx_handle;
+ OMX_STATETYPE omx_state;
+ GCond *omx_state_condition;
+ GMutex *omx_state_mutex;
};
static CustomData *
custom_data_new (void)
{
- CustomData *custom_data;
- custom_data = g_new0 (CustomData, 1);
- custom_data->omx_state_condition = g_cond_new ();
- custom_data->omx_state_mutex = g_mutex_new ();
- return custom_data;
+ CustomData *custom_data;
+ custom_data = g_new0 (CustomData, 1);
+ custom_data->omx_state_condition = g_cond_new ();
+ custom_data->omx_state_mutex = g_mutex_new ();
+ return custom_data;
}
static void
-custom_data_free (CustomData *custom_data)
+custom_data_free (CustomData * custom_data)
{
- g_mutex_free (custom_data->omx_state_mutex);
- g_cond_free (custom_data->omx_state_condition);
- g_free (custom_data);
+ g_mutex_free (custom_data->omx_state_mutex);
+ g_cond_free (custom_data->omx_state_condition);
+ g_free (custom_data);
}
static inline void
-change_state (CustomData *core,
- OMX_STATETYPE state)
+change_state (CustomData * core, OMX_STATETYPE state)
{
- fail_if (OMX_SendCommand (core->omx_handle, OMX_CommandStateSet, state, NULL) != OMX_ErrorNone);
+ fail_if (OMX_SendCommand (core->omx_handle, OMX_CommandStateSet, state,
+ NULL) != OMX_ErrorNone);
}
static inline void
-complete_change_state (CustomData *core,
- OMX_STATETYPE state)
+complete_change_state (CustomData * core, OMX_STATETYPE state)
{
- g_mutex_lock (core->omx_state_mutex);
+ g_mutex_lock (core->omx_state_mutex);
- core->omx_state = state;
- g_cond_signal (core->omx_state_condition);
+ core->omx_state = state;
+ g_cond_signal (core->omx_state_condition);
- g_mutex_unlock (core->omx_state_mutex);
+ g_mutex_unlock (core->omx_state_mutex);
}
static inline void
-wait_for_state (CustomData *core,
- OMX_STATETYPE state)
+wait_for_state (CustomData * core, OMX_STATETYPE state)
{
- g_mutex_lock (core->omx_state_mutex);
+ g_mutex_lock (core->omx_state_mutex);
- while (core->omx_state != state)
- g_cond_wait (core->omx_state_condition, core->omx_state_mutex);
+ while (core->omx_state != state)
+ g_cond_wait (core->omx_state_condition, core->omx_state_mutex);
- g_mutex_unlock (core->omx_state_mutex);
+ g_mutex_unlock (core->omx_state_mutex);
}
static OMX_ERRORTYPE
EventHandler (OMX_HANDLETYPE omx_handle,
- OMX_PTR app_data,
- OMX_EVENTTYPE event,
- OMX_U32 data_1,
- OMX_U32 data_2,
- OMX_PTR event_data)
+ OMX_PTR app_data,
+ OMX_EVENTTYPE event, OMX_U32 data_1, OMX_U32 data_2, OMX_PTR event_data)
{
- CustomData *core;
+ CustomData *core;
- core = app_data;
+ core = app_data;
- switch (event)
+ switch (event) {
+ case OMX_EventCmdComplete:
{
- case OMX_EventCmdComplete:
- {
- OMX_COMMANDTYPE cmd;
-
- cmd = (OMX_COMMANDTYPE) data_1;
-
- switch (cmd)
- {
- case OMX_CommandStateSet:
- complete_change_state (core, data_2);
- break;
- default:
- break;
- }
- break;
- }
+ OMX_COMMANDTYPE cmd;
+
+ cmd = (OMX_COMMANDTYPE) data_1;
+
+ switch (cmd) {
+ case OMX_CommandStateSet:
+ complete_change_state (core, data_2);
+ break;
default:
- break;
+ break;
+ }
+ break;
}
+ default:
+ break;
+ }
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static OMX_CALLBACKTYPE callbacks = { EventHandler, NULL, NULL };
START_TEST (test_basic)
{
- OMX_ERRORTYPE omx_error;
- omx_error = init ();
- fail_if (omx_error != OMX_ErrorNone);
- omx_error = deinit ();
- fail_if (omx_error != OMX_ErrorNone);
+ OMX_ERRORTYPE omx_error;
+ omx_error = init ();
+ fail_if (omx_error != OMX_ErrorNone);
+ omx_error = deinit ();
+ fail_if (omx_error != OMX_ErrorNone);
}
-END_TEST
+END_TEST
START_TEST (test_handle)
{
- OMX_ERRORTYPE omx_error;
- OMX_HANDLETYPE omx_handle;
+ OMX_ERRORTYPE omx_error;
+ OMX_HANDLETYPE omx_handle;
- omx_error = init ();
- fail_if (omx_error != OMX_ErrorNone);
+ omx_error = init ();
+ fail_if (omx_error != OMX_ErrorNone);
- omx_error = get_handle (&omx_handle, "OMX.check.dummy", NULL, NULL);
- fail_if (omx_error != OMX_ErrorNone);
+ omx_error = get_handle (&omx_handle, "OMX.check.dummy", NULL, NULL);
+ fail_if (omx_error != OMX_ErrorNone);
- omx_error = free_handle (omx_handle);
- fail_if (omx_error != OMX_ErrorNone);
+ omx_error = free_handle (omx_handle);
+ fail_if (omx_error != OMX_ErrorNone);
- omx_error = deinit ();
- fail_if (omx_error != OMX_ErrorNone);
+ omx_error = deinit ();
+ fail_if (omx_error != OMX_ErrorNone);
}
-END_TEST
+END_TEST
START_TEST (test_idle)
{
- CustomData *custom_data;
- OMX_ERRORTYPE omx_error;
- OMX_HANDLETYPE omx_handle;
+ CustomData *custom_data;
+ OMX_ERRORTYPE omx_error;
+ OMX_HANDLETYPE omx_handle;
- custom_data = custom_data_new ();
+ custom_data = custom_data_new ();
- omx_error = init ();
- fail_if (omx_error != OMX_ErrorNone);
+ omx_error = init ();
+ fail_if (omx_error != OMX_ErrorNone);
- omx_error = get_handle (&omx_handle, "OMX.check.dummy", custom_data, &callbacks);
- fail_if (omx_error != OMX_ErrorNone);
+ omx_error =
+ get_handle (&omx_handle, "OMX.check.dummy", custom_data, &callbacks);
+ fail_if (omx_error != OMX_ErrorNone);
- custom_data->omx_handle = omx_handle;
+ custom_data->omx_handle = omx_handle;
- change_state (custom_data, OMX_StateIdle);
+ change_state (custom_data, OMX_StateIdle);
- /* allocate_buffers */
+ /* allocate_buffers */
- wait_for_state (custom_data, OMX_StateIdle);
+ wait_for_state (custom_data, OMX_StateIdle);
- change_state (custom_data, OMX_StateLoaded);
+ change_state (custom_data, OMX_StateLoaded);
- /* free_buffers */
+ /* free_buffers */
- wait_for_state (custom_data, OMX_StateLoaded);
+ wait_for_state (custom_data, OMX_StateLoaded);
- omx_error = free_handle (omx_handle);
- fail_if (omx_error != OMX_ErrorNone);
+ omx_error = free_handle (omx_handle);
+ fail_if (omx_error != OMX_ErrorNone);
- omx_error = deinit ();
- fail_if (omx_error != OMX_ErrorNone);
+ omx_error = deinit ();
+ fail_if (omx_error != OMX_ErrorNone);
- custom_data_free (custom_data);
+ custom_data_free (custom_data);
}
-END_TEST
-static Suite *
+END_TEST static Suite *
util_suite (void)
{
- Suite *s = suite_create ("libomxil");
- TCase *tc_chain = tcase_create ("general");
+ Suite *s = suite_create ("libomxil");
+ TCase *tc_chain = tcase_create ("general");
- lib_name = "libomxil-foo.so";
+ lib_name = "libomxil-foo.so";
- if (!g_thread_supported ())
- g_thread_init (NULL);
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
- {
- dl_handle = dlopen (lib_name, RTLD_LAZY);
- if (!dl_handle)
- {
+ {
+ dl_handle = dlopen (lib_name, RTLD_LAZY);
+ if (!dl_handle) {
/** @todo report error. */
- }
-
- init = dlsym (dl_handle, "OMX_Init");
- deinit = dlsym (dl_handle, "OMX_Deinit");
- get_handle = dlsym (dl_handle, "OMX_GetHandle");
- free_handle = dlsym (dl_handle, "OMX_FreeHandle");
}
- tcase_add_test (tc_chain, test_basic);
- tcase_add_test (tc_chain, test_handle);
- tcase_add_test (tc_chain, test_idle);
- suite_add_tcase (s, tc_chain);
+ init = dlsym (dl_handle, "OMX_Init");
+ deinit = dlsym (dl_handle, "OMX_Deinit");
+ get_handle = dlsym (dl_handle, "OMX_GetHandle");
+ free_handle = dlsym (dl_handle, "OMX_FreeHandle");
+ }
+
+ tcase_add_test (tc_chain, test_basic);
+ tcase_add_test (tc_chain, test_handle);
+ tcase_add_test (tc_chain, test_idle);
+ suite_add_tcase (s, tc_chain);
- return s;
+ return s;
}
int
main (void)
{
- int number_failed;
- Suite *s;
- SRunner *sr;
+ int number_failed;
+ Suite *s;
+ SRunner *sr;
- s = util_suite ();
- sr = srunner_create (s);
- srunner_run_all (sr, CK_NORMAL);
- number_failed = srunner_ntests_failed (sr);
- srunner_free (sr);
+ s = util_suite ();
+ sr = srunner_create (s);
+ srunner_run_all (sr, CK_NORMAL);
+ number_failed = srunner_ntests_failed (sr);
+ srunner_free (sr);
- return (number_failed == 0) ? 0 : 1;
+ return (number_failed == 0) ? 0 : 1;
}
diff --git a/tests/standalone/core.c b/tests/standalone/core.c
index c145524..36e11d7 100644
--- a/tests/standalone/core.c
+++ b/tests/standalone/core.c
@@ -24,8 +24,8 @@
#include <glib.h>
-#include <stdlib.h> /* For calloc, free */
-#include <string.h> /* For memcpy */
+#include <stdlib.h> /* For calloc, free */
+#include <string.h> /* For memcpy */
#include "async_queue.h"
@@ -34,18 +34,17 @@ static void *foo_thread (void *cb_data);
OMX_ERRORTYPE
OMX_Init (void)
{
- if (!g_thread_supported ())
- {
- g_thread_init (NULL);
- }
+ if (!g_thread_supported ()) {
+ g_thread_init (NULL);
+ }
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
OMX_ERRORTYPE
OMX_Deinit (void)
{
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
typedef struct CompPrivate CompPrivate;
@@ -53,349 +52,332 @@ typedef struct CompPrivatePort CompPrivatePort;
struct CompPrivate
{
- OMX_STATETYPE state;
- OMX_CALLBACKTYPE *callbacks;
- OMX_PTR app_data;
- CompPrivatePort *ports;
- gboolean done;
- GMutex *flush_mutex;
+ OMX_STATETYPE state;
+ OMX_CALLBACKTYPE *callbacks;
+ OMX_PTR app_data;
+ CompPrivatePort *ports;
+ gboolean done;
+ GMutex *flush_mutex;
};
struct CompPrivatePort
{
- OMX_PARAM_PORTDEFINITIONTYPE port_def;
- AsyncQueue *queue;
+ OMX_PARAM_PORTDEFINITIONTYPE port_def;
+ AsyncQueue *queue;
};
static OMX_ERRORTYPE
-comp_GetState (OMX_HANDLETYPE handle,
- OMX_STATETYPE *state)
+comp_GetState (OMX_HANDLETYPE handle, OMX_STATETYPE * state)
{
- OMX_COMPONENTTYPE *comp;
- CompPrivate *private;
+ OMX_COMPONENTTYPE *comp;
+ CompPrivate *private;
- /* printf ("GetState\n"); */
+ /* printf ("GetState\n"); */
- comp = handle;
- private = comp->pComponentPrivate;
+ comp = handle;
+ private = comp->pComponentPrivate;
- *state = private->state;
+ *state = private->state;
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static OMX_ERRORTYPE
-comp_GetParameter (OMX_HANDLETYPE handle,
- OMX_INDEXTYPE index,
- OMX_PTR param)
+comp_GetParameter (OMX_HANDLETYPE handle, OMX_INDEXTYPE index, OMX_PTR param)
{
- OMX_COMPONENTTYPE *comp;
- CompPrivate *private;
+ OMX_COMPONENTTYPE *comp;
+ CompPrivate *private;
- /* printf ("GetParameter\n"); */
+ /* printf ("GetParameter\n"); */
- comp = handle;
- private = comp->pComponentPrivate;
+ comp = handle;
+ private = comp->pComponentPrivate;
- switch (index)
+ switch (index) {
+ case OMX_IndexParamPortDefinition:
{
- case OMX_IndexParamPortDefinition:
- {
- OMX_PARAM_PORTDEFINITIONTYPE *port_def;
- port_def = param;
- memcpy (port_def, &private->ports[port_def->nPortIndex].port_def, port_def->nSize);
- break;
- }
- default:
- break;
+ OMX_PARAM_PORTDEFINITIONTYPE *port_def;
+ port_def = param;
+ memcpy (port_def, &private->ports[port_def->nPortIndex].port_def,
+ port_def->nSize);
+ break;
}
+ default:
+ break;
+ }
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static OMX_ERRORTYPE
-comp_SetParameter (OMX_HANDLETYPE handle,
- OMX_INDEXTYPE index,
- OMX_PTR param)
+comp_SetParameter (OMX_HANDLETYPE handle, OMX_INDEXTYPE index, OMX_PTR param)
{
- OMX_COMPONENTTYPE *comp;
- CompPrivate *private;
+ OMX_COMPONENTTYPE *comp;
+ CompPrivate *private;
- /* printf ("SetParameter\n"); */
+ /* printf ("SetParameter\n"); */
- comp = handle;
- private = comp->pComponentPrivate;
+ comp = handle;
+ private = comp->pComponentPrivate;
- switch (index)
+ switch (index) {
+ case OMX_IndexParamPortDefinition:
{
- case OMX_IndexParamPortDefinition:
- {
- OMX_PARAM_PORTDEFINITIONTYPE *port_def;
- port_def = param;
- memcpy (&private->ports[port_def->nPortIndex].port_def, port_def, port_def->nSize);
- break;
- }
- default:
- break;
+ OMX_PARAM_PORTDEFINITIONTYPE *port_def;
+ port_def = param;
+ memcpy (&private->ports[port_def->nPortIndex].port_def, port_def,
+ port_def->nSize);
+ break;
}
+ default:
+ break;
+ }
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static OMX_ERRORTYPE
comp_SendCommand (OMX_HANDLETYPE handle,
- OMX_COMMANDTYPE command,
- OMX_U32 param_1,
- OMX_PTR data)
+ OMX_COMMANDTYPE command, OMX_U32 param_1, OMX_PTR data)
{
- OMX_COMPONENTTYPE *comp;
- CompPrivate *private;
+ OMX_COMPONENTTYPE *comp;
+ CompPrivate *private;
- /* printf ("SendCommand\n"); */
+ /* printf ("SendCommand\n"); */
- comp = handle;
- private = comp->pComponentPrivate;
+ comp = handle;
+ private = comp->pComponentPrivate;
- switch (command)
+ switch (command) {
+ case OMX_CommandStateSet:
{
- case OMX_CommandStateSet:
- {
- if (private->state == OMX_StateLoaded && param_1 == OMX_StateIdle)
- {
- g_thread_create (foo_thread, comp, TRUE, NULL);
- }
- private->state = param_1;
- private->callbacks->EventHandler (handle,
- private->app_data, OMX_EventCmdComplete,
- OMX_CommandStateSet, private->state, data);
- }
- break;
- case OMX_CommandFlush:
- {
- g_mutex_lock (private->flush_mutex);
- {
- OMX_BUFFERHEADERTYPE *buffer;
-
- while ((buffer = async_queue_pop_forced (private->ports[0].queue)))
- {
- private->callbacks->EmptyBufferDone (comp,
- private->app_data, buffer);
- }
-
- while ((buffer = async_queue_pop_forced (private->ports[1].queue)))
- {
- private->callbacks->FillBufferDone (comp,
- private->app_data, buffer);
- }
- }
- g_mutex_unlock (private->flush_mutex);
-
- private->callbacks->EventHandler (handle,
- private->app_data, OMX_EventCmdComplete,
- OMX_CommandFlush, param_1, data);
- }
- break;
- default:
- /* printf ("command: %d\n", command); */
- break;
+ if (private->state == OMX_StateLoaded && param_1 == OMX_StateIdle) {
+ g_thread_create (foo_thread, comp, TRUE, NULL);
+ }
+ private->state = param_1;
+ private->callbacks->EventHandler (handle,
+ private->app_data, OMX_EventCmdComplete,
+ OMX_CommandStateSet, private->state, data);
}
+ break;
+ case OMX_CommandFlush:
+ {
+ g_mutex_lock (private->flush_mutex);
+ {
+ OMX_BUFFERHEADERTYPE *buffer;
- return OMX_ErrorNone;
-}
-
-static OMX_ERRORTYPE
-comp_UseBuffer (OMX_HANDLETYPE handle,
- OMX_BUFFERHEADERTYPE **buffer_header,
- OMX_U32 index,
- OMX_PTR data,
- OMX_U32 size,
- OMX_U8 *buffer)
-{
- OMX_BUFFERHEADERTYPE *new;
+ while ((buffer = async_queue_pop_forced (private->ports[0].queue))) {
+ private->callbacks->EmptyBufferDone (comp, private->app_data, buffer);
+ }
- new = calloc (1, sizeof (OMX_BUFFERHEADERTYPE));
- new->nSize = sizeof (OMX_BUFFERHEADERTYPE);
- new->nVersion.nVersion = 1;
- new->pBuffer = buffer;
- new->nAllocLen = size;
+ while ((buffer = async_queue_pop_forced (private->ports[1].queue))) {
+ private->callbacks->FillBufferDone (comp, private->app_data, buffer);
+ }
+ }
+ g_mutex_unlock (private->flush_mutex);
- switch (index)
- {
- case 0: new->nInputPortIndex = 0; break;
- case 1: new->nOutputPortIndex = 1; break;
- default: break;
+ private->callbacks->EventHandler (handle,
+ private->app_data, OMX_EventCmdComplete,
+ OMX_CommandFlush, param_1, data);
}
+ break;
+ default:
+ /* printf ("command: %d\n", command); */
+ break;
+ }
- *buffer_header = new;
+ return OMX_ErrorNone;
+}
- return OMX_ErrorNone;
+static OMX_ERRORTYPE
+comp_UseBuffer (OMX_HANDLETYPE handle,
+ OMX_BUFFERHEADERTYPE ** buffer_header,
+ OMX_U32 index, OMX_PTR data, OMX_U32 size, OMX_U8 * buffer)
+{
+ OMX_BUFFERHEADERTYPE *new;
+
+ new = calloc (1, sizeof (OMX_BUFFERHEADERTYPE));
+ new->nSize = sizeof (OMX_BUFFERHEADERTYPE);
+ new->nVersion.nVersion = 1;
+ new->pBuffer = buffer;
+ new->nAllocLen = size;
+
+ switch (index) {
+ case 0:
+ new->nInputPortIndex = 0;
+ break;
+ case 1:
+ new->nOutputPortIndex = 1;
+ break;
+ default:
+ break;
+ }
+
+ *buffer_header = new;
+
+ return OMX_ErrorNone;
}
static OMX_ERRORTYPE
comp_FreeBuffer (OMX_HANDLETYPE handle,
- OMX_U32 index,
- OMX_BUFFERHEADERTYPE *buffer_header)
+ OMX_U32 index, OMX_BUFFERHEADERTYPE * buffer_header)
{
- free (buffer_header);
+ free (buffer_header);
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static gpointer
foo_thread (gpointer cb_data)
{
- OMX_COMPONENTTYPE *comp;
- CompPrivate *private;
+ OMX_COMPONENTTYPE *comp;
+ CompPrivate *private;
- comp = cb_data;
- private = comp->pComponentPrivate;
+ comp = cb_data;
+ private = comp->pComponentPrivate;
- while (!private->done)
- {
- OMX_BUFFERHEADERTYPE *in_buffer;
- OMX_BUFFERHEADERTYPE *out_buffer;
-
- in_buffer = async_queue_pop (private->ports[0].queue);
- if (!in_buffer) continue;
-
- out_buffer = async_queue_pop (private->ports[1].queue);
- if (!out_buffer) continue;
-
- /* process buffers */
- {
- unsigned long size;
- size = MIN (in_buffer->nFilledLen, out_buffer->nAllocLen);
- memcpy (out_buffer->pBuffer, in_buffer->pBuffer, size);
- out_buffer->nFilledLen = size;
- in_buffer->nFilledLen -= size;
- out_buffer->nTimeStamp = in_buffer->nTimeStamp;
- out_buffer->nFlags = in_buffer->nFlags;
- }
+ while (!private->done) {
+ OMX_BUFFERHEADERTYPE *in_buffer;
+ OMX_BUFFERHEADERTYPE *out_buffer;
- g_mutex_lock (private->flush_mutex);
+ in_buffer = async_queue_pop (private->ports[0].queue);
+ if (!in_buffer)
+ continue;
- private->callbacks->FillBufferDone (comp,
- private->app_data, out_buffer);
- if (in_buffer->nFilledLen == 0)
- {
- private->callbacks->EmptyBufferDone (comp,
- private->app_data, in_buffer);
- }
+ out_buffer = async_queue_pop (private->ports[1].queue);
+ if (!out_buffer)
+ continue;
- g_mutex_unlock (private->flush_mutex);
+ /* process buffers */
+ {
+ unsigned long size;
+ size = MIN (in_buffer->nFilledLen, out_buffer->nAllocLen);
+ memcpy (out_buffer->pBuffer, in_buffer->pBuffer, size);
+ out_buffer->nFilledLen = size;
+ in_buffer->nFilledLen -= size;
+ out_buffer->nTimeStamp = in_buffer->nTimeStamp;
+ out_buffer->nFlags = in_buffer->nFlags;
}
- return NULL;
+ g_mutex_lock (private->flush_mutex);
+
+ private->callbacks->FillBufferDone (comp, private->app_data, out_buffer);
+ if (in_buffer->nFilledLen == 0) {
+ private->callbacks->EmptyBufferDone (comp, private->app_data, in_buffer);
+ }
+
+ g_mutex_unlock (private->flush_mutex);
+ }
+
+ return NULL;
}
static OMX_ERRORTYPE
comp_EmptyThisBuffer (OMX_HANDLETYPE handle,
- OMX_BUFFERHEADERTYPE *buffer_header)
+ OMX_BUFFERHEADERTYPE * buffer_header)
{
- OMX_COMPONENTTYPE *comp;
- CompPrivate *private;
+ OMX_COMPONENTTYPE *comp;
+ CompPrivate *private;
- /* printf ("EmptyThisBuffer\n"); */
+ /* printf ("EmptyThisBuffer\n"); */
- comp = handle;
- private = comp->pComponentPrivate;
+ comp = handle;
+ private = comp->pComponentPrivate;
- async_queue_push (private->ports[0].queue, buffer_header);
+ async_queue_push (private->ports[0].queue, buffer_header);
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
static OMX_ERRORTYPE
comp_FillThisBuffer (OMX_HANDLETYPE handle,
- OMX_BUFFERHEADERTYPE *buffer_header)
+ OMX_BUFFERHEADERTYPE * buffer_header)
{
- OMX_COMPONENTTYPE *comp;
- CompPrivate *private;
+ OMX_COMPONENTTYPE *comp;
+ CompPrivate *private;
- /* printf ("FillThisBuffer\n"); */
+ /* printf ("FillThisBuffer\n"); */
- comp = handle;
- private = comp->pComponentPrivate;
+ comp = handle;
+ private = comp->pComponentPrivate;
- async_queue_push (private->ports[1].queue, buffer_header);
+ async_queue_push (private->ports[1].queue, buffer_header);
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
OMX_ERRORTYPE
-OMX_GetHandle (OMX_HANDLETYPE *handle,
- OMX_STRING component_name,
- OMX_PTR data,
- OMX_CALLBACKTYPE *callbacks)
+OMX_GetHandle (OMX_HANDLETYPE * handle,
+ OMX_STRING component_name, OMX_PTR data, OMX_CALLBACKTYPE * callbacks)
{
- OMX_COMPONENTTYPE *comp;
+ OMX_COMPONENTTYPE *comp;
+
+ comp = calloc (1, sizeof (OMX_COMPONENTTYPE));
+ comp->nSize = sizeof (OMX_COMPONENTTYPE);
+ comp->nVersion.nVersion = 1;
+
+ comp->GetState = comp_GetState;
+ comp->GetParameter = comp_GetParameter;
+ comp->SetParameter = comp_SetParameter;
+ comp->SendCommand = comp_SendCommand;
+ comp->UseBuffer = comp_UseBuffer;
+ comp->FreeBuffer = comp_FreeBuffer;
+ comp->EmptyThisBuffer = comp_EmptyThisBuffer;
+ comp->FillThisBuffer = comp_FillThisBuffer;
+
+ {
+ CompPrivate *private;
- comp = calloc (1, sizeof (OMX_COMPONENTTYPE));
- comp->nSize = sizeof (OMX_COMPONENTTYPE);
- comp->nVersion.nVersion = 1;
+ private = calloc (1, sizeof (CompPrivate));
+ private->state = OMX_StateLoaded;
+ private->callbacks = callbacks;
+ private->app_data = data;
+ private->ports = calloc (2, sizeof (CompPrivatePort));
+ private->flush_mutex = g_mutex_new ();
- comp->GetState = comp_GetState;
- comp->GetParameter = comp_GetParameter;
- comp->SetParameter = comp_SetParameter;
- comp->SendCommand = comp_SendCommand;
- comp->UseBuffer = comp_UseBuffer;
- comp->FreeBuffer = comp_FreeBuffer;
- comp->EmptyThisBuffer = comp_EmptyThisBuffer;
- comp->FillThisBuffer = comp_FillThisBuffer;
+ private->ports[0].queue = async_queue_new ();
+ private->ports[1].queue = async_queue_new ();
{
- CompPrivate *private;
-
- private = calloc (1, sizeof (CompPrivate));
- private->state = OMX_StateLoaded;
- private->callbacks = callbacks;
- private->app_data = data;
- private->ports = calloc (2, sizeof (CompPrivatePort));
- private->flush_mutex = g_mutex_new ();
-
- private->ports[0].queue = async_queue_new ();
- private->ports[1].queue = async_queue_new ();
-
- {
- OMX_PARAM_PORTDEFINITIONTYPE *port_def;
-
- port_def = &private->ports[0].port_def;
- port_def->nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- port_def->nVersion.nVersion = 1;
- port_def->nPortIndex = 0;
- port_def->eDir = OMX_DirInput;
- port_def->nBufferCountActual = 1;
- port_def->nBufferCountMin = 1;
- port_def->nBufferSize = 0x1000;
- port_def->eDomain = OMX_PortDomainAudio;
-
- }
+ OMX_PARAM_PORTDEFINITIONTYPE *port_def;
+
+ port_def = &private->ports[0].port_def;
+ port_def->nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
+ port_def->nVersion.nVersion = 1;
+ port_def->nPortIndex = 0;
+ port_def->eDir = OMX_DirInput;
+ port_def->nBufferCountActual = 1;
+ port_def->nBufferCountMin = 1;
+ port_def->nBufferSize = 0x1000;
+ port_def->eDomain = OMX_PortDomainAudio;
- {
- OMX_PARAM_PORTDEFINITIONTYPE *port_def;
-
- port_def = &private->ports[1].port_def;
- port_def->nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
- port_def->nVersion.nVersion = 1;
- port_def->nPortIndex = 1;
- port_def->eDir = OMX_DirOutput;
- port_def->nBufferCountActual = 1;
- port_def->nBufferCountMin = 1;
- port_def->nBufferSize = 0x1000;
- port_def->eDomain = OMX_PortDomainAudio;
- }
+ }
- comp->pComponentPrivate = private;
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE *port_def;
+
+ port_def = &private->ports[1].port_def;
+ port_def->nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
+ port_def->nVersion.nVersion = 1;
+ port_def->nPortIndex = 1;
+ port_def->eDir = OMX_DirOutput;
+ port_def->nBufferCountActual = 1;
+ port_def->nBufferCountMin = 1;
+ port_def->nBufferSize = 0x1000;
+ port_def->eDomain = OMX_PortDomainAudio;
}
- *handle = comp;
+ comp->pComponentPrivate = private;
+ }
+
+ *handle = comp;
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
OMX_ERRORTYPE
OMX_FreeHandle (OMX_HANDLETYPE handle)
{
/** @todo Free private structure? */
- return OMX_ErrorNone;
+ return OMX_ErrorNone;
}
diff --git a/util/async_queue.c b/util/async_queue.c
index 95833dc..9a71152 100644
--- a/util/async_queue.c
+++ b/util/async_queue.c
@@ -26,130 +26,125 @@
AsyncQueue *
async_queue_new (void)
{
- AsyncQueue *queue;
+ AsyncQueue *queue;
- queue = g_slice_new0 (AsyncQueue);
+ queue = g_slice_new0 (AsyncQueue);
- queue->condition = g_cond_new ();
- queue->mutex = g_mutex_new ();
- queue->enabled = TRUE;
+ queue->condition = g_cond_new ();
+ queue->mutex = g_mutex_new ();
+ queue->enabled = TRUE;
- return queue;
+ return queue;
}
void
-async_queue_free (AsyncQueue *queue)
+async_queue_free (AsyncQueue * queue)
{
- g_cond_free (queue->condition);
- g_mutex_free (queue->mutex);
+ g_cond_free (queue->condition);
+ g_mutex_free (queue->mutex);
- g_list_free (queue->head);
- g_slice_free (AsyncQueue, queue);
+ g_list_free (queue->head);
+ g_slice_free (AsyncQueue, queue);
}
void
-async_queue_push (AsyncQueue *queue,
- gpointer data)
+async_queue_push (AsyncQueue * queue, gpointer data)
{
- g_mutex_lock (queue->mutex);
+ g_mutex_lock (queue->mutex);
- queue->head = g_list_prepend (queue->head, data);
- if (!queue->tail)
- queue->tail = queue->head;
- queue->length++;
+ queue->head = g_list_prepend (queue->head, data);
+ if (!queue->tail)
+ queue->tail = queue->head;
+ queue->length++;
- g_cond_signal (queue->condition);
+ g_cond_signal (queue->condition);
- g_mutex_unlock (queue->mutex);
+ g_mutex_unlock (queue->mutex);
}
gpointer
-async_queue_pop (AsyncQueue *queue)
+async_queue_pop (AsyncQueue * queue)
{
- gpointer data = NULL;
+ gpointer data = NULL;
- g_mutex_lock (queue->mutex);
+ g_mutex_lock (queue->mutex);
- if (!queue->enabled)
- {
- /* g_warning ("not enabled!"); */
- goto leave;
- }
+ if (!queue->enabled) {
+ /* g_warning ("not enabled!"); */
+ goto leave;
+ }
- if (!queue->tail)
- {
- g_cond_wait (queue->condition, queue->mutex);
- }
+ if (!queue->tail) {
+ g_cond_wait (queue->condition, queue->mutex);
+ }
+ if (queue->tail) {
+ GList *node = queue->tail;
+ data = node->data;
+
+ queue->tail = node->prev;
if (queue->tail)
- {
- GList *node = queue->tail;
- data = node->data;
-
- queue->tail = node->prev;
- if (queue->tail)
- queue->tail->next = NULL;
- else
- queue->head = NULL;
- queue->length--;
- g_list_free_1 (node);
- }
+ queue->tail->next = NULL;
+ else
+ queue->head = NULL;
+ queue->length--;
+ g_list_free_1 (node);
+ }
leave:
- g_mutex_unlock (queue->mutex);
+ g_mutex_unlock (queue->mutex);
- return data;
+ return data;
}
gpointer
-async_queue_pop_forced (AsyncQueue *queue)
+async_queue_pop_forced (AsyncQueue * queue)
{
- gpointer data = NULL;
+ gpointer data = NULL;
+
+ g_mutex_lock (queue->mutex);
- g_mutex_lock (queue->mutex);
+ if (queue->tail) {
+ GList *node = queue->tail;
+ data = node->data;
+ queue->tail = node->prev;
if (queue->tail)
- {
- GList *node = queue->tail;
- data = node->data;
-
- queue->tail = node->prev;
- if (queue->tail)
- queue->tail->next = NULL;
- else
- queue->head = NULL;
- queue->length--;
- g_list_free_1 (node);
- }
-
- g_mutex_unlock (queue->mutex);
-
- return data;
+ queue->tail->next = NULL;
+ else
+ queue->head = NULL;
+ queue->length--;
+ g_list_free_1 (node);
+ }
+
+ g_mutex_unlock (queue->mutex);
+
+ return data;
}
void
-async_queue_disable (AsyncQueue *queue)
+async_queue_disable (AsyncQueue * queue)
{
- g_mutex_lock (queue->mutex);
- queue->enabled = FALSE;
- g_cond_broadcast (queue->condition);
- g_mutex_unlock (queue->mutex);
+ g_mutex_lock (queue->mutex);
+ queue->enabled = FALSE;
+ g_cond_broadcast (queue->condition);
+ g_mutex_unlock (queue->mutex);
}
void
-async_queue_enable (AsyncQueue *queue)
+async_queue_enable (AsyncQueue * queue)
{
- g_mutex_lock (queue->mutex);
- queue->enabled = TRUE;
- g_mutex_unlock (queue->mutex);
+ g_mutex_lock (queue->mutex);
+ queue->enabled = TRUE;
+ g_mutex_unlock (queue->mutex);
}
void
-async_queue_flush (AsyncQueue *queue)
+async_queue_flush (AsyncQueue * queue)
{
- g_mutex_lock (queue->mutex);
- g_list_free (queue->head);
- queue->head = queue->tail = NULL;
- queue->length = 0;
- g_mutex_unlock (queue->mutex);
+ g_mutex_lock (queue->mutex);
+ g_list_free (queue->head);
+ queue->head = queue->tail = NULL;
+ queue->length = 0;
+ g_mutex_unlock (queue->mutex);
}
diff --git a/util/async_queue.h b/util/async_queue.h
index eec497e..fe459af 100644
--- a/util/async_queue.h
+++ b/util/async_queue.h
@@ -28,21 +28,21 @@ typedef struct AsyncQueue AsyncQueue;
struct AsyncQueue
{
- GMutex *mutex;
- GCond *condition;
- GList *head;
- GList *tail;
- guint length;
- gboolean enabled;
+ GMutex *mutex;
+ GCond *condition;
+ GList *head;
+ GList *tail;
+ guint length;
+ gboolean enabled;
};
AsyncQueue *async_queue_new (void);
-void async_queue_free (AsyncQueue *queue);
-void async_queue_push (AsyncQueue *queue, gpointer data);
-gpointer async_queue_pop (AsyncQueue *queue);
-gpointer async_queue_pop_forced (AsyncQueue *queue);
-void async_queue_disable (AsyncQueue *queue);
-void async_queue_enable (AsyncQueue *queue);
-void async_queue_flush (AsyncQueue *queue);
+void async_queue_free (AsyncQueue * queue);
+void async_queue_push (AsyncQueue * queue, gpointer data);
+gpointer async_queue_pop (AsyncQueue * queue);
+gpointer async_queue_pop_forced (AsyncQueue * queue);
+void async_queue_disable (AsyncQueue * queue);
+void async_queue_enable (AsyncQueue * queue);
+void async_queue_flush (AsyncQueue * queue);
#endif /* ASYNC_QUEUE_H */
diff --git a/util/sem.c b/util/sem.c
index 2ac6fac..3336024 100644
--- a/util/sem.c
+++ b/util/sem.c
@@ -26,46 +26,45 @@
GSem *
g_sem_new (void)
{
- GSem *sem;
+ GSem *sem;
- sem = g_new (GSem, 1);
- sem->condition = g_cond_new ();
- sem->mutex = g_mutex_new ();
- sem->counter = 0;
+ sem = g_new (GSem, 1);
+ sem->condition = g_cond_new ();
+ sem->mutex = g_mutex_new ();
+ sem->counter = 0;
- return sem;
+ return sem;
}
void
-g_sem_free (GSem *sem)
+g_sem_free (GSem * sem)
{
- g_cond_free (sem->condition);
- g_mutex_free (sem->mutex);
- g_free (sem);
+ g_cond_free (sem->condition);
+ g_mutex_free (sem->mutex);
+ g_free (sem);
}
void
-g_sem_down (GSem *sem)
+g_sem_down (GSem * sem)
{
- g_mutex_lock (sem->mutex);
+ g_mutex_lock (sem->mutex);
- while (sem->counter == 0)
- {
- g_cond_wait (sem->condition, sem->mutex);
- }
+ while (sem->counter == 0) {
+ g_cond_wait (sem->condition, sem->mutex);
+ }
- sem->counter--;
+ sem->counter--;
- g_mutex_unlock (sem->mutex);
+ g_mutex_unlock (sem->mutex);
}
void
-g_sem_up (GSem *sem)
+g_sem_up (GSem * sem)
{
- g_mutex_lock (sem->mutex);
+ g_mutex_lock (sem->mutex);
- sem->counter++;
- g_cond_signal (sem->condition);
+ sem->counter++;
+ g_cond_signal (sem->condition);
- g_mutex_unlock (sem->mutex);
+ g_mutex_unlock (sem->mutex);
}
diff --git a/util/sem.h b/util/sem.h
index 7d8b342..764850d 100644
--- a/util/sem.h
+++ b/util/sem.h
@@ -28,14 +28,14 @@ typedef struct GSem GSem;
struct GSem
{
- GCond *condition;
- GMutex *mutex;
- gint counter;
+ GCond *condition;
+ GMutex *mutex;
+ gint counter;
};
GSem *g_sem_new (void);
-void g_sem_free (GSem *sem);
-void g_sem_down (GSem *sem);
-void g_sem_up (GSem *sem);
+void g_sem_free (GSem * sem);
+void g_sem_down (GSem * sem);
+void g_sem_up (GSem * sem);
#endif /* SEM_H */