fakesink, identity: print metas attached to buffer in silent=false mode
authorTim-Philipp Müller <tim@centricular.com>
Wed, 29 Jun 2016 18:36:09 +0000 (19:36 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 5 Dec 2016 20:29:25 +0000 (20:29 +0000)
plugins/elements/gstelements_private.c
plugins/elements/gstelements_private.h
plugins/elements/gstfakesink.c
plugins/elements/gstidentity.c

index cba04b1..2c0ca58 100644 (file)
@@ -52,7 +52,7 @@
 G_STATIC_ASSERT ((1 << BUFFER_FLAG_SHIFT) == GST_MINI_OBJECT_FLAG_LAST);
 
 /* Returns a newly allocated string describing the flags on this buffer */
-char *
+gchar *
 gst_buffer_get_flags_string (GstBuffer * buffer)
 {
   static const char flag_strings[] =
@@ -84,6 +84,28 @@ gst_buffer_get_flags_string (GstBuffer * buffer)
   return flag_str;
 }
 
+/* Returns a newly-allocated string describing the metas on this buffer, or NULL */
+gchar *
+gst_buffer_get_meta_string (GstBuffer * buffer)
+{
+  gpointer state = NULL;
+  GstMeta *meta;
+  GString *s = NULL;
+
+  while ((meta = gst_buffer_iterate_meta (buffer, &state))) {
+    const gchar *desc = g_type_name (meta->info->type);
+
+    if (s == NULL)
+      s = g_string_new (NULL);
+    else
+      g_string_append (s, ", ");
+
+    g_string_append (s, desc);
+  }
+
+  return (s != NULL) ? g_string_free (s, FALSE) : NULL;
+}
+
 /* Define our own iovec structure here, so that we can use it unconditionally
  * in the code below and use almost the same code path for systems where
  * writev() is supported and those were it's not supported */
index d6a8908..d196594 100644 (file)
 G_BEGIN_DECLS
 
 G_GNUC_INTERNAL
-char *    gst_buffer_get_flags_string                   (GstBuffer *buffer);
+gchar *   gst_buffer_get_flags_string (GstBuffer *buffer);
+
+G_GNUC_INTERNAL
+gchar *   gst_buffer_get_meta_string (GstBuffer * buffer);
 
 G_GNUC_INTERNAL
 GstFlowReturn  gst_writev_buffers (GstObject * sink, gint fd, GstPoll * fdset,
index 9f75e48..0c7e84a 100644 (file)
@@ -448,7 +448,7 @@ gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf)
 
   if (!sink->silent) {
     gchar dts_str[64], pts_str[64], dur_str[64];
-    gchar *flag_str;
+    gchar *flag_str, *meta_str;
 
     GST_OBJECT_LOCK (sink);
     g_free (sink->last_message);
@@ -475,16 +475,19 @@ gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf)
     }
 
     flag_str = gst_buffer_get_flags_string (buf);
+    meta_str = gst_buffer_get_meta_string (buf);
 
     sink->last_message =
         g_strdup_printf ("chain   ******* (%s:%s) (%u bytes, dts: %s, pts: %s"
         ", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %"
-        G_GINT64_FORMAT ", flags: %08x %s) %p",
+        G_GINT64_FORMAT ", flags: %08x %s, meta: %s) %p",
         GST_DEBUG_PAD_NAME (GST_BASE_SINK_CAST (sink)->sinkpad),
         (guint) gst_buffer_get_size (buf), dts_str, pts_str,
         dur_str, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
-        GST_MINI_OBJECT_CAST (buf)->flags, flag_str, buf);
+        GST_MINI_OBJECT_CAST (buf)->flags, flag_str,
+        meta_str ? meta_str : "none", buf);
     g_free (flag_str);
+    g_free (meta_str);
     GST_OBJECT_UNLOCK (sink);
 
     gst_fake_sink_notify_last_message (sink);
index e05ff1e..58e5b3b 100644 (file)
@@ -537,23 +537,24 @@ gst_identity_update_last_message_for_buffer (GstIdentity * identity,
     const gchar * action, GstBuffer * buf, gsize size)
 {
   gchar dts_str[64], pts_str[64], dur_str[64];
-  gchar *flag_str;
+  gchar *flag_str, *meta_str;
 
   GST_OBJECT_LOCK (identity);
 
   flag_str = gst_buffer_get_flags_string (buf);
+  meta_str = gst_buffer_get_meta_string (buf);
 
   g_free (identity->last_message);
   identity->last_message = g_strdup_printf ("%s   ******* (%s:%s) "
       "(%" G_GSIZE_FORMAT " bytes, dts: %s, pts: %s, duration: %s, offset: %"
       G_GINT64_FORMAT ", " "offset_end: % " G_GINT64_FORMAT
-      ", flags: %08x %s) %p", action,
+      ", flags: %08x %s, meta: %s) %p", action,
       GST_DEBUG_PAD_NAME (GST_BASE_TRANSFORM_CAST (identity)->sinkpad), size,
       print_pretty_time (dts_str, sizeof (dts_str), GST_BUFFER_DTS (buf)),
       print_pretty_time (pts_str, sizeof (pts_str), GST_BUFFER_PTS (buf)),
       print_pretty_time (dur_str, sizeof (dur_str), GST_BUFFER_DURATION (buf)),
       GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
-      GST_BUFFER_FLAGS (buf), flag_str, buf);
+      GST_BUFFER_FLAGS (buf), flag_str, meta_str ? meta_str : "none", buf);
   g_free (flag_str);
 
   GST_OBJECT_UNLOCK (identity);