summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Cerveau <scerveau@collabora.com>2021-07-15 12:02:40 +0200
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2021-08-17 16:09:14 -0400
commit508a565163990e6f24e00d73f0b9715eec668443 (patch)
tree777cc5ffd15812ace0af2399c372827bd9e43ce3
parent65deef0b0cd8716c0d06fa9445a5219edb700e40 (diff)
downloadgstreamer-plugins-good-508a565163990e6f24e00d73f0b9715eec668443.tar.gz
matroska: demux: update stream_start_time
The stream_start_time can be less than the first detected. In case of B-Frame based media, the first frame PTS might be greater than the next one. Need to keep the segment.start if a seek has been performed. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1030>
-rw-r--r--gst/matroska/matroska-demux.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 3f03b707f..75319bc95 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -4611,6 +4611,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
gboolean delta_unit = FALSE;
guint64 duration = 0;
gint64 lace_time = 0;
+ gboolean keep_seek_start = TRUE;
GstEvent *protect_event;
stream = g_ptr_array_index (demux->common.src, stream_num);
@@ -4639,6 +4640,15 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
}
/* need to refresh segment info ASAP */
+ if (GST_CLOCK_TIME_IS_VALID (lace_time)
+ && GST_CLOCK_TIME_IS_VALID (demux->stream_start_time)
+ && lace_time < demux->stream_start_time) {
+ keep_seek_start =
+ (demux->common.segment.start > demux->stream_start_time);
+ demux->stream_start_time = lace_time;
+ demux->need_segment = TRUE;
+ }
+
if (GST_CLOCK_TIME_IS_VALID (lace_time) && demux->need_segment) {
GstSegment *segment = &demux->common.segment;
guint64 clace_time;
@@ -4651,10 +4661,10 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
GST_TIME_ARGS (lace_time));
}
clace_time = MAX (lace_time, demux->stream_start_time);
- if (GST_CLOCK_TIME_IS_VALID (demux->common.segment.position) &&
- demux->common.segment.position != 0) {
- GST_DEBUG_OBJECT (demux,
- "using stored seek position %" GST_TIME_FORMAT,
+ if (keep_seek_start
+ && GST_CLOCK_TIME_IS_VALID (demux->common.segment.position)
+ && demux->common.segment.position != 0) {
+ GST_DEBUG_OBJECT (demux, "using stored seek position %" GST_TIME_FORMAT,
GST_TIME_ARGS (demux->common.segment.position));
clace_time = demux->common.segment.position;
}