diff --git a/livesupport/modules/playlistExecutor/etc/Makefile.in b/livesupport/modules/playlistExecutor/etc/Makefile.in index 53bf324d7..fb493db89 100644 --- a/livesupport/modules/playlistExecutor/etc/Makefile.in +++ b/livesupport/modules/playlistExecutor/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: maroy $ -# Version : $Revision: 1.11 $ +# Version : $Revision: 1.12 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/etc/Makefile.in,v $ # # @configure_input@ @@ -135,7 +135,8 @@ PLAYLIST_EXECUTOR_LIB_OBJS = ${TMP_DIR}/HelixPlayer.o \ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ ${TMP_DIR}/GstreamerPlayerTest.o \ ${TMP_DIR}/HelixPlayerTest.o \ - ${TMP_DIR}/AudioPlayerFactoryTest.o + ${TMP_DIR}/AudioPlayerFactoryTest.o \ + ${TMP_DIR}/AudioPlayerFactoryGstreamerTest.o TEST_RUNNER_LIBS = -l${PLAYLIST_EXECUTOR_LIB} -l${CORE_LIB} \ ${HELIX_LIBS} ${TAGLIB_LIBS} \ -lcppunit -ldl -lm -lxmlrpc++ diff --git a/livesupport/modules/playlistExecutor/etc/audioPlayer.xml b/livesupport/modules/playlistExecutor/etc/audioPlayer.xml index 7bc5b74aa..5d058287d 100644 --- a/livesupport/modules/playlistExecutor/etc/audioPlayer.xml +++ b/livesupport/modules/playlistExecutor/etc/audioPlayer.xml @@ -1,13 +1,16 @@ + + + + ]> + + + + + + + + + + +]> + + + diff --git a/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerFactory.h b/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerFactory.h index f42e4bc28..da3dacb28 100644 --- a/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerFactory.h +++ b/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerFactory.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/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerFactory.h,v $ ------------------------------------------------------------------------------*/ @@ -81,15 +81,17 @@ using namespace LiveSupport::Core; * The DTD for the above XML structure is: * *

- *  
+ *  
  *  
