summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@collabora.com>2013-07-07 15:04:18 +0200
committerEdward Hervey <edward@collabora.com>2013-08-26 08:13:20 +0200
commitd1d9b630aa7c7f8fe4da696cca43d1457ba4f4b7 (patch)
treec0f92366a57ab1d259eaccaf2563d825a5ea5019
parente481ecbf2229468873296b350c1ff5b3ea28a71f (diff)
WIP examples: Add descriptor dumpingdescriptordump
-rw-r--r--tests/examples/mpegts/ts-parser.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/examples/mpegts/ts-parser.c b/tests/examples/mpegts/ts-parser.c
index 89db16f07..271fd8f46 100644
--- a/tests/examples/mpegts/ts-parser.c
+++ b/tests/examples/mpegts/ts-parser.c
@@ -24,12 +24,59 @@
#include "config.h"
#endif
+#define DUMP_DESCRIPTORS 1
+
#include <glib.h>
#include <glib-object.h>
#include <glib/gprintf.h>
#include <gst/gst.h>
#include <gst/mpegts/mpegts.h>
+static void
+gst_info_dump_mem_line (gchar * linebuf, gsize linebuf_size,
+ const guint8 * mem, gsize mem_offset, gsize mem_size)
+{
+ gchar hexstr[50], ascstr[18], digitstr[4];
+
+ if (mem_size > 16)
+ mem_size = 16;
+
+ hexstr[0] = '\0';
+ ascstr[0] = '\0';
+
+ if (mem != NULL) {
+ guint i = 0;
+
+ mem += mem_offset;
+ while (i < mem_size) {
+ ascstr[i] = (g_ascii_isprint (mem[i])) ? mem[i] : '.';
+ g_snprintf (digitstr, sizeof (digitstr), "%02x ", mem[i]);
+ g_strlcat (hexstr, digitstr, sizeof (hexstr));
+ ++i;
+ }
+ ascstr[i] = '\0';
+ }
+
+ g_snprintf (linebuf, linebuf_size, "%08x: %-48.48s %-16.16s",
+ (guint) mem_offset, hexstr, ascstr);
+}
+
+static void
+dump_memory_content (GstMpegTsDescriptor * desc, guint spacing)
+{
+ gsize off = 0;
+
+ while (off < desc->descriptor_length) {
+ gchar buf[128];
+
+ /* gst_info_dump_mem_line will process 16 bytes at most */
+ gst_info_dump_mem_line (buf, sizeof (buf), desc->descriptor_data, off + 2,
+ desc->descriptor_length - off);
+ g_printf ("%*s %s\n", spacing, "", buf);
+ off += 16;
+ }
+}
+
static const gchar *
descriptor_name (gint val)
{
@@ -128,6 +175,8 @@ dump_descriptors (GPtrArray * descriptors, guint spacing)
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);
+ if (DUMP_DESCRIPTORS)
+ dump_memory_content (desc, spacing + 2);
switch (desc->tag) {
case GST_MTS_DESC_REGISTRATION:
{