diff options
author | Edward Hervey <edward@centricular.com> | 2016-05-26 17:38:37 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2016-05-30 12:13:03 +0200 |
commit | ef8cabd86d4fee9fbcb368677d87010cf88fcf83 (patch) | |
tree | ecd1b003f812a60109483a9e21f501d5993d0efb | |
parent | 251ecc40275447143988afb05259d3359beef3c4 (diff) |
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.
-rw-r--r-- | gst/isomp4/qtdemux.c | 38 |
1 files 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; + } } } |