From fe67cd3d002afec55a2a69a01c8cb51ee76d6a88 Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Mon, 21 Jul 2014 13:48:31 +0300 Subject: [PATCH] discoverer: prettier image tag printing Rather than dumping the serialized sample value, the code now prints the number of bytes in the buffer, then the caps in a human-readable format. https://bugzilla.gnome.org/show_bug.cgi?id=733482 --- tools/gst-discoverer.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/gst-discoverer.c b/tools/gst-discoverer.c index db351b3..1f0b4d0 100644 --- a/tools/gst-discoverer.c +++ b/tools/gst-discoverer.c @@ -309,7 +309,27 @@ print_tag_foreach (const GstTagList * tags, const gchar * tag, if (G_VALUE_HOLDS_STRING (&val)) str = g_value_dup_string (&val); - else + else if (G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE) { + GstSample *sample = gst_value_get_sample (&val); + GstBuffer *img = gst_sample_get_buffer (sample); + GstCaps *caps = gst_sample_get_caps (sample); + + if (img) { + if (caps) { + gchar *caps_str; + + caps_str = gst_caps_to_string (caps); + str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes, " + "type: %s", gst_buffer_get_size (img), caps_str); + g_free (caps_str); + } else { + str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes", + gst_buffer_get_size (img)); + } + } else { + str = g_strdup ("NULL buffer"); + } + } else str = gst_value_serialize (&val); g_print ("%*s%s: %s\n", 2 * depth, " ", gst_tag_get_nick (tag), str); -- 2.7.4