Generate a gstreamer pipeline diagram on SIGHUP.

Useful for debugging a pipeline that refuses to enter a given state.

https://bugzilla.gnome.org/show_bug.cgi?id=783661
This commit is contained in:
Graham Leggett 2017-06-11 15:15:13 +00:00 committed by Tim-Philipp Müller
parent bd5b1d00e6
commit cfe59c285c
3 changed files with 40 additions and 6 deletions

View file

@ -357,6 +357,12 @@ strategic places (like when the pipeline state changes or an error occurs).
gst-launch-&GST_API_VERSION; is one such application. gst-launch-&GST_API_VERSION; is one such application.
</para> </para>
<para> <para>
When gst-launch-&GST_API_VERSION; changes state through NULL to PLAYING
and back to NULL, a dot file is generated on each state change. To have
gst-launch-&GST_API_VERSION; write a snapshot of the pipeline state, send
a SIGHUP to the gst-launch-&GST_API_VERSION; process.
</para>
<para>
These .dot files can then be turned into images using the 'dot' utility These .dot files can then be turned into images using the 'dot' utility
from the graphviz set of tools, like this: from the graphviz set of tools, like this:
<command>dot foo.dot -Tsvg -o foo.svg</command> or <command>dot foo.dot -Tsvg -o foo.svg</command> or

View file

@ -434,6 +434,10 @@ These can then later be converted into an image using the 'dot' utility from
the graphviz set of tools, like this: dot foo.dot \-Tsvg \-o foo.svg (png or jpg the graphviz set of tools, like this: dot foo.dot \-Tsvg \-o foo.svg (png or jpg
are also possible as output format). There is also a utility called 'xdot' are also possible as output format). There is also a utility called 'xdot'
which allows you to view the .dot file directly without converting it first. which allows you to view the .dot file directly without converting it first.
.br
When the pipeline changes state through NULL to PLAYING and back to NULL, a
dot file is generated on each state change. To write a snapshot of the
pipeline state, send a SIGHUP to the process.
.TP .TP
\fBGST_REGISTRY\fR \fBGST_REGISTRY\fR
Path of the plugin registry file. Default is Path of the plugin registry file. Default is

View file

@ -467,7 +467,8 @@ print_toc_entry (gpointer data, gpointer user_data)
} }
#if defined(G_OS_UNIX) || defined(G_OS_WIN32) #if defined(G_OS_UNIX) || defined(G_OS_WIN32)
static guint signal_watch_id; static guint signal_watch_intr_id;
static guint signal_watch_hup_id;
#if defined(G_OS_WIN32) #if defined(G_OS_WIN32)
static GstElement *intr_pipeline; static GstElement *intr_pipeline;
#endif #endif
@ -490,8 +491,27 @@ intr_handler (gpointer user_data)
"message", G_TYPE_STRING, "Pipeline interrupted", NULL))); "message", G_TYPE_STRING, "Pipeline interrupted", NULL)));
/* remove signal handler */ /* remove signal handler */
signal_watch_id = 0; signal_watch_intr_id = 0;
return FALSE; return G_SOURCE_REMOVE;
}
static gboolean
hup_handler (gpointer user_data)
{
GstElement *pipeline = (GstElement *) user_data;
if (g_getenv ("GST_DEBUG_DUMP_DOT_DIR") != NULL) {
PRINT ("SIGHUP: dumping dot file snapshot ...\n");
} else {
PRINT ("SIGHUP: not dumping dot file snapshot, GST_DEBUG_DUMP_DOT_DIR "
"environment variable not set.\n");
}
/* dump graph on hup */
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
GST_DEBUG_GRAPH_SHOW_ALL, "gst-launch.snapshot");
return G_SOURCE_CONTINUE;
} }
#if defined(G_OS_WIN32) /* G_OS_UNIX */ #if defined(G_OS_WIN32) /* G_OS_UNIX */
@ -521,8 +541,10 @@ event_loop (GstElement * pipeline, gboolean blocking, gboolean do_progress,
bus = gst_element_get_bus (GST_ELEMENT (pipeline)); bus = gst_element_get_bus (GST_ELEMENT (pipeline));
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
signal_watch_id = signal_watch_intr_id =
g_unix_signal_add (SIGINT, (GSourceFunc) intr_handler, pipeline); g_unix_signal_add (SIGINT, (GSourceFunc) intr_handler, pipeline);
signal_watch_hup_id =
g_unix_signal_add (SIGHUP, (GSourceFunc) hup_handler, pipeline);
#elif defined(G_OS_WIN32) #elif defined(G_OS_WIN32)
intr_pipeline = NULL; intr_pipeline = NULL;
if (SetConsoleCtrlHandler (w32_intr_handler, TRUE)) if (SetConsoleCtrlHandler (w32_intr_handler, TRUE))
@ -893,8 +915,10 @@ exit:
gst_message_unref (message); gst_message_unref (message);
gst_object_unref (bus); gst_object_unref (bus);
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
if (signal_watch_id > 0) if (signal_watch_intr_id > 0)
g_source_remove (signal_watch_id); g_source_remove (signal_watch_intr_id);
if (signal_watch_hup_id > 0)
g_source_remove (signal_watch_hup_id);
#elif defined(G_OS_WIN32) #elif defined(G_OS_WIN32)
intr_pipeline = NULL; intr_pipeline = NULL;
SetConsoleCtrlHandler (w32_intr_handler, FALSE); SetConsoleCtrlHandler (w32_intr_handler, FALSE);