felipec gst-openmax: gst-openmax/omx/
[email protected] Mon, 8 Dec 2008 13:09:52 -0800 (PST)
| Newsgroups | gmane.comp.video.gstreamer.cvs |
|---|---|
| Message-ID | <[email protected]> |
CVS Root: /cvs/gstreamer
Module: gst-openmax
Changes by: felipec
Date: Mon Dec 08 2008 21:09:52 UTC
Log message:
adpcm: Fix capabilities negotation.
Modified files:
omx : gstomx_adpcmdec.c gstomx_adpcmenc.c
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx_adpcmdec.c.diff?r1=1.8&r2=1.9
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx_adpcmenc.c.diff?r1=1.8&r2=1.9
====Begin Diffs====
Index: gstomx_adpcmdec.c
===================================================================
RCS file: /cvs/gstreamer/gst-openmax/omx/gstomx_adpcmdec.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- gstomx_adpcmdec.c 20 Nov 2008 16:47:32 -0000 1.8
+++ gstomx_adpcmdec.c 8 Dec 2008 21:09:38 -0000 1.9
@@ -52,7 +52,7 @@
GstCaps *caps;
caps = gst_caps_new_simple ("audio/x-adpcm",
- "string", G_TYPE_STRING, "dvi",
+ "layout", G_TYPE_STRING, "dvi",
"rate", GST_TYPE_INT_RANGE, 8000, 96000,
"channels", GST_TYPE_INT_RANGE, 1, 8,
NULL);
@@ -106,17 +106,25 @@
parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
}
-static void
-settings_changed_cb (GOmxCore *core)
+static gboolean
+sink_setcaps (GstPad *pad,
+ GstCaps *caps)
{
+ GstStructure *structure;
GstOmxBaseFilter *omx_base;
- guint rate;
- guint channels;
+ GOmxCore *gomx;
+ gint rate = 0;
- omx_base = core->client_data;
+ omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
+ gomx = (GOmxCore *) omx_base->gomx;
- GST_DEBUG_OBJECT (omx_base, "settings changed");
+ GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ structure = gst_caps_get_structure (caps, 0);
+
+ gst_structure_get_int (structure, "rate", &rate);
+ /* Input port configuration. */
{
OMX_AUDIO_PARAM_PCMMODETYPE *param;
@@ -128,40 +136,31 @@
param->nPortIndex = 1;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, param);
- rate = param->nSamplingRate;
- channels = param->nChannels;
+ param->nSamplingRate = rate;
+ OMX_SetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, param);
free (param);
}
+ /* set caps on the srcpad */
- 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 ? 1234 : 4321,
- "channels", G_TYPE_INT, channels,
- NULL);
+ GstCaps *tmp_caps;
- GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
- gst_pad_set_caps (omx_base->srcpad, new_caps);
- }
-}
+ tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
+ tmp_caps = gst_caps_make_writable (tmp_caps);
+ gst_caps_truncate (tmp_caps);
-static gboolean
-sink_setcaps (GstPad *pad,
- GstCaps *caps)
-{
- GstOmxBaseFilter *omx_base;
- GOmxCore *gomx;
+ gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
- omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
- gomx = (GOmxCore *) omx_base->gomx;
+ 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_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+ gst_caps_unref (tmp_caps);
+ }
return gst_pad_set_caps (pad, caps);
@@ -176,8 +175,6 @@
omx_base->omx_component = g_strdup (OMX_COMPONENT_NAME);
- omx_base->gomx->settings_changed_cb = settings_changed_cb;
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
Index: gstomx_adpcmenc.c
RCS file: /cvs/gstreamer/gst-openmax/omx/gstomx_adpcmenc.c,v
--- gstomx_adpcmenc.c 20 Nov 2008 16:47:33 -0000 1.8
+++ gstomx_adpcmenc.c 8 Dec 2008 21:09:38 -0000 1.9
@@ -35,7 +35,7 @@
"channels", G_TYPE_INT, 1,
@@ -140,7 +140,7 @@
GstCaps *new_caps;
new_caps = gst_caps_new_simple ("audio/x-adpcm",
- "string", G_TYPE_STRING, "dvi",
+ "layout", G_TYPE_STRING, "dvi",
"rate", G_TYPE_INT, rate,
"channels", G_TYPE_INT, 1,
NULL);
@@ -154,21 +154,36 @@
sink_setcaps (GstPad *pad,
GstCaps *caps)
+ GstCaps *peer_caps;
GstStructure *structure;
GOmxCore *gomx;
gint rate = 0;
+ gboolean ret = TRUE;
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);
- g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
+ peer_caps = gst_pad_peer_get_caps (omx_base->srcpad);
- structure = gst_caps_get_structure (caps, 0);
+ g_return_val_if_fail (peer_caps, FALSE);
- gst_structure_get_int (structure, "rate", &rate);
+ 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);
+ gst_structure_get_int (structure, "rate", &rate);
+ else
+ structure = gst_caps_get_structure (caps, 0);
/* Input port configuration. */
@@ -189,7 +204,33 @@
- return gst_pad_set_caps (pad, caps);
+ GstStructure *tmp_structure;
+ tmp_structure = gst_caps_get_structure (tmp_caps, 0);
+ gst_structure_fixate_field_nearest_int (tmp_structure, "rate", rate);
+ ret = gst_pad_set_caps (pad, caps);
+ gst_caps_unref (peer_caps);
+ return ret;
static void
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/