mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 23:58:17 +00:00
mpegtsbase/packetizer: Add CAT section handling
Allows reporting the global EMM
This commit is contained in:
parent
dfe6863387
commit
63f8b970af
3 changed files with 75 additions and 0 deletions
|
@ -1011,6 +1011,16 @@ same_program:
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mpegts_base_apply_cat (MpegTSBase * base, GstStructure * cat_info)
|
||||
{
|
||||
GST_DEBUG_OBJECT (base, "CAT %" GST_PTR_FORMAT, cat_info);
|
||||
|
||||
gst_element_post_message (GST_ELEMENT_CAST (base),
|
||||
gst_message_new_element (GST_OBJECT (base),
|
||||
gst_structure_copy (cat_info)));
|
||||
}
|
||||
|
||||
static void
|
||||
mpegts_base_apply_nit (MpegTSBase * base,
|
||||
guint16 pmt_pid, GstStructure * nit_info)
|
||||
|
@ -1099,7 +1109,16 @@ mpegts_base_handle_psi (MpegTSBase * base, MpegTSPacketizerSection * section)
|
|||
res = FALSE;
|
||||
|
||||
break;
|
||||
case 0x01:
|
||||
/* CAT */
|
||||
structure = mpegts_packetizer_parse_cat (base->packetizer, section);
|
||||
if (structure)
|
||||
mpegts_base_apply_cat (base, structure);
|
||||
else
|
||||
res = FALSE;
|
||||
break;
|
||||
case 0x02:
|
||||
/* PMT */
|
||||
structure = mpegts_packetizer_parse_pmt (base->packetizer, section);
|
||||
if (G_LIKELY (structure))
|
||||
mpegts_base_apply_pmt (base, section->pid, structure);
|
||||
|
|
|
@ -48,6 +48,8 @@ static GQuark QUARK_PROGRAM_NUMBER;
|
|||
static GQuark QUARK_PID;
|
||||
static GQuark QUARK_PROGRAMS;
|
||||
|
||||
static GQuark QUARK_CAT;
|
||||
|
||||
static GQuark QUARK_PMT;
|
||||
static GQuark QUARK_PCR_PID;
|
||||
static GQuark QUARK_VERSION_NUMBER;
|
||||
|
@ -522,6 +524,56 @@ error:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
GstStructure *
|
||||
mpegts_packetizer_parse_cat (MpegTSPacketizer2 * packetizer,
|
||||
MpegTSPacketizerSection * section)
|
||||
{
|
||||
GstStructure *cat_info = NULL;
|
||||
guint8 *data;
|
||||
guint8 tmp;
|
||||
GValueArray *descriptors;
|
||||
GstMPEGDescriptor *desc;
|
||||
guint desc_len;
|
||||
|
||||
/* Skip parts already parsed */
|
||||
data = section->data + 3;
|
||||
|
||||
/* reserved : 18bits */
|
||||
data += 2;
|
||||
|
||||
/* version_number : 5 bits
|
||||
* current_next_indicator : 1 bit */
|
||||
tmp = *data++;
|
||||
section->version_number = (tmp >> 1) & 0x1F;
|
||||
section->current_next_indicator = tmp & 0x01;
|
||||
|
||||
/* skip already handled section_number and last_section_number */
|
||||
data += 2;
|
||||
|
||||
cat_info = gst_structure_new_id_empty (QUARK_CAT);
|
||||
|
||||
/* descriptors */
|
||||
desc_len = section->section_length - 4 - 8;
|
||||
desc = gst_mpeg_descriptor_parse (data, desc_len);
|
||||
if (desc)
|
||||
gst_mpeg_descriptor_free (desc);
|
||||
descriptors = g_value_array_new (0);
|
||||
if (!mpegts_packetizer_parse_descriptors (packetizer, &data, data + desc_len,
|
||||
descriptors)) {
|
||||
g_value_array_free (descriptors);
|
||||
goto error;
|
||||
}
|
||||
gst_structure_id_set (cat_info, QUARK_DESCRIPTORS, G_TYPE_VALUE_ARRAY,
|
||||
descriptors, NULL);
|
||||
g_value_array_free (descriptors);
|
||||
|
||||
return cat_info;
|
||||
error:
|
||||
if (cat_info)
|
||||
gst_structure_free (cat_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GstStructure *
|
||||
mpegts_packetizer_parse_pat (MpegTSPacketizer2 * packetizer,
|
||||
MpegTSPacketizerSection * section)
|
||||
|
@ -2579,6 +2631,8 @@ _init_local (void)
|
|||
QUARK_PID = g_quark_from_string ("pid");
|
||||
QUARK_PROGRAMS = g_quark_from_string ("programs");
|
||||
|
||||
QUARK_CAT = g_quark_from_string ("pat");
|
||||
|
||||
QUARK_PMT = g_quark_from_string ("pmt");
|
||||
QUARK_PCR_PID = g_quark_from_string ("pcr-pid");
|
||||
QUARK_VERSION_NUMBER = g_quark_from_string ("version-number");
|
||||
|
|
|
@ -192,6 +192,8 @@ void mpegts_packetizer_remove_stream(MpegTSPacketizer2 *packetizer,
|
|||
|
||||
gboolean mpegts_packetizer_push_section (MpegTSPacketizer2 *packetzer,
|
||||
MpegTSPacketizerPacket *packet, MpegTSPacketizerSection *section);
|
||||
GstStructure *mpegts_packetizer_parse_cat (MpegTSPacketizer2 *packetizer,
|
||||
MpegTSPacketizerSection *section);
|
||||
GstStructure *mpegts_packetizer_parse_pat (MpegTSPacketizer2 *packetizer,
|
||||
MpegTSPacketizerSection *section);
|
||||
GstStructure *mpegts_packetizer_parse_pmt (MpegTSPacketizer2 *packetizer,
|
||||
|
|
Loading…
Reference in a new issue