[gst-devel] Caps problem when writing encoder/decoder

Marco Ballesio gibrovacco at gmail.com
Sun May 23 10:23:54 CEST 2010


Hi,

looks like the mailing list is getting your emails twice.. can you
please check your mail client settings?

On Thu, May 20, 2010 at 1:54 PM, Hunterwood
<markus.jagerskogh at imentum.se> wrote:
> Hi again,
>
>
>
> I think you are right, Marco, about the caps of the buffer. I didn’t think
> about that!
>
> I haven’t been able to get it to work, though.
>
> At first I tried:
>
>   base_caps = gst_caps_copy (gst_pad_get_pad_template_caps
> (filter->srcpad));
>
>   gst_buffer_set_caps(outbuf, base_caps);
>
>
>
> But I got the error:
>
> ** (gst-launch-0.10:6344): CRITICAL **: file
> ..\Source\gstreamer\gst\gstpad.c: line 2508: assertion `caps == NULL ||
> gst_caps_is_fixed (caps)' failed
>
>

it's because template caps are not fixed. Try the following:

gst_buffer_set_caps(buf, GST_PAD_CAPS (filter->srcpad));

>
> So I tried to remove the fixed caps and use _set_caps-functions for the
> pads.
>
> But what do I need to do in the _set_caps-functions? The input to the
> encoder has a fixed format and the output from the decoder has the same
> fixed format.
>
> The compressed audio could have different rates, that could be represented
> in the caps. Do the _set_caps for the sink-pad need to set the caps of the
> source?
>
> I tried:
>
>   ...
>
>   filter = GST_GtestENC (gst_pad_get_parent (pad));
>
>   otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
>
>   base_caps = gst_caps_copy (GST_PAD_CAPS(otherpad));
>
>   return gst_pad_set_caps (otherpad, base_caps);

here you're setting the caps of one pad of your filter into another..
what's the purpose of this?

>
> But I get an empty caps from GST_PAD_CAPS(filter->sinkpad) and gst_caps_copy
> gives this error:
>
> ** (gst-launch-0.10:6724): CRITICAL **: file
> ..\Source\gstreamer\gst\gstcaps.c: line 280: assertion `GST_IS_CAPS (caps)'
> failed
>
>
>
> However. In my “real” encoder/decoder I do set the caps in my
> _chain-function:
>
>   ret =
>
>     gst_pad_alloc_buffer_and_set_caps (filter->srcpad,
> GST_BUFFER_OFFSET_NONE,
>
>                FRAME_LENGTH, GST_PAD_CAPS (filter->srcpad), &outbuf);
>
>
>
> But I get an error in the _set_caps-function for the sink in the decoder:
>
> static gboolean
>
> gst_mydec_sink_set_caps (GstPad * pad, GstCaps * caps)
>
> {
>
>   mydec *filter;
>
>   GstPad *otherpad;
>
>   GstCaps *base_caps;
>
>   GstFlowReturn ret;
>
>
>
>   filter = GST_MYDEC (gst_pad_get_parent (pad));
>
>   otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
>
>   base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));
>
>
>
>   ret = gst_pad_set_caps (otherpad, base_caps); // error
>
>
>
>   return ret;
>
> }
>
>
>
> The error I get is:
>
> ** (gst-launch-0.10:2964): CRITICAL **: file
> ..\Source\gstreamer\gst\gstpad.c: line 2508: assertion `caps == NULL ||
> gst_caps_is_fixed (caps)' failed
>
>
>
> But I checked with GST_IS_CAPS (base_caps) and gst_caps_is_fixed(base_caps)
> and base_caps IS a caps and it is not fixed, so why do I get an error?
>

it looks pretty strange that gst_pad_get_pad_template_caps () can
return fixed caps, but maybe you encoder is defining exactly one value
for each field in the structure so it may make sense. Please check
again with the correct GST_DEBUG messages.

For a good caps negotation example, please check e.g.
ext/speex/gstspeexenc.c in gst-plugins-good.

Regards

>
>
> Clearly there is something I have done wrong or misunderstood, but I can’t
> figure it out…
>
>
>
> Regards
>
> Markus
>
> ________________________________
> View this message in context: SV: Caps problem when writing encoder/decoder
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>




More information about the gstreamer-devel mailing list