Allow dumping pipelines as dot graphs. Fixes #456573.
[platform/upstream/gstreamer.git] / gst / gstdebugutils.h
1 /* GStreamer
2  * Copyright (C) 2007 Stefan Kost <ensonic@users.sf.net>
3  *
4  * gstdebugutils.h: debugging and analysis utillities
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __GSTDEBUGUTILS_H__
23 #define __GSTDEBUGUTILS_H__
24
25 #include <glib.h>
26 #include <glib-object.h>
27 #include <gst/gstconfig.h>
28 #include <gst/gstbin.h>
29
30 G_BEGIN_DECLS
31
32 /**
33  * GstDebugGraphDetails:
34  * @GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE: show caps-name on edges
35  * @GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS: show caps-details on edges
36  * @GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS: show modified parameters on elements
37  * @GST_DEBUG_GRAPH_SHOW_STATES: show element states
38  * @GST_DEBUG_GRAPH_SHOW_ALL: show all details
39  *
40  * Available details for pipeline graphs produced by GST_DEBUG_BIN_TO_DOT_FILE()
41  * and GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS().
42  */
43 typedef enum {
44   GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE         = (1<<0),
45   GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS       = (1<<1),
46   GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS = (1<<2),
47   GST_DEBUG_GRAPH_SHOW_STATES             = (1<<3),
48   GST_DEBUG_GRAPH_SHOW_ALL                = ((1<<4)-1)
49 } GstDebugGraphDetails;
50
51
52 #ifndef GST_DISABLE_GST_DEBUG
53
54 /********** pipeline graphs **********/
55
56 void _gst_debug_bin_to_dot_file (GstBin *bin, GstDebugGraphDetails details, const gchar *file_name);
57 void _gst_debug_bin_to_dot_file_with_ts (GstBin *bin, GstDebugGraphDetails details, const gchar *file_tmpl);
58
59 /**
60  * GST_DEBUG_BIN_TO_DOT_FILE:
61  * @bin: the top-level pipeline that should be analyzed
62  * @details: graph-details to show
63  * @file_name: output filename (e.g. "/tmp/metadata.dot")
64  *
65  * To aid debugging applications one can use this method to write out the whole
66  * network of gstreamer elements that form the pipeline into an dot file.
67  * This file can be processed with graphviz to get an image.
68  * <informalexample><programlisting>
69  *  dot -Tpng -oimage.png graph_lowlevel.dot
70  * </programlisting></informalexample>
71  *
72  * The macro is only active if gstreamer is configured with
73  * &quot;--gst-enable-gst-debug&quot; and the environment variable
74  * GST_DEBUG_DUMP_DOT_FILES is set (e.g. to 1).
75  */
76 #define GST_DEBUG_BIN_TO_DOT_FILE(bin, details, file_name) _gst_debug_bin_to_dot_file (bin, details, file_name)
77
78 /**
79  * GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS:
80  * @bin: the top-level pipeline that should be analyzed
81  * @details: graph-details to show
82  * @file_tmpl: output filename template
83  *             (e.g. "/tmp/metadata.%" GST_TIME_FORMAT ".dot")
84  *
85  * This works like _gst_debug_bin_to_dot_file(), but fills the filename template
86  * with the timestamp, so that it can be used to take multiple snapshots.
87  */
88 #define GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(bin, details, file_tmpl) _gst_debug_bin_to_dot_file_with_ts (bin, details, file_tmpl)
89
90
91 #else /* GST_DISABLE_GST_DEBUG */
92
93
94 #define GST_DEBUG_BIN_TO_DOT_FILE(bin, details, file_name)
95 #define GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(bin, details, file_tmpl)
96
97 #endif /* GST_DISABLE_GST_DEBUG */
98
99 G_END_DECLS
100
101 #endif /* __GSTDEBUGUTILS_H__ */
102