delete a pipeline the right way?

Yuniesky Vasconcelo yvasconcelo at gmail.com
Sat Jul 29 03:16:40 UTC 2017


I am developing an application that needs to create and remove the pipeline
repeatedly. When I do this the memory of the application grows and grows,
it never decreases. Even after 10 repetitions I remove all the pipeline and
call gst_deinit and it is not released. This is the code:
void GstVideo::createPipeline()
    m_pipeline = ("filesrc location=/media/datos/video.mp4 ! qtdemux !
avdec_h264 ! videoconvert ! video/x-raw,format=RGB ! appsink name=appsink");
    if(!err)
    {
        GstElement* sink = gst_bin_get_by_name((GstBin*)m_pipeline,
"appsink");
        gst_app_sink_set_emit_signals(GST_APP_SINK(sink), TRUE);
        gst_app_sink_set_max_buffers(GST_APP_SINK(sink), 1);
        gst_app_sink_set_drop(GST_APP_SINK(sink), TRUE);
        g_signal_connect(sink, "new-sample",
G_CALLBACK(GstVideo::newSample), (gpointer)this);
        g_signal_connect(sink, "eos", G_CALLBACK(GstVideo::eos),
(gpointer)this);
    }
    else
    {
        g_error_free(err);
    }
}


GstFlowReturn GstVideo::newSample(GstAppSink *sink, gpointer user_data)
{
    GstSample* sinkSample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
    if(sinkSample) {
    GstMapInfo info;
    GstBuffer* buffer  = gst_sample_get_buffer(sinkSample);
    gst_buffer_map(buffer, &info, GST_MAP_READ);
    GstCaps *caps = gst_sample_get_caps(sinkSample);
    GstStructure * structure = gst_caps_get_structure(caps, 0);

    [...]

    gst_buffer_unmap(buffer, &info);
    gst_sample_unref(sinkSample);
    }
    return GST_FLOW_OK;
}

GstVideo::~GstVideo()
{
    if(m_pipeline) {
        gst_element_set_state(m_pipeline, GST_STATE_NULL);
        gst_object_unref( m_pipeline);
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170728/923b9312/attachment.html>


More information about the gstreamer-devel mailing list