How to transfer GstBuffer from one pipeline to other pipeline

Andy Devar andy.devar at gmail.com
Sun Nov 29 22:06:31 UTC 2020


Hi,

how to do this correctly? I'm referring to Anton's suggestion to use
gst_sample_copy/gst_buffer_copy_deep.

As soon as I copy the buffer (see example below), I get a memory leak
(megabytes per second, so I think the buffer won't be disposed).

If I don't copy the buffer, I get warnings - probably because the copied
sample references the buffer of the sample received from appsink:
"free_priv_data: object finalizing but still has 1 parents
(object:000001E0052CED80)"

gstreamer version: 1.18.1 x64 msvc


g_signal_connect(videosink, "new-sample",
G_CALLBACK(on_new_sample_from_appsink), data);

on_new_sample_from_appsink(GstElement * elt, ProgramData * data)
{
/* get the sample from appsink */
GstSample *sample_in;
sample_in = gst_app_sink_pull_sample(GST_APP_SINK(elt));

// Copy the sample.
GstSample* sample_out = gst_sample_copy(sample_in);
// Now, the buffer of sample_out is a reference to the buffer of sample_in.

// Copy the buffer of sample_in and set it as buffer of sample_out
GstBuffer *buffer_in = gst_sample_get_buffer(sample_in);
GstBuffer *buffer_out = gst_buffer_copy_deep(buffer_in);
gst_sample_set_buffer(sample_out, buffer_out);
gst_buffer_unref(buffer_out);

// Push sample_out to appsource
GstElement* appsource = gst_bin_get_by_name(GST_BIN(data->targetpipeline),
"appsource");
gst_app_src_push_sample(GST_APP_SRC(appsource), sample_out);

gst_sample_unref(sample_in);
gst_object_unref(appsource);

return GST_FLOW_OK;
}


Thanks,

Andy

Am Mo., 21. Sept. 2020 um 14:23 Uhr schrieb shiva.mudugal <
shiva.mudugal at gmail.com>:

> Hello Anton,
>
> Thanks for your response. In understand you point, but is there a way to do
> this without creating the deep copy  from pipeline1 to pipeline2 ?
>
> My intention is to avoid deep copy from pipeline1 to pipeline2. Can we just
> increase the reference count of the buffer in the appsink callback of
> pipeline1 to then apsrc_push to pipeline2 ?
>
> -Regards,
> Shiva
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20201129/829779d0/attachment.htm>


More information about the gstreamer-devel mailing list