qtdemux: fix accumulated base offset in segment seeks
authorChristian Meissl <meissl.christian@gmail.com>
Tue, 17 Dec 2024 19:08:24 +0000 (20:08 +0100)
committerBackport Bot <gitlab-backport-bot@gstreamer-foundation.org>
Mon, 6 Jan 2025 11:45:56 +0000 (11:45 +0000)
analog to fix for matroska-demux
commit f3c126d07c8a85e76bf5abdfa7f140bbf20545ea

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

subprojects/gst-plugins-good/gst/isomp4/qtdemux.c

index 48b628494aaf35d889fe6fbedc390d92a05d10e2..d1aaae8fd6109973a3812438f44711d0ba743c24 100644 (file)
@@ -7403,6 +7403,21 @@ pause:
           GstMessage *message;
           GstEvent *event;
 
+          /* segment.position will still be at the last timestamp and won't always
+           * include the duration of the last packet. Expand that to the segment
+           * duration so that segment.base is increased correctly to include the
+           * length of the last packet when doing segment seeks. We need to do
+           * this before the segment-done event goes out so everything's ready
+           * for the next seek request coming in. */
+          if (GST_CLOCK_TIME_IS_VALID (stop)) {
+            GST_DEBUG_OBJECT (qtdemux,
+                "End of segment, updating segment.position from %"
+                GST_TIME_FORMAT " to stop %" GST_TIME_FORMAT,
+                GST_TIME_ARGS (qtdemux->segment.position),
+                GST_TIME_ARGS (stop));
+            qtdemux->segment.position = stop;
+          }
+
           GST_LOG_OBJECT (qtdemux, "Sending segment done, at end of segment");
           message = gst_message_new_segment_done (GST_OBJECT_CAST (qtdemux),
               GST_FORMAT_TIME, stop);