diff --git a/livesupport/modules/core/etc/playlist.xml b/livesupport/modules/core/etc/playlist.xml index 59c9665c9..9c38aef3d 100644 --- a/livesupport/modules/core/etc/playlist.xml +++ b/livesupport/modules/core/etc/playlist.xml @@ -22,10 +22,12 @@ - + - + diff --git a/livesupport/modules/core/include/LiveSupport/Core/Playlist.h b/livesupport/modules/core/include/LiveSupport/Core/Playlist.h index 37e82a887..9de29d1a7 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/Playlist.h +++ b/livesupport/modules/core/include/LiveSupport/Core/Playlist.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.9 $ + Version : $Revision: 1.10 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $ ------------------------------------------------------------------------------*/ @@ -71,7 +71,7 @@ using namespace boost::posix_time; * the playlist. * * @author $Author: fgerlits $ - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ */ class Playlist : public Configurable { @@ -368,6 +368,13 @@ class Playlist : public Configurable void revertToSavedCopy(void) throw (std::logic_error); + /** + * Return a SMIL XML document representation of the playlist. + * The playlist needs to be opened for playing first; otherwise + * an exception is thrown. + */ + Ptr::Ref + toSmil(void) const throw (std::logic_error); }; diff --git a/livesupport/modules/core/include/LiveSupport/Core/StorageClientInterface.h b/livesupport/modules/core/include/LiveSupport/Core/StorageClientInterface.h index 089994ef2..84b53caa6 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/StorageClientInterface.h +++ b/livesupport/modules/core/include/LiveSupport/Core/StorageClientInterface.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Attic/StorageClientInterface.h,v $ ------------------------------------------------------------------------------*/ @@ -61,7 +61,7 @@ namespace Core { * An interface for storage clients. * * @author $Author: fgerlits $ - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class StorageClientInterface { @@ -90,6 +90,19 @@ class StorageClientInterface throw (std::invalid_argument) = 0; + /** + * Release the lock on a playlist with the specified id. + * + * @param id the id of the playlist to release. + * @exception std::invalid_argument if no playlist with the specified + * id exists. + */ + virtual void + releasePlaylist(Ptr::Ref id) const + throw (std::invalid_argument, + std::logic_error) + = 0; + /** * Delete a playlist with the specified id. * @@ -132,7 +145,7 @@ class StorageClientInterface /** * Return an audio clip with the specified id. * - * @param id the id of the playlist to return. + * @param id the id of the audio clip to return. * @return the requested audio clip. * @exception std::invalid_argument if no audio clip with the * specified id exists. @@ -142,6 +155,18 @@ class StorageClientInterface throw (std::invalid_argument) = 0; + /** + * Release the lock on an audio clip with the specified id. + * + * @param id the id of the audio clip to release. + * @exception std::invalid_argument if no audio clip with the + * specified id exists. + */ + virtual void + releaseAudioClip(Ptr::Ref id) const + throw (std::invalid_argument) + = 0; + /** * Delete an audio clip with the specified id. * diff --git a/livesupport/modules/core/src/Playlist.cxx b/livesupport/modules/core/src/Playlist.cxx index 8eb9dd461..7cfb9a2ce 100644 --- a/livesupport/modules/core/src/Playlist.cxx +++ b/livesupport/modules/core/src/Playlist.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $ ------------------------------------------------------------------------------*/ @@ -66,6 +66,58 @@ static const std::string playlengthAttrName = "playlength"; */ static const std::string elementListAttrName = "playlistElement"; +/** + * The XML version used to create the SMIL file. + */ +static const std::string xmlVersion = "1.0"; + +/** + * The name of the SMIL root node. + */ +static const std::string smilRootNodeName = "smil"; + +/** + * The name of the SMIL language description attribute. + */ +static const std::string smilLanguageAttrName = "xmlns"; + +/** + * The value of the SMIL language description attribute. + */ +static const std::string smilLanguageAttrValue + = "http://www.w3.org/2001/SMIL20/Language"; + +/** + * The name of the SMIL real networks extension attribute. + */ +static const std::string smilExtensionsAttrName = "xmlns:rn"; + +/** + * The value of the SMIL real networks extension attribute. + */ +static const std::string smilExtensionsAttrValue + = "http://features.real.com/2001/SMIL20/Extensions"; + +/** + * The name of the body node in the SMIL file. + */ +static const std::string smilBodyNodeName = "body"; + +/** + * The name of the sequential audio clip list node in the SMIL file. + */ +static const std::string smilSeqNodeName = "seq"; + +/** + * The name of the audio clip element node in the SMIL file. + */ +static const std::string smilAudioClipNodeName = "audio"; + +/** + * The name of the attribute containing the URI of the audio clip element. + */ +static const std::string smilAudioClipUriAttrName = "src"; + /* =============================================== local function prototypes */ @@ -314,3 +366,42 @@ Playlist::revertToSavedCopy(void) throw (std::logic_error) savedCopy.reset(); } + + +/*------------------------------------------------------------------------------ + * Return a SMIL XML element representation of the playlist. + *----------------------------------------------------------------------------*/ +Ptr::Ref +Playlist::toSmil(void) const throw (std::logic_error) +{ + if (!isLockedForPlaying) { + throw (std::logic_error("playlist not open for playing")); + } + + Ptr::Ref + smilDocument(new xmlpp::Document(xmlVersion)); + xmlpp::Element * smilRootNode + = smilDocument->create_root_node(smilRootNodeName); + smilRootNode->set_attribute(smilLanguageAttrName, + smilLanguageAttrValue); + smilRootNode->set_attribute(smilExtensionsAttrName, + smilExtensionsAttrValue); + + xmlpp::Element * smilBodyNode + = smilRootNode->add_child(smilBodyNodeName); + xmlpp::Element * smilSeqNode + = smilBodyNode->add_child(smilSeqNodeName); + + PlaylistElementListType::const_iterator it = elementList->begin(); + + while (it != elementList->end()) { + xmlpp::Element * smilAudioClipNode + = smilSeqNode->add_child(smilAudioClipNodeName); + smilAudioClipNode->set_attribute( + smilAudioClipUriAttrName, + *(it->second->getAudioClip()->getUri())); + ++it; + } + + return smilDocument; +} diff --git a/livesupport/modules/core/src/PlaylistTest.cxx b/livesupport/modules/core/src/PlaylistTest.cxx index 7f041771d..07d656494 100644 --- a/livesupport/modules/core/src/PlaylistTest.cxx +++ b/livesupport/modules/core/src/PlaylistTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.9 $ + Version : $Revision: 1.10 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -63,6 +63,21 @@ CPPUNIT_TEST_SUITE_REGISTRATION(PlaylistTest); */ static const std::string configFileName = "etc/playlist.xml"; +/** + * The playlist in SMIL XML format. + */ +static const std::string smilPlaylist = + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + "\n"; + /* =============================================== local function prototypes */ @@ -354,3 +369,26 @@ PlaylistTest :: fadeInfoTest(void) catch (std::invalid_argument &e) { } } + + +/*------------------------------------------------------------------------------ + * Check if the conversion to SMIL works + *----------------------------------------------------------------------------*/ +void +PlaylistTest :: toSmilTest(void) + throw (CPPUNIT_NS::Exception) +{ + playlist->setLockedForPlaying(true); + + std::string newSmilPlaylist; + try { + newSmilPlaylist = playlist->toSmil() + ->write_to_string_formatted("UTF-8"); + } + catch (std::logic_error &e) { + CPPUNIT_FAIL(e.what()); + } + CPPUNIT_ASSERT(newSmilPlaylist == smilPlaylist); + + playlist->setLockedForPlaying(true); +} diff --git a/livesupport/modules/core/src/PlaylistTest.h b/livesupport/modules/core/src/PlaylistTest.h index faef90865..fb1465726 100644 --- a/livesupport/modules/core/src/PlaylistTest.h +++ b/livesupport/modules/core/src/PlaylistTest.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,7 +58,7 @@ namespace Core { * Unit test for the UploadPlaylistMetohd class. * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * @see Playlist */ class PlaylistTest : public CPPUNIT_NS::TestFixture @@ -69,6 +69,7 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(audioClipTest); CPPUNIT_TEST(savedCopyTest); CPPUNIT_TEST(fadeInfoTest); + CPPUNIT_TEST(toSmilTest); CPPUNIT_TEST_SUITE_END(); private: @@ -120,6 +121,14 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture void fadeInfoTest(void) throw (CPPUNIT_NS::Exception); + /** + * Check if the conversion to SMIL works. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + toSmilTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/livesupport/modules/storage/etc/storageClient.xml b/livesupport/modules/storage/etc/storageClient.xml index b17aa123f..080f95818 100644 --- a/livesupport/modules/storage/etc/storageClient.xml +++ b/livesupport/modules/storage/etc/storageClient.xml @@ -16,15 +16,18 @@ + ]> - + - + diff --git a/livesupport/modules/storage/etc/testStorage.xml b/livesupport/modules/storage/etc/testStorage.xml index 9d768ddad..c0c91c1d0 100644 --- a/livesupport/modules/storage/etc/testStorage.xml +++ b/livesupport/modules/storage/etc/testStorage.xml @@ -14,16 +14,21 @@ + ]> - + - + - - + + diff --git a/livesupport/modules/storage/src/TestStorageClient.cxx b/livesupport/modules/storage/src/TestStorageClient.cxx index 540328b5d..a16ef96e7 100644 --- a/livesupport/modules/storage/src/TestStorageClient.cxx +++ b/livesupport/modules/storage/src/TestStorageClient.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $ ------------------------------------------------------------------------------*/ @@ -133,6 +133,42 @@ TestStorageClient :: getPlaylist(Ptr::Ref id) const } +/*------------------------------------------------------------------------------ + * Release a playlist. + *----------------------------------------------------------------------------*/ +void +TestStorageClient :: releasePlaylist(Ptr::Ref id) const + throw (std::invalid_argument, + std::logic_error) +{ + PlaylistMap::const_iterator it = playlistMap.find(id->getId()); + + if (it == playlistMap.end()) { + throw std::invalid_argument("no such playlist"); + } + + Ptr::Ref playlist = it->second; + if (playlist->isLocked()) { + throw std::logic_error("playlist is locked"); + } + + bool success = true; + Playlist::const_iterator playlistIt = playlist->begin(); + while (playlistIt != playlist->end()) { + try { + releaseAudioClip(playlistIt->second->getAudioClip()->getId()); + } + catch (std::invalid_argument &e) { + success = false; + } + ++playlistIt; + } + if (!success) { + throw std::logic_error("some audio clips in playlist do not exist"); + } +} + + /*------------------------------------------------------------------------------ * Delete a playlist. *----------------------------------------------------------------------------*/ @@ -218,6 +254,21 @@ TestStorageClient :: getAudioClip(Ptr::Ref id) const } +/*------------------------------------------------------------------------------ + * Release an audio clip. + *----------------------------------------------------------------------------*/ +void +TestStorageClient :: releaseAudioClip(Ptr::Ref id) const + throw (std::invalid_argument) +{ + AudioClipMap::const_iterator it = audioClipMap.find(id->getId()); + + if (it == audioClipMap.end()) { + throw std::invalid_argument("no such audio clip"); + } +} + + /*------------------------------------------------------------------------------ * Delete an audio clip. *----------------------------------------------------------------------------*/ diff --git a/livesupport/modules/storage/src/TestStorageClient.h b/livesupport/modules/storage/src/TestStorageClient.h index 7d48eba1e..fb0e50be3 100644 --- a/livesupport/modules/storage/src/TestStorageClient.h +++ b/livesupport/modules/storage/src/TestStorageClient.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $ ------------------------------------------------------------------------------*/ @@ -67,7 +67,7 @@ using namespace LiveSupport::Core; * A dummy storage client, only used for test purposes. * * @author $Author: fgerlits $ - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class TestStorageClient : virtual public Configurable, @@ -160,6 +160,19 @@ class TestStorageClient : getPlaylist(Ptr::Ref id) const throw (std::invalid_argument); + /** + * Release the lock on a playlist with the specified id. + * At this point, this does not do anything. + * + * @param id the id of the playlist to release. + * @exception std::invalid_argument if no playlist with the specified + * specified id exists. + */ + virtual void + releasePlaylist(Ptr::Ref id) const + throw (std::invalid_argument, + std::logic_error); + /** * Delete the playlist with the specified id. * @@ -210,6 +223,18 @@ class TestStorageClient : getAudioClip(Ptr::Ref id) const throw (std::invalid_argument); + /** + * Release the lock on an audio clip with the specified id. + * At this point, this does not do anything. + * + * @param id the id of the audio clip to release. + * @exception std::invalid_argument if no audio clip with the + * specified id exists. + */ + virtual void + releaseAudioClip(Ptr::Ref id) const + throw (std::invalid_argument); + /** * Delete the audio clip with the specified id. * diff --git a/livesupport/modules/storage/src/TestStorageClientTest.cxx b/livesupport/modules/storage/src/TestStorageClientTest.cxx index 1c46e959a..638efb0e1 100644 --- a/livesupport/modules/storage/src/TestStorageClientTest.cxx +++ b/livesupport/modules/storage/src/TestStorageClientTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClientTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -116,6 +116,32 @@ TestStorageClientTest :: firstTest(void) Ptr::Ref playlist = tsc->getPlaylist(id1); CPPUNIT_ASSERT(playlist->getId()->getId() == id1->getId()); + + try { + tsc->releasePlaylist(id1); + } + catch (std::invalid_argument &e) { + std::string eMsg = "could not release playlist: "; + eMsg += e.what(); + CPPUNIT_FAIL(eMsg); + } + catch (std::logic_error &e) { + std::string eMsg = "could not release playlist: "; + eMsg += e.what(); + CPPUNIT_FAIL(eMsg); + } + + try { + tsc->releasePlaylist(id2); + CPPUNIT_FAIL("allowed to release non-existent playlist"); + } + catch (std::invalid_argument &e) { + } + catch (std::logic_error &e) { + std::string eMsg = "release of non-existent playlist reports: "; + eMsg += e.what(); + CPPUNIT_FAIL(eMsg); + } } diff --git a/livesupport/products/scheduler/doc/model/SchedulerModel.zuml b/livesupport/products/scheduler/doc/model/SchedulerModel.zuml index dcbbf837f..c75349a55 100644 Binary files a/livesupport/products/scheduler/doc/model/SchedulerModel.zuml and b/livesupport/products/scheduler/doc/model/SchedulerModel.zuml differ diff --git a/livesupport/products/scheduler/etc/playlist.xml b/livesupport/products/scheduler/etc/playlist.xml index 1756dfb49..9c38aef3d 100644 --- a/livesupport/products/scheduler/etc/playlist.xml +++ b/livesupport/products/scheduler/etc/playlist.xml @@ -5,20 +5,30 @@ - + + + + + + + ]> - - + + - - + + + diff --git a/livesupport/products/scheduler/etc/storageClient.xml b/livesupport/products/scheduler/etc/storageClient.xml index a3f707b97..75ac2c703 100644 --- a/livesupport/products/scheduler/etc/storageClient.xml +++ b/livesupport/products/scheduler/etc/storageClient.xml @@ -16,6 +16,7 @@ + @@ -26,15 +27,17 @@ - + - - + - - + +