tsdemux: keep track of current position
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 9 Mar 2015 09:56:38 +0000 (09:56 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 9 Apr 2015 14:44:20 +0000 (15:44 +0100)
This allows seeking to correctly set the base on the segment.

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

gst/mpegtsdemux/tsdemux.c

index 9313cc5..b7bae7d 100644 (file)
@@ -1957,12 +1957,14 @@ calculate_and_push_newsegment (GstTSDemux * demux, TSDemuxStream * stream)
       demux->segment = base->segment;
     } else {
       /* Start from the first ts/pts */
+      GstClockTime base = demux->segment.base;
       gst_segment_init (&demux->segment, GST_FORMAT_TIME);
       demux->segment.start = firstts;
       demux->segment.stop = GST_CLOCK_TIME_NONE;
       demux->segment.position = firstts;
       demux->segment.time = firstts;
       demux->segment.rate = demux->rate;
+      demux->segment.base = base;
     }
   } else if (demux->segment.start < firstts) {
     /* Take into account the offset to the first buffer timestamp */
@@ -2200,6 +2202,9 @@ gst_ts_demux_push_pending_data (GstTSDemux * demux, TSDemuxStream * stream)
     GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
   stream->discont = FALSE;
 
+  if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buffer)))
+    demux->segment.position = GST_BUFFER_DTS (buffer);
+
   res = gst_pad_push (stream->pad, buffer);
   /* Record that a buffer was pushed */
   stream->nb_out_buffers += 1;