diff --git a/livesupport/modules/gstreamerElements/etc/Makefile.in b/livesupport/modules/gstreamerElements/etc/Makefile.in index cd727bc20..6f0157cdf 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.2 $ +# Version : $Revision: 1.3 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/etc/Makefile.in,v $ # # @configure_input@ @@ -140,9 +140,13 @@ SWITCHER_LIB_OBJS = ${TMP_DIR}/smil-util.o \ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ ${TMP_DIR}/SwitcherTest.o \ + ${TMP_DIR}/SeekPackTest.o \ ${TMP_DIR}/PartialPlayTest.o \ ${TMP_DIR}/OneshotReaderTest.o \ - ${TMP_DIR}/MinimalAudioSmilTest.o + ${TMP_DIR}/MinimalAudioSmilTest.o \ + ${TMP_DIR}/seek.o \ + ${TMP_DIR}/util.o \ + ${TMP_DIR}/seek-pack.o TEST_RUNNER_LIBS = -l${CORE_LIB} -lcppunit -ldl -lxmlrpc++ diff --git a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx index ae6b14896..318423e04 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.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -57,7 +57,15 @@ using namespace LiveSupport::GstreamerElements; CPPUNIT_TEST_SUITE_REGISTRATION(MinimalAudioSmilTest); -static const char * testFile = "var/simple.smil"; +/** + * A simple smil file. + */ +static const char * simpleFile = "var/simple.smil"; + +/** + * A parallel smil file. + */ +static const char * parallelFile = "var/parallel.smil"; /* =============================================== local function prototypes */ @@ -84,10 +92,10 @@ MinimalAudioSmilTest :: tearDown(void) throw () /*------------------------------------------------------------------------------ - * A simple smoke test. + * Play a SMIL file. *----------------------------------------------------------------------------*/ void -MinimalAudioSmilTest :: firstTest(void) +MinimalAudioSmilTest :: playSmilFile(const char * smilFile) throw (CPPUNIT_NS::Exception) { GstElement * pipeline; @@ -99,12 +107,12 @@ MinimalAudioSmilTest :: firstTest(void) gst_init(0, 0); /* create elements */ - pipeline = gst_pipeline_new("my_pipeline"); - filesrc = gst_element_factory_make("filesrc", "my_filesource"); - smil = gst_element_factory_make("minimalaudiosmil", "my_smil"); + pipeline = gst_pipeline_new("pipeline"); + filesrc = gst_element_factory_make("filesrc", "filesource"); + smil = gst_element_factory_make("minimalaudiosmil", "smil"); sink = gst_element_factory_make("alsasink", "audiosink"); - g_object_set(G_OBJECT(filesrc), "location", testFile, NULL); + g_object_set(G_OBJECT(filesrc), "location", smilFile, NULL); /* link everything together */ gst_element_link_many(filesrc, smil, sink, NULL); @@ -119,3 +127,25 @@ MinimalAudioSmilTest :: firstTest(void) gst_object_unref(GST_OBJECT(pipeline)); } + +/*------------------------------------------------------------------------------ + * A simple smoke test. + *----------------------------------------------------------------------------*/ +void +MinimalAudioSmilTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + playSmilFile(simpleFile); +} + + +/*------------------------------------------------------------------------------ + * Test SMIL elements + *----------------------------------------------------------------------------*/ +void +MinimalAudioSmilTest :: parallelTest(void) + throw (CPPUNIT_NS::Exception) +{ + playSmilFile(parallelFile); +} + diff --git a/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h b/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h index 4d33377a7..9ed09eb3b 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.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,14 +58,28 @@ namespace GstreamerElements { * Unit test for the partialplay gstreamer element. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE(MinimalAudioSmilTest); CPPUNIT_TEST(firstTest); + CPPUNIT_TEST(parallelTest); CPPUNIT_TEST_SUITE_END(); + private: + + /** + * Play a smil file. + * + * @param smilFile the name of the smil file to play. + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + playSmilFile(const char * smilFile) + throw (CPPUNIT_NS::Exception); + + protected: /** @@ -76,6 +90,14 @@ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture void firstTest(void) throw (CPPUNIT_NS::Exception); + /** + * Test on elements in a SMIL file. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + parallelTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/livesupport/modules/gstreamerElements/src/PartialPlayTest.cxx b/livesupport/modules/gstreamerElements/src/PartialPlayTest.cxx index 7b953c84f..582675144 100644 --- a/livesupport/modules/gstreamerElements/src/PartialPlayTest.cxx +++ b/livesupport/modules/gstreamerElements/src/PartialPlayTest.cxx @@ -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/PartialPlayTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -50,6 +50,9 @@ using namespace LiveSupport::GstreamerElements; CPPUNIT_TEST_SUITE_REGISTRATION(PartialPlayTest); +/** + * A test file. + */ static const char * testFile = "var/1minutecounter.mp3"; @@ -90,7 +93,8 @@ PartialPlayTest :: tearDown(void) throw () * A simple smoke test. *----------------------------------------------------------------------------*/ void -PartialPlayTest :: firstTest(void) +PartialPlayTest :: playFile(const char * audioFile, + const char * config) throw (CPPUNIT_NS::Exception) { GstElement * pipeline; @@ -106,8 +110,8 @@ PartialPlayTest :: firstTest(void) sink = gst_element_factory_make("alsasink", "alsa-output"); /* set filename property on the file source */ - g_object_set(G_OBJECT(filter), "location", testFile, NULL); - g_object_set(G_OBJECT(filter), "config", "3s;10s-17s", NULL); + g_object_set(G_OBJECT(filter), "location", audioFile, NULL); + g_object_set(G_OBJECT(filter), "config", config, NULL); g_signal_connect(filter, "eos", G_CALLBACK(eos_signal_handler), pipeline); gst_element_link(filter, sink); @@ -142,3 +146,25 @@ eos_signal_handler(GstElement * element, gst_element_set_eos(container); } + +/*------------------------------------------------------------------------------ + * A simple smoke test. + *----------------------------------------------------------------------------*/ +void +PartialPlayTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + playFile(testFile, "3s;10s-13s"); +} + + +/*------------------------------------------------------------------------------ + * Open ended test + *----------------------------------------------------------------------------*/ +void +PartialPlayTest :: openEndedTest(void) + throw (CPPUNIT_NS::Exception) +{ + playFile(testFile, "3s;10s-"); +} + diff --git a/livesupport/modules/gstreamerElements/src/PartialPlayTest.h b/livesupport/modules/gstreamerElements/src/PartialPlayTest.h index dbe95ea81..b909765cd 100644 --- a/livesupport/modules/gstreamerElements/src/PartialPlayTest.h +++ b/livesupport/modules/gstreamerElements/src/PartialPlayTest.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/PartialPlayTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,14 +58,30 @@ namespace GstreamerElements { * Unit test for the partialplay gstreamer element. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class PartialPlayTest : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE(PartialPlayTest); CPPUNIT_TEST(firstTest); + CPPUNIT_TEST(openEndedTest); CPPUNIT_TEST_SUITE_END(); + private: + + /** + * Play a file, with a specific partial play config. + * + * @param audioFile the file to play + * @param config the partial play config to use when playing the file + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + playFile(const char * audioFile, + const char * config) + throw (CPPUNIT_NS::Exception); + + protected: /** @@ -76,6 +92,14 @@ class PartialPlayTest : public CPPUNIT_NS::TestFixture void firstTest(void) throw (CPPUNIT_NS::Exception); + /** + * An open ended play test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + openEndedTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx b/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx index 74a7d0c29..663f197bc 100644 --- a/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx +++ b/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -50,7 +50,7 @@ using namespace LiveSupport::GstreamerElements; CPPUNIT_TEST_SUITE_REGISTRATION(SwitcherTest); -static const char * testFile = "var/1minutecounter.mp3"; +static const char * testFile = "var/5seccounter.mp3"; /* =============================================== local function prototypes */ @@ -87,10 +87,11 @@ SwitcherTest :: tearDown(void) throw () /*------------------------------------------------------------------------------ - * A simple smoke test. + * Play an audio file *----------------------------------------------------------------------------*/ -void -SwitcherTest :: firstTest(void) +gint64 +SwitcherTest :: playFile(const char * audioFile, + const char * sourceConfig) throw (CPPUNIT_NS::Exception) { GstElement * pipeline; @@ -99,6 +100,8 @@ SwitcherTest :: firstTest(void) GstElement * sw; GstElement * switcher; GstElement * sink; + GstFormat format; + gint64 timePlayed; /* initialize GStreamer */ gst_init(0, 0); @@ -112,8 +115,8 @@ SwitcherTest :: firstTest(void) sink = gst_element_factory_make("alsasink", "alsa-output"); /* set filename property on the file source */ - g_object_set(G_OBJECT(source), "location", testFile, NULL); - g_object_set(G_OBJECT(switcher), "source-config", "0[3s]", NULL); + g_object_set(G_OBJECT(source), "location", audioFile, NULL); + g_object_set(G_OBJECT(switcher), "source-config", sourceConfig, NULL); /* listen for the eos event on switcher, so the pipeline can be stopped */ g_signal_connect(switcher, "eos", G_CALLBACK(eos_signal_handler), pipeline); @@ -126,9 +129,14 @@ SwitcherTest :: firstTest(void) while (gst_bin_iterate(GST_BIN(pipeline))); + format = GST_FORMAT_TIME; + gst_element_query(sink, GST_QUERY_POSITION, &format, &timePlayed); + /* clean up nicely */ gst_element_set_state(pipeline, GST_STATE_NULL); gst_object_unref(GST_OBJECT (pipeline)); + + return timePlayed; } @@ -148,3 +156,34 @@ eos_signal_handler(GstElement * element, gst_element_set_eos(container); } + +/*------------------------------------------------------------------------------ + * A simple smoke test. + *----------------------------------------------------------------------------*/ +void +SwitcherTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + + timePlayed = playFile(testFile, "0[3s]"); + CPPUNIT_ASSERT(timePlayed > 2.9 * GST_SECOND); + CPPUNIT_ASSERT(timePlayed < 3.1 * GST_SECOND); +} + + +/*------------------------------------------------------------------------------ + * Play a file until its end. + *----------------------------------------------------------------------------*/ +void +SwitcherTest :: openEndedTest(void) + throw (CPPUNIT_NS::Exception) +{ + gint64 timePlayed; + + timePlayed = playFile(testFile, "0[]"); + CPPUNIT_ASSERT(timePlayed > 4.9 * GST_SECOND); + CPPUNIT_ASSERT(timePlayed < 5.1 * GST_SECOND); +} + + diff --git a/livesupport/modules/gstreamerElements/src/SwitcherTest.h b/livesupport/modules/gstreamerElements/src/SwitcherTest.h index 73b482408..a78d1e3d5 100644 --- a/livesupport/modules/gstreamerElements/src/SwitcherTest.h +++ b/livesupport/modules/gstreamerElements/src/SwitcherTest.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SwitcherTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,14 +58,31 @@ namespace GstreamerElements { * Unit test for the partialplay gstreamer element. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class SwitcherTest : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE(SwitcherTest); CPPUNIT_TEST(firstTest); + CPPUNIT_TEST(openEndedTest); CPPUNIT_TEST_SUITE_END(); + private: + + /** + * Play a specific file, with a specific switcher configuration. + * + * @param audioFile the name of the audio file to play. + * @param sourceConfig the source config to use. + * @return the number of milliseconds played. + * @exception CPPUNIT_NS::Exception on test failures. + */ + gint64 + playFile(const char * audioFile, + const char * sourceConfig) + throw (CPPUNIT_NS::Exception); + + protected: /** @@ -76,6 +93,14 @@ class SwitcherTest : public CPPUNIT_NS::TestFixture void firstTest(void) throw (CPPUNIT_NS::Exception); + /** + * A test to play a file until its end. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + openEndedTest(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 913093aa4..752000e65 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.2 $ + Version : $Revision: 1.3 $ 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.2 $", + "$Revision: 1.3 $", "GPL", "LiveSupport", "http://livesupport.campware.org/" @@ -409,6 +409,9 @@ update_source_config(LivesupportPartialPlay * pplay) if (sscanf(token, "%[^-]-%s", from, to) == 2) { pplay->playFrom = smil_clock_value_to_nanosec(from); pplay->playTo = smil_clock_value_to_nanosec(to); + } else if (sscanf(token, "%[^-]-", from) == 1) { + pplay->playFrom = smil_clock_value_to_nanosec(from); + pplay->playTo = -1LL; } g_free(to); diff --git a/livesupport/modules/gstreamerElements/src/seek-pack.h b/livesupport/modules/gstreamerElements/src/seek-pack.h index 7c3cd6499..8be860194 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.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.h,v $ ------------------------------------------------------------------------------*/ @@ -35,9 +35,13 @@ * some silence and then some specified part of the source. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ +#ifdef __cplusplus +extern "C" { +#endif + /* ============================================================ include files */ @@ -172,5 +176,11 @@ livesupport_seek_pack_set_state(LivesupportSeekPack * seekPack, gboolean livesupport_seek_pack_iterate(LivesupportSeekPack * seekPack); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* SeekPack_h */ diff --git a/livesupport/modules/gstreamerElements/src/switcher.c b/livesupport/modules/gstreamerElements/src/switcher.c index 3710688d5..3959bfc56 100644 --- a/livesupport/modules/gstreamerElements/src/switcher.c +++ b/livesupport/modules/gstreamerElements/src/switcher.c @@ -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/switcher.c,v $ ------------------------------------------------------------------------------*/ @@ -64,7 +64,7 @@ GST_PLUGIN_DEFINE ( "switcher", "A filter that connects to a swtich, and changes its source", plugin_init, - "$Revision: 1.2 $", + "$Revision: 1.3 $", "GPL", "LiveSupport", "http://livesupport.campware.org/" @@ -406,16 +406,23 @@ livesupport_switcher_chain(GstPad * pad, switcher->currentConfig->data; } - if (config->duration < 0) { + if (config->duration < 0LL) { /* handle config->duration == -1LL (play until EOS) */ if (GST_IS_EVENT(in)) { GstEvent * event = GST_EVENT(in); if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) { switch_to_next_source(switcher); - return; + } else { + gst_pad_event_default(switcher->srcpad, event); } + } else { + buf = GST_BUFFER(in); + + /* just push out the incoming buffer without touching it */ + gst_pad_push(switcher->srcpad, GST_DATA(buf)); } + return; } if (GST_IS_EVENT(in)) { diff --git a/livesupport/modules/gstreamerElements/var/5seccounter.mp3 b/livesupport/modules/gstreamerElements/var/5seccounter.mp3 new file mode 100644 index 000000000..cb164840f Binary files /dev/null and b/livesupport/modules/gstreamerElements/var/5seccounter.mp3 differ diff --git a/livesupport/modules/gstreamerElements/var/parallel.smil b/livesupport/modules/gstreamerElements/var/parallel.smil new file mode 100644 index 000000000..3efe2e3fe --- /dev/null +++ b/livesupport/modules/gstreamerElements/var/parallel.smil @@ -0,0 +1,16 @@ + + + + + + + diff --git a/livesupport/modules/gstreamerElements/var/simple.smil b/livesupport/modules/gstreamerElements/var/simple.smil index db0803083..cca5ff45e 100644 --- a/livesupport/modules/gstreamerElements/var/simple.smil +++ b/livesupport/modules/gstreamerElements/var/simple.smil @@ -4,8 +4,7 @@