qtdemux: Fix data dropping for fragmented streams
authorThiago Santos <thiagoss@osg.samsung.com>
Mon, 26 Jan 2015 20:08:12 +0000 (17:08 -0300)
committerThiago Santos <thiagoss@osg.samsung.com>
Tue, 27 Jan 2015 11:54:19 +0000 (08:54 -0300)
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

gst/isomp4/qtdemux.c

index fb469c5..32ab273 100644 (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? */