mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
mpegtsdemux: Also parse TOT (Time Offset Section)
It's the same as TDT, except with descriptors at the end
This commit is contained in:
parent
d9121c38ea
commit
e2576f0e86
3 changed files with 59 additions and 15 deletions
|
@ -1200,6 +1200,14 @@ mpegts_base_handle_psi (MpegTSBase * base, MpegTSPacketizerSection * section)
|
|||
else
|
||||
res = FALSE;
|
||||
break;
|
||||
case TABLE_ID_TIME_OFFSET:
|
||||
/* TOT (Time Offset table) */
|
||||
structure = mpegts_packetizer_parse_tot (base->packetizer, section);
|
||||
if (G_LIKELY (structure))
|
||||
mpegts_base_apply_tdt (base, section->pid, structure);
|
||||
else
|
||||
res = FALSE;
|
||||
break;
|
||||
default:
|
||||
GST_WARNING ("Unhandled or unknown section type (table_id 0x%02x)",
|
||||
section->table_id);
|
||||
|
|
|
@ -2175,26 +2175,23 @@ error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
GstStructure *
|
||||
mpegts_packetizer_parse_tdt (MpegTSPacketizer2 * packetizer,
|
||||
MpegTSPacketizerSection * section)
|
||||
static GstStructure *
|
||||
parse_tdt_tot_common (MpegTSPacketizer2 * packetizer,
|
||||
MpegTSPacketizerSection * section, const gchar * name)
|
||||
{
|
||||
GstStructure *tdt = NULL;
|
||||
GstStructure *res;
|
||||
guint16 mjd;
|
||||
guint year, month, day, hour, minute, second;
|
||||
guint8 *data, *utc_ptr;
|
||||
|
||||
GST_DEBUG ("TDT");
|
||||
|
||||
/* length always 8 */
|
||||
/* length at least 8 */
|
||||
if (section->section_length < 8) {
|
||||
GST_WARNING ("PID %d invalid TDT size %d",
|
||||
GST_WARNING ("PID %d invalid TDT/TOT size %d",
|
||||
section->pid, section->section_length);
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = section->data;
|
||||
|
||||
data += 3;
|
||||
|
||||
mjd = GST_READ_UINT16_BE (data);
|
||||
|
@ -2219,20 +2216,57 @@ mpegts_packetizer_parse_tdt (MpegTSPacketizer2 * packetizer,
|
|||
minute = ((utc_ptr[1] & 0xF0) >> 4) * 10 + (utc_ptr[1] & 0x0F);
|
||||
second = ((utc_ptr[2] & 0xF0) >> 4) * 10 + (utc_ptr[2] & 0x0F);
|
||||
}
|
||||
tdt = gst_structure_new ("tdt",
|
||||
res = gst_structure_new (name,
|
||||
"year", G_TYPE_UINT, year,
|
||||
"month", G_TYPE_UINT, month,
|
||||
"day", G_TYPE_UINT, day,
|
||||
"hour", G_TYPE_UINT, hour,
|
||||
"minute", G_TYPE_UINT, minute, "second", G_TYPE_UINT, second, NULL);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GstStructure *
|
||||
mpegts_packetizer_parse_tdt (MpegTSPacketizer2 * packetizer,
|
||||
MpegTSPacketizerSection * section)
|
||||
{
|
||||
GstStructure *tdt = NULL;
|
||||
GST_DEBUG ("TDT");
|
||||
|
||||
tdt = parse_tdt_tot_common (packetizer, section, "tdt");
|
||||
|
||||
return tdt;
|
||||
}
|
||||
|
||||
error:
|
||||
if (tdt)
|
||||
gst_structure_free (tdt);
|
||||
GstStructure *
|
||||
mpegts_packetizer_parse_tot (MpegTSPacketizer2 * packetizer,
|
||||
MpegTSPacketizerSection * section)
|
||||
{
|
||||
guint8 *data;
|
||||
GstStructure *tot = NULL;
|
||||
GValueArray *descriptors;
|
||||
guint16 desc_len;
|
||||
|
||||
return NULL;
|
||||
GST_DEBUG ("TOT");
|
||||
|
||||
tot = parse_tdt_tot_common (packetizer, section, "tot");
|
||||
data = section->data + 8;
|
||||
|
||||
desc_len = ((*data++) & 0xf) << 8;
|
||||
desc_len |= *data++;
|
||||
descriptors = g_value_array_new (0);
|
||||
|
||||
if (!mpegts_packetizer_parse_descriptors (packetizer, &data, data + desc_len,
|
||||
descriptors)) {
|
||||
g_value_array_free (descriptors);
|
||||
gst_structure_free (tot);
|
||||
return NULL;
|
||||
}
|
||||
gst_structure_id_set (tot, QUARK_DESCRIPTORS, G_TYPE_VALUE_ARRAY, descriptors,
|
||||
NULL);
|
||||
g_value_array_free (descriptors);
|
||||
|
||||
return tot;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -212,6 +212,8 @@ GstStructure *mpegts_packetizer_parse_eit (MpegTSPacketizer2 *packetizer,
|
|||
MpegTSPacketizerSection *section);
|
||||
GstStructure *mpegts_packetizer_parse_tdt (MpegTSPacketizer2 *packetizer,
|
||||
MpegTSPacketizerSection *section);
|
||||
GstStructure *mpegts_packetizer_parse_tot (MpegTSPacketizer2 *packetizer,
|
||||
MpegTSPacketizerSection *section);
|
||||
|
||||
/* Only valid if calculate_offset is TRUE */
|
||||
guint mpegts_packetizer_get_seen_pcr (MpegTSPacketizer2 *packetizer);
|
||||
|
|
Loading…
Reference in a new issue