Flushing a pipeline with appsrc

Alexey Chernov 4ernov at gmail.com
Mon Dec 16 12:13:06 PST 2013


В письме от 16 дек 2013 16:58:50 Вы написали:
> On Mon, 2013-12-16 at 08:55 -0500, Nicolas Dufresne wrote:
> > The only way you can flush your pipeline from the application is by
> > doing a flushing seek (that is true for any pipeline with sources
> > implemented using GstBaseSrc). If I remember well, there should be
> > nearly no difference between 1.0 and 0.10 in this regard.
> 
> Not sure this is true. You can send flush-start/stop events on the
> pipeline/source via gst_element_send_event().
> 
> Some patches to improve GstBaseSrc behaviour in this case landed in 1.2
> IIRC.

I just can confirm Tim Philipp's words are true: since 1.2 it's possible to 
send flush-start and flush-stop events to pipeline without turning life into 
hurt and pain right after that :) And yes, it didn't work before 1.2 (I've 
tested with 1.0.9 at least).

Here's a code snippet:

GST_INFO_OBJECT(pipeline, "flushing pipeline...");
GstEvent* flush_start = gst_event_new_flush_start();
gboolean ret = FALSE;
ret = gst_element_send_event(GST_ELEMENT(pipeline), flush_start);
if (!ret)
  GST_INFO_OBJECT(pipeline, "failed to send flush-start event");

GstEvent* flush_stop = gst_event_new_flush_stop(TRUE);

ret = gst_element_send_event(GST_ELEMENT(pipeline), flush_stop);
if (!ret)
  GST_INFO_OBJECT(pipeline, "failed to send flush-stop event");

As documentation reads, boolean parameter 'reset-time' to flush-stop event 
constructor decides whether there's new segment sent immediately after the 
flush stop (so all the timestamps should go from 0 again after that). Both 
cases work well for now.

Please note though that not all the elements process flush events correctly, 
especially in case of some complex pipelines. For instance, AFAIK, many mux 
elements simply ignore flush events so that they can render pipeline to stall. 
Be careful.


More information about the gstreamer-devel mailing list