gst/mpegtsparse/: A sub table is identified by the pair table_id and sub_table_identifier, not by pid. So hash with t...

Original commit message from CVS:
* gst/mpegtsparse/mpegtspacketizer.c:
* gst/mpegtsparse/mpegtsparse.c:
A sub table is identified by the pair table_id and
sub_table_identifier, not by pid. So hash with that.
* sys/dvb/dvbbasebin.c:
Make sure initial pids are added properly to filter,
This commit is contained in:
Zaheer Abbas Merali 2007-12-05 12:40:05 +00:00
parent b762832214
commit 3966e730c9
4 changed files with 57 additions and 30 deletions

View file

@ -1,3 +1,12 @@
2007-12-05 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* gst/mpegtsparse/mpegtspacketizer.c:
* gst/mpegtsparse/mpegtsparse.c:
A sub table is identified by the pair table_id and
sub_table_identifier, not by pid. So hash with that.
* sys/dvb/dvbbasebin.c:
Make sure initial pids are added properly to filter,
2007-12-05 Andy Wingo <wingo@pobox.com>
* gst/switch/gstswitch.c (gst_switch_set_property): Don't push

View file

@ -37,7 +37,11 @@ static void mpegts_packetizer_finalize (GObject * object);
typedef struct
{
guint16 pid;
guint8 table_id;
/* the spec says sub_table_extension is the fourth and fifth byte of a
* section when the section_syntax_indicator is set to a value of "1". If
* section_syntax_indicator is 0, sub_table_extension will be set to 0 */
guint16 sub_table_extension;
guint continuity_counter;
GstAdapter *section_adapter;
guint section_length;
@ -45,13 +49,14 @@ typedef struct
} MpegTSPacketizerStream;
static MpegTSPacketizerStream *
mpegts_packetizer_stream_new (guint16 pid)
mpegts_packetizer_stream_new (guint8 table_id, guint16 sub_table_extension)
{
MpegTSPacketizerStream *stream;
stream = (MpegTSPacketizerStream *) g_new0 (MpegTSPacketizerStream, 1);
stream->section_adapter = gst_adapter_new ();
stream->pid = pid;
stream->table_id = table_id;
stream->sub_table_extension = sub_table_extension;
stream->continuity_counter = CONTINUITY_UNSET;
stream->section_version_number = SECTION_VERSION_NUMBER_NOTSET;
return stream;
@ -89,7 +94,7 @@ static void
mpegts_packetizer_init (MpegTSPacketizer * packetizer)
{
packetizer->adapter = gst_adapter_new ();
packetizer->streams = g_hash_table_new (g_direct_hash, g_direct_equal);
packetizer->streams = g_hash_table_new (g_str_hash, g_str_equal);
}
static void
@ -1053,9 +1058,11 @@ mpegts_packetizer_push_section (MpegTSPacketizer * packetizer,
gboolean res = FALSE;
MpegTSPacketizerStream *stream;
guint8 pointer, table_id;
guint16 sub_table_extension;
guint section_length;
GstBuffer *sub_buf;
guint8 *data;
gchar *sub_table_identifier;
g_return_val_if_fail (GST_IS_MPEGTS_PACKETIZER (packetizer), FALSE);
g_return_val_if_fail (packet != NULL, FALSE);
@ -1064,14 +1071,6 @@ mpegts_packetizer_push_section (MpegTSPacketizer * packetizer,
data = packet->data;
section->pid = packet->pid;
stream = (MpegTSPacketizerStream *) g_hash_table_lookup (packetizer->streams,
GINT_TO_POINTER ((gint) packet->pid));
if (stream == NULL) {
stream = mpegts_packetizer_stream_new (packet->pid);
g_hash_table_insert (packetizer->streams,
GINT_TO_POINTER ((gint) packet->pid), stream);
}
if (packet->payload_unit_start_indicator == 1) {
pointer = *data++;
if (data + pointer > packet->data_end) {
@ -1082,8 +1081,24 @@ mpegts_packetizer_push_section (MpegTSPacketizer * packetizer,
data += pointer;
}
table_id = *data++;
/* sub_table_extension should be read from 4th and 5th bytes only if
* section_syntax_indicator is 1 */
if ((data[0] & 0x80) == 0)
sub_table_extension = 0;
else
sub_table_extension = GST_READ_UINT16_BE (data + 2);
sub_table_identifier =
g_strdup_printf ("%d,%d", table_id, sub_table_extension);
GST_DEBUG ("sub table identifier is: %s", sub_table_identifier);
stream = (MpegTSPacketizerStream *) g_hash_table_lookup (packetizer->streams,
sub_table_identifier);
if (stream == NULL) {
stream = mpegts_packetizer_stream_new (table_id, sub_table_extension);
g_hash_table_insert (packetizer->streams, sub_table_identifier, stream);
} else {
g_free (sub_table_identifier);
}
section_length = GST_READ_UINT16_BE (data) & 0x0FFF;
data += 2;

View file

@ -940,30 +940,27 @@ static void
mpegts_parse_apply_nit (MpegTSParse * parse,
guint16 pmt_pid, GstStructure * nit_info)
{
/*gst_element_post_message(GST_ELEMENT_CAST(parse),
* gst_message_new_element (GST_OBJECT(parse),
* gst_structure_copy(nit_info)));
*/
gst_element_post_message (GST_ELEMENT_CAST (parse),
gst_message_new_element (GST_OBJECT (parse),
gst_structure_copy (nit_info)));
}
static void
mpegts_parse_apply_sdt (MpegTSParse * parse,
guint16 pmt_pid, GstStructure * sdt_info)
{
/*gst_element_post_message(GST_ELEMENT_CAST(parse),
* gst_message_new_element (GST_OBJECT(parse),
* gst_structure_copy(sdt_info)));
*/
gst_element_post_message (GST_ELEMENT_CAST (parse),
gst_message_new_element (GST_OBJECT (parse),
gst_structure_copy (sdt_info)));
}
static void
mpegts_parse_apply_eit (MpegTSParse * parse,
guint16 pmt_pid, GstStructure * eit_info)
{
/*gst_element_post_message(GST_ELEMENT_CAST(parse),
* gst_message_new_element (GST_OBJECT(parse),
* gst_structure_copy(eit_info)));
*/
gst_element_post_message (GST_ELEMENT_CAST (parse),
gst_message_new_element (GST_OBJECT (parse),
gst_structure_copy (eit_info)));
}
static gboolean

View file

@ -309,9 +309,14 @@ dvb_base_bin_reset (DvbBaseBin * dvbbasebin)
}
}
static gint16 initial_pids[] = { 0, 1, 0x10, 0x11, 0x12, -1 };
static void
dvb_base_bin_init (DvbBaseBin * dvbbasebin, DvbBaseBinClass * klass)
{
DvbBaseBinStream *stream;
int i;
dvbbasebin->dvbsrc = gst_element_factory_make ("dvbsrc", NULL);
dvbbasebin->buffer_queue = gst_element_factory_make ("queue", NULL);
dvbbasebin->mpegtsparse = gst_element_factory_make ("mpegtsparse", NULL);
@ -338,11 +343,12 @@ dvb_base_bin_init (DvbBaseBin * dvbbasebin, DvbBaseBinClass * klass)
dvb_base_bin_reset (dvbbasebin);
/* add PAT, CAT, NIT, SDT, EIT to pids filter for dvbsrc */
dvb_base_bin_add_stream (dvbbasebin, 0);
dvb_base_bin_add_stream (dvbbasebin, 1);
dvb_base_bin_add_stream (dvbbasebin, 10);
dvb_base_bin_add_stream (dvbbasebin, 11);
dvb_base_bin_add_stream (dvbbasebin, 12);
i = 0;
while (initial_pids[i] >= 0) {
stream = dvb_base_bin_add_stream (dvbbasebin, (guint16) initial_pids[i]);
++stream->usecount;
i++;
}
dvb_base_bin_rebuild_filter (dvbbasebin);
}