[gst-devel] Problem using GstAdapter in GstBaseTransform-based element

Jan Schmidt thaytan at noraisin.net
Tue Feb 21 09:26:09 CET 2006

On Tue, 2006-02-21 at 17:33 +0100, Dominique Würtz wrote:
> Hi,
> I'm creating an GstElement derived from GstBaseTransform. For this I 
> need to use a GstAdapter. Unfortunately, it seems that adapters don't 
> work with transform elements. A (test) implementation of the 
> _transform() vfunc as listed below results in a segfault. It seems that 
> somewhere outside _transform() the inbuf is destroyed though this has 
> already been done by gst_adapter_flush(). Any ideas what I'm doing wrong?
> static GstFlowReturn
> my_element_transform (GstBaseTransform *trans, GstBuffer *inbuf,
>                       GstBuffer *outbuf)
> {
>     MyElement *filter;
>     filter = MY_ELEMENT (trans);
>     gst_adapter_push (filter->adapter, inbuf);
>     while (gst_adapter_available (filter->adapter) >= 512) {
>         gst_adapter_peek (filter->adapter, 512);
>         gst_adapter_flush (filter->adapter, 512);
>     }
>     return GST_FLOW_OK;

If you want to keep a reference to the buffer, you need to ref it with
gst_buffer_ref. BaseTransform will drop the reference it is providing to
you after it leaves the transform function, but gst_adapter_push expects
that you are transferring a refcount when giving it the buffer.

The transform function above doesn't look like a good fit for the "1
buffer in, 1 buffer out" use cases GstBaseTransform was designed for.


Jan Schmidt thaytan at noraisin.net

"Don't Panic" -- The Hitchhiker's Guide to the Galaxy

More information about the gstreamer-devel mailing list