mpegtspacketizer: memcmp potentially seen_before data

Theoretically the version number is incremented every time there's a new
section, but in a world of streaming we can't easily make that
assumption.

An example of a broken use case is when we're cat-ing two mpeg-ts files
together, which is equivalent of capturing a DVB stream while switching
channels. A set-top box would know that we switched the channels and
reset the demuxer, but in practice this might not happen.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2468>
This commit is contained in:
Vivia Nikolaidou 2021-08-16 18:15:42 +03:00 committed by GStreamer Marge Bot
parent f74a2bd303
commit fcad4cc646

View file

@ -157,7 +157,7 @@ find_subtable (GSList * subtables, guint8 table_id, guint16 subtable_extension)
static gboolean
seen_section_before (MpegTSPacketizerStream * stream, guint8 table_id,
guint16 subtable_extension, guint8 version_number, guint8 section_number,
guint8 last_section_number)
guint8 last_section_number, guint8 * data_start, gsize to_read)
{
MpegTSPacketizerStreamSubtable *subtable;
@ -178,7 +178,17 @@ seen_section_before (MpegTSPacketizerStream * stream, guint8 table_id,
return FALSE;
}
/* Finally return whether we saw that section or not */
return MPEGTS_BIT_IS_SET (subtable->seen_section, section_number);
if (!MPEGTS_BIT_IS_SET (subtable->seen_section, section_number)) {
GST_DEBUG ("Different section_number");
return FALSE;
}
if (stream->section_data) {
/* Everything else is the same, fall back to memcmp */
return (memcmp (stream->section_data, data_start, to_read) != 0);
}
return FALSE;
}
static MpegTSPacketizerStreamSubtable *
@ -1192,7 +1202,8 @@ section_start:
* * same section_number was seen
*/
if (seen_section_before (stream, table_id, subtable_extension,
version_number, section_number, last_section_number)) {
version_number, section_number, last_section_number, data_start,
to_read)) {
GST_DEBUG
("PID 0x%04x Already processed table_id:0x%02x subtable_extension:0x%04x, version_number:%d, section_number:%d",
packet->pid, table_id, subtable_extension, version_number,