+2007-10-29 Stefan Kost <ensonic@users.sf.net>
+
+ * docs/gst/running.xml:
+ * gst/gst.c:
+ * gst/gstdebugutils.c:
+ * gst/gstdebugutils.h:
+ * tools/gst-launch.c:
+ Improve bin graph dumping, by using the envvar to specify a path.
+ Rename the envvar to GST_DEBUG_DUMP_DOT_DIR.
+
2007-10-29 Tim-Philipp Müller <tim at centricular dot net>
* plugins/elements/gsttypefindelement.c:
</formalpara>
-<formalpara id="GST_DEBUG_DUMP_DOT_FILES">
- <title><envar>GST_DEBUG_DUMP_DOT_FILES</envar></title>
+<formalpara id="GST_DEBUG_DUMP_DOT_DIR">
+ <title><envar>GST_DEBUG_DUMP_DOT_DIR</envar></title>
<para>
-Set this environment variable to any value ("1" typically) to turn on all
-#GST_DEBUG_BIN_TO_DOT_FILE or #GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS calls.
+Set this environment variable to a path to turn on all
+#GST_DEBUG_BIN_TO_DOT_FILE or #GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS calls
+and have the dot files in that location.
</para>
</formalpara>
#endif
extern gint _gst_trace_on;
-extern gboolean _gst_debug_dump_dot_files_on;
+extern const gchar *_gst_debug_dump_dot_dir;
/* defaults */
#ifdef HAVE_FORK
parse_debug_list (debug_list);
}
- if (g_getenv ("GST_DEBUG_DUMP_DOT_FILES") != NULL)
- _gst_debug_dump_dot_files_on = TRUE;
+ _gst_debug_dump_dot_dir = g_getenv ("GST_DEBUG_DUMP_DOT_DIR");
}
#endif
/* This is the earliest we can make stuff show up in the logs.
/*** PIPELINE GRAPHS **********************************************************/
-gboolean _gst_debug_dump_dot_files_on = FALSE;
+const gchar *_gst_debug_dump_dot_dir = NULL;
extern GstClockTime _gst_info_start_time;
static gchar *
/*
* _gst_debug_bin_to_dot_file:
* @bin: the top-level pipeline that should be analyzed
- * @file_name: output filename (e.g. "/tmp/metadata.dot")
+ * @file_name: output base filename (e.g. "myplayer")
*
* 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.
_gst_debug_bin_to_dot_file (GstBin * bin, GstDebugGraphDetails details,
const gchar * file_name)
{
+ gchar *full_file_name = NULL;
FILE *out;
g_return_if_fail (GST_IS_BIN (bin));
- g_return_if_fail (file_name != NULL);
- if (!_gst_debug_dump_dot_files_on)
+ if (!_gst_debug_dump_dot_dir)
return;
- if ((out = fopen (file_name, "wb"))) {
+ 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",
+ _gst_debug_dump_dot_dir, file_name);
+
+ if ((out = fopen (full_file_name, "wb"))) {
gchar *state_name = NULL;
gchar *param_name = NULL;
fprintf (out, "}\n");
fclose (out);
}
- GST_INFO ("wrote bin graph to : '%s'", file_name);
+ GST_INFO ("wrote bin graph to : '%s'", full_file_name);
+ g_free (full_file_name);
}
/*
* _gst_debug_bin_to_dot_file_with_ts:
* @bin: the top-level pipeline that should be analyzed
- * @file_tmpl: output filename template
- * (e.g. "/tmp/metadata.%" GST_TIME_FORMAT ".dot")
+ * @file_name: output base filename (e.g. "myplayer")
*
- * This works like _gst_debug_bin_to_dot_file(), but fills the filename template
- * with the timestamp, so that it can be used to take multiple snapshots.
+ * 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.
*/
void
_gst_debug_bin_to_dot_file_with_ts (GstBin * bin, GstDebugGraphDetails details,
- const gchar * file_tmpl)
+ const gchar * file_name)
{
- gchar *file_name = NULL;
- const gchar *pos;
+ gchar *ts_file_name = NULL;
GTimeVal now;
GstClockTime elapsed;
- guint fmt_ct = 0;
g_return_if_fail (GST_IS_BIN (bin));
- g_return_if_fail (file_tmpl != NULL);
-
- /* check file-name template */
- pos = strchr (file_tmpl, '%');
- if (pos) {
- do {
- pos++;
- if (*pos != '\0') {
- if (*pos != '%')
- fmt_ct++;
- pos++;
- }
- pos = strchr (pos, '%');
- } while (pos);
- }
- if (fmt_ct == 0) {
- GST_WARNING ("file template has no valid placeholder");
- return;
- } else if (fmt_ct != 4) {
- GST_WARNING ("file template must have 4 placeholders, but has %d", fmt_ct);
- return;
+
+ if (!file_name) {
+ file_name = g_get_application_name ();
+ if (!file_name)
+ file_name = "unnamed";
}
/* add timestamp */
g_get_current_time (&now);
elapsed = GST_TIMEVAL_TO_TIME (now) - _gst_info_start_time;
- file_name = g_strdup_printf (file_tmpl, GST_TIME_ARGS (elapsed));
+ ts_file_name =
+ g_strdup_printf ("%" GST_TIME_FORMAT "-%s", GST_TIME_ARGS (elapsed),
+ file_name);
- _gst_debug_bin_to_dot_file (bin, details, file_name);
- g_free (file_name);
+ _gst_debug_bin_to_dot_file (bin, details, ts_file_name);
+ g_free (ts_file_name);
}
#endif /* GST_DISABLE_GST_DEBUG */
* GST_DEBUG_BIN_TO_DOT_FILE:
* @bin: the top-level pipeline that should be analyzed
* @details: graph-details to show
- * @file_name: output filename (e.g. "/tmp/metadata.dot")
+ * @file_name: output base filename (e.g. "myplayer")
*
* 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.
*
* The macro is only active if gstreamer is configured with
* "--gst-enable-gst-debug" and the environment variable
- * GST_DEBUG_DUMP_DOT_FILES is set (e.g. to 1).
+ * GST_DEBUG_DUMP_DOT_DIR is set to a basepath (e.g. /tmp).
*/
#define GST_DEBUG_BIN_TO_DOT_FILE(bin, details, file_name) _gst_debug_bin_to_dot_file (bin, details, file_name)
* GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS:
* @bin: the top-level pipeline that should be analyzed
* @details: graph-details to show
- * @file_tmpl: output filename template
- * (e.g. "/tmp/metadata.%" GST_TIME_FORMAT ".dot")
+ * @file_name: output base filename (e.g. "myplayer")
*
- * This works like _gst_debug_bin_to_dot_file(), but fills the filename template
- * with the timestamp, so that it can be used to take multiple snapshots.
+ * 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.
*/
#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)
/* dump graph on warning */
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
- GST_DEBUG_GRAPH_SHOW_ALL,
- "/tmp/gst-launch.warning.%" GST_TIME_FORMAT ".dot");
+ GST_DEBUG_GRAPH_SHOW_ALL, "gst-launch.warning");
gst_message_parse_warning (message, &gerror, &debug);
g_print (_("WARNING: from element %s: %s\n"), name, gerror->message);
/* dump graph on error */
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
- GST_DEBUG_GRAPH_SHOW_ALL,
- "/tmp/gst-launch.error.%" GST_TIME_FORMAT ".dot");
+ GST_DEBUG_GRAPH_SHOW_ALL, "gst-launch.error");
gst_message_parse_error (message, &gerror, &debug);
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
gst_message_parse_state_changed (message, &old, &new, &pending);
/* debug each state change
- GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(pipeline),GST_DEBUG_GRAPH_SHOW_ALL,"/tmp/gst-launch.%" GST_TIME_FORMAT ".dot");
+ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "gst-launch");
*/
/* we only care about pipeline state change messages */
break;
/* debug only overall state changes
- FIXME: add statename to name template: gst_element_state_get_name(new);
- GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(pipeline),GST_DEBUG_GRAPH_SHOW_ALL,"/tmp/gst-launch.%" GST_TIME_FORMAT ".dot");
+ {
+ gchar *dump_name;
+
+ dump_name = g_strdup_printf ("gst-launch.%s",gst_element_state_get_name (new);
+ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, dump_name);
+ g_free (dump_name);
+ }
*/
/* ignore when we are buffering since then we mess with the states