diff --git a/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx b/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx index f64b98195..cefe46d4c 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.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -71,6 +71,16 @@ static const char * smilTestFile = "var/simple.smil"; */ static const char * badFile = "src/AutoplugTest.cxx"; +/** + * A very short file. + */ +static const char * shortFile = "var/test-short.mp3"; + +/** + * A SMIL file referring to a very short file. + */ +static const char * shortSmilFile = "var/short.smil"; + /* =============================================== local function prototypes */ @@ -219,3 +229,37 @@ AutoplugTest :: negativeTest(void) CPPUNIT_ASSERT_MESSAGE(str, timePlayed == 0LL); } + +/*------------------------------------------------------------------------------ + * Test on a very short file. + *----------------------------------------------------------------------------*/ +void +AutoplugTest :: shortTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + char str[256]; + + timePlayed = playFile(shortFile); + g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed); + CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 1.9 * GST_SECOND); + CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 2.1 * GST_SECOND); +} + + +/*------------------------------------------------------------------------------ + * Test on a SMIL file referring to a very short file. + *----------------------------------------------------------------------------*/ +void +AutoplugTest :: shortSmilTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + char str[256]; + + timePlayed = playFile(shortSmilFile); + g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed); + CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 1.9 * GST_SECOND); + CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 2.1 * GST_SECOND); +} + diff --git a/livesupport/modules/gstreamerElements/src/AutoplugTest.h b/livesupport/modules/gstreamerElements/src/AutoplugTest.h index 2ae74652e..94aeb7e8a 100644 --- a/livesupport/modules/gstreamerElements/src/AutoplugTest.h +++ b/livesupport/modules/gstreamerElements/src/AutoplugTest.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/AutoplugTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,7 +58,7 @@ namespace GstreamerElements { * Unit test for the partialplay gstreamer element. * * @author $Author: maroy $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class AutoplugTest : public CPPUNIT_NS::TestFixture { @@ -67,6 +67,8 @@ class AutoplugTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(oggVorbisTest); CPPUNIT_TEST(smilTest); CPPUNIT_TEST(negativeTest); + CPPUNIT_TEST(shortTest); + CPPUNIT_TEST(shortSmilTest); CPPUNIT_TEST_SUITE_END(); private: @@ -117,6 +119,22 @@ class AutoplugTest : public CPPUNIT_NS::TestFixture void negativeTest(void) throw (CPPUNIT_NS::Exception); + /** + * A test on a very short file. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + shortTest(void) throw (CPPUNIT_NS::Exception); + + /** + * A test on a SMIL file referring to a very short file. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + shortSmilTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/livesupport/modules/gstreamerElements/src/seek-pack.c b/livesupport/modules/gstreamerElements/src/seek-pack.c index 10affcf64..60f471951 100644 --- a/livesupport/modules/gstreamerElements/src/seek-pack.c +++ b/livesupport/modules/gstreamerElements/src/seek-pack.c @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.c,v $ ------------------------------------------------------------------------------*/ @@ -199,10 +199,17 @@ livesupport_seek_pack_init(LivesupportSeekPack * seekPack, seekPack->switcher, NULL); - /* seek on the decoder, and link it up with the switcher */ - gst_element_link(seekPack->source, seekPack->decoder); - livesupport_seek_pack_seek(seekPack); - gst_element_link(seekPack->decoder, seekPack->switcher); + if (seekPack->decoder) { + /* seek on the decoder, and link it up with the switcher */ + gst_element_link(seekPack->source, seekPack->decoder); + livesupport_seek_pack_seek(seekPack); + gst_element_link(seekPack->decoder, seekPack->switcher); + } else { + /* just fake the content with silence, + * if it could not be auto-plugged */ + seekPack->decoder = gst_element_factory_make("silence", "decoder"); + gst_element_link(seekPack->decoder, seekPack->switcher); + } /* put all inside the bin, and link up a ghost pad to switch's src pad */ gst_bin_add_many(GST_BIN(seekPack->bin), diff --git a/livesupport/modules/gstreamerElements/var/short.smil b/livesupport/modules/gstreamerElements/var/short.smil new file mode 100644 index 000000000..892faffd6 --- /dev/null +++ b/livesupport/modules/gstreamerElements/var/short.smil @@ -0,0 +1,8 @@ + + + + + + + diff --git a/livesupport/modules/gstreamerElements/var/test-short.mp3 b/livesupport/modules/gstreamerElements/var/test-short.mp3 new file mode 100644 index 000000000..03814e73d Binary files /dev/null and b/livesupport/modules/gstreamerElements/var/test-short.mp3 differ