1From 7706971089dbae3a24b3073ecf2b7a225715d6a6 Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Tue, 24 May 2022 12:40:03 +0800
4Subject: [PATCH 09/12] matroska-{demux,parse}: Disable QoS lace skipping by
5 default
6
7The QoS's timestamp would not reset in some cases, using it to skip late
8laces rather dangerous.
9
10Tested with:
11gst-play-1.0 --gapless 1.webm 1.webm
12
13Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
14---
15 gst/matroska/matroska-demux.c       | 1 +
16 gst/matroska/matroska-parse.c       | 1 +
17 gst/matroska/matroska-read-common.c | 2 ++
18 gst/matroska/matroska-read-common.h | 2 ++
19 4 files changed, 6 insertions(+)
20
21diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
22index 1e771b0..721db0d 100644
23--- a/gst/matroska/matroska-demux.c
24+++ b/gst/matroska/matroska-demux.c
25@@ -4770,6 +4770,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
26          index entries point to keyframes, but if that is not true we
27          will instead skip until the next keyframe. */
28       if (GST_CLOCK_TIME_IS_VALID (lace_time) &&
29+          demux->common.allow_skipping &&
30           stream->type == GST_MATROSKA_TRACK_TYPE_VIDEO &&
31           stream->index_table && demux->common.segment.rate > 0.0) {
32         GstMatroskaTrackVideoContext *videocontext =
33diff --git a/gst/matroska/matroska-parse.c b/gst/matroska/matroska-parse.c
34index 3fcb5c5..ff22ec2 100644
35--- a/gst/matroska/matroska-parse.c
36+++ b/gst/matroska/matroska-parse.c
37@@ -1878,6 +1878,7 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
38          index entries point to keyframes, but if that is not true we
39          will instead skip until the next keyframe. */
40       if (GST_CLOCK_TIME_IS_VALID (lace_time) &&
41+          parse->common.allow_skipping &&
42           stream->type == GST_MATROSKA_TRACK_TYPE_VIDEO &&
43           stream->index_table && parse->common.segment.rate > 0.0) {
44         GstMatroskaTrackVideoContext *videocontext =
45diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c
46index 6fadbba..eff8812 100644
47--- a/gst/matroska/matroska-read-common.c
48+++ b/gst/matroska/matroska-read-common.c
49@@ -3417,6 +3417,8 @@ gst_matroska_read_common_reset (GstElement * element,
50     ctx->internal_toc = NULL;
51   }
52   ctx->toc_updated = FALSE;
53+
54+  ctx->allow_skipping = !!g_getenv ("GST_MATROSKA_ALLOW_SKIP");
55 }
56
57 /* call with object lock held */
58diff --git a/gst/matroska/matroska-read-common.h b/gst/matroska/matroska-read-common.h
59index 98cfc24..40ea641 100644
60--- a/gst/matroska/matroska-read-common.h
61+++ b/gst/matroska/matroska-read-common.h
62@@ -115,6 +115,8 @@ typedef struct _GstMatroskaReadCommon {
63   /* cache for track tags that forward-reference their tracks */
64   GHashTable *cached_track_taglists ;
65
66+  /* allow QoS lace skipping */
67+  gboolean allow_skipping;
68 } GstMatroskaReadCommon;
69
70 GstFlowReturn gst_matroska_decode_content_encodings (GArray * encodings);
71--
722.20.1
73
74