From 20d0351b76c71a3642ee72180515c431e32a20e3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 23 Mar 2009 16:59:36 +0100 Subject: [PATCH] tests: print some more info in the text example Print both the position and the running_time when the subtitle becomes available in the application. --- tests/icles/playbin-text.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/icles/playbin-text.c b/tests/icles/playbin-text.c index 63f9fa8542..a986804828 100644 --- a/tests/icles/playbin-text.c +++ b/tests/icles/playbin-text.c @@ -95,8 +95,24 @@ have_subtitle (GstElement * appsink, App * app) if (buffer) { guint8 *data; guint size; + GstFormat format; + gint64 position; + GstClock *clock; + GstClockTime base_time, running_time; - g_message ("received a subtitle"); + format = GST_FORMAT_TIME; + gst_element_query_position (appsink, &format, &position); + + clock = gst_element_get_clock (appsink); + base_time = gst_element_get_base_time (appsink); + + running_time = gst_clock_get_time (clock) - base_time; + + gst_object_unref (clock); + + g_message ("received a subtitle at position %" GST_TIME_FORMAT + ", running_time %" GST_TIME_FORMAT, GST_TIME_ARGS (position), + GST_TIME_ARGS (running_time)); data = GST_BUFFER_DATA (buffer); size = GST_BUFFER_SIZE (buffer); @@ -127,6 +143,7 @@ main (int argc, char *argv[]) /* set appsink to get the subtitles */ app->textsink = gst_element_factory_make ("appsink", "subtitle_sink"); g_object_set (G_OBJECT (app->textsink), "emit-signals", TRUE, NULL); + g_object_set (G_OBJECT (app->textsink), "ts-offset", 0 * GST_SECOND, NULL); g_signal_connect (app->textsink, "new-buffer", G_CALLBACK (have_subtitle), app);