After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689113 - No application-level method of flushing pipeline
No application-level method of flushing pipeline
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.36
Other All
: Normal major
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-11-26 20:10 UTC by Alexey Chernov
Modified: 2014-05-28 12:36 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Alexey Chernov 2012-11-26 20:10:56 UTC
It's nearly impossible to flush the pipeline using higher-level method. There're several workarounds to do that mentioned in gst-mailing-list:
http://gstreamer-devel.966125.n4.nabble.com/how-to-flush-a-gstreamer-pipeline-td2553146.html
http://gstreamer-devel.966125.n4.nabble.com/Flush-RTSP-pipeline-td4655706.html

But there's no single public 'pure' method for this functionality. Still it's obviously quite necessary action, especially when using dynamic pipelines or appsrc/appsink-based pipelines.

Here's what absence of such functionality implies:
- it's virtually impossible to clear data from internal queues in certain complex elements as appsrc or decodebin(2), which additionaly cannot be fully reduced (queue size of 0 usually means automatic control of queue size and not a zero size)
- it's virtually impossible to flush data from non-seekable pipeline as the 'flushing-seek' workaround can't be used in this case
- it's too hard to flush the whole pipeline and consequently to keep the timestamping logic intact as it's too hard to send the necessary events from the very upstream (i.e. some source elements).

Here's some steps one should take to make a proper flush in her pipeline:
1. Send FLUSH_START and FLUSH_STOP events possibly from the very upstream element.
2. Create and send proper new-segment event as FLUSH_STOP event resets running-time of the pipeline.
3. Serialize (1) and (2) above with data flow so that fresh buffers won't go ahead of these events.
4. Look after the message bus.

Probably that's not all of them. If something above is done wrong the pipeline usually get stalled or stops with error. Other than it's not that really application-level routines, another problem that arises is that some elements don't send events received with gst_element_send_event() downstream, so you should use (sink) pads which are absent in 'src' elements etc. etc.

So I think it would be natural to make a high-level and well-tested method in, e.g. GstPipeline interface, to make the pipeline properly flushed to receive fresh data and present it in a seamless way.
Comment 1 Wim Taymans 2012-12-10 12:37:14 UTC
I'm inclined to close this bug now. In 1.0 you can do a non-time-reset flush. You can push these events to the pipeline and most sources should forward them correctly.
Comment 2 Tim-Philipp Müller 2012-12-10 13:02:13 UTC
Let's do that then. Alexey, please re-open with more information if there are still open issues with the 1.0 API.
Comment 3 Alexey Chernov 2012-12-10 18:00:17 UTC
Wim, Tim-Philipp, thank you very much for attention and answers. Yes, it needs to work some more with 1.0 API as I wrote concerning mainly 0.10 branch.

Is it right to use gst_element_send_event to push such events to sources to have them sent downstream?
Comment 4 Tim-Philipp Müller 2012-12-10 18:09:55 UTC
> Is it right to use gst_element_send_event to push such events to sources to
> have them sent downstream?

Yes. GstBins / the pipeline will send downstream events further down the bin hierarchy on the source side, while upstream events will get passed down the bin hierarchy on the sink side, until a real source or sink is found, which will then inject the event into the pipeline.
Comment 5 Alexey Chernov 2012-12-10 18:28:47 UTC
Hmm, is it true for 0.10 branch and flush events (as the only both up- and downstream ones)?

I thought it's processed some different manner as I experimented with it lately and didn't manage to pick flush-start or flush-stop events sent to the pipeline on src pad of a queue inside it while events sent to some upstream pad were delivered.
Comment 6 Tim-Philipp Müller 2012-12-10 18:44:38 UTC
I don't remember what happens for events that are both up and downstream, and especially not in 0.10, you'd have to check the code.
Comment 7 Alexey Chernov 2012-12-10 18:53:04 UTC
Yeah, I'll try to know it better. Thank you for detailed information!
Comment 8 Nicolas Dufresne (ndufresne) 2014-05-27 20:31:00 UTC
For the record, because it came back on the mailing list and in case it wasn't clear, a pipeline can be flushed by operating a flushing seek. In 1.0, we can skip specifying start/stop and it should just flush. In 0.10, one would need to query the position. This bugs was obsolete from 0.10 point of view, and invalid for 1.0 and so on.
Comment 9 Alexey Chernov 2014-05-27 21:00:31 UTC
Yes, I agree. There were several reports on this issue, so this one I forgot about completely, sorry. Another solution is sending FLUSH_START and FLUSH_STOP to the pipeline, it works since 1.2 IIRC. I think I posted the code snippet some time before in the list.
Comment 10 Tim-Philipp Müller 2014-05-27 21:39:04 UTC
Nicolas, sending flush start/stop to the pipeline should work just as well really (depending on the context), and it's been fixed up for cases where that makes sense.
Comment 11 Nicolas Dufresne (ndufresne) 2014-05-28 12:36:29 UTC
Ok, sorry for the noise. I've just re-read that code, and it indeed changed a lot since last time (there was a warning there).