dashdemux2: Set timestamp relative to period start
authorJunsoo Park <junsoo81.park@lge.com>
Tue, 23 Aug 2022 14:12:44 +0000 (23:12 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 27 Sep 2022 00:00:49 +0000 (00:00 +0000)
These values will be referred to as timestamp relative to period start
so need to subtract period start time from the values.

Fixes a problem with determining the start position when playing Live content
with SegmentTimeline, presentationTimeOffset and a non-0 period start time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3025>

subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstmpdclient.c

index 9dab04a..3a7ed98 100644 (file)
@@ -1862,7 +1862,7 @@ gst_mpd_client2_get_last_fragment_timestamp_end (GstMPDClient2 * client,
 
   if (!stream->segments) {
     stream_period = gst_mpd_client2_get_stream_period (client);
-    *ts = stream_period->start + stream_period->duration;
+    *ts = stream_period->duration;
   } else {
     segment_idx = gst_mpd_client2_get_segments_counts (client, stream) - 1;
     if (segment_idx >= stream->segments->len) {
@@ -1875,14 +1875,15 @@ gst_mpd_client2_get_last_fragment_timestamp_end (GstMPDClient2 * client,
     if (currentChunk->repeat >= 0) {
       *ts =
           currentChunk->start + (currentChunk->duration * (1 +
-              currentChunk->repeat));
+              currentChunk->repeat)) -
+          gst_mpd_client2_get_period_start_time (client);
     } else {
       /* 5.3.9.6.1: negative repeat means repeat till the end of the
        * period, or the next update of the MPD (which I think is
        * implicit, as this will all get deleted/recreated), or the
        * start of the next segment, if any. */
       stream_period = gst_mpd_client2_get_stream_period (client);
-      *ts = stream_period->start + stream_period->duration;
+      *ts = stream_period->duration;
     }
   }
 
@@ -1909,7 +1910,8 @@ gst_mpd_client2_get_next_fragment_timestamp (GstMPDClient2 * client,
 
     *ts =
         currentChunk->start +
-        (currentChunk->duration * stream->segment_repeat_index);
+        (currentChunk->duration * stream->segment_repeat_index) -
+        gst_mpd_client2_get_period_start_time (client);
   } else {
     GstClockTime duration =
         gst_mpd_client2_get_segment_duration (client, stream, NULL);
@@ -2067,7 +2069,8 @@ gst_mpd_client2_get_next_fragment (GstMPDClient2 * client,
 
     fragment->timestamp =
         currentChunk->start +
-        stream->segment_repeat_index * currentChunk->duration;
+        stream->segment_repeat_index * currentChunk->duration -
+        gst_mpd_client2_get_period_start_time (client);
     fragment->duration = currentChunk->duration;
     if (currentChunk->SegmentURL) {
       if (currentChunk->SegmentURL->mediaRange) {