diff --git a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx index 2ac776952..f7bf676da 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.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -96,6 +96,29 @@ static const char * oggVorbisSmilFile = "var/simple-ogg.smil"; */ static const char * embeddedSmilFile = "var/embedded.smil"; +/** + * A SMIL file containing sound animation. + */ +static const char * soundAnimationSmilFile = "var/animateSound.smil"; + +/** + * A SMIL file containing sound animation with two parallel files. + */ +static const char * soundAnimationParallelSmilFile = + "var/animateSoundParallel.smil"; + +/** + * A SMIL file containing sound animation in effect of a fade in / out. + */ +static const char * fadeInOutSmilFile = "var/fadeInOut.smil"; + +/** + * A SMIL file containing sound animation in effect of a fade in / out, + * with two overlapping audio files. + */ +static const char * fadeInOutParallelSmilFile = + "var/fadeInOutParallel.smil"; + /* =============================================== local function prototypes */ @@ -282,3 +305,74 @@ MinimalAudioSmilTest :: embeddedTest(void) CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 5.1 * GST_SECOND); } + +/*------------------------------------------------------------------------------ + * Test a SMIL file containing sound level animation. + *----------------------------------------------------------------------------*/ +void +MinimalAudioSmilTest :: soundAnimationTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + char str[256]; + + timePlayed = playSmilFile(soundAnimationSmilFile); + 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); +} + + +/*------------------------------------------------------------------------------ + * Test a SMIL file containing sound level animation with two files in + * parallel. + *----------------------------------------------------------------------------*/ +void +MinimalAudioSmilTest :: soundAnimationParallelTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + char str[256]; + + timePlayed = playSmilFile(soundAnimationParallelSmilFile); + 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); +} + + +/*------------------------------------------------------------------------------ + * Test a SMIL file containing sound level animation resulting in a fade + * in / fade out effect. + *----------------------------------------------------------------------------*/ +void +MinimalAudioSmilTest :: fadeInOutTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + char str[256]; + + timePlayed = playSmilFile(fadeInOutSmilFile); + 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); +} + + +/*------------------------------------------------------------------------------ + * Test a SMIL file containing sound level animation resulting in a fade + * in / fade out effect, with two parallel files + *----------------------------------------------------------------------------*/ +void +MinimalAudioSmilTest :: fadeInOutParallelTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + char str[256]; + + timePlayed = playSmilFile(fadeInOutParallelSmilFile); + 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); +} + diff --git a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h index 78c9ace03..998935d64 100644 --- a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h +++ b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h @@ -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/MinimalAudioSmilTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,20 +58,22 @@ namespace GstreamerElements { * Unit test for the partialplay gstreamer element. * * @author $Author: maroy $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE(MinimalAudioSmilTest); -#if 0 CPPUNIT_TEST(firstTest); CPPUNIT_TEST(simpleClipBeginTest); CPPUNIT_TEST(simpleClipBeginEndTest); CPPUNIT_TEST(parallelTest); CPPUNIT_TEST(parallelClipBeginEndTest); -#endif CPPUNIT_TEST(oggVorbisTest); CPPUNIT_TEST(embeddedTest); + CPPUNIT_TEST(soundAnimationTest); + CPPUNIT_TEST(soundAnimationParallelTest); + CPPUNIT_TEST(fadeInOutTest); + CPPUNIT_TEST(fadeInOutParallelTest); CPPUNIT_TEST_SUITE_END(); private: @@ -147,6 +149,39 @@ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture void embeddedTest(void) throw (CPPUNIT_NS::Exception); + /** + * Test sound level animation. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + soundAnimationTest(void) throw (CPPUNIT_NS::Exception); + + /** + * Test sound level animation with two parallel elements. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + soundAnimationParallelTest(void) throw (CPPUNIT_NS::Exception); + + /** + * Test fade in / fade out using sound level animation. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + fadeInOutTest(void) throw (CPPUNIT_NS::Exception); + + /** + * Test fade in / fade out using sound level animation, + * with two parallel audio files. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + fadeInOutParallelTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c b/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c index 9de402bd6..1313fa8ce 100644 --- a/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c +++ b/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c,v $ ------------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ #include #include +#include "smil-util.h" #include "minimal-audio-smil.h" @@ -90,6 +91,9 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ( /* ================================================ local constants & macros */ +#define NSEC_PER_SEC_FLOAT 1000000000.0 + + #define UNREF_IF_NOT_NULL(gst_object) \ { \ if ((gst_object)) { \ @@ -110,7 +114,7 @@ GST_PLUGIN_DEFINE(GST_VERSION_MAJOR, "minimalaudiosmil", "Minimal Audio-only SMIL", plugin_init, - "$Revision: 1.4 $", + "$Revision: 1.5 $", "GPL", "LiveSupport", "http://livesupport.campware.org/") @@ -142,19 +146,61 @@ static xmlNode * get_body_element(xmlDocPtr document); /** - * Handle an "