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 749066 - asfdemux: can't seek back after reaching EOS in push mode
asfdemux: can't seek back after reaching EOS in push mode
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-ugly
git master
Other Linux
: Normal normal
: 1.8.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-05-07 11:46 UTC by Vootele Vesterblom
Modified: 2016-05-27 16:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix the EOS that happens after seeking (2.31 KB, patch)
2015-05-12 08:34 UTC, Vootele Vesterblom
none Details | Review

Description Vootele Vesterblom 2015-05-07 11:46:10 UTC
Playing a WMA audio file over http (something that allows seeking ex. DLNA).
Playback has reached the last seconds of the track so that:
This code path from gst_asf_demux_chain has already been executed:
      if (G_UNLIKELY (demux->num_packets != 0 && demux->packet >= 0
              && demux->packet >= demux->num_packets)) {
        demux->state = GST_ASF_DEMUX_STATE_INDEX;
      }

Issuing a seek on pipeline element.
After seeking you think the playback is going to start from the position you seeked to, but it also might happen that the gst_asf_demux_chain returns EOS, because the following code path is executed where result == GST_ASF_DEMUX_CHECK_HEADER_NO:
case GST_ASF_DEMUX_STATE_INDEX:{
      gint result = gst_asf_demux_check_header (demux);
      if (result == GST_ASF_DEMUX_CHECK_HEADER_NEED_DATA)       /* need more data */
        break;

      if (result == GST_ASF_DEMUX_CHECK_HEADER_NO) {
        /* we don't care about this, probably an index */
        /* TODO maybe would be smarter to skip all the indices
         * until we got a new header or EOS to decide */
        GST_LOG_OBJECT (demux, "Received index object, its EOS");
        goto eos;
      } else {
        GST_INFO_OBJECT (demux, "Chained asf starting");
        /* cleanup and get ready for a chained asf */
        gst_asf_demux_reset (demux, TRUE);
        /* fall through */
      }
    }
Comment 1 Vootele Vesterblom 2015-05-12 08:34:04 UTC
Created attachment 303246 [details] [review]
Patch to fix the EOS that happens after seeking

Since the segment event is received before data (I think).
Then it's ok to set the demux->state to GST_ASF_DEMUX_STATE_DATA when a segment event is received that goes past data_offset.
Because if we were to seek to the last packet. Then in the chain method the demux->state is set to INDEX.
Comment 2 Thiago Sousa Santos 2015-11-10 10:41:43 UTC
Sorry for the delay on reviewing this. Can you share a GST_DEBUG log showing the problem? Ideally GST_DEBUG=6 or at least GST_DEBUG=asfdemux:6 to try to understand what is happening.

Any public streams or setup we could do to reproduce the issue?
Comment 3 Tim-Philipp Müller 2016-05-24 20:31:59 UTC
This can be reproduced with a pipeline like this:

 gst-launch-1.0 filesrc location=song.wma ! queue ! asfdemux ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=0 ! fakesink silent=true

Set to playing, wait a second or so (until file has been processed and asfdemux reache EOS), then do a flushing seek back to wherever.

I would suggest the following variant of your patch, so it's (a) clearer what the purpose of this is, and (b) it's not triggered at the initial segment event when asfdemux->data_offset is still 0 because the header hasn't been parsed (and start will be 0, so then 0 >= 0).

diff --git a/gst/asfdemux/gstasfdemux.c b/gst/asfdemux/gstasfdemux.c
index 27bba9c..ae419ec 100644
--- a/gst/asfdemux/gstasfdemux.c
+++ b/gst/asfdemux/gstasfdemux.c
@@ -428,6 +428,11 @@ gst_asf_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
       demux->need_newsegment = TRUE;
       demux->segment_seqnum = gst_event_get_seqnum (event);
       gst_asf_demux_reset_stream_state_after_discont (demux);
+      /* if we seek back after reaching EOS, go back to data reading state */
+      if (demux->data_offset > 0 && segment->start >= demux->data_offset
+          && demux->state == GST_ASF_DEMUX_STATE_INDEX) {
+        demux->state = GST_ASF_DEMUX_STATE_DATA;
+      }
       GST_OBJECT_UNLOCK (demux);
Comment 4 Tim-Philipp Müller 2016-05-27 16:24:33 UTC
Thanks for the patch and for debugging this!

Pushed your patch with my modifications, hope you don't mind:

commit 6ff1c761e4de7fcbf96d21c0769766cf877f3146
Author: Vootele Vesterblom <vov@bang-olufsen.dk>
Date:   Tue May 12 11:08:55 2015 +0300

    asfdemux: fix seeking back after EOS has been reached in push mode
    
    Fix seeking when demuxer is in INDEX state. This happens when we
    reached the end of the stream. It should still be possible to do
    a flushing seek and seek back to any other position though. Instead
    the demuxer would just go straight to EOS again instead of going
    back to processing packets again from the new position.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749066