summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst/mpegtsdemux/mpegtsbase.c8
-rw-r--r--gst/mpegtsdemux/mpegtspacketizer.c64
-rw-r--r--gst/mpegtsdemux/mpegtspacketizer.h2
3 files changed, 59 insertions, 15 deletions
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c
index b6a1530e7..48bba568b 100644
--- a/gst/mpegtsdemux/mpegtsbase.c
+++ b/gst/mpegtsdemux/mpegtsbase.c
@@ -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);
diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c
index 5536dbc40..afe102f69 100644
--- a/gst/mpegtsdemux/mpegtspacketizer.c
+++ b/gst/mpegtsdemux/mpegtspacketizer.c
@@ -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
diff --git a/gst/mpegtsdemux/mpegtspacketizer.h b/gst/mpegtsdemux/mpegtspacketizer.h
index b971b3571..5d80d3603 100644
--- a/gst/mpegtsdemux/mpegtspacketizer.h
+++ b/gst/mpegtsdemux/mpegtspacketizer.h
@@ -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);