mpegtsparse: Ignore subtable extension when parsing PAT

Fixes #569673.
This commit is contained in:
Vincent Genieux 2009-05-03 17:42:44 +01:00 committed by Zaheer Merali
parent 8ef8daf4db
commit e41401e317
3 changed files with 23 additions and 5 deletions

View file

@ -241,7 +241,8 @@ mpegts_packetizer_parse_section_header (MpegTSPacketizer * packetizer,
data = GST_BUFFER_DATA (section->buffer);
section->table_id = *data++;
if ((data[0] & 0x80) == 0)
/* if table_id is 0 (pat) then ignore the subtable extension */
if ((data[0] & 0x80) == 0 || section->table_id == 0)
section->subtable_extension = 0;
else
section->subtable_extension = GST_READ_UINT16_BE (data + 2);
@ -1844,6 +1845,22 @@ mpegts_packetizer_clear (MpegTSPacketizer * packetizer)
gst_adapter_clear (packetizer->adapter);
}
void
mpegts_packetizer_remove_stream (MpegTSPacketizer * packetizer, gint16 pid)
{
MpegTSPacketizerStream *stream =
(MpegTSPacketizerStream *) g_hash_table_lookup (packetizer->streams,
GINT_TO_POINTER ((gint) pid));
if (stream) {
GST_INFO ("Removing stream for PID %d", pid);
g_hash_table_remove (packetizer->streams, GINT_TO_POINTER ((gint) pid));
g_object_unref (stream->section_adapter);
g_free (stream);
}
}
MpegTSPacketizer *
mpegts_packetizer_new ()
{

View file

@ -116,6 +116,8 @@ gboolean mpegts_packetizer_next_packet (MpegTSPacketizer *packetizer,
MpegTSPacketizerPacket *packet);
void mpegts_packetizer_clear_packet (MpegTSPacketizer *packetizer,
MpegTSPacketizerPacket *packet);
void mpegts_packetizer_remove_stream(MpegTSPacketizer *packetizer,
gint16 pid);
gboolean mpegts_packetizer_push_section (MpegTSPacketizer *packetzer,
MpegTSPacketizerPacket *packet, MpegTSPacketizerSection *section);

View file

@ -350,7 +350,7 @@ mpegts_parse_add_program (MpegTSParse * parse,
program->pcr_pid = G_MAXUINT16;
program->streams = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, (GDestroyNotify) mpegts_parse_free_stream);
program->patcount = 1;
program->patcount = 0;
program->selected = 0;
program->active = FALSE;
@ -890,14 +890,12 @@ mpegts_parse_apply_pat (MpegTSParse * parse, GstStructure * pat_info)
g_hash_table_insert (parse->psi_pids,
GINT_TO_POINTER ((gint) pid), GINT_TO_POINTER (1));
}
program->patcount += 1;
} else {
g_hash_table_insert (parse->psi_pids,
GINT_TO_POINTER ((gint) pid), GINT_TO_POINTER (1));
program = mpegts_parse_add_program (parse, program_number, pid);
}
program->patcount += 1;
if (program->selected && !program->active)
parse->pads_to_add = g_list_append (parse->pads_to_add,
mpegts_parse_activate_program (parse, program));
@ -938,6 +936,7 @@ mpegts_parse_apply_pat (MpegTSParse * parse, GstStructure * pat_info)
mpegts_parse_remove_program (parse, program_number);
g_hash_table_remove (parse->psi_pids, GINT_TO_POINTER ((gint) pid));
mpegts_packetizer_remove_stream (parse->packetizer, pid);
}
gst_structure_free (old_pat);