qtdemux: accumulate previous edts entries into segment.base
authorThiago Santos <thiagoss@osg.samsung.com>
Tue, 23 Jun 2015 14:49:32 +0000 (11:49 -0300)
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Wed, 24 Jun 2015 02:34:36 +0000 (22:34 -0400)
Allows playing edts editted files with proper synchronization of
streams. This patch fixes the regression introduced by
bf95f93c0189aa04f18e264b86b6527e431c5d53 that was added to fix
segment seeks handling.

Having the accumulated_base separated from the main segment.base
allows handling both segment seeks and edts editted files.

https://bugzilla.gnome.org/show_bug.cgi?id=751361

gst/isomp4/qtdemux.c

index b963225..edd0a58 100644 (file)
@@ -304,6 +304,7 @@ struct _QtDemuxStream
   guint32 segment_index;
   guint32 sample_index;
   GstClockTime time_position;   /* in gst time */
+  guint64 accumulated_base;
 
   /* the Gst segment we are processing out, used for clipping */
   GstSegment segment;
@@ -1428,6 +1429,7 @@ gst_qtdemux_perform_seek (GstQTDemux * qtdemux, GstSegment * segment,
     QtDemuxStream *stream = qtdemux->streams[n];
 
     stream->time_position = desired_offset;
+    stream->accumulated_base = 0;
     stream->sample_index = -1;
     stream->offset_in_sample = 0;
     stream->segment_index = -1;
@@ -1921,6 +1923,7 @@ gst_qtdemux_reset (GstQTDemux * qtdemux, gboolean hard)
       qtdemux->streams[n]->sent_eos = FALSE;
       qtdemux->streams[n]->segment_seqnum = 0;
       qtdemux->streams[n]->time_position = 0;
+      qtdemux->streams[n]->accumulated_base = 0;
     }
   }
 }
@@ -2182,6 +2185,7 @@ gst_qtdemux_stream_flush_samples_data (GstQTDemux * qtdemux,
   stream->n_samples = 0;
   stream->time_position = 0;
   stream->segment_index = -1;
+  stream->accumulated_base = 0;
 }
 
 static void
@@ -3747,10 +3751,14 @@ gst_qtdemux_activate_segment (GstQTDemux * qtdemux, QtDemuxStream * stream,
   /* Copy flags from main segment */
   stream->segment.flags = qtdemux->segment.flags;
 
-  /* update the segment values used for clipping */
   /* accumulate previous segments */
+  if (GST_CLOCK_TIME_IS_VALID (stream->segment.stop))
+    stream->accumulated_base += (stream->segment.stop - stream->segment.start) /
+        ABS (stream->segment.rate);
+
+  /* update the segment values used for clipping */
   stream->segment.offset = qtdemux->segment.offset;
-  stream->segment.base = qtdemux->segment.base;
+  stream->segment.base = qtdemux->segment.base + stream->accumulated_base;
   stream->segment.applied_rate = qtdemux->segment.applied_rate;
   stream->segment.rate = rate;
   stream->segment.start = start + QTSTREAMTIME_TO_GSTTIME (stream,