1From bc5d9e1d9e1b352b2a9c4b56ce055229010be8c1 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Fri, 23 Oct 2020 11:11:11 +0800 4Subject: [PATCH 11/33] mpegtsdemux: Create new PCR group for big gap 5 6Currently it would try to reuse the current group and handle the gap by 7just adding 500ms to pcroffset. 8 9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 10--- 11 gst/mpegtsdemux/mpegtspacketizer.c | 11 +++++++++++ 12 1 file changed, 11 insertions(+) 13 14diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c 15index de8b571..6747fc6 100644 16--- a/gst/mpegtsdemux/mpegtspacketizer.c 17+++ b/gst/mpegtsdemux/mpegtspacketizer.c 18@@ -1997,6 +1997,7 @@ record_pcr (MpegTSPacketizer2 * packetizer, MpegTSPCR * pcrtable, 19 * Initialize current to that group 20 */ 21 GST_DEBUG ("No current window estimator, Checking for group to use"); 22+create_new_group: 23 for (tmp = pcrtable->groups; tmp; tmp = tmp->next) { 24 PCROffsetGroup *group = (PCROffsetGroup *) tmp->data; 25 26@@ -2069,6 +2070,15 @@ record_pcr (MpegTSPacketizer2 * packetizer, MpegTSPCR * pcrtable, 27 if (G_UNLIKELY (corpcr - current->pending[current->last].pcr > 28 500 * PCR_MSECOND)) { 29 GST_DEBUG ("New PCR more than 500ms away, handling discont"); 30+ 31+#if 1 32+ /** 33+ * Create new discont group instead of reusing the current, otherwise 34+ * it will try to handle the gap by just adding 500ms to pcroffset. 35+ */ 36+ _close_current_group (pcrtable); 37+ goto create_new_group; 38+#else 39 /* Take values from current and put them in the current group (closing it) */ 40 /* Create new group with pcr/offset just after the current group 41 * and mark it as a discont */ 42@@ -2076,6 +2086,7 @@ record_pcr (MpegTSPacketizer2 * packetizer, MpegTSPCR * pcrtable, 43 _append_group_values (current->group, current->pending[current->last]); 44 _set_current_group (pcrtable, current->group, pcr, offset, TRUE); 45 return; 46+#endif 47 } 48 49 if (G_UNLIKELY (corpcr == current->last_value.pcr)) { 50-- 512.20.1 52 53