mpegts: Check continuity counter on section streams

This wasn't really done, and is needed in order to detect potential section
changes for sections that have got identical information (such as when switching
between streams that have the same PAT/PMT pid and subtable information).

Other checks exist in tsbase to detect if the "new" PAT/PMT really is an update or not.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3530>
This commit is contained in:
Edward Hervey 2022-12-06 11:30:47 +01:00 committed by GStreamer Marge Bot
parent fa71217502
commit c81facec5f

View file

@ -963,6 +963,7 @@ mpegts_packetizer_push_section (MpegTSPacketizer2 * packetizer,
guint8 packet_cc; guint8 packet_cc;
GList *others = NULL; GList *others = NULL;
guint8 version_number, section_number, last_section_number; guint8 version_number, section_number, last_section_number;
gboolean cc_discont = FALSE;
data = packet->data; data = packet->data;
packet_cc = FLAGS_CONTINUITY_COUNTER (packet->scram_afc_cc); packet_cc = FLAGS_CONTINUITY_COUNTER (packet->scram_afc_cc);
@ -1009,24 +1010,18 @@ mpegts_packetizer_push_section (MpegTSPacketizer2 * packetizer,
* *
**/ **/
if (packet->payload_unit_start_indicator) { if (packet->payload_unit_start_indicator)
pointer = *data++; pointer = *data++;
/* If the pointer is zero, we're guaranteed to be able to handle it */
if (pointer == 0) {
GST_LOG
("PID 0x%04x PUSI and pointer == 0, skipping straight to section_start parsing",
packet->pid);
mpegts_packetizer_clear_section (stream);
goto section_start;
}
}
if (stream->continuity_counter == CONTINUITY_UNSET || if (stream->continuity_counter == CONTINUITY_UNSET ||
(stream->continuity_counter + 1) % 16 != packet_cc) { (stream->continuity_counter + 1) % 16 != packet_cc) {
if (stream->continuity_counter != CONTINUITY_UNSET) if (stream->continuity_counter != CONTINUITY_UNSET) {
GST_WARNING ("PID 0x%04x section discontinuity (%d vs %d)", packet->pid, GST_WARNING ("PID 0x%04x section discontinuity (%d vs %d)", packet->pid,
stream->continuity_counter, packet_cc); stream->continuity_counter, packet_cc);
cc_discont = TRUE;
}
mpegts_packetizer_clear_section (stream); mpegts_packetizer_clear_section (stream);
stream->continuity_counter = packet_cc;
/* If not a PUSI, not much we can do */ /* If not a PUSI, not much we can do */
if (!packet->payload_unit_start_indicator) { if (!packet->payload_unit_start_indicator) {
GST_LOG ("PID 0x%04x continuity discont/unset and not PUSI, bailing out", GST_LOG ("PID 0x%04x continuity discont/unset and not PUSI, bailing out",
@ -1041,6 +1036,19 @@ mpegts_packetizer_push_section (MpegTSPacketizer2 * packetizer,
goto section_start; goto section_start;
} }
if (packet->payload_unit_start_indicator && pointer == 0) {
/* If the pointer is zero, we're guaranteed to be able to handle it */
GST_LOG
("PID 0x%04x PUSI and pointer == 0, skipping straight to section_start parsing",
packet->pid);
mpegts_packetizer_clear_section (stream);
stream->continuity_counter = packet_cc;
goto section_start;
}
stream->continuity_counter = packet_cc;
GST_LOG ("Accumulating data from beginning of packet"); GST_LOG ("Accumulating data from beginning of packet");
data_start = data; data_start = data;
@ -1192,7 +1200,7 @@ section_start:
* * same last_section_number * * same last_section_number
* * same section_number was seen * * same section_number was seen
*/ */
if (seen_section_before (stream, table_id, subtable_extension, if (!cc_discont && seen_section_before (stream, table_id, subtable_extension,
version_number, section_number, last_section_number)) { version_number, section_number, last_section_number)) {
GST_DEBUG GST_DEBUG
("PID 0x%04x Already processed table_id:0x%02x subtable_extension:0x%04x, version_number:%d, section_number:%d", ("PID 0x%04x Already processed table_id:0x%02x subtable_extension:0x%04x, version_number:%d, section_number:%d",