From ef8cabd86d4fee9fbcb368677d87010cf88fcf83 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 26 May 2016 17:38:37 +0200 Subject: qtdemux: Fine-tune gap handling some more We need to reset ourself if the incoming discont buffer is *not* at the beginning of a sample. --- gst/isomp4/qtdemux.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index f76c46bd5..efd096052 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -6068,6 +6068,7 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf) * in the case of trick-mode DASH for example) */ if (demux->upstream_format_is_time && GST_BUFFER_OFFSET (inbuf) != GST_BUFFER_OFFSET_NONE) { + gboolean is_gap_input = FALSE; gint i; for (i = 0; i < demux->n_streams; i++) { guint32 res; @@ -6077,22 +6078,33 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf) res = gst_qtdemux_find_index_for_given_media_offset_linear (demux, demux->streams[i], GST_BUFFER_OFFSET (inbuf)); - if (res != -1 - && demux->streams[i]->samples[res].offset == - GST_BUFFER_OFFSET (inbuf)) { + if (res != -1) { + QtDemuxSample *sample = &demux->streams[i]->samples[res]; GST_LOG_OBJECT (demux, - "new buffer corresponds to a valid sample : %" G_GUINT32_FORMAT, - res); - /* We can go back to standard playback mode */ - demux->state = QTDEMUX_STATE_MOVIE; - /* Remember which sample this stream is at */ - demux->streams[i]->sample_index = res; - /* Finally update all push-based values to the expected values */ - demux->neededbytes = demux->streams[i]->samples[res].size; - demux->todrop = 0; - demux->offset = GST_BUFFER_OFFSET (inbuf); + "Checking if sample %d from stream %d is valid (offset:%" + G_GUINT64_FORMAT " size:%" G_GUINT32_FORMAT ")", res, i, + sample->offset, sample->size); + if (sample->offset == GST_BUFFER_OFFSET (inbuf)) { + GST_LOG_OBJECT (demux, + "new buffer corresponds to a valid sample : %" G_GUINT32_FORMAT, + res); + is_gap_input = TRUE; + /* We can go back to standard playback mode */ + demux->state = QTDEMUX_STATE_MOVIE; + /* Remember which sample this stream is at */ + demux->streams[i]->sample_index = res; + /* Finally update all push-based values to the expected values */ + demux->neededbytes = demux->streams[i]->samples[res].size; + demux->todrop = 0; + demux->offset = GST_BUFFER_OFFSET (inbuf); + } } } + if (!is_gap_input) { + /* Reset state if it's a real discont */ + demux->neededbytes = 16; + demux->state = QTDEMUX_STATE_INITIAL; + } } } -- cgit v1.2.3