qtdemux: Fix data dropping for fragmented streams

For fragmented streams with extra data at the end of the mdat
qtdemux was not dropping those bytes and would try to use
that extra data as the beginning of a new atom, causing the
stream to fail.

https://bugzilla.gnome.org/show_bug.cgi?id=743407
This commit is contained in:
Thiago Santos 2015-01-26 17:08:12 -03:00
parent e4ed852041
commit 2586a219f6

View file

@ -4910,6 +4910,18 @@ done:
demux->upstream_size = seekable ? stop : -1;
}
static void
gst_qtdemux_drop_data (GstQTDemux * demux, gint bytes)
{
g_return_if_fail (bytes <= demux->todrop);
GST_LOG_OBJECT (demux, "Dropping %d bytes", bytes);
gst_adapter_flush (demux->adapter, bytes);
demux->neededbytes -= bytes;
demux->offset += bytes;
demux->todrop -= bytes;
}
/* FIXME, unverified after edit list updates */
static GstFlowReturn
gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf)
@ -5285,9 +5297,9 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force)
} else {
GST_DEBUG_OBJECT (demux, "data atom emptied; resuming atom scan");
/* so we are dropping more than left in this atom */
demux->todrop -= demux->mdatleft;
demux->neededbytes -= demux->mdatleft;
gst_qtdemux_drop_data (demux, demux->mdatleft);
demux->mdatleft = 0;
/* need to resume atom parsing so we do not miss any other pieces */
demux->state = QTDEMUX_STATE_INITIAL;
demux->neededbytes = 16;
@ -5306,10 +5318,7 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force)
}
if (demux->todrop) {
GST_LOG_OBJECT (demux, "Dropping %d bytes", demux->todrop);
gst_adapter_flush (demux->adapter, demux->todrop);
demux->neededbytes -= demux->todrop;
demux->offset += demux->todrop;
gst_qtdemux_drop_data (demux, demux->todrop);
}
/* first buffer? */