How to flush gstreamer pipeline

13.5k views Asked by At

Case
Reading from a file continuously and feeding to appsrc element. Source - appsrc

I have a GStreamer pipeline in PLAYING state. Now would want the pipeline to flush / clean when I press a button that means appsrc queue should be cleared. The playback should start from whatever buffers are now added to / or were added after flush.

Issue
the APIs I used returned false. I am not able to flush.

fprintf(stderr, "The flush event start was <%d>",gst_element_send_event(GST_ELEMENT (pipe), gst_event_new_flush_start());    
fprintf(stderr, "The flush event stop was  <%d>",gst_element_send_event(GST_ELEMENT (pipe), gst_event_new_flush_stop()));

Both the above returned 0. That means false. What is the reason for this false ?

How can I try flushing the data in a pipeline with some API? Or Is there any other API for skipping playback ?

Tried

  • Sending gst_event_new_flush_start () and gst_event_new_flush_stop () to the pipeline with and without a gap of some milliseconds
  • gst_event_new_seek (1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, 0);
  • setting pipeline to NULL and then to PLAYING again

All these could not work.

1

There are 1 answers

0
user2618142 On BEST ANSWER

It was not working for me, because I was using 0.10 v of gstreamer.If there is not a constraint to use 0.10 version of gstreamer, please use 1.2 version of gstreamer.

However, in v 0.10 the flushing seek generally works as a substitute to flush the pipeline.

While using 1.2v, the two APIs gst_event_new_flush_start () and gst_event_new_flush_stop () work. In that case you can use the flush directly.

In either way you should be able to flush. Make an internal API where you do a flushing seek and use it as your flush API.

There is a post in gstreamer-devel mailing listwhich has talked about behavior of flush in the two versions.