Using "convert-sample" from playbin
Chris Tapp
opensource at keylevel.com
Sun Aug 3 12:12:00 PDT 2014
On 3 Aug 2014, at 08:37, Sebastian Dröge <sebastian at centricular.com> wrote:
> On So, 2014-08-03 at 01:45 +0100, Chris Tapp wrote:
>> I want to be able to grab a converted copy of the most recent frame from a video pipeline.
>>
>> The pipeline is created using gst_parse_launch() and contains a "playbin" element.
>
> You can also just use pipeline = gst_element_factory_make("playbin", NULL);
>
>> I then use the following to grab and process the converted frames:
>>
>> g_signal_emit_by_name( pipeline, "convert-sample", target_caps, &frame );
>>
>> // Process frame...
>>
>> gst_sample_unref( frame );
>>
>> However, this causes a memory leak. What am I doing wrong?
>
> Impossible to say without more code. Can you provide a testcase that
> reproduces it?
I've actually reduced the code to just a little bit more than above and still see the problem:
GstCaps * caps;
caps = gst_caps_new_simple( ... );
g_signal_emit_by_name( pipeline, "convert-sample", target_caps, &frame );
// Process frame...
gst_sample_unref( frame );
gst_caps_unref( caps );
After a bit of digging I noticed that GST_OBJECT_REFCOUNT_VALUE( frame ) reports a ref count of 2, but I would have expected a value of 1.
Adding a second gst_sample_unref( frame ) call fixes the problem.
> Are you maybe leaking the target_caps?
>
> --
> Sebastian Dröge, Centricular Ltd - http://www.centricular.com
> Expertise, Straight from the Source
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Chris Tapp
opensource at keylevel.com
www.keylevel.com
More information about the gstreamer-devel
mailing list