[Spice-devel] [PATCH spice-gtk v4 7/7] display-gst: Debug video pipeline on stream-start message

Victor Toso victortoso at redhat.com
Wed Jun 28 12:43:04 UTC 2017


From: Victor Toso <me at victortoso.com>

On GST_MESSAGE_STREAM_START our stream is about to start and it seems
a good moment to debug GStreamer pipeline if requested.

That we can do with GST_DEBUG_BIN_TO_DOT_FILE() which iterates
recursively in the whole pipeline and generates a dot file with all
the information, the filename is 'spice-gtk-gst-pipeline-debug.dot'.

One can generate png image out of this dot file with the command:
  dot -Tpng -oimage.png spice-gtk-gst-pipeline-debug.dot

Not that GST_DEBUG_BIN_TO_DOT_FILE() will only work if Gstreamer was
configured with --gst-enable-gst-debug and the environment variable
GST_DEBUG_DUMP_DOT_DIR was properly set.

Full example:

1) GST_DEBUG_DUMP_DOT_DIR=/tmp remote-viewer ...
2) dot -Tpng -oimage.png spice-gtk-gst-pipeline-debug.dot

Signed-off-by: Victor Toso <victortoso at redhat.com>
Signed-off-by: Victor Toso <me at victortoso.com>
---
 src/channel-display-gst.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index df58de3..04710e8 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -298,7 +298,8 @@ static gboolean handle_pipeline_message(GstBus *bus, GstMessage *msg, gpointer v
 {
     SpiceGstDecoder *decoder = video_decoder;
 
-    if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR) {
+    switch(GST_MESSAGE_TYPE(msg)) {
+    case GST_MESSAGE_ERROR: {
         GError *err = NULL;
         gchar *debug_info = NULL;
         gst_message_parse_error(msg, &err, &debug_info);
@@ -312,6 +313,18 @@ static gboolean handle_pipeline_message(GstBus *bus, GstMessage *msg, gpointer v
 
         /* We won't be able to process any more frame anyway */
         free_pipeline(decoder);
+        break;
+    }
+    case GST_MESSAGE_STREAM_START:
+        GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(decoder->pipeline),
+                                  GST_DEBUG_GRAPH_SHOW_ALL
+                                    | GST_DEBUG_GRAPH_SHOW_FULL_PARAMS
+                                    | GST_DEBUG_GRAPH_SHOW_STATES,
+                                  "spice-gtk-gst-pipeline-debug");
+        break;
+    default:
+        /* not being handled */
+        break;
     }
     return TRUE;
 }
-- 
2.13.0



More information about the Spice-devel mailing list