* - * For the DTD and details of the helixPlayer configuration - * element, see the HelixPlayer documentation. + * For the DTD and details of the helixPlayer or gstreamerPlayer configuration + * element, see the HelixPlayer or the GstreamerPlayer documentation, + * respectively. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see HelixPlayer + * @see GstreamerPlayer */ class AudioPlayerFactory : virtual public Configurable diff --git a/livesupport/modules/playlistExecutor/src/AudioPlayerFactory.cxx b/livesupport/modules/playlistExecutor/src/AudioPlayerFactory.cxx index be34ce11f..b39dec520 100644 --- a/livesupport/modules/playlistExecutor/src/AudioPlayerFactory.cxx +++ b/livesupport/modules/playlistExecutor/src/AudioPlayerFactory.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/AudioPlayerFactory.cxx,v $ ------------------------------------------------------------------------------*/ @@ -35,6 +35,7 @@ #include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h" #include "HelixPlayer.h" +#include "GstreamerPlayer.h" using namespace LiveSupport::Core; @@ -92,20 +93,32 @@ AudioPlayerFactory :: configure(const xmlpp::Element & element) audioPlayer.reset(); + xmlpp::Node::NodeList nodes; + // try to look for a HelixPlayer configuration element - xmlpp::Node::NodeList nodes = element.get_children( - HelixPlayer::getConfigElementName()); + nodes = element.get_children(HelixPlayer::getConfigElementName()); if (nodes.size() >= 1) { const xmlpp::Element * configElement = dynamic_cast (*(nodes.begin())); Ptr::Ref hp(new HelixPlayer()); hp->configure(*configElement); audioPlayer = hp; + + return; } - if (!audioPlayer) { - throw std::invalid_argument("no audio player factories to configure"); + nodes = element.get_children(GstreamerPlayer::getConfigElementName()); + if (nodes.size() >= 1) { + const xmlpp::Element * configElement = + dynamic_cast (*(nodes.begin())); + Ptr::Ref gp(new GstreamerPlayer()); + gp->configure(*configElement); + audioPlayer = gp; + + return; } + + throw std::invalid_argument("no audio player factories to configure"); } diff --git a/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryGstreamerTest.cxx b/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryGstreamerTest.cxx new file mode 100644 index 000000000..c5fb018a8 --- /dev/null +++ b/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryGstreamerTest.cxx @@ -0,0 +1,184 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryGstreamerTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#if HAVE_UNISTD_H +#include +#else +#error "Need unistd.h" +#endif + + +#include +#include + +#include "LiveSupport/Core/TimeConversion.h" + +#include "AudioPlayerFactoryGstreamerTest.h" + + +using namespace LiveSupport::PlaylistExecutor; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(AudioPlayerFactoryGstreamerTest); + +/** + * The name of the configuration file for the Helix player. + */ +static const std::string configFileName = "etc/audioPlayerGstreamer.xml"; + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +AudioPlayerFactoryGstreamerTest :: setUp(void) throw () +{ + try { + Ptr::Ref parser( + new xmlpp::DomParser(configFileName, true)); + const xmlpp::Document * document = parser->get_document(); + const xmlpp::Element * root = document->get_root_node(); + + Ptr::Ref audioPlayerFactory; + + audioPlayerFactory = AudioPlayerFactory::getInstance(); + audioPlayerFactory->configure(*root); + + // initialize the audio player configured by the factory + Ptr::Ref audioPlayer; + audioPlayer = audioPlayerFactory->getAudioPlayer(); + audioPlayer->initialize(); + + } catch (std::invalid_argument &e) { + std::cerr << "semantic error in configuration file" << std::endl; + } catch (xmlpp::exception &e) { + std::cerr << e.what() << std::endl; + } +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +AudioPlayerFactoryGstreamerTest :: tearDown(void) throw () +{ + try { + Ptr::Ref audioPlayerFactory; + audioPlayerFactory = AudioPlayerFactory::getInstance(); + + // de-initialize the audio player configured by the factory + Ptr::Ref audioPlayer; + audioPlayer = audioPlayerFactory->getAudioPlayer(); + audioPlayer->deInitialize(); + } catch (xmlpp::exception &e) { + std::cerr << e.what() << std::endl; + } +} + + +/*------------------------------------------------------------------------------ + * Test to see if the HelixPlayer engine can be started and stopped + *----------------------------------------------------------------------------*/ +void +AudioPlayerFactoryGstreamerTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + Ptr::Ref audioPlayerFactory; + + audioPlayerFactory = AudioPlayerFactory::getInstance(); + CPPUNIT_ASSERT(audioPlayerFactory.get()); + + Ptr::Ref audioPlayer; + + audioPlayer = audioPlayerFactory->getAudioPlayer(); + CPPUNIT_ASSERT(audioPlayer.get()); + CPPUNIT_ASSERT(!audioPlayer->isPlaying()); +} + + +/*------------------------------------------------------------------------------ + * Play something simple + *----------------------------------------------------------------------------*/ +void +AudioPlayerFactoryGstreamerTest :: simplePlayTest(void) + throw (CPPUNIT_NS::Exception) +{ + Ptr::Ref audioPlayerFactory; + Ptr::Ref audioPlayer; + Ptr::Ref sleepT; + + audioPlayerFactory = AudioPlayerFactory::getInstance(); + audioPlayer = audioPlayerFactory->getAudioPlayer(); + + try { + audioPlayer->open("file:var/test.mp3"); + } catch (std::invalid_argument &e) { + CPPUNIT_FAIL(e.what()); + } + CPPUNIT_ASSERT(!audioPlayer->isPlaying()); + audioPlayer->start(); + CPPUNIT_ASSERT(audioPlayer->isPlaying()); + + sleepT.reset(new time_duration(seconds(5))); + TimeConversion::sleep(sleepT); + audioPlayer->pause(); + sleepT.reset(new time_duration(seconds(1))); + TimeConversion::sleep(sleepT); + audioPlayer->start(); + sleepT.reset(new time_duration(seconds(2))); + TimeConversion::sleep(sleepT); + audioPlayer->pause(); + sleepT.reset(new time_duration(seconds(1))); + TimeConversion::sleep(sleepT); + audioPlayer->start(); + + sleepT.reset(new time_duration(microseconds(10))); + while (audioPlayer->isPlaying()) { + TimeConversion::sleep(sleepT); + } + CPPUNIT_ASSERT(!audioPlayer->isPlaying()); + audioPlayer->close(); +} + diff --git a/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryGstreamerTest.h b/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryGstreamerTest.h new file mode 100644 index 000000000..78d552761 --- /dev/null +++ b/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryGstreamerTest.h @@ -0,0 +1,117 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryGstreamerTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef AudioPlayerFactoryGstreamerTest_h +#define AudioPlayerFactoryGstreamerTest_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h" + + +namespace LiveSupport { +namespace PlaylistExecutor { + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the AudioPlayerFactory class. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + * @see AudioPlayerFactory + */ +class AudioPlayerFactoryGstreamerTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(AudioPlayerFactoryGstreamerTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST(simplePlayTest); + CPPUNIT_TEST_SUITE_END(); + + protected: + + /** + * A simple test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + firstTest(void) throw (CPPUNIT_NS::Exception); + + /** + * Play something simple. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + simplePlayTest(void) throw (CPPUNIT_NS::Exception); + + public: + + /** + * Set up the environment for the test case. + */ + void + setUp(void) throw (); + + /** + * Clean up the environment after the test case. + */ + void + tearDown(void) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace PlaylistExecutor +} // namespace LiveSupport + +#endif // AudioPlayerFactoryGstreamerTest_h + diff --git a/livesupport/modules/playlistExecutor/src/GstreamerPlayer.h b/livesupport/modules/playlistExecutor/src/GstreamerPlayer.h index b0659f3e5..d1751d36e 100644 --- a/livesupport/modules/playlistExecutor/src/GstreamerPlayer.h +++ b/livesupport/modules/playlistExecutor/src/GstreamerPlayer.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/playlistExecutor/src/GstreamerPlayer.h,v $ ------------------------------------------------------------------------------*/ @@ -72,39 +72,21 @@ using namespace LiveSupport::Core; * This class can be configured with the following XML element. * *

