qtdemux: rework segment event handling for adaptive streaming
authorThiago Santos <thiagoss@osg.samsung.com>
Wed, 8 Jul 2015 18:02:24 +0000 (15:02 -0300)
committerThiago Santos <thiagoss@osg.samsung.com>
Thu, 9 Jul 2015 02:23:53 +0000 (23:23 -0300)
When a new time segment is received upstream is going to restart
with a new atom. Make the neededbytes and todrop variables
reflect that to avoid waiting too much or dropping the
initial bytes that contain the header.

gst/isomp4/qtdemux.c

index 920fc64..8153abb 100644 (file)
@@ -2029,20 +2029,25 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstObject * parent,
 
       /* clear leftover in current segment, if any */
       gst_adapter_clear (demux->adapter);
+
       /* set up streaming thread */
-      gst_qtdemux_find_sample (demux, offset, TRUE, TRUE, &stream, &idx, NULL);
       demux->offset = offset;
-      if (stream) {
-        demux->todrop = stream->samples[idx].offset - offset;
-        demux->neededbytes = demux->todrop + stream->samples[idx].size;
+      if (demux->upstream_format_is_time) {
+        GST_DEBUG_OBJECT (demux, "Upstream is driving in time format, "
+            "set values to restart reading from a new atom");
+        demux->neededbytes = 16;
+        demux->todrop = 0;
       } else {
-        /* set up for EOS */
-        if (demux->upstream_format_is_time) {
-          demux->neededbytes = 16;
+        gst_qtdemux_find_sample (demux, offset, TRUE, TRUE, &stream, &idx,
+            NULL);
+        if (stream) {
+          demux->todrop = stream->samples[idx].offset - offset;
+          demux->neededbytes = demux->todrop + stream->samples[idx].size;
         } else {
+          /* set up for EOS */
           demux->neededbytes = -1;
+          demux->todrop = 0;
         }
-        demux->todrop = 0;
       }
     exit:
       gst_event_unref (event);