dashdemux: only start timestamp from 0 for live stream
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 13 Mar 2013 14:55:03 +0000 (15:55 +0100)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 8 May 2013 21:14:45 +0000 (18:14 -0300)
We only want to adjust the timestamps so that they start from 0 for live
streams. Non-live streams already start from 0 and after a seek we actually want
to timestamp to be the position we seek to.

ext/dash/gstdashdemux.c

index 1f21fb9..a14b223 100644 (file)
@@ -539,12 +539,16 @@ gst_dash_demux_src_event (GstPad * pad, GstEvent * event)
 
         /* select the requested Period in the Media Presentation */
         target_pos = (GstClockTime) demux->segment.start;
+        GST_DEBUG_OBJECT (demux, "Seeking to target %" GST_TIME_FORMAT,
+            GST_TIME_ARGS (target_pos));
         current_period = 0;
         for (list = g_list_first (demux->client->periods); list;
             list = g_list_next (list)) {
           period = list->data;
           current_pos = period->start;
           current_period = period->number;
+          GST_DEBUG_OBJECT (demux, "Looking at period %u pos %" GST_TIME_FORMAT,
+              current_period, GST_TIME_ARGS (current_pos));
           if (current_pos <= target_pos
               && target_pos < current_pos + period->duration) {
             break;
@@ -573,11 +577,6 @@ gst_dash_demux_src_event (GstPad * pad, GstEvent * event)
           gst_dash_demux_remove_streams (demux, streams);
         }
 
-        if (list == NULL) {
-          GST_WARNING_OBJECT (demux, "Could not find seeked fragment");
-          return FALSE;
-        }
-
         /* Update the current sequence on all streams */
         for (iter = demux->streams; iter; iter = g_slist_next (iter)) {
           GstDashDemuxStream *stream = iter->data;
@@ -630,6 +629,7 @@ gst_dash_demux_src_event (GstPad * pad, GstEvent * event)
           GstDashDemuxStream *stream = iter->data;
           gst_data_queue_set_flushing (stream->queue, FALSE);
         }
+        demux->timestamp_offset = 0;
         demux->need_segment = TRUE;
         gst_uri_downloader_reset (demux->downloader);
         GST_DEBUG_OBJECT (demux, "Resuming tasks after seeking");
@@ -810,6 +810,7 @@ gst_dash_demux_sink_event (GstPad * pad, GstEvent * event)
               "mediaPresentationDuration unknown, can not send the duration message");
         }
       }
+      demux->timestamp_offset = -1;
       demux->need_segment = TRUE;
       gst_dash_demux_resume_download_task (demux);
       gst_dash_demux_resume_stream_task (demux);
@@ -1138,7 +1139,8 @@ gst_dash_demux_stream_loop (GstDashDemux * demux)
       timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
       if (demux->need_segment) {
-        demux->timestamp_offset = timestamp;
+        if (demux->timestamp_offset == -1)
+          demux->timestamp_offset = timestamp;
 
         /* And send a newsegment */
         for (iter = demux->streams; iter; iter = g_slist_next (iter)) {