- *  
- *  

+ *  
+ *  
* - * where the dllPath is the path to the directory containing the Helix - * library shared objects. The optional audioDevice argument sets the - * AUDIO environment variable which is read by the Helix client. + * where the optional audioDevice argument specifies the audio device + * (currently ALSA device) to use for playing. * - * There are two parameters which are only there because the current version - * of the Helix client does not handle animation tags in SMIL files properly. - * They will be removed from later versions. - *
    - *
  • audioStreamTimeOut (milliseconds) - the time to wait for each - * GetAudioStream() operation before a timeout occurs; - * the default is 5;
  • - *
  • fadeLookAheadTime (milliseconds) - each fade-in or fade-out is - * scheduled (using IHXAudioCrossFade::CrossFade()) this - * much time before it is to happen; the default is 2500.
  • - *
- * * The DTD for the above configuration is the following: * *

- *  
- *  
- *  
- *  
- *  
- *  
+ * + * + *
* * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class GstreamerPlayer : virtual public Configurable, virtual public AudioPlayerInterface diff --git a/livesupport/modules/playlistExecutor/src/HelixPlayer.h b/livesupport/modules/playlistExecutor/src/HelixPlayer.h index e347228e1..c6d249d71 100644 --- a/livesupport/modules/playlistExecutor/src/HelixPlayer.h +++ b/livesupport/modules/playlistExecutor/src/HelixPlayer.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.18 $ + Version : $Revision: 1.19 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.h,v $ ------------------------------------------------------------------------------*/ @@ -83,7 +83,7 @@ using namespace LiveSupport::Core; * - *

+ *  
* * where the dllPath is the path to the directory containing the Helix * library shared objects. The optional audioDevice argument sets the @@ -109,10 +109,10 @@ using namespace LiveSupport::Core; * * * - * + * * * @author $Author: maroy $ - * @version $Revision: 1.18 $ + * @version $Revision: 1.19 $ */ class HelixPlayer : virtual public Configurable, virtual public AudioPlayerInterface,