discoverer: prettier image tag printing
authorVivia Nikolaidou <n.vivia@gmail.com>
Mon, 21 Jul 2014 10:48:31 +0000 (13:48 +0300)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 21 Jul 2014 11:42:32 +0000 (12:42 +0100)
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

index db351b3..1f0b4d0 100644 (file)
@@ -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);