From 29c507bf3a685c2cc89971f4b6d87a9f6fd7a82f Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 9 Nov 2020 11:44:36 +0100 Subject: examples: Properly handle extended descriptors By checking the extended tag. Provides a bit more information (if extended tag is known) Part-of: --- tests/examples/mpegts/ts-parser.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/examples/mpegts/ts-parser.c b/tests/examples/mpegts/ts-parser.c index cf339f8a6..ad667f6ec 100644 --- a/tests/examples/mpegts/ts-parser.c +++ b/tests/examples/mpegts/ts-parser.c @@ -80,12 +80,20 @@ dump_memory_bytes (guint8 * data, guint len, guint spacing) #define dump_memory_content(desc, spacing) dump_memory_bytes((desc)->data + 2, (desc)->length, spacing) static const gchar * -descriptor_name (gint val) +descriptor_name (GstMpegtsDescriptor * desc) { - GEnumValue *en; + GEnumValue *en = NULL; + gint val = desc->tag; - en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek - (GST_TYPE_MPEGTS_DESCRIPTOR_TYPE)), val); + /* Treat extended descriptors */ + if (val == 0x7f) { + en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek + (GST_TYPE_MPEGTS_DVB_EXTENDED_DESCRIPTOR_TYPE)), + desc->tag_extension); + } + if (en == NULL) + en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek + (GST_TYPE_MPEGTS_DESCRIPTOR_TYPE)), val); if (en == NULL) /* Else try with DVB enum types */ en = g_enum_get_value (G_ENUM_CLASS (g_type_class_peek @@ -510,7 +518,7 @@ dump_descriptors (GPtrArray * descriptors, guint spacing) for (i = 0; i < descriptors->len; i++) { GstMpegtsDescriptor *desc = g_ptr_array_index (descriptors, i); g_printf ("%*s [descriptor 0x%02x (%s) length:%d]\n", spacing, "", - desc->tag, descriptor_name (desc->tag), desc->length); + desc->tag, descriptor_name (desc), desc->length); if (DUMP_DESCRIPTORS) dump_memory_content (desc, spacing + 2); switch (desc->tag) { @@ -1340,6 +1348,7 @@ main (int argc, gchar ** argv) g_type_class_ref (GST_TYPE_MPEGTS_RUNNING_STATUS); g_type_class_ref (GST_TYPE_MPEGTS_DESCRIPTOR_TYPE); g_type_class_ref (GST_TYPE_MPEGTS_DVB_DESCRIPTOR_TYPE); + g_type_class_ref (GST_TYPE_MPEGTS_DVB_EXTENDED_DESCRIPTOR_TYPE); g_type_class_ref (GST_TYPE_MPEGTS_ATSC_DESCRIPTOR_TYPE); g_type_class_ref (GST_TYPE_MPEGTS_ISDB_DESCRIPTOR_TYPE); g_type_class_ref (GST_TYPE_MPEGTS_MISC_DESCRIPTOR_TYPE); -- cgit v1.2.1