Correspondence between appsrc input and appsink output buffers

Sebastian Dröge sebastian at centricular.com
Thu Nov 10 05:40:15 UTC 2016


On Wed, 2016-11-09 at 22:24 +0100, benjamin.hepp at posteo.de wrote:
> On 09.11.2016 08:49, Sebastian Dröge wrote:
> 
> > That's generally not a good idea and should cause crashes or other
> > problems over time. You always have to do the reference counting
> > correct.
> 
> Of course, after decreasing the ref count to 1 and adding the GstMeta
> to the buffer one has to increase the ref count to the previous
> value.

Nothing prevents another thread from calling unref() for its own
reference at the same time, which then would cause the buffer to be
destroyed as you removed all additional references.

Also other code might be iterating the metas at this very moment, and
if a new one is added then random things could happen.

> > If a buffer is not writable, you need to copy it (the buffer, not
> > the
> > actual memory inside it). See gst_buffer_make_writable() for
> > automating
> > that task.
> 
> I don't see how that can work for the GstMeta transformation
> function:
> ***_meta_transform (GstBuffer * transbuf, GstMeta * meta,
>      GstBuffer * buffer, GQuark type, gpointer data)
> 
> You can very well copy the transbuf buffer and add the GstMeta to
> the 
> copy but then how could you replace transbuf with it?

If the buffer is not writable in this method, then that's a bug in
basetransform somewhere.

-- 
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 931 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20161110/1d658c06/attachment.sig>


More information about the gstreamer-devel mailing list