diff --git a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx index f7bf676da..aea5093d6 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.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -119,6 +119,13 @@ static const char * fadeInOutSmilFile = "var/fadeInOut.smil"; static const char * fadeInOutParallelSmilFile = "var/fadeInOutParallel.smil"; +/** + * A SMIL file containing several audio elements in a par, that in effect + * play sequentially. + */ +static const char * sequentialSmilFile = + "var/sequentialSmil.smil"; + /* =============================================== local function prototypes */ @@ -376,3 +383,20 @@ MinimalAudioSmilTest :: fadeInOutParallelTest(void) CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 5.1 * GST_SECOND); } + +/*------------------------------------------------------------------------------ + * A sequential par element test. + *----------------------------------------------------------------------------*/ +void +MinimalAudioSmilTest :: sequentialSmilTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + char str[256]; + + timePlayed = playSmilFile(sequentialSmilFile); + g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed); + CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 34.7 * GST_SECOND); + CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 35.0 * GST_SECOND); +} + diff --git a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h index 998935d64..acb97b0ff 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.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,7 +58,7 @@ namespace GstreamerElements { * Unit test for the partialplay gstreamer element. * * @author $Author: maroy $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture { @@ -74,6 +74,7 @@ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(soundAnimationParallelTest); CPPUNIT_TEST(fadeInOutTest); CPPUNIT_TEST(fadeInOutParallelTest); + CPPUNIT_TEST(sequentialSmilTest); CPPUNIT_TEST_SUITE_END(); private: @@ -182,6 +183,14 @@ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture void fadeInOutParallelTest(void) throw (CPPUNIT_NS::Exception); + /** + * A sequential par element test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + sequentialSmilTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/livesupport/modules/gstreamerElements/src/partial-play.c b/livesupport/modules/gstreamerElements/src/partial-play.c index 752000e65..dd45c8505 100644 --- a/livesupport/modules/gstreamerElements/src/partial-play.c +++ b/livesupport/modules/gstreamerElements/src/partial-play.c @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/partial-play.c,v $ ------------------------------------------------------------------------------*/ @@ -86,7 +86,7 @@ GST_PLUGIN_DEFINE ( "partialplay", "Partial play", plugin_init, - "$Revision: 1.3 $", + "$Revision: 1.4 $", "GPL", "LiveSupport", "http://livesupport.campware.org/" @@ -232,6 +232,7 @@ livesupport_partial_play_change_state(GstElement * element) switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: + livesupport_seek_pack_set_state(pplay->seekPack, GST_STATE_READY); break; case GST_STATE_READY_TO_PAUSED: @@ -269,6 +270,7 @@ livesupport_partial_play_change_state(GstElement * element) break; case GST_STATE_READY_TO_NULL: + livesupport_seek_pack_set_state(pplay->seekPack, GST_STATE_NULL); break; default: diff --git a/livesupport/modules/gstreamerElements/src/seek-pack.c b/livesupport/modules/gstreamerElements/src/seek-pack.c index 60f471951..8ca04226c 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.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.c,v $ ------------------------------------------------------------------------------*/ @@ -117,13 +117,16 @@ livesupport_seek_pack_new(const gchar * uniqueName) g_snprintf(str, len, "%s_seekPackSilence", uniqueName); seekPack->silence = gst_element_factory_make("silence", str); - g_snprintf(str, len, "%s_seekPackAudioConvert", uniqueName); - seekPack->audioconvert = gst_element_factory_make("audioconvert", str); + g_snprintf(str, len, "%s_seekPackSilenceAudioConvert", uniqueName); + seekPack->silenceConvert = gst_element_factory_make("audioconvert", + str); seekPack->source = NULL; /* generate decoder later, by autoplugging */ - seekPack->decoder = 0; + seekPack->decoder = 0; + seekPack->decoderConvert = 0; + seekPack->decoderScale = 0; g_snprintf(str, len, "%s_seekPackSwitcher", uniqueName); seekPack->switcher = gst_element_factory_make("switcher", str); g_snprintf(str, len, "%s_seekPackBin", uniqueName); @@ -191,32 +194,41 @@ livesupport_seek_pack_init(LivesupportSeekPack * seekPack, g_snprintf(name, len, "%s_seekPackDecoder", seekPack->name); seekPack->decoder = ls_gst_autoplug_plug_source(seekPack->source, name); + g_snprintf(name, len, "%s_seekPackDecoderConvert", seekPack->name); + seekPack->decoderConvert = gst_element_factory_make("audioconvert", name); + g_snprintf(name, len, "%s_seekPackDecoderScale", seekPack->name); + seekPack->decoderScale = gst_element_factory_make("audioscale", name); g_free(name); /* link up the silence element with the switcher first */ gst_element_link_many(seekPack->silence, - seekPack->audioconvert, + seekPack->silenceConvert, seekPack->switcher, NULL); if (seekPack->decoder) { /* seek on the decoder, and link it up with the switcher */ - gst_element_link(seekPack->source, seekPack->decoder); + gst_element_link_many(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); } + gst_element_link_many(seekPack->decoder, + seekPack->decoderConvert, + seekPack->decoderScale, + seekPack->switcher, + NULL); /* put all inside the bin, and link up a ghost pad to switch's src pad */ gst_bin_add_many(GST_BIN(seekPack->bin), seekPack->silence, - seekPack->audioconvert, + seekPack->silenceConvert, seekPack->source, seekPack->decoder, + seekPack->decoderConvert, + seekPack->decoderScale, NULL); /* put the switcher last into the bin, and also link it as last @@ -287,15 +299,27 @@ livesupport_seek_pack_set_state(LivesupportSeekPack * seekPack, { /* FIXME: resetting the source from PLAYING state would make it lose * it's seek position */ - if (seekPack->audioconvert) { - gst_element_set_state(seekPack->audioconvert, state); + if (seekPack->silence) { + gst_element_set_state(seekPack->silence, state); + } + if (seekPack->silenceConvert) { + gst_element_set_state(seekPack->silenceConvert, state); } if (seekPack->decoder) { gst_element_set_state(seekPack->decoder, state); } + if (seekPack->decoderConvert) { + gst_element_set_state(seekPack->decoderConvert, state); + } + if (seekPack->decoderScale) { + gst_element_set_state(seekPack->decoderScale, state); + } if (seekPack->switcher) { gst_element_set_state(seekPack->switcher, state); } + if (seekPack->bin) { + gst_element_set_state(seekPack->bin, state); + } } diff --git a/livesupport/modules/gstreamerElements/src/seek-pack.h b/livesupport/modules/gstreamerElements/src/seek-pack.h index 39c23db40..fcb3304f6 100644 --- a/livesupport/modules/gstreamerElements/src/seek-pack.h +++ b/livesupport/modules/gstreamerElements/src/seek-pack.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/seek-pack.h,v $ ------------------------------------------------------------------------------*/ @@ -35,7 +35,7 @@ * some silence and then some specified part of the source. * * @author $Author: maroy $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ #ifdef __cplusplus @@ -67,10 +67,12 @@ struct _LivesupportSeekPack { gchar * name; GstElement * silence; - GstElement * audioconvert; + GstElement * silenceConvert; GstElement * source; GstElement * decoder; + GstElement * decoderConvert; + GstElement * decoderScale; GstElement * switcher; GstElement * bin; diff --git a/livesupport/modules/gstreamerElements/var/sequentialSmil.smil b/livesupport/modules/gstreamerElements/var/sequentialSmil.smil new file mode 100644 index 000000000..92be03461 --- /dev/null +++ b/livesupport/modules/gstreamerElements/var/sequentialSmil.smil @@ -0,0 +1,10 @@ + + + + + + + diff --git a/livesupport/modules/gstreamerElements/var/test10001.mp3 b/livesupport/modules/gstreamerElements/var/test10001.mp3 new file mode 100644 index 000000000..3010d9cf4 Binary files /dev/null and b/livesupport/modules/gstreamerElements/var/test10001.mp3 differ diff --git a/livesupport/modules/gstreamerElements/var/test10002.mp3 b/livesupport/modules/gstreamerElements/var/test10002.mp3 new file mode 100644 index 000000000..3f8612ec9 Binary files /dev/null and b/livesupport/modules/gstreamerElements/var/test10002.mp3 differ diff --git a/livesupport/modules/gstreamerElements/var/test10003.mp3 b/livesupport/modules/gstreamerElements/var/test10003.mp3 new file mode 100644 index 000000000..d82e40e7e Binary files /dev/null and b/livesupport/modules/gstreamerElements/var/test10003.mp3 differ