2 * Copyright (C) 2007 Stefan Kost <ensonic@users.sf.net>
4 * gstdebugutils.c: debugging and analysis utillities
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.
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.
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., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 * edge [ constraint=false ];
23 * this creates strange graphs ("minlen=0" is better)
24 * try puting src/sink ghostpads for each bin into invisible clusters
26 * for more compact nodes, try
27 * - changing node-shape from box into record
28 * - use labels like : element [ label="{element | <src> src | <sink> sink}"]
29 * - point to record-connectors : element1:src -> element2:sink
30 * - we use head/tail labels for pad-caps right now
31 * - this does not work well, as dot seems to not look at their size when
33 * - we could add the caps to the pad itself, then we should use one line per
34 * caps (simple caps = one line)
37 #include "gst_private.h"
38 #include "gstdebugutils.h"
40 #ifndef GST_DISABLE_GST_DEBUG
49 #include "gstobject.h"
50 #include "gstghostpad.h"
55 /*** PIPELINE GRAPHS **********************************************************/
57 extern const gchar *priv_gst_dump_dot_dir; /* NULL *//* set from gst.c */
59 #define PARAM_MAX_LENGTH 80
61 const gchar spaces[] = {
68 #define MAKE_INDENT(indent) \
69 &spaces[MAX (sizeof (spaces) - (1 + (indent) * 2), 0)]
72 debug_dump_make_object_name (GstObject * obj)
74 return g_strcanon (g_strdup_printf ("%s_%p", GST_OBJECT_NAME (obj), obj),
75 G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "_", '_');
79 debug_dump_get_element_state (GstElement * element)
81 gchar *state_name = NULL;
82 const gchar *state_icons = "~0-=>";
83 GstState state = GST_STATE_VOID_PENDING, pending = GST_STATE_VOID_PENDING;
85 gst_element_get_state (element, &state, &pending, 0);
86 if (pending == GST_STATE_VOID_PENDING) {
87 gboolean is_locked = gst_element_is_locked_state (element);
88 state_name = g_strdup_printf ("\\n[%c]%s", state_icons[state],
89 (is_locked ? "(locked)" : ""));
91 state_name = g_strdup_printf ("\\n[%c] -> [%c]", state_icons[state],
92 state_icons[pending]);
98 debug_dump_get_object_params (GObject * object,
99 GstDebugGraphDetails details, const char *const *ignored_propnames)
101 gchar *param_name = NULL;
102 GParamSpec **properties, *property;
103 GValue value = { 0, };
104 guint i, number_of_properties;
105 gchar *tmp, *value_str;
106 const gchar *ellipses;
108 /* get paramspecs and show non-default properties */
110 g_object_class_list_properties (G_OBJECT_GET_CLASS (object),
111 &number_of_properties);
113 for (i = 0; i < number_of_properties; i++) {
115 gboolean ignore = FALSE;
116 property = properties[i];
118 /* skip some properties */
119 if (!(property->flags & G_PARAM_READABLE))
121 if (!strcmp (property->name, "name"))
124 if (ignored_propnames)
125 for (j = 0; ignored_propnames[j]; j++)
126 if (!g_strcmp0 (ignored_propnames[j], property->name))
132 g_value_init (&value, property->value_type);
133 g_object_get_property (G_OBJECT (object), property->name, &value);
134 if (!(g_param_value_defaults (property, &value))) {
135 tmp = g_strdup_value_contents (&value);
136 value_str = g_strescape (tmp, NULL);
139 /* too long, ellipsize */
140 if (!(details & GST_DEBUG_GRAPH_SHOW_FULL_PARAMS) &&
141 strlen (value_str) > PARAM_MAX_LENGTH)
151 if (details & GST_DEBUG_GRAPH_SHOW_FULL_PARAMS) {
152 param_name = g_strdup_printf ("%s\\n%s=%s", tmp, property->name,
155 param_name = g_strdup_printf ("%s\\n%s=%."
156 G_STRINGIFY (PARAM_MAX_LENGTH) "s%s", tmp, property->name,
157 value_str, ellipses);
165 g_value_unset (&value);
173 debug_dump_pad (GstPad * pad, const gchar * color_name,
174 const gchar * element_name, GstDebugGraphDetails details, GString * str,
177 GstPadTemplate *pad_templ;
178 GstPadPresence presence;
179 gchar *pad_name, *param_name = NULL;
180 const gchar *style_name;
181 static const char *const ignore_propnames[] =
182 { "parent", "direction", "template",
185 const gchar *spc = MAKE_INDENT (indent);
187 pad_name = debug_dump_make_object_name (GST_OBJECT (pad));
189 /* pad availability */
190 style_name = "filled,solid";
191 if ((pad_templ = gst_pad_get_pad_template (pad))) {
192 presence = GST_PAD_TEMPLATE_PRESENCE (pad_templ);
193 gst_object_unref (pad_templ);
194 if (presence == GST_PAD_SOMETIMES) {
195 style_name = "filled,dotted";
196 } else if (presence == GST_PAD_REQUEST) {
197 style_name = "filled,dashed";
202 debug_dump_get_object_params (G_OBJECT (pad), details, ignore_propnames);
203 if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
205 const gchar *activation_mode = "-><";
206 const gchar *task_mode = "";
209 GST_OBJECT_LOCK (pad);
210 task = GST_PAD_TASK (pad);
212 switch (gst_task_get_state (task)) {
213 case GST_TASK_STARTED:
216 case GST_TASK_PAUSED:
220 /* Invalid task state, ignoring */
224 GST_OBJECT_UNLOCK (pad);
226 /* check if pad flags */
228 GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED) ? 'B' : 'b';
230 GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING) ? 'F' : 'f';
232 GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING) ? 'B' : 'b';
235 g_string_append_printf (str,
236 "%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s%s\\n[%c][%s]%s\", height=\"0.2\", style=\"%s\"];\n",
237 spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
238 (param_name ? param_name : ""),
239 activation_mode[pad->mode], pad_flags, task_mode, style_name);
241 g_string_append_printf (str,
242 "%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s%s\", height=\"0.2\", style=\"%s\"];\n",
243 spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
244 (param_name ? param_name : ""), style_name);
252 debug_dump_element_pad (GstPad * pad, GstElement * element,
253 GstDebugGraphDetails details, GString * str, const gint indent)
255 GstElement *target_element;
256 GstPad *target_pad, *tmp_pad;
259 gchar *target_element_name;
260 const gchar *color_name;
262 dir = gst_pad_get_direction (pad);
263 element_name = debug_dump_make_object_name (GST_OBJECT (element));
264 if (GST_IS_GHOST_PAD (pad)) {
266 (dir == GST_PAD_SRC) ? "#ffdddd" : ((dir ==
267 GST_PAD_SINK) ? "#ddddff" : "#ffffff");
268 /* output target-pad so that it belongs to this element */
269 if ((tmp_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad)))) {
270 if ((target_pad = gst_pad_get_peer (tmp_pad))) {
271 gchar *pad_name, *target_pad_name;
272 const gchar *spc = MAKE_INDENT (indent);
274 if ((target_element = gst_pad_get_parent_element (target_pad))) {
275 target_element_name =
276 debug_dump_make_object_name (GST_OBJECT (target_element));
278 target_element_name = g_strdup ("");
280 debug_dump_pad (target_pad, color_name, target_element_name, details,
282 /* src ghostpad relationship */
283 pad_name = debug_dump_make_object_name (GST_OBJECT (pad));
284 target_pad_name = debug_dump_make_object_name (GST_OBJECT (target_pad));
285 if (dir == GST_PAD_SRC) {
286 g_string_append_printf (str,
287 "%s%s_%s -> %s_%s [style=dashed, minlen=0]\n", spc,
288 target_element_name, target_pad_name, element_name, pad_name);
290 g_string_append_printf (str,
291 "%s%s_%s -> %s_%s [style=dashed, minlen=0]\n", spc,
292 element_name, pad_name, target_element_name, target_pad_name);
294 g_free (target_pad_name);
295 g_free (target_element_name);
297 gst_object_unref (target_element);
298 gst_object_unref (target_pad);
301 gst_object_unref (tmp_pad);
305 (dir == GST_PAD_SRC) ? "#ffaaaa" : ((dir ==
306 GST_PAD_SINK) ? "#aaaaff" : "#cccccc");
309 debug_dump_pad (pad, color_name, element_name, details, str, indent);
310 g_free (element_name);
314 string_append_field (GQuark field, const GValue * value, gpointer ptr)
316 GString *str = (GString *) ptr;
317 gchar *value_str = gst_value_serialize (value);
318 gchar *esc_value_str;
320 if (value_str == NULL) {
321 g_string_append_printf (str, " %18s: NULL\\l", g_quark_to_string (field));
325 /* some enums can become really long */
326 if (strlen (value_str) > 25) {
330 value_str[25] = '\0';
332 /* mirror any brackets and quotes */
333 if (value_str[0] == '<')
334 value_str[pos--] = '>';
335 if (value_str[0] == '[')
336 value_str[pos--] = ']';
337 if (value_str[0] == '(')
338 value_str[pos--] = ')';
339 if (value_str[0] == '{')
340 value_str[pos--] = '}';
341 if (value_str[0] == '"')
342 value_str[pos--] = '"';
344 value_str[pos--] = ' ';
346 value_str[pos--] = '.';
347 value_str[pos--] = '.';
348 value_str[pos--] = '.';
350 esc_value_str = g_strescape (value_str, NULL);
352 g_string_append_printf (str, " %18s: %s\\l", g_quark_to_string (field),
356 g_free (esc_value_str);
361 debug_dump_describe_caps (GstCaps * caps, GstDebugGraphDetails details)
365 if (details & GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS) {
367 if (gst_caps_is_any (caps) || gst_caps_is_empty (caps)) {
368 media = gst_caps_to_string (caps);
375 for (i = 0; i < gst_caps_get_size (caps); i++) {
377 STRUCTURE_ESTIMATED_STRING_LEN (gst_caps_get_structure (caps, i));
380 str = g_string_sized_new (slen);
381 for (i = 0; i < gst_caps_get_size (caps); i++) {
382 GstCapsFeatures *features = __gst_caps_get_features_unchecked (caps, i);
383 GstStructure *structure = gst_caps_get_structure (caps, i);
385 g_string_append (str, gst_structure_get_name (structure));
387 if (features && (gst_caps_features_is_any (features)
388 || !gst_caps_features_is_equal (features,
389 GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) {
390 g_string_append_c (str, '(');
391 priv_gst_caps_features_append_to_gstring (features, str);
392 g_string_append_c (str, ')');
394 g_string_append (str, "\\l");
396 gst_structure_foreach (structure, string_append_field, (gpointer) str);
399 media = g_string_free (str, FALSE);
403 if (GST_CAPS_IS_SIMPLE (caps))
405 g_strdup (gst_structure_get_name (gst_caps_get_structure (caps, 0)));
407 media = g_strdup ("*");
413 debug_dump_element_pad_link (GstPad * pad, GstElement * element,
414 GstDebugGraphDetails details, GString * str, const gint indent)
416 GstElement *peer_element;
418 GstCaps *caps, *peer_caps;
420 gchar *media_src = NULL, *media_sink = NULL;
421 gchar *pad_name, *element_name;
422 gchar *peer_pad_name, *peer_element_name;
423 const gchar *spc = MAKE_INDENT (indent);
425 if ((peer_pad = gst_pad_get_peer (pad))) {
426 if ((details & GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE) ||
427 (details & GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS)
429 caps = gst_pad_get_current_caps (pad);
431 caps = gst_pad_get_pad_template_caps (pad);
432 peer_caps = gst_pad_get_current_caps (peer_pad);
434 peer_caps = gst_pad_get_pad_template_caps (peer_pad);
436 media = debug_dump_describe_caps (caps, details);
437 /* check if peer caps are different */
438 if (peer_caps && !gst_caps_is_equal (caps, peer_caps)) {
441 tmp = debug_dump_describe_caps (peer_caps, details);
442 if (gst_pad_get_direction (pad) == GST_PAD_SRC) {
451 gst_caps_unref (peer_caps);
452 gst_caps_unref (caps);
455 pad_name = debug_dump_make_object_name (GST_OBJECT (pad));
457 element_name = debug_dump_make_object_name (GST_OBJECT (element));
459 element_name = g_strdup ("");
461 peer_pad_name = debug_dump_make_object_name (GST_OBJECT (peer_pad));
462 if ((peer_element = gst_pad_get_parent_element (peer_pad))) {
464 debug_dump_make_object_name (GST_OBJECT (peer_element));
466 peer_element_name = g_strdup ("");
471 g_string_append_printf (str, "%s%s_%s -> %s_%s [label=\"%s\"]\n", spc,
472 element_name, pad_name, peer_element_name, peer_pad_name, media);
474 } else if (media_src && media_sink) {
475 /* dot has some issues with placement of head and taillabels,
476 * we need an empty label to make space */
477 g_string_append_printf (str,
478 "%s%s_%s -> %s_%s [labeldistance=\"10\", labelangle=\"0\", "
480 "taillabel=\"%s\", headlabel=\"%s\"]\n",
481 spc, element_name, pad_name, peer_element_name, peer_pad_name,
482 media_src, media_sink);
486 g_string_append_printf (str, "%s%s_%s -> %s_%s\n", spc,
487 element_name, pad_name, peer_element_name, peer_pad_name);
491 g_free (element_name);
492 g_free (peer_pad_name);
493 g_free (peer_element_name);
495 gst_object_unref (peer_element);
496 gst_object_unref (peer_pad);
501 debug_dump_element_pads (GstIterator * pad_iter, GstPad * pad,
502 GstElement * element, GstDebugGraphDetails details, GString * str,
503 const gint indent, guint * num_pads, gchar * cluster_name,
504 gchar ** first_pad_name)
506 GValue item = { 0, };
508 const gchar *spc = MAKE_INDENT (indent);
512 switch (gst_iterator_next (pad_iter, &item)) {
513 case GST_ITERATOR_OK:
514 pad = g_value_get_object (&item);
516 g_string_append_printf (str, "%ssubgraph cluster_%s {\n", spc,
518 g_string_append_printf (str, "%s label=\"\";\n", spc);
519 g_string_append_printf (str, "%s style=\"invis\";\n", spc);
520 (*first_pad_name) = debug_dump_make_object_name (GST_OBJECT (pad));
522 debug_dump_element_pad (pad, element, details, str, indent);
524 g_value_reset (&item);
526 case GST_ITERATOR_RESYNC:
527 gst_iterator_resync (pad_iter);
529 case GST_ITERATOR_ERROR:
530 case GST_ITERATOR_DONE:
536 g_string_append_printf (str, "%s}\n\n", spc);
541 * debug_dump_element:
542 * @bin: the bin that should be analyzed
543 * @out: file to write to
544 * @indent: level of graph indentation
546 * Helper for gst_debug_bin_to_dot_file() to recursively dump a pipeline.
549 debug_dump_element (GstBin * bin, GstDebugGraphDetails details,
550 GString * str, const gint indent)
552 GstIterator *element_iter, *pad_iter;
553 gboolean elements_done, pads_done;
554 GValue item = { 0, };
555 GValue item2 = { 0, };
558 guint src_pads, sink_pads;
559 gchar *src_pad_name = NULL, *sink_pad_name = NULL;
561 gchar *state_name = NULL;
562 gchar *param_name = NULL;
563 const gchar *spc = MAKE_INDENT (indent);
565 element_iter = gst_bin_iterate_elements (bin);
566 elements_done = FALSE;
567 while (!elements_done) {
568 switch (gst_iterator_next (element_iter, &item)) {
569 case GST_ITERATOR_OK:
570 element = g_value_get_object (&item);
571 element_name = debug_dump_make_object_name (GST_OBJECT (element));
573 if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
574 state_name = debug_dump_get_element_state (GST_ELEMENT (element));
576 if (details & GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS) {
577 param_name = debug_dump_get_object_params (G_OBJECT (element),
581 g_string_append_printf (str, "%ssubgraph cluster_%s {\n", spc,
583 g_string_append_printf (str, "%s fontname=\"Bitstream Vera Sans\";\n",
585 g_string_append_printf (str, "%s fontsize=\"8\";\n", spc);
586 g_string_append_printf (str, "%s style=\"filled,rounded\";\n", spc);
587 g_string_append_printf (str, "%s color=black;\n", spc);
588 g_string_append_printf (str, "%s label=\"%s\\n%s%s%s\";\n", spc,
589 G_OBJECT_TYPE_NAME (element), GST_OBJECT_NAME (element),
590 (state_name ? state_name : ""), (param_name ? param_name : "")
601 src_pads = sink_pads = 0;
602 if ((pad_iter = gst_element_iterate_sink_pads (element))) {
603 gchar *cluster_name = g_strdup_printf ("%s_sink", element_name);
604 debug_dump_element_pads (pad_iter, pad, element, details, str,
605 indent + 1, &sink_pads, cluster_name, &sink_pad_name);
606 g_free (cluster_name);
607 gst_iterator_free (pad_iter);
609 if ((pad_iter = gst_element_iterate_src_pads (element))) {
610 gchar *cluster_name = g_strdup_printf ("%s_src", element_name);
611 debug_dump_element_pads (pad_iter, pad, element, details, str,
612 indent + 1, &src_pads, cluster_name, &src_pad_name);
613 g_free (cluster_name);
614 gst_iterator_free (pad_iter);
616 if (sink_pads && src_pads) {
617 /* add invisible link from first sink to first src pad */
618 g_string_append_printf (str,
619 "%s %s_%s -> %s_%s [style=\"invis\"];\n",
620 spc, element_name, sink_pad_name, element_name, src_pad_name);
622 g_free (sink_pad_name);
623 g_free (src_pad_name);
624 g_free (element_name);
625 sink_pad_name = src_pad_name = NULL;
626 if (GST_IS_BIN (element)) {
627 g_string_append_printf (str, "%s fillcolor=\"#ffffff\";\n", spc);
629 debug_dump_element (GST_BIN (element), details, str, indent + 1);
631 if (src_pads && !sink_pads)
632 g_string_append_printf (str, "%s fillcolor=\"#ffaaaa\";\n", spc);
633 else if (!src_pads && sink_pads)
634 g_string_append_printf (str, "%s fillcolor=\"#aaaaff\";\n", spc);
635 else if (src_pads && sink_pads)
636 g_string_append_printf (str, "%s fillcolor=\"#aaffaa\";\n", spc);
638 g_string_append_printf (str, "%s fillcolor=\"#ffffff\";\n", spc);
640 g_string_append_printf (str, "%s}\n\n", spc);
641 if ((pad_iter = gst_element_iterate_pads (element))) {
644 switch (gst_iterator_next (pad_iter, &item2)) {
645 case GST_ITERATOR_OK:
646 pad = g_value_get_object (&item2);
647 if (gst_pad_is_linked (pad)) {
648 if (gst_pad_get_direction (pad) == GST_PAD_SRC) {
649 debug_dump_element_pad_link (pad, element, details, str,
652 GstPad *peer_pad = gst_pad_get_peer (pad);
655 if (!GST_IS_GHOST_PAD (peer_pad)
656 && GST_IS_PROXY_PAD (peer_pad)) {
657 debug_dump_element_pad_link (peer_pad, NULL, details,
660 gst_object_unref (peer_pad);
664 g_value_reset (&item2);
666 case GST_ITERATOR_RESYNC:
667 gst_iterator_resync (pad_iter);
669 case GST_ITERATOR_ERROR:
670 case GST_ITERATOR_DONE:
675 g_value_unset (&item2);
676 gst_iterator_free (pad_iter);
678 g_value_reset (&item);
680 case GST_ITERATOR_RESYNC:
681 gst_iterator_resync (element_iter);
683 case GST_ITERATOR_ERROR:
684 case GST_ITERATOR_DONE:
685 elements_done = TRUE;
690 g_value_unset (&item);
691 gst_iterator_free (element_iter);
695 debug_dump_header (GstBin * bin, GstDebugGraphDetails details, GString * str)
697 gchar *state_name = NULL;
698 gchar *param_name = NULL;
700 if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
701 state_name = debug_dump_get_element_state (GST_ELEMENT (bin));
703 if (details & GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS) {
704 param_name = debug_dump_get_object_params (G_OBJECT (bin), details, NULL);
708 g_string_append_printf (str,
709 "digraph pipeline {\n"
711 " fontname=\"sans\";\n"
712 " fontsize=\"10\";\n"
716 " label=\"<%s>\\n%s%s%s\";\n"
717 " node [style=\"filled,rounded\", shape=box, fontsize=\"9\", fontname=\"sans\", margin=\"0.0,0.0\"];\n"
718 " edge [labelfontsize=\"6\", fontsize=\"9\", fontname=\"monospace\"];\n"
722 " margin=\"0.05,0.05\",\n"
723 " style=\"filled\",\n"
724 " label=\"Legend\\lElement-States: [~] void-pending, [0] null, [-] ready, [=] paused, [>] playing\\lPad-Activation: [-] none, [>] push, [<] pull\\lPad-Flags: [b]locked, [f]lushing, [b]locking; upper-case is set\\lPad-Task: [T] has started task, [t] has paused task\\l\",\n"
726 "\n", G_OBJECT_TYPE_NAME (bin), GST_OBJECT_NAME (bin),
727 (state_name ? state_name : ""), (param_name ? param_name : "")
737 debug_dump_footer (GString * str)
739 g_string_append_printf (str, "}\n");
743 * gst_debug_bin_to_dot_data:
744 * @bin: the top-level pipeline that should be analyzed
746 * To aid debugging applications one can use this method to obtain the whole
747 * network of gstreamer elements that form the pipeline into an dot file.
748 * This data can be processed with graphviz to get an image.
750 * Returns: (transfer full): a string containing the pipeline in graphviz
754 gst_debug_bin_to_dot_data (GstBin * bin, GstDebugGraphDetails details)
758 g_return_val_if_fail (GST_IS_BIN (bin), NULL);
760 str = g_string_new (NULL);
762 debug_dump_header (bin, details, str);
763 debug_dump_element (bin, details, str, 1);
764 debug_dump_footer (str);
766 return g_string_free (str, FALSE);
770 * gst_debug_bin_to_dot_file:
771 * @bin: the top-level pipeline that should be analyzed
772 * @file_name: output base filename (e.g. "myplayer")
774 * To aid debugging applications one can use this method to write out the whole
775 * network of gstreamer elements that form the pipeline into an dot file.
776 * This file can be processed with graphviz to get an image.
777 * <informalexample><programlisting>
778 * dot -Tpng -oimage.png graph_lowlevel.dot
779 * </programlisting></informalexample>
782 gst_debug_bin_to_dot_file (GstBin * bin, GstDebugGraphDetails details,
783 const gchar * file_name)
785 gchar *full_file_name = NULL;
788 g_return_if_fail (GST_IS_BIN (bin));
790 if (G_LIKELY (priv_gst_dump_dot_dir == NULL))
794 file_name = g_get_application_name ();
796 file_name = "unnamed";
799 full_file_name = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s.dot",
800 priv_gst_dump_dot_dir, file_name);
802 if ((out = fopen (full_file_name, "wb"))) {
805 buf = gst_debug_bin_to_dot_data (bin, details);
811 GST_INFO ("wrote bin graph to : '%s'", full_file_name);
813 GST_WARNING ("Failed to open file '%s' for writing: %s", full_file_name,
816 g_free (full_file_name);
820 * gst_debug_bin_to_dot_file_with_ts:
821 * @bin: the top-level pipeline that should be analyzed
822 * @file_name: output base filename (e.g. "myplayer")
824 * This works like gst_debug_bin_to_dot_file(), but adds the current timestamp
825 * to the filename, so that it can be used to take multiple snapshots.
828 gst_debug_bin_to_dot_file_with_ts (GstBin * bin,
829 GstDebugGraphDetails details, const gchar * file_name)
831 gchar *ts_file_name = NULL;
832 GstClockTime elapsed;
834 g_return_if_fail (GST_IS_BIN (bin));
837 file_name = g_get_application_name ();
839 file_name = "unnamed";
843 elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
844 gst_util_get_timestamp ());
846 /* we don't use GST_TIME_FORMAT as such filenames would fail on some
847 * filesystems like fat */
849 g_strdup_printf ("%u.%02u.%02u.%09u-%s", GST_TIME_ARGS (elapsed),
852 gst_debug_bin_to_dot_file (bin, details, ts_file_name);
853 g_free (ts_file_name);
855 #else /* !GST_DISABLE_GST_DEBUG */
856 #ifndef GST_REMOVE_DISABLED
858 gst_debug_bin_to_dot_file (GstBin * bin, GstDebugGraphDetails details,
859 const gchar * file_name)
864 gst_debug_bin_to_dot_file_with_ts (GstBin * bin, GstDebugGraphDetails details,
865 const gchar * file_name)
868 #endif /* GST_REMOVE_DISABLED */
869 #endif /* GST_DISABLE_GST_DEBUG */