[Gstreamer-openmax] [PATCH] RFC: template caps from config file
Rob Clark
rob at ti.com
Mon Nov 1 08:56:22 PDT 2010
The omx_mpeg4dec element is converted.. the remaining changes are largly
manual (ie. adding caps to config file, removing from individual element
class files and adding appropriate calls to gstomx_template_caps()). But I
thought I'd send what I have so far so folks could comment before I spend
some boring time converting the rest of the elements ;-)
---
v2: split out some of the cosmetic changes into a different patchset to
simplify this patch
omx/gstomx.c | 30 ++++++++++++++++++++++++
omx/gstomx.conf.in | 21 ++++++++++++++++
omx/gstomx.h | 1 +
omx/gstomx_base_videodec.c | 54 -------------------------------------------
omx/gstomx_mpeg4dec.c | 55 ++++---------------------------------------
5 files changed, 58 insertions(+), 103 deletions(-)
diff --git a/omx/gstomx.c b/omx/gstomx.c
index 8b375c0..c444de5 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -327,6 +327,36 @@ gstomx_core_new (void *object, GType type)
return core;
}
+GstCaps *
+gstomx_template_caps (GType type, const gchar * pad_name)
+{
+ const gchar *element_name;
+ GstStructure *element;
+ const gchar *caps_str;
+
+ element_name = g_type_get_qdata (type, element_name_quark);
+ element = get_element_entry (element_name);
+
+
+ /* this shouldn't really happen.. */
+ if (!element)
+ return GST_CAPS_ANY;
+
+ caps_str = gst_structure_get_string (element, pad_name);
+
+ GST_DEBUG ("%s: %s", element_name, caps_str);
+
+ /* default to ANY.. at least for now.. maybe when everything is converted
+ * over, we should treat missing caps as a more serious condition?
+ */
+ if (!caps_str) {
+ g_warning ("%s is missing required field: %s", element_name, pad_name);
+ return GST_CAPS_ANY;
+ }
+
+ return gst_caps_from_string (caps_str);
+}
+
void
gstomx_install_property_helper (GObjectClass * gobject_class)
{
diff --git a/omx/gstomx.conf.in b/omx/gstomx.conf.in
index c22c6d6..ed74ec2 100644
--- a/omx/gstomx.conf.in
+++ b/omx/gstomx.conf.in
@@ -20,10 +20,31 @@ omx_dummy_2,
component-name=OMX.st.dummy2,
rank=256;
+/* standard width/height/framerate that applies to video decoders and encoders
+ * on both src and sink pad:
+ */
+#define VIDEO_SIZE_RATE \
+ "width=(int)[16,4096], " \
+ "height=(int)[16,4096], " \
+ "framerate=(fraction)[0,max]"
+
+/* standard raw video caps that applies to all video decoder src pads and
+ * video encoder sink pads:
+ */
+#define RAW_VIDEO_CAPS \
+ "video/x-raw-yuv, " \
+ VIDEO_SIZE_RATE ", " \
+ "format=(fourcc){I420, YUY2, UYVY, NV12}; "
+
omx_mpeg4dec,
type=GstOmxMpeg4Dec,
library-name=libomxil-bellagio.so.0,
component-name=OMX.st.video_decoder.mpeg4,
+ src=RAW_VIDEO_CAPS,
+ sink="video/mpeg, mpegversion=(int)4, systemstream=false, " VIDEO_SIZE_RATE ";"\
+ "video/x-divx, divxversion=(int)[4,5], " VIDEO_SIZE_RATE ";" \
+ "video/x-xvid, " VIDEO_SIZE_RATE ";" \
+ "video/x-3ivx, " VIDEO_SIZE_RATE ";",
rank=256;
omx_h264dec,
diff --git a/omx/gstomx.h b/omx/gstomx.h
index a2377d3..1a9013a 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -44,6 +44,7 @@ enum
gboolean gstomx_get_component_info (void *core, GType type);
void *gstomx_core_new (void *object, GType type);
+GstCaps *gstomx_template_caps (GType type, const gchar * pad_name);
void gstomx_install_property_helper (GObjectClass * gobject_class);
gboolean gstomx_get_property_helper (void *core, guint prop_id, GValue * value);
diff --git a/omx/gstomx_base_videodec.c b/omx/gstomx_base_videodec.c
index de36899..9148dec 100644
--- a/omx/gstomx_base_videodec.c
+++ b/omx/gstomx_base_videodec.c
@@ -25,63 +25,9 @@
GSTOMX_BOILERPLATE (GstOmxBaseVideoDec, gst_omx_base_videodec, GstOmxBaseFilter,
GST_OMX_BASE_FILTER_TYPE);
-static GstCaps *
-generate_src_template (void)
-{
- GstCaps *caps;
- GstStructure *struc;
-
- 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);
-
- {
- GValue list;
- GValue val;
-
- list.g_type = val.g_type = 0;
-
- 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 ('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_structure_set_value (struc, "format", &list);
-
- g_value_unset (&val);
- g_value_unset (&list);
- }
-
- gst_caps_append_structure (caps, struc);
-
- return caps;
-}
-
static void
type_base_init (gpointer g_class)
{
- GstElementClass *element_class;
-
- element_class = GST_ELEMENT_CLASS (g_class);
-
- {
- GstPadTemplate *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);
- }
}
static void
diff --git a/omx/gstomx_mpeg4dec.c b/omx/gstomx_mpeg4dec.c
index f112ecb..1286f65 100644
--- a/omx/gstomx_mpeg4dec.c
+++ b/omx/gstomx_mpeg4dec.c
@@ -25,48 +25,6 @@
GSTOMX_BOILERPLATE (GstOmxMpeg4Dec, gst_omx_mpeg4dec, GstOmxBaseVideoDec,
GST_OMX_BASE_VIDEODEC_TYPE);
-static GstCaps *
-generate_sink_template (void)
-{
- GstCaps *caps;
- GstStructure *struc;
-
- 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);
-
- 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);
-
- 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);
-
- 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);
-
- gst_caps_append_structure (caps, struc);
-
- return caps;
-}
-
static void
type_base_init (gpointer g_class)
{
@@ -79,14 +37,13 @@ type_base_init (gpointer g_class)
"Codec/Decoder/Video",
"Decodes video in MPEG-4 format with OpenMAX IL", "Felipe Contreras");
- {
- GstPadTemplate *template;
-
- template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS, generate_sink_template ());
+ gst_element_class_add_pad_template (element_class,
+ gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
+ gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "sink")));
- gst_element_class_add_pad_template (element_class, template);
- }
+ gst_element_class_add_pad_template (element_class,
+ gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "src")));
}
static void
--
1.7.1.1
More information about the Gstreamer-openmax
mailing list