From 131679b9d0e137980f9d1ae3ee828df0f959f4f3 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 23 Apr 2024 10:53:54 +0200 Subject: [PATCH] mpegtsbase: Fix Program equality check There was an issue with this equality check, which was to figure out what to do with PCR pids (whether they were part of the streams present or not) and whether we ignore PCR or not. Turns out ... we already took care of that further up in the function. The length check can be simplified by just checking whether the length of the *original* PMT and the new PMT are identical. Since we don't store "magic" PCR streams in those, we can just use them as-is. Part-of: --- .../gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c b/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c index d938b7693e..f53544361c 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c @@ -815,7 +815,6 @@ mpegts_base_is_same_program (MpegTSBase * base, MpegTSBaseProgram * oldprogram, { guint i, nbstreams; MpegTSBaseStream *oldstream; - gboolean sawpcrpid = FALSE; if (oldprogram->pmt_pid != new_pmt_pid) { GST_DEBUG ("Different pmt_pid (new:0x%04x, old:0x%04x)", new_pmt_pid, @@ -829,7 +828,6 @@ mpegts_base_is_same_program (MpegTSBase * base, MpegTSBaseProgram * oldprogram, return FALSE; } - /* Check the streams */ nbstreams = new_pmt->streams->len; for (i = 0; i < nbstreams; ++i) { GstMpegtsPMTStream *stream = g_ptr_array_index (new_pmt->streams, i); @@ -845,17 +843,14 @@ mpegts_base_is_same_program (MpegTSBase * base, MpegTSBaseProgram * oldprogram, stream->pid, stream->stream_type, oldstream->stream_type); return FALSE; } - if (stream->pid == oldprogram->pcr_pid) - sawpcrpid = TRUE; } - /* If we have a PCR PID and the pcr is not shared with an existing stream, we'll have one extra stream */ - if (!sawpcrpid && !base->ignore_pcr) - nbstreams += 1; + /* We can now just check the number of streams from each PMT. The check for + * PCR was already done previously */ - if (nbstreams != g_list_length (oldprogram->stream_list)) { - GST_DEBUG ("Different number of streams (new:%d, old:%d)", - nbstreams, g_list_length (oldprogram->stream_list)); + if (nbstreams != oldprogram->pmt->streams->len) { + GST_DEBUG ("Different number of streams (new:%d, old:%u)", + nbstreams, oldprogram->pmt->streams->len); return FALSE; }