How to clear the rendering pipeline which receive data from two streaming pipeline

prakash b erprakash2006 at gmail.com
Wed Jun 21 14:30:44 UTC 2023


Hi Everyone,

I have two streaming pipelines and one rendering pipeline.

First Streaming pipeline: (live source)
    uridecodebin uri=<StreamingURL> ! audioconvert !
audio/x-raw,format=S16LE,layout=interleaved,rate=48000 ! appsink name=sink1

    g_signal_connect(g_sink1, "new-sample",
G_CALLBACK(&onNewSampleFromSink), (gpointer)1);

Second Streaming one (beep sound) from audiotestsrc:
    audiotestsrc is-live=true ! audioconvert !
audio/x-raw,format=S16LE,layout=interleaved,rate=48000 ! appsink name=sink2

    g_signal_connect(g_sink2, "new-sample",
G_CALLBACK(&onNewSampleFromSink), (gpointer)2);

Rendering pipeline
    appsrc name=renderPipelineSource ! queue ! pulsesink or  appsrc ! queue
! pulsesink name=renderPipelineSink


With some user input i can control the appsink Callbacks and I decide which
data to push to the rendering pipeline. (g_selectedSource = 1)

GstFlowReturn onNewSampleFromSink(GstElement* const element, gpointer
userData)
{
    long val = (long)userData;
    GstSample* sample = gst_app_sink_pull_sample((GstAppSink*)element);
    if(g_selectedSource == val)
    {
        GstSample* copy = gst_sample_copy(sample);
        gst_app_src_push_sample((GstAppSrc*)data.renderPipelineSource,
copy);
        gst_sample_unref(copy);
    }
    gst_sample_unref(sample);
    return GST_FLOW_OK;
}


For instance
    data from First Streaming pipeline are pushed to appsrc of rendering
pipeline (live audio)
    data from Second streaming pipeline are not sent to the rendering
pipeline.

After some time I wanted to change the source from first to second.
(g_selectedSource = 2)
    After changing
        data from Second Streaming pipeline are pushed to appsrc of
rendering pipeline (Beep sound)
        data from First streaming pipeline are not sent to the rendering
pipeline.

The problem:
Even after i Change the source to beep sound, I hear the live audio for
even 4 to 5 seconds.
I tried

1. gst_element_seek(renderPipeline, 1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE,
GST_CLOCK_TIME_NONE);

2. gst_element_send_event(data.renderPipelineSource,
gst_event_new_flush_start());
   gst_element_send_event(data.renderPipelineSource,
gst_event_new_flush_stop(TRUE));

3.  GstPad *sink_pad = gst_element_get_static_pad(data.renderPipelineSink,
"sink");
    GstEvent *flush_start_event = gst_event_new_flush_start();
    GstEvent *flush_stop_event = gst_event_new_flush_stop(TRUE);

    /* Send flush-start event */
    gst_pad_push_event(sink_pad, flush_start_event);
    gst_pad_send_event(sink_pad, flush_start_event);

    /* Wait for the pipeline to handle the flush-start event */
    gst_element_get_state(data.renderPipeline, NULL, NULL,
GST_CLOCK_TIME_NONE);

    /* Send flush-stop event */
    gst_pad_push_event(sink_pad, flush_stop_event);
    gst_pad_send_event(sink_pad, flush_stop_event);

    gst_object_unref(sink_pad);

4.  gst_element_set_state(data.renderPipeline, GST_STATE_PAUSED);
    gst_element_get_state(data.renderPipeline, NULL, NULL,
GST_CLOCK_TIME_NONE);
    gst_element_set_state(data.renderPipeline, GST_STATE_PLAYING);

5. Setting properties of the src, queue and pulsesink of rendering pipeline
    g_object_set(G_OBJECT(data.renderPipelineSource), "max-bytes", 1024,
NULL);  // Set the maximum number of bytes
    g_object_set(G_OBJECT(data.renderPipelineSource), "max-time",
500000000, NULL);

    g_object_set(G_OBJECT(data.renderPipelineQueue), "max-size-bytes",
1024, NULL);  // Set the maximum number of bytes
    g_object_set(G_OBJECT(data.renderPipelineQueue), "max-size-time",
500000000, NULL);

    g_object_set(G_OBJECT(data.renderPipelineSink), "blocksize", 1024,
NULL);  // Set the maximum number of bytes
    g_object_set(G_OBJECT(data.renderPipelineSink), "can-activate-pull",
TRUE, NULL);  // Set the maximum number of bytes

None of the above methods helped. I do not want to set the renderPipeline
to NULL then set it to Play state for internal reasons.
Any helping leads are appreciated. Thanks in advance.
Regards,
Prakash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230621/e78d94c3/attachment.htm>


More information about the gstreamer-devel mailing list