[gst-devel] Problem using GstAdapter in GstBaseTransform-based element
Dominique Würtz
housirer at gmx.de
Wed Feb 22 02:20:06 CET 2006
Thanks for clearing things up.
Regarding the use case: my element will work in a similar way to
audioresample from -base which derives from TransformBase as well. The
input/output buffer size ratio can be any non-integer fraction. So what
I want to do in _transform() is fetch the input data using the adapter,
calculate as much output as possible given the data available, adjust
the size of the output buffer and store the remaining samples (as a
result of non-integer fractions) for the next iteration. I wonder why
audioresample isn't using GstAdpapter for the same purpose.
Regards,
Dominique
Jan Schmidt wrote:
>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.
>
>Regards,
>Jan
>
>
>
More information about the gstreamer-devel
mailing list