tsdemux: set correct newsegment fields on _TIME seeks
authorAlessandro Decina <alessandro.d@gmail.com>
Thu, 5 Apr 2012 04:18:28 +0000 (06:18 +0200)
committerAlessandro Decina <alessandro.d@gmail.com>
Thu, 5 Apr 2012 07:16:07 +0000 (09:16 +0200)
Forward the seek rate and set NS.start to the seek target so that decoders can
apply clipping where necessary.

gst/mpegtsdemux/tsdemux.c

index 8f4d78d..96eb75c 100644 (file)
@@ -1449,11 +1449,26 @@ calculate_and_push_newsegment (GstTSDemux * demux, TSDemuxStream * stream)
   }
 
   if (!demux->segment_event) {
+    gint64 start, stop, time;
+
     GST_DEBUG ("Calculating actual segment");
-    /* FIXME : Set proper values */
+
+    if (demux->segment.format == GST_FORMAT_TIME) {
+      /* if we have a TIME segment, set NS.start to the target ts so downstream
+       * can clip
+       */
+      start = demux->segment.start;
+      stop = demux->segment.stop;
+      time = demux->segment.time;
+    } else {
+      /* ...else start from the first ts/pts */
+      start = firstts;
+      stop = GST_CLOCK_TIME_NONE;
+      time = firstts;
+    }
     demux->segment_event =
-        gst_event_new_new_segment_full (FALSE, 1.0, 1.0, GST_FORMAT_TIME,
-        firstts, GST_CLOCK_TIME_NONE, firstts);
+        gst_event_new_new_segment_full (FALSE, demux->segment.rate,
+        demux->segment.applied_rate, GST_FORMAT_TIME, start, stop, time);
     GST_EVENT_SRC (demux->segment_event) = gst_object_ref (demux);
   }