2007-10-17 12:58:23 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2007 Stefan Kost <ensonic@users.sf.net>
|
|
|
|
*
|
|
|
|
* gstdebugutils.c: debugging and analysis utillities
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2007-11-22 15:59:01 +00:00
|
|
|
/* TODO:
|
|
|
|
* edge [ constraint=false ];
|
2008-07-12 09:59:32 +00:00
|
|
|
* this creates strange graphs ("minlen=0" is better)
|
|
|
|
* try puting src/sink ghostpads for each bin into invisible clusters
|
2009-01-01 21:27:06 +00:00
|
|
|
*
|
|
|
|
* for more compact nodes, try
|
|
|
|
* - changing node-shape from box into record
|
|
|
|
* - use labels like : element [ label="{element | <src> src | <sink> sink}"]
|
|
|
|
* - point to record-connectors : element1:src -> element2:sink
|
2009-05-13 08:03:27 +00:00
|
|
|
* - we use head/tail labels for pad-caps right now
|
2010-06-09 09:17:03 +00:00
|
|
|
* - this does not work well, as dot seems to not look at their size when
|
2009-05-13 08:03:27 +00:00
|
|
|
* doing the layout
|
|
|
|
* - we could add the caps to the pad itself, then we should use one line per
|
|
|
|
* caps (simple caps = one line)
|
2007-11-22 15:59:01 +00:00
|
|
|
*/
|
2007-10-17 12:58:23 +00:00
|
|
|
|
|
|
|
#include "gst_private.h"
|
2007-11-18 19:30:10 +00:00
|
|
|
#include "gstdebugutils.h"
|
|
|
|
|
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2007-10-17 12:58:23 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2008-01-05 13:45:22 +00:00
|
|
|
#include <errno.h>
|
2007-10-17 12:58:23 +00:00
|
|
|
|
|
|
|
#include "gstinfo.h"
|
|
|
|
#include "gstbin.h"
|
|
|
|
#include "gstobject.h"
|
|
|
|
#include "gstghostpad.h"
|
|
|
|
#include "gstpad.h"
|
|
|
|
#include "gstutils.h"
|
2009-03-11 08:27:16 +00:00
|
|
|
#include "gstvalue.h"
|
2007-10-17 12:58:23 +00:00
|
|
|
|
|
|
|
/*** PIPELINE GRAPHS **********************************************************/
|
|
|
|
|
2007-11-07 15:53:52 +00:00
|
|
|
const gchar *priv_gst_dump_dot_dir; /* NULL *//* set from gst.c */
|
|
|
|
|
2009-03-11 13:20:36 +00:00
|
|
|
const gchar spaces[] = {
|
|
|
|
" " /* 32 */
|
|
|
|
" " /* 64 */
|
|
|
|
" " /* 96 */
|
|
|
|
" " /* 128 */
|
|
|
|
};
|
|
|
|
|
2007-11-06 15:10:36 +00:00
|
|
|
extern GstClockTime _priv_gst_info_start_time;
|
2007-10-17 12:58:23 +00:00
|
|
|
|
|
|
|
static gchar *
|
|
|
|
debug_dump_make_object_name (GstObject * element)
|
|
|
|
{
|
|
|
|
return g_strcanon (g_strdup_printf ("%s_%p", GST_OBJECT_NAME (element),
|
|
|
|
element), G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "_", '_');
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
debug_dump_get_element_state (GstElement * element)
|
|
|
|
{
|
|
|
|
gchar *state_name = NULL;
|
|
|
|
const gchar *state_icons = "~0-=>";
|
|
|
|
GstState state = 0, pending = 0;
|
|
|
|
|
|
|
|
gst_element_get_state (element, &state, &pending, 0);
|
|
|
|
if (pending == GST_STATE_VOID_PENDING) {
|
|
|
|
state_name = g_strdup_printf ("\\n[%c]", state_icons[state]);
|
|
|
|
} else {
|
2009-03-11 08:27:16 +00:00
|
|
|
state_name = g_strdup_printf ("\\n[%c] -> [%c]", state_icons[state],
|
2007-10-17 12:58:23 +00:00
|
|
|
state_icons[pending]);
|
|
|
|
}
|
|
|
|
return state_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
debug_dump_get_element_params (GstElement * element)
|
|
|
|
{
|
|
|
|
gchar *param_name = NULL;
|
|
|
|
GParamSpec **properties, *property;
|
|
|
|
GValue value = { 0, };
|
|
|
|
guint i, number_of_properties;
|
|
|
|
gchar *tmp, *value_str;
|
|
|
|
|
|
|
|
/* get paramspecs and show non-default properties */
|
|
|
|
properties =
|
|
|
|
g_object_class_list_properties (G_OBJECT_CLASS (GST_ELEMENT_GET_CLASS
|
|
|
|
(element)), &number_of_properties);
|
|
|
|
if (properties) {
|
|
|
|
for (i = 0; i < number_of_properties; i++) {
|
|
|
|
property = properties[i];
|
|
|
|
|
|
|
|
/* ski some properties */
|
|
|
|
if (!(property->flags & G_PARAM_READABLE))
|
|
|
|
continue;
|
|
|
|
if (!strcmp (property->name, "name"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
g_value_init (&value, property->value_type);
|
|
|
|
g_object_get_property (G_OBJECT (element), property->name, &value);
|
|
|
|
if (!(g_param_value_defaults (property, &value))) {
|
|
|
|
tmp = g_strdup_value_contents (&value);
|
|
|
|
value_str = g_strescape (tmp, NULL);
|
|
|
|
g_free (tmp);
|
|
|
|
if (param_name) {
|
|
|
|
tmp = param_name;
|
|
|
|
param_name = g_strdup_printf ("%s\\n%s=%s",
|
|
|
|
tmp, property->name, value_str);
|
|
|
|
g_free (tmp);
|
|
|
|
} else {
|
|
|
|
param_name = g_strdup_printf ("\\n%s=%s", property->name, value_str);
|
|
|
|
}
|
|
|
|
g_free (value_str);
|
|
|
|
}
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
g_free (properties);
|
|
|
|
}
|
|
|
|
return param_name;
|
|
|
|
}
|
|
|
|
|
2009-05-13 08:03:27 +00:00
|
|
|
static void
|
2010-03-03 10:45:38 +00:00
|
|
|
debug_dump_pad (GstPad * pad, const gchar * color_name,
|
|
|
|
const gchar * element_name, GstDebugGraphDetails details, FILE * out,
|
|
|
|
const gint indent)
|
2009-05-13 08:03:27 +00:00
|
|
|
{
|
|
|
|
GstPadTemplate *pad_templ;
|
|
|
|
GstPadPresence presence;
|
2010-03-03 10:45:38 +00:00
|
|
|
gchar *pad_name;
|
|
|
|
const gchar *style_name;
|
2009-05-13 08:03:27 +00:00
|
|
|
const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)];
|
|
|
|
|
|
|
|
pad_name = debug_dump_make_object_name (GST_OBJECT (pad));
|
|
|
|
|
|
|
|
/* pad availability */
|
|
|
|
style_name = "filled,solid";
|
|
|
|
if ((pad_templ = gst_pad_get_pad_template (pad))) {
|
|
|
|
presence = GST_PAD_TEMPLATE_PRESENCE (pad_templ);
|
|
|
|
if (presence == GST_PAD_SOMETIMES) {
|
|
|
|
style_name = "filled,dotted";
|
|
|
|
} else if (presence == GST_PAD_REQUEST) {
|
|
|
|
style_name = "filled,dashed";
|
|
|
|
}
|
|
|
|
}
|
2009-10-25 19:35:09 +00:00
|
|
|
if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
|
|
|
|
gchar pad_flags[6];
|
|
|
|
const gchar *activation_mode = "-><";
|
|
|
|
|
|
|
|
/* check if pad flags */
|
|
|
|
pad_flags[0] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED) ? 'B' : 'b';
|
|
|
|
pad_flags[1] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING) ? 'F' : 'f';
|
|
|
|
pad_flags[2] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS) ? 'G' : 'g';
|
2010-02-26 07:29:23 +00:00
|
|
|
pad_flags[3] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS) ? 'S' : 's';
|
2009-10-25 19:35:09 +00:00
|
|
|
pad_flags[4] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING) ? 'B' : 'b';
|
|
|
|
pad_flags[5] = '\0';
|
|
|
|
|
|
|
|
fprintf (out,
|
|
|
|
"%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s\\n[%c][%s]\", height=\"0.2\", style=\"%s\"];\n",
|
|
|
|
spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
|
|
|
|
activation_mode[pad->mode], pad_flags, style_name);
|
|
|
|
} else {
|
|
|
|
fprintf (out,
|
|
|
|
"%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s\", height=\"0.2\", style=\"%s\"];\n",
|
|
|
|
spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
|
|
|
|
style_name);
|
|
|
|
}
|
2009-05-13 08:03:27 +00:00
|
|
|
|
|
|
|
g_free (pad_name);
|
|
|
|
}
|
|
|
|
|
2008-04-30 07:56:39 +00:00
|
|
|
static void
|
|
|
|
debug_dump_element_pad (GstPad * pad, GstElement * element,
|
|
|
|
GstDebugGraphDetails details, FILE * out, const gint indent)
|
|
|
|
{
|
|
|
|
GstElement *target_element;
|
|
|
|
GstPad *target_pad, *tmp_pad;
|
|
|
|
GstPadDirection dir;
|
2009-08-08 12:47:40 +00:00
|
|
|
gchar *element_name;
|
2009-05-13 08:03:27 +00:00
|
|
|
gchar *target_element_name;
|
2010-03-03 10:45:38 +00:00
|
|
|
const gchar *color_name;
|
2008-04-30 07:56:39 +00:00
|
|
|
|
|
|
|
dir = gst_pad_get_direction (pad);
|
|
|
|
element_name = debug_dump_make_object_name (GST_OBJECT (element));
|
|
|
|
if (GST_IS_GHOST_PAD (pad)) {
|
|
|
|
color_name =
|
|
|
|
(dir == GST_PAD_SRC) ? "#ffdddd" : ((dir ==
|
|
|
|
GST_PAD_SINK) ? "#ddddff" : "#ffffff");
|
|
|
|
/* output target-pad so that it belongs to this element */
|
|
|
|
if ((tmp_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad)))) {
|
|
|
|
if ((target_pad = gst_pad_get_peer (tmp_pad))) {
|
|
|
|
if ((target_element = gst_pad_get_parent_element (target_pad))) {
|
|
|
|
target_element_name =
|
|
|
|
debug_dump_make_object_name (GST_OBJECT (target_element));
|
|
|
|
} else {
|
2010-03-03 10:45:38 +00:00
|
|
|
target_element_name = g_strdup ("");
|
2008-04-30 07:56:39 +00:00
|
|
|
}
|
2009-10-25 19:35:09 +00:00
|
|
|
debug_dump_pad (target_pad, color_name, target_element_name, details,
|
|
|
|
out, indent);
|
2010-03-03 10:45:38 +00:00
|
|
|
g_free (target_element_name);
|
|
|
|
if (target_element)
|
2008-04-30 07:56:39 +00:00
|
|
|
gst_object_unref (target_element);
|
|
|
|
gst_object_unref (target_pad);
|
|
|
|
}
|
|
|
|
gst_object_unref (tmp_pad);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
color_name =
|
|
|
|
(dir == GST_PAD_SRC) ? "#ffaaaa" : ((dir ==
|
|
|
|
GST_PAD_SINK) ? "#aaaaff" : "#cccccc");
|
|
|
|
}
|
|
|
|
/* pads */
|
2009-10-25 19:35:09 +00:00
|
|
|
debug_dump_pad (pad, color_name, element_name, details, out, indent);
|
2008-04-30 07:56:39 +00:00
|
|
|
g_free (element_name);
|
|
|
|
}
|
|
|
|
|
2009-03-11 08:27:16 +00:00
|
|
|
static gboolean
|
|
|
|
string_append_field (GQuark field, const GValue * value, gpointer ptr)
|
|
|
|
{
|
|
|
|
GString *str = (GString *) ptr;
|
|
|
|
gchar *value_str = gst_value_serialize (value);
|
2010-06-25 18:23:22 +00:00
|
|
|
gchar *esc_value_str;
|
2009-03-11 08:27:16 +00:00
|
|
|
|
2009-03-11 13:20:36 +00:00
|
|
|
/* some enums can become really long */
|
|
|
|
if (strlen (value_str) > 25) {
|
|
|
|
gint pos = 24;
|
|
|
|
|
|
|
|
/* truncate */
|
|
|
|
value_str[25] = '\0';
|
|
|
|
|
2010-06-25 18:23:22 +00:00
|
|
|
/* mirror any brackets and quotes */
|
2009-03-11 13:20:36 +00:00
|
|
|
if (value_str[0] == '<')
|
|
|
|
value_str[pos--] = '>';
|
|
|
|
if (value_str[0] == '[')
|
|
|
|
value_str[pos--] = ']';
|
|
|
|
if (value_str[0] == '(')
|
|
|
|
value_str[pos--] = ')';
|
|
|
|
if (value_str[0] == '{')
|
|
|
|
value_str[pos--] = '}';
|
2010-06-25 18:23:22 +00:00
|
|
|
if (value_str[0] == '"')
|
|
|
|
value_str[pos--] = '"';
|
2009-03-11 13:20:36 +00:00
|
|
|
if (pos != 24)
|
|
|
|
value_str[pos--] = ' ';
|
|
|
|
/* elippsize */
|
|
|
|
value_str[pos--] = '.';
|
|
|
|
value_str[pos--] = '.';
|
|
|
|
value_str[pos--] = '.';
|
|
|
|
}
|
2010-06-25 18:23:22 +00:00
|
|
|
esc_value_str = g_strescape (value_str, NULL);
|
|
|
|
|
2009-03-11 13:20:36 +00:00
|
|
|
g_string_append_printf (str, " %18s: %s\\l", g_quark_to_string (field),
|
2010-06-25 18:23:22 +00:00
|
|
|
esc_value_str);
|
2009-03-11 08:27:16 +00:00
|
|
|
|
|
|
|
g_free (value_str);
|
2010-06-25 18:23:22 +00:00
|
|
|
g_free (esc_value_str);
|
2009-03-11 08:27:16 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-03-07 22:27:26 +00:00
|
|
|
static gchar *
|
2010-03-03 10:45:38 +00:00
|
|
|
debug_dump_describe_caps (GstCaps * caps, GstDebugGraphDetails details)
|
2009-03-07 22:27:26 +00:00
|
|
|
{
|
|
|
|
gchar *media = NULL;
|
|
|
|
|
|
|
|
if (details & GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS) {
|
2009-03-11 08:27:16 +00:00
|
|
|
|
|
|
|
if (gst_caps_is_any (caps) || gst_caps_is_empty (caps)) {
|
|
|
|
media = gst_caps_to_string (caps);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
GString *str = NULL;
|
|
|
|
guint i;
|
|
|
|
guint slen = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
2009-03-11 13:20:36 +00:00
|
|
|
slen += 25 +
|
2009-03-11 08:27:16 +00:00
|
|
|
STRUCTURE_ESTIMATED_STRING_LEN (gst_caps_get_structure (caps, i));
|
2009-03-07 22:27:26 +00:00
|
|
|
}
|
|
|
|
|
2009-03-11 08:27:16 +00:00
|
|
|
str = g_string_sized_new (slen);
|
|
|
|
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
|
|
|
GstStructure *structure = gst_caps_get_structure (caps, i);
|
|
|
|
|
|
|
|
g_string_append (str, gst_structure_get_name (structure));
|
|
|
|
g_string_append (str, "\\l");
|
|
|
|
|
|
|
|
gst_structure_foreach (structure, string_append_field, (gpointer) str);
|
|
|
|
}
|
|
|
|
|
|
|
|
media = g_string_free (str, FALSE);
|
|
|
|
}
|
2009-03-07 22:27:26 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
if (GST_CAPS_IS_SIMPLE (caps))
|
|
|
|
media =
|
2010-03-03 10:45:38 +00:00
|
|
|
g_strdup (gst_structure_get_name (gst_caps_get_structure (caps, 0)));
|
2009-03-07 22:27:26 +00:00
|
|
|
else
|
2010-03-03 10:45:38 +00:00
|
|
|
media = g_strdup ("*");
|
2009-03-07 22:27:26 +00:00
|
|
|
}
|
|
|
|
return media;
|
|
|
|
}
|
|
|
|
|
2008-04-30 07:56:39 +00:00
|
|
|
static void
|
|
|
|
debug_dump_element_pad_link (GstPad * pad, GstElement * element,
|
|
|
|
GstDebugGraphDetails details, FILE * out, const gint indent)
|
|
|
|
{
|
|
|
|
GstElement *peer_element, *target_element;
|
|
|
|
GstPad *peer_pad, *target_pad, *tmp_pad;
|
2009-03-07 22:27:26 +00:00
|
|
|
GstCaps *caps, *peer_caps;
|
2008-04-30 07:56:39 +00:00
|
|
|
gchar *media = NULL;
|
2009-03-11 13:20:36 +00:00
|
|
|
gchar *media_src = NULL, *media_sink = NULL;
|
2008-04-30 07:56:39 +00:00
|
|
|
gchar *pad_name, *element_name;
|
|
|
|
gchar *peer_pad_name, *peer_element_name;
|
|
|
|
gchar *target_pad_name, *target_element_name;
|
2009-03-11 13:20:36 +00:00
|
|
|
const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)];
|
2008-04-30 07:56:39 +00:00
|
|
|
|
|
|
|
if ((peer_pad = gst_pad_get_peer (pad))) {
|
|
|
|
if ((details & GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE) ||
|
|
|
|
(details & GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS)
|
|
|
|
) {
|
2010-03-03 10:45:38 +00:00
|
|
|
caps = gst_pad_get_negotiated_caps (pad);
|
|
|
|
if (!caps)
|
|
|
|
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
|
|
|
peer_caps = gst_pad_get_negotiated_caps (peer_pad);
|
|
|
|
if (!peer_caps)
|
|
|
|
peer_caps = gst_caps_copy (gst_pad_get_pad_template_caps (peer_pad));
|
|
|
|
|
|
|
|
media = debug_dump_describe_caps (caps, details);
|
|
|
|
/* check if peer caps are different */
|
|
|
|
if (peer_caps && !gst_caps_is_equal (caps, peer_caps)) {
|
|
|
|
gchar *tmp;
|
|
|
|
|
|
|
|
tmp = debug_dump_describe_caps (peer_caps, details);
|
|
|
|
if (gst_pad_get_direction (pad) == GST_PAD_SRC) {
|
|
|
|
media_src = media;
|
|
|
|
media_sink = tmp;
|
|
|
|
} else {
|
|
|
|
media_src = tmp;
|
|
|
|
media_sink = media;
|
2008-04-30 07:56:39 +00:00
|
|
|
}
|
2010-03-03 10:45:38 +00:00
|
|
|
media = NULL;
|
2008-04-30 07:56:39 +00:00
|
|
|
}
|
2010-03-03 10:45:38 +00:00
|
|
|
gst_caps_unref (peer_caps);
|
|
|
|
gst_caps_unref (caps);
|
2008-04-30 07:56:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pad_name = debug_dump_make_object_name (GST_OBJECT (pad));
|
|
|
|
if (element) {
|
|
|
|
element_name = debug_dump_make_object_name (GST_OBJECT (element));
|
|
|
|
} else {
|
2010-03-03 10:45:38 +00:00
|
|
|
element_name = g_strdup ("");
|
2008-04-30 07:56:39 +00:00
|
|
|
}
|
|
|
|
peer_pad_name = debug_dump_make_object_name (GST_OBJECT (peer_pad));
|
|
|
|
if ((peer_element = gst_pad_get_parent_element (peer_pad))) {
|
|
|
|
peer_element_name =
|
|
|
|
debug_dump_make_object_name (GST_OBJECT (peer_element));
|
|
|
|
} else {
|
2010-03-03 10:45:38 +00:00
|
|
|
peer_element_name = g_strdup ("");
|
2008-04-30 07:56:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_IS_GHOST_PAD (pad)) {
|
|
|
|
if ((tmp_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad)))) {
|
|
|
|
if ((target_pad = gst_pad_get_peer (tmp_pad))) {
|
|
|
|
target_pad_name =
|
|
|
|
debug_dump_make_object_name (GST_OBJECT (target_pad));
|
|
|
|
if ((target_element = gst_pad_get_parent_element (target_pad))) {
|
|
|
|
target_element_name =
|
|
|
|
debug_dump_make_object_name (GST_OBJECT (target_element));
|
|
|
|
} else {
|
2010-03-03 10:45:38 +00:00
|
|
|
target_element_name = g_strdup ("");
|
2008-04-30 07:56:39 +00:00
|
|
|
}
|
|
|
|
/* src ghostpad relationship */
|
2008-07-12 09:59:32 +00:00
|
|
|
fprintf (out, "%s%s_%s -> %s_%s [style=dashed, minlen=0]\n", spc,
|
2008-04-30 07:56:39 +00:00
|
|
|
target_element_name, target_pad_name, element_name, pad_name);
|
|
|
|
|
|
|
|
g_free (target_pad_name);
|
2010-03-03 10:45:38 +00:00
|
|
|
g_free (target_element_name);
|
|
|
|
if (target_element)
|
2008-04-30 07:56:39 +00:00
|
|
|
gst_object_unref (target_element);
|
|
|
|
gst_object_unref (target_pad);
|
|
|
|
}
|
|
|
|
gst_object_unref (tmp_pad);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (GST_IS_GHOST_PAD (peer_pad)) {
|
|
|
|
if ((tmp_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (peer_pad)))) {
|
|
|
|
if ((target_pad = gst_pad_get_peer (tmp_pad))) {
|
|
|
|
target_pad_name =
|
|
|
|
debug_dump_make_object_name (GST_OBJECT (target_pad));
|
|
|
|
if ((target_element = gst_pad_get_parent_element (target_pad))) {
|
|
|
|
target_element_name =
|
|
|
|
debug_dump_make_object_name (GST_OBJECT (target_element));
|
|
|
|
} else {
|
2010-03-03 10:45:38 +00:00
|
|
|
target_element_name = g_strdup ("");
|
2008-04-30 07:56:39 +00:00
|
|
|
}
|
|
|
|
/* sink ghostpad relationship */
|
2008-07-12 09:59:32 +00:00
|
|
|
fprintf (out, "%s%s_%s -> %s_%s [style=dashed, minlen=0]\n", spc,
|
2008-04-30 07:56:39 +00:00
|
|
|
peer_element_name, peer_pad_name,
|
|
|
|
target_element_name, target_pad_name);
|
|
|
|
/* FIXME: we are missing links from the proxy pad
|
|
|
|
* theoretically we need to:
|
|
|
|
* pad=gst_object_ref(target_pad);
|
|
|
|
* goto line 280: if ((peer_pad = gst_pad_get_peer (pad)))
|
2009-03-11 13:20:36 +00:00
|
|
|
* as this would be ugly we need to refactor ...
|
2008-04-30 07:56:39 +00:00
|
|
|
*/
|
|
|
|
debug_dump_element_pad_link (target_pad, target_element, details, out,
|
|
|
|
indent);
|
|
|
|
g_free (target_pad_name);
|
2010-03-03 10:45:38 +00:00
|
|
|
g_free (target_element_name);
|
|
|
|
if (target_element)
|
2008-04-30 07:56:39 +00:00
|
|
|
gst_object_unref (target_element);
|
|
|
|
gst_object_unref (target_pad);
|
|
|
|
}
|
|
|
|
gst_object_unref (tmp_pad);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pad link */
|
|
|
|
if (media) {
|
|
|
|
fprintf (out, "%s%s_%s -> %s_%s [label=\"%s\"]\n", spc,
|
|
|
|
element_name, pad_name, peer_element_name, peer_pad_name, media);
|
2010-03-03 10:45:38 +00:00
|
|
|
g_free (media);
|
2009-03-11 13:20:36 +00:00
|
|
|
} else if (media_src && media_sink) {
|
|
|
|
/* dot has some issues with placement of head and taillabels,
|
|
|
|
* we need an empty label to make space */
|
2009-05-12 21:29:57 +00:00
|
|
|
fprintf (out, "%s%s_%s -> %s_%s [labeldistance=\"10\", labelangle=\"0\", "
|
|
|
|
"label=\" \", "
|
2009-03-11 13:20:36 +00:00
|
|
|
"headlabel=\"%s\", taillabel=\"%s\"]\n",
|
|
|
|
spc, element_name, pad_name, peer_element_name, peer_pad_name,
|
|
|
|
media_src, media_sink);
|
2010-03-03 10:45:38 +00:00
|
|
|
g_free (media_src);
|
|
|
|
g_free (media_sink);
|
2008-04-30 07:56:39 +00:00
|
|
|
} else {
|
|
|
|
fprintf (out, "%s%s_%s -> %s_%s\n", spc,
|
|
|
|
element_name, pad_name, peer_element_name, peer_pad_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (pad_name);
|
2010-03-03 10:45:38 +00:00
|
|
|
g_free (element_name);
|
2008-04-30 07:56:39 +00:00
|
|
|
g_free (peer_pad_name);
|
2010-03-03 10:45:38 +00:00
|
|
|
g_free (peer_element_name);
|
|
|
|
if (peer_element)
|
2008-04-30 07:56:39 +00:00
|
|
|
gst_object_unref (peer_element);
|
|
|
|
gst_object_unref (peer_pad);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-17 12:58:23 +00:00
|
|
|
/*
|
|
|
|
* debug_dump_element:
|
|
|
|
* @bin: the bin that should be analyzed
|
|
|
|
* @out: file to write to
|
|
|
|
* @indent: level of graph indentation
|
|
|
|
*
|
|
|
|
* Helper for _gst_debug_bin_to_dot_file() to recursively dump a pipeline.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
debug_dump_element (GstBin * bin, GstDebugGraphDetails details, FILE * out,
|
|
|
|
const gint indent)
|
|
|
|
{
|
|
|
|
GstIterator *element_iter, *pad_iter;
|
|
|
|
gboolean elements_done, pads_done;
|
2008-04-30 07:56:39 +00:00
|
|
|
GstElement *element;
|
|
|
|
GstPad *pad;
|
2007-10-17 12:58:23 +00:00
|
|
|
GstPadDirection dir;
|
|
|
|
guint src_pads, sink_pads;
|
2008-04-30 07:56:39 +00:00
|
|
|
gchar *element_name;
|
2007-10-17 12:58:23 +00:00
|
|
|
gchar *state_name = NULL;
|
|
|
|
gchar *param_name = NULL;
|
2009-03-11 13:20:36 +00:00
|
|
|
const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)];
|
2007-10-17 12:58:23 +00:00
|
|
|
|
|
|
|
element_iter = gst_bin_iterate_elements (bin);
|
|
|
|
elements_done = FALSE;
|
|
|
|
while (!elements_done) {
|
|
|
|
switch (gst_iterator_next (element_iter, (gpointer) & element)) {
|
|
|
|
case GST_ITERATOR_OK:
|
|
|
|
element_name = debug_dump_make_object_name (GST_OBJECT (element));
|
|
|
|
|
|
|
|
if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
|
|
|
|
state_name = debug_dump_get_element_state (GST_ELEMENT (element));
|
|
|
|
}
|
|
|
|
if (details & GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS) {
|
|
|
|
param_name = debug_dump_get_element_params (GST_ELEMENT (element));
|
|
|
|
}
|
|
|
|
/* elements */
|
|
|
|
fprintf (out, "%ssubgraph cluster_%s {\n", spc, element_name);
|
|
|
|
fprintf (out, "%s fontname=\"Bitstream Vera Sans\";\n", spc);
|
|
|
|
fprintf (out, "%s fontsize=\"8\";\n", spc);
|
|
|
|
fprintf (out, "%s style=filled;\n", spc);
|
|
|
|
fprintf (out, "%s color=black;\n\n", spc);
|
2008-07-12 09:59:32 +00:00
|
|
|
fprintf (out, "%s label=\"%s\\n%s%s%s\";\n", spc,
|
2007-10-17 12:58:23 +00:00
|
|
|
G_OBJECT_TYPE_NAME (element), GST_OBJECT_NAME (element),
|
|
|
|
(state_name ? state_name : ""), (param_name ? param_name : "")
|
|
|
|
);
|
|
|
|
if (state_name) {
|
|
|
|
g_free (state_name);
|
|
|
|
state_name = NULL;
|
|
|
|
}
|
|
|
|
if (param_name) {
|
|
|
|
g_free (param_name);
|
|
|
|
param_name = NULL;
|
|
|
|
}
|
|
|
|
g_free (element_name);
|
|
|
|
|
|
|
|
src_pads = sink_pads = 0;
|
|
|
|
if ((pad_iter = gst_element_iterate_pads (element))) {
|
|
|
|
pads_done = FALSE;
|
|
|
|
while (!pads_done) {
|
|
|
|
switch (gst_iterator_next (pad_iter, (gpointer) & pad)) {
|
|
|
|
case GST_ITERATOR_OK:
|
2008-04-30 07:56:39 +00:00
|
|
|
debug_dump_element_pad (pad, element, details, out, indent);
|
2007-10-17 12:58:23 +00:00
|
|
|
dir = gst_pad_get_direction (pad);
|
|
|
|
if (dir == GST_PAD_SRC)
|
|
|
|
src_pads++;
|
|
|
|
else if (dir == GST_PAD_SINK)
|
|
|
|
sink_pads++;
|
|
|
|
gst_object_unref (pad);
|
|
|
|
break;
|
|
|
|
case GST_ITERATOR_RESYNC:
|
|
|
|
gst_iterator_resync (pad_iter);
|
|
|
|
break;
|
|
|
|
case GST_ITERATOR_ERROR:
|
|
|
|
case GST_ITERATOR_DONE:
|
|
|
|
pads_done = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_iterator_free (pad_iter);
|
|
|
|
}
|
|
|
|
if (GST_IS_BIN (element)) {
|
|
|
|
fprintf (out, "%s fillcolor=\"#ffffff\";\n", spc);
|
|
|
|
/* recurse */
|
|
|
|
debug_dump_element (GST_BIN (element), details, out, indent + 1);
|
|
|
|
} else {
|
|
|
|
if (src_pads && !sink_pads)
|
|
|
|
fprintf (out, "%s fillcolor=\"#ffaaaa\";\n", spc);
|
|
|
|
else if (!src_pads && sink_pads)
|
|
|
|
fprintf (out, "%s fillcolor=\"#aaaaff\";\n", spc);
|
|
|
|
else if (src_pads && sink_pads)
|
|
|
|
fprintf (out, "%s fillcolor=\"#aaffaa\";\n", spc);
|
|
|
|
else
|
|
|
|
fprintf (out, "%s fillcolor=\"#ffffff\";\n", spc);
|
|
|
|
}
|
|
|
|
fprintf (out, "%s}\n\n", spc);
|
|
|
|
if ((pad_iter = gst_element_iterate_pads (element))) {
|
|
|
|
pads_done = FALSE;
|
|
|
|
while (!pads_done) {
|
|
|
|
switch (gst_iterator_next (pad_iter, (gpointer) & pad)) {
|
|
|
|
case GST_ITERATOR_OK:
|
|
|
|
if (gst_pad_is_linked (pad)
|
|
|
|
&& gst_pad_get_direction (pad) == GST_PAD_SRC) {
|
2008-04-30 07:56:39 +00:00
|
|
|
debug_dump_element_pad_link (pad, element, details, out,
|
|
|
|
indent);
|
2007-10-17 12:58:23 +00:00
|
|
|
}
|
|
|
|
gst_object_unref (pad);
|
|
|
|
break;
|
|
|
|
case GST_ITERATOR_RESYNC:
|
|
|
|
gst_iterator_resync (pad_iter);
|
|
|
|
break;
|
|
|
|
case GST_ITERATOR_ERROR:
|
|
|
|
case GST_ITERATOR_DONE:
|
|
|
|
pads_done = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_iterator_free (pad_iter);
|
|
|
|
}
|
|
|
|
gst_object_unref (element);
|
|
|
|
break;
|
|
|
|
case GST_ITERATOR_RESYNC:
|
|
|
|
gst_iterator_resync (element_iter);
|
|
|
|
break;
|
|
|
|
case GST_ITERATOR_ERROR:
|
|
|
|
case GST_ITERATOR_DONE:
|
|
|
|
elements_done = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_iterator_free (element_iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _gst_debug_bin_to_dot_file:
|
|
|
|
* @bin: the top-level pipeline that should be analyzed
|
2007-10-29 13:46:25 +00:00
|
|
|
* @file_name: output base filename (e.g. "myplayer")
|
2007-10-17 12:58:23 +00:00
|
|
|
*
|
|
|
|
* To aid debugging applications one can use this method to write out the whole
|
|
|
|
* network of gstreamer elements that form the pipeline into an dot file.
|
|
|
|
* This file can be processed with graphviz to get an image.
|
|
|
|
* <informalexample><programlisting>
|
|
|
|
* dot -Tpng -oimage.png graph_lowlevel.dot
|
|
|
|
* </programlisting></informalexample>
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
_gst_debug_bin_to_dot_file (GstBin * bin, GstDebugGraphDetails details,
|
|
|
|
const gchar * file_name)
|
|
|
|
{
|
2007-10-29 13:46:25 +00:00
|
|
|
gchar *full_file_name = NULL;
|
2007-10-17 12:58:23 +00:00
|
|
|
FILE *out;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
|
|
|
|
2007-11-07 15:53:52 +00:00
|
|
|
if (G_LIKELY (priv_gst_dump_dot_dir == NULL))
|
2007-10-17 12:58:23 +00:00
|
|
|
return;
|
|
|
|
|
2007-10-29 13:46:25 +00:00
|
|
|
if (!file_name) {
|
|
|
|
file_name = g_get_application_name ();
|
|
|
|
if (!file_name)
|
|
|
|
file_name = "unnamed";
|
|
|
|
}
|
|
|
|
|
|
|
|
full_file_name = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s.dot",
|
2007-11-07 15:53:52 +00:00
|
|
|
priv_gst_dump_dot_dir, file_name);
|
2007-10-29 13:46:25 +00:00
|
|
|
|
|
|
|
if ((out = fopen (full_file_name, "wb"))) {
|
2007-10-17 12:58:23 +00:00
|
|
|
gchar *state_name = NULL;
|
|
|
|
gchar *param_name = NULL;
|
|
|
|
|
|
|
|
if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
|
|
|
|
state_name = debug_dump_get_element_state (GST_ELEMENT (bin));
|
|
|
|
}
|
|
|
|
if (details & GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS) {
|
|
|
|
param_name = debug_dump_get_element_params (GST_ELEMENT (bin));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write header */
|
|
|
|
fprintf (out,
|
|
|
|
"digraph pipeline {\n"
|
|
|
|
" rankdir=LR;\n"
|
2009-03-11 08:27:16 +00:00
|
|
|
" fontname=\"sans\";\n"
|
2009-05-12 21:29:57 +00:00
|
|
|
" fontsize=\"10\";\n"
|
2007-10-17 12:58:23 +00:00
|
|
|
" labelloc=t;\n"
|
2007-11-22 15:59:01 +00:00
|
|
|
" nodesep=.1;\n"
|
|
|
|
" ranksep=.2;\n"
|
2007-10-17 12:58:23 +00:00
|
|
|
" label=\"<%s>\\n%s%s%s\";\n"
|
2009-05-12 21:29:57 +00:00
|
|
|
" node [style=filled, shape=box, fontsize=\"9\", fontname=\"sans\", margin=\"0.0,0.0\"];\n"
|
|
|
|
" edge [labelfontsize=\"6\", fontsize=\"9\", fontname=\"monospace\"];\n"
|
2007-10-17 12:58:23 +00:00
|
|
|
"\n", G_OBJECT_TYPE_NAME (bin), GST_OBJECT_NAME (bin),
|
|
|
|
(state_name ? state_name : ""), (param_name ? param_name : "")
|
|
|
|
);
|
|
|
|
if (state_name)
|
|
|
|
g_free (state_name);
|
|
|
|
if (param_name)
|
|
|
|
g_free (param_name);
|
|
|
|
|
|
|
|
debug_dump_element (bin, details, out, 1);
|
|
|
|
|
|
|
|
/* write footer */
|
|
|
|
fprintf (out, "}\n");
|
|
|
|
fclose (out);
|
2007-12-30 12:22:49 +00:00
|
|
|
GST_INFO ("wrote bin graph to : '%s'", full_file_name);
|
|
|
|
} else {
|
2008-01-05 13:45:22 +00:00
|
|
|
GST_WARNING ("Failed to open file '%s' for writing: %s", full_file_name,
|
|
|
|
g_strerror (errno));
|
2007-10-17 12:58:23 +00:00
|
|
|
}
|
2007-10-29 13:46:25 +00:00
|
|
|
g_free (full_file_name);
|
2007-10-17 12:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _gst_debug_bin_to_dot_file_with_ts:
|
|
|
|
* @bin: the top-level pipeline that should be analyzed
|
2007-10-29 13:46:25 +00:00
|
|
|
* @file_name: output base filename (e.g. "myplayer")
|
2007-10-17 12:58:23 +00:00
|
|
|
*
|
2007-10-29 13:46:25 +00:00
|
|
|
* This works like _gst_debug_bin_to_dot_file(), but adds the current timestamp
|
|
|
|
* to the filename, so that it can be used to take multiple snapshots.
|
2007-10-17 12:58:23 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
_gst_debug_bin_to_dot_file_with_ts (GstBin * bin, GstDebugGraphDetails details,
|
2007-10-29 13:46:25 +00:00
|
|
|
const gchar * file_name)
|
2007-10-17 12:58:23 +00:00
|
|
|
{
|
2007-10-29 13:46:25 +00:00
|
|
|
gchar *ts_file_name = NULL;
|
2007-12-11 20:23:58 +00:00
|
|
|
GstClockTime elapsed;
|
2007-10-17 12:58:23 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_BIN (bin));
|
2007-10-29 13:46:25 +00:00
|
|
|
|
|
|
|
if (!file_name) {
|
|
|
|
file_name = g_get_application_name ();
|
|
|
|
if (!file_name)
|
|
|
|
file_name = "unnamed";
|
2007-10-17 12:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add timestamp */
|
2007-12-11 20:23:58 +00:00
|
|
|
elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
|
|
|
|
gst_util_get_timestamp ());
|
2009-03-09 14:01:20 +00:00
|
|
|
|
|
|
|
/* we don't use GST_TIME_FORMAT as such filenames would fail on some
|
|
|
|
* filesystems like fat */
|
2007-10-29 13:46:25 +00:00
|
|
|
ts_file_name =
|
2009-03-09 14:01:20 +00:00
|
|
|
g_strdup_printf ("%u.%02u.%02u.%09u-%s", GST_TIME_ARGS (elapsed),
|
2007-10-29 13:46:25 +00:00
|
|
|
file_name);
|
2007-10-17 12:58:23 +00:00
|
|
|
|
2007-10-29 13:46:25 +00:00
|
|
|
_gst_debug_bin_to_dot_file (bin, details, ts_file_name);
|
|
|
|
g_free (ts_file_name);
|
2007-10-17 12:58:23 +00:00
|
|
|
}
|
2009-03-23 13:18:21 +00:00
|
|
|
#else /* !GST_DISABLE_GST_DEBUG */
|
|
|
|
#ifndef GST_REMOVE_DISABLED
|
|
|
|
void
|
|
|
|
_gst_debug_bin_to_dot_file (GstBin * bin, GstDebugGraphDetails details,
|
|
|
|
const gchar * file_name)
|
|
|
|
{
|
|
|
|
}
|
2007-10-17 12:58:23 +00:00
|
|
|
|
2009-03-23 13:18:21 +00:00
|
|
|
void
|
|
|
|
_gst_debug_bin_to_dot_file_with_ts (GstBin * bin, GstDebugGraphDetails details,
|
|
|
|
const gchar * file_name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* GST_REMOVE_DISABLED */
|
2007-10-17 12:58:23 +00:00
|
|
|
#endif /* GST_DISABLE_GST_DEBUG */
|