[gst-devel] Upstream caps (re)negotiation

Martin Bisson martin.bisson at gmail.com
Thu May 27 11:41:08 CEST 2010


Hi,

I have questions about upstream caps renegotiation.  I've read
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-nego-upstream.htmlbut
I still have questions on the concrete implementation.

I'm not sure what to do when caps needs to be renegotated.  As an example,
let's take a simple plugin that takes a video stream from its sink pad, does
a simple thing to it by copying it into another buffer, then pushes that
buffer on its source pad.

The chain function would try to get the output buffer using
gst_pad_alloc_buffer.  In the normal case, it would return a buffer of the
same caps.

But in case of caps renegotiation coming from upstream, the buffer caps
might be different.  And I wonder what to do in that case.  I have kind of a
tree of questions about what to do in every case.  I guess the first thing
to do would be to try to set the caps on the plugin's source pad
(gst_pad_set_caps), which would in turn set the caps on the plugin's sink
pad.

1) If gst_pad_set_caps function fails on the source pad (which would have
also tried to call it on the sink pad), I guess this means that the
negotiation failed (no possible format from downstream).  So the chain
function should stop what it is doing, unref the input buffer and the output
buffer, and return GST_FLOW_NOT_NEGOTIATED?
2) If gst_pad_set_caps function succeeds on the sink pad, I guess it means
the caps were succesfully negotiated upstream.  So what happens to the input
buffer during all that procedure?  Is it still valid or not?
3) If it's not valid, I guess the chain function just has to stop what it's
doing, unref the output (and the input?) buffer, but what should it returns
as a return value?
4) If the input buffer is still valid after caps renegotiation, I see two
possibilities: it either can be used with the new caps or it cannot.  For
instance, if the plugin is just flipping an image upside down, maybe it's
able to flip a yuv buffer into another yuv buffer, a rgb buffer into another
rgb buffer, but not a yuv buffer into a rgb buffer.  So two possibilities
depending on wether the plugin can convert the buffer in the old caps into a
buffer in the new caps.
5) If it can do it, I guess there is no problem and the chain function just
does it and returns GST_FLOW_OK
6) But if it can't do it, what does the function do?  I guess it unrefs the
input & output buffer, but what would the return value be?

Thanks a lot in advance for any explanations,

Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20100527/71e8edbf/attachment.htm>


More information about the gstreamer-devel mailing list