mpegts: Handle "empty" PMT gracefully
authorEdward Hervey <edward@centricular.com>
Wed, 27 Apr 2022 13:24:50 +0000 (15:24 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 28 Apr 2022 09:36:54 +0000 (09:36 +0000)
Some streams have 2 PMT sections in a single TS packet. The first one is "valid"
but doesn't contain/define any streams. That causes an unrecoverable issue when
we try to activate the 2nd (valid) PMT.

Instead of doing that, pre-emptively refuse to process PMT without any streams
present within. We still do post that section on the bus to inform applications.

Fixes #1181

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

subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c

index 5a0d309..2f9e88c 100644 (file)
@@ -1190,6 +1190,12 @@ mpegts_base_apply_pmt (MpegTSBase * base, GstMpegtsSection * section)
     return TRUE;
   }
 
+  /* Don't attempt to handle pmt without any streams */
+  if (G_UNLIKELY (pmt->streams->len == 0)) {
+    GST_WARNING ("Skipping PMT without any entries");
+    return TRUE;
+  }
+
   program_number = section->subtable_extension;
   GST_DEBUG ("Applying PMT (program_number:%d, pid:0x%04x)",
       program_number, section->pid);