From 0c4639c314d008287c77b2f65572b8bee11bb976 Mon Sep 17 00:00:00 2001 From: maroy Date: Wed, 7 Sep 2005 13:56:10 +0000 Subject: [PATCH] updates for position reporting --- .../modules/gstreamerElements/etc/Makefile.in | 5 ++-- .../gstreamerElements/src/AutoplugTest.cxx | 28 +++++++++++++------ .../src/MinimalAudioSmilTest.cxx | 6 ++-- .../modules/gstreamerElements/src/autoplug.c | 7 ++--- .../gstreamerElements/var/embedded.smil | 3 ++ 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/livesupport/modules/gstreamerElements/etc/Makefile.in b/livesupport/modules/gstreamerElements/etc/Makefile.in index 5f7d5d1ac..f3de5e408 100644 --- a/livesupport/modules/gstreamerElements/etc/Makefile.in +++ b/livesupport/modules/gstreamerElements/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: maroy $ -# Version : $Revision: 1.10 $ +# Version : $Revision: 1.11 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/etc/Makefile.in,v $ # # @configure_input@ @@ -145,7 +145,8 @@ PARTIAL_PLAY_LIB_OBJS = ${TMP_DIR}/partial-play.o SWITCHER_LIB_OBJS = ${TMP_DIR}/switcher.o TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ - ${TMP_DIR}/AutoplugTest.o \ + ${TMP_DIR}/AutoplugTest.o +DONT_TEST= ${TMP_DIR}/AutoplugTest.o \ ${TMP_DIR}/SeekTest.o \ ${TMP_DIR}/SwitcherTest.o \ ${TMP_DIR}/SeekPackTest.o \ diff --git a/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx b/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx index cc162eebf..9043ac09e 100644 --- a/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx +++ b/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.11 $ + Version : $Revision: 1.12 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -55,10 +55,15 @@ using namespace LiveSupport::GstreamerElements; CPPUNIT_TEST_SUITE_REGISTRATION(AutoplugTest); /** - * Define this is time statistics should be printed while running tests. + * Define this if time statistics should be printed while running tests. */ #undef PRINT_TIMES +/** + * Define this if time statistics should be printed for each iteration. + */ +#undef PRINT_ITERATION_TIMES + /** * An mp3 test file. @@ -156,7 +161,6 @@ AutoplugTest :: playFile(const char * audioFile) GstElement * decoder; GstElement * sink; GstCaps * caps; - GstFormat format; gint64 timePlayed; /* initialize GStreamer */ @@ -196,12 +200,14 @@ AutoplugTest :: playFile(const char * audioFile) gst_element_set_state(sink, GST_STATE_PAUSED); gst_element_set_state(pipeline, GST_STATE_PLAYING); - while (gst_bin_iterate(GST_BIN(pipeline))); + while (gst_bin_iterate(GST_BIN(pipeline))) { +#ifdef PRINT_ITERATION_TIMES + timePlayed = ls_gst_autoplug_get_position(decoder); + std::cerr << "iteration time: " << timePlayed << std::endl; +#endif + } - /* FIXME: query the decoder, as for some reason, the sink will return - * unreal numbers, when playing back mp3s only! */ - format = GST_FORMAT_TIME; - gst_element_query(decoder, GST_QUERY_POSITION, &format, &timePlayed); + timePlayed = ls_gst_autoplug_get_position(decoder); /* clean up nicely */ gst_element_set_state(pipeline, GST_STATE_NULL); @@ -494,5 +500,11 @@ AutoplugTest :: playDurationTest(void) std::cerr << "duration for " << sequentialSmilFile << ": " << duration << std::endl; #endif + + duration = playFile(embeddedSmilFile); +#ifdef PRINT_TIMES + std::cerr << "duration for " << embeddedSmilFile << ": " + << duration << std::endl; +#endif } diff --git a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx index aea5093d6..d4147f4b2 100644 --- a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx +++ b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -308,8 +308,8 @@ MinimalAudioSmilTest :: embeddedTest(void) timePlayed = playSmilFile(embeddedSmilFile); g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed); - CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 4.9 * GST_SECOND); - CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 5.1 * GST_SECOND); + CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 9.9 * GST_SECOND); + CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 10.1 * GST_SECOND); } diff --git a/livesupport/modules/gstreamerElements/src/autoplug.c b/livesupport/modules/gstreamerElements/src/autoplug.c index 3b352057f..aff5c60e9 100644 --- a/livesupport/modules/gstreamerElements/src/autoplug.c +++ b/livesupport/modules/gstreamerElements/src/autoplug.c @@ -27,7 +27,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.10 $ + Version : $Revision: 1.11 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/autoplug.c,v $ ------------------------------------------------------------------------------*/ @@ -815,12 +815,9 @@ ls_gst_autoplug_get_position(GstElement * element) if (!element || !GST_IS_BIN(element)) { return 0LL; } - if (!(sink = gst_bin_get_by_name(GST_BIN(element), "audiosink"))) { - return 0LL; - } format = GST_FORMAT_TIME; - if (!gst_element_query(sink, GST_QUERY_POSITION, &format, &position) + if (!gst_element_query(element, GST_QUERY_POSITION, &format, &position) || format != GST_FORMAT_TIME) { return 0LL; } diff --git a/livesupport/modules/gstreamerElements/var/embedded.smil b/livesupport/modules/gstreamerElements/var/embedded.smil index bfb2bcc46..9b54cca47 100644 --- a/livesupport/modules/gstreamerElements/var/embedded.smil +++ b/livesupport/modules/gstreamerElements/var/embedded.smil @@ -4,6 +4,9 @@