From d8fc68479c7fe6f8d976d4609504c9c0d21c9dad Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 9 Jan 2014 11:13:40 +0100 Subject: [PATCH] validate:tools: Print position every 50ms in gst-validate --- validate/tools/gst-validate.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/validate/tools/gst-validate.c b/validate/tools/gst-validate.c index 4322def707..8eb97bb12e 100644 --- a/validate/tools/gst-validate.c +++ b/validate/tools/gst-validate.c @@ -53,6 +53,35 @@ intr_handler (gpointer user_data) } #endif /* G_OS_UNIX */ +static gboolean +print_position (void) +{ + GstQuery *query; + gint64 position, duration; + + gdouble rate = 1.0; + GstFormat format = GST_FORMAT_TIME; + + gst_element_query_position (pipeline, format, &position); + + format = GST_FORMAT_TIME; + gst_element_query_duration (pipeline, format, &duration); + + query = gst_query_new_segment (GST_FORMAT_DEFAULT); + if (gst_element_query (pipeline, query)) + gst_query_parse_segment (query, &rate, NULL, NULL, NULL); + gst_query_unref (query); + + g_print ("\r", GST_TIME_ARGS (position), GST_TIME_ARGS (duration), + rate); + + GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), + GST_DEBUG_GRAPH_SHOW_ALL, "position"); + + return TRUE; +} + static gboolean bus_callback (GstBus * bus, GstMessage * message, gpointer data) { @@ -217,6 +246,7 @@ main (int argc, gchar ** argv) goto exit; } + g_timeout_add (50, (GSourceFunc) print_position, NULL); g_print ("Pipeline started\n"); g_main_loop_run (mainloop);