cleaned up Playlist, AudioClip etc.
This commit is contained in:
parent
fdc4cbd087
commit
aca8977831
|
@ -19,7 +19,7 @@
|
|||
<dcterms:valid >2004-05-25</dcterms:valid>
|
||||
<dc:type xsi:type="dcterms:DCMIType" >Sound</dc:type>
|
||||
<dc:format xsi:type="dcterms:IMT" >audio/mpeg</dc:format>
|
||||
<dcterms:extent >123</dcterms:extent>
|
||||
<dcterms:extent >00:18:30.000000</dcterms:extent>
|
||||
<dcterms:medium >online</dcterms:medium>
|
||||
<dc:identifier >streamonthefly:</dc:identifier>
|
||||
<dc:identifier >http://some.url.mdlf.org/</dc:identifier>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist title CDATA "" >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement ((audioClip|playlist), fadeInfo?) >
|
||||
|
@ -22,6 +23,7 @@
|
|||
]>
|
||||
|
||||
<playlist id="0000000000000001"
|
||||
title="My First Playlist"
|
||||
playlength="00:00:34.000" >
|
||||
<playlistElement id="0000000000000101"
|
||||
relativeOffset="0" >
|
||||
|
@ -43,7 +45,7 @@
|
|||
<playlistElement id="0000000000000103"
|
||||
relativeOffset="00:00:23.000000" >
|
||||
<playlist id="0000000000000002"
|
||||
playlength="00:00:11.000000" >
|
||||
playlength="00:00:11.000000" >
|
||||
<playlistElement id="0000000000000111"
|
||||
relativeOffset="0" >
|
||||
<audioClip id="0000000000010003"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.20 $
|
||||
Version : $Revision: 1.21 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -124,7 +124,7 @@ using namespace boost::posix_time;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.20 $
|
||||
* @version $Revision: 1.21 $
|
||||
*/
|
||||
class AudioClip : public Configurable,
|
||||
public Playable
|
||||
|
@ -209,7 +209,7 @@ class AudioClip : public Configurable,
|
|||
* Create an audio clip by specifying its unique ID.
|
||||
* The other fields will be filled in by configure().
|
||||
*
|
||||
* This constructor creates a Playlist with a null pointer
|
||||
* This constructor creates an AudioClip with a null pointer
|
||||
* for all fields except the ID! It is meant for internal use only.
|
||||
* If you want to upload a new audio clip to the storage,
|
||||
* use the constructor with (title, playlength, uri) arguments.
|
||||
|
@ -457,20 +457,45 @@ class AudioClip : public Configurable,
|
|||
|
||||
|
||||
/**
|
||||
* Return an XML representation of this audio clip
|
||||
* (in UTF-8 encoding).
|
||||
* This consists of minimal information (ID, playlength, title)
|
||||
* only, without any metadata.
|
||||
* Return a partial XML representation of this audio clip or playlist.
|
||||
*
|
||||
* This is a string containing a single <audioClip> or <playlist>
|
||||
* XML element, with minimal information (ID, title, playlength)
|
||||
* only, without an XML header or any other metadata.
|
||||
*
|
||||
* @return a string representation of the audio clip in XML
|
||||
* The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
|
||||
* time durations have the format "hh:mm:ss.ssssss".
|
||||
*
|
||||
* @return a string representation of the audio clip as an XML element
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlString(void) throw ();
|
||||
getXmlElementString(void) throw ();
|
||||
|
||||
|
||||
/**
|
||||
* Return an XML representation of the metadata of the audio clip
|
||||
* (in UTF-8 encoding). This has the (pseudo-) DTD
|
||||
* Return a complete XML representation of this audio clip.
|
||||
*
|
||||
* This is a string containing a an XML document with an <audioClip>
|
||||
* root node, together with an XML header.
|
||||
*
|
||||
* The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
|
||||
* time durations have the format "hh:mm:ss.ssssss".
|
||||
*
|
||||
* The audio clip or playlist can be completely reconstructed from
|
||||
* the string returned by this method:
|
||||
* <pre><code>
|
||||
* Ptr<AudioClip>::Ref audioClip1 = ... something ...;
|
||||
* Ptr<xmlpp::DomParser>::Ref parser;
|
||||
* parser->parse_memory(*audioClip1->getXmlDocumentString());
|
||||
* const xmlpp::Document* document = parser->get_document();
|
||||
* const xmlpp::Element* root = document->get_root_node();
|
||||
* Ptr<AudioClip>::Ref audioClip2(new AudioClip());
|
||||
* audioClip2->configure(*root);
|
||||
* </code></pre>
|
||||
* results in two identical audio clips (and the same works for
|
||||
* playlists, too).
|
||||
*
|
||||
* The XML document has the (pseudo-) DTD
|
||||
* <pre><code>
|
||||
* <!ELEMENT audioClip (metadata) >
|
||||
* <!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
|
@ -484,10 +509,10 @@ class AudioClip : public Configurable,
|
|||
* it was created by the default constructor or the constructor
|
||||
* which takes a unique ID only), a null pointer is returned.
|
||||
*
|
||||
* @return a string representation of the metadata in XML
|
||||
* @return a string representation of the audio clip as an XML document
|
||||
*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
getMetadataString() throw ();
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlDocumentString(void) throw ();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/FadeInfo.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -89,7 +89,7 @@ using namespace boost::posix_time;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.6 $
|
||||
*/
|
||||
class FadeInfo : public Configurable
|
||||
{
|
||||
|
@ -221,12 +221,20 @@ class FadeInfo : public Configurable
|
|||
}
|
||||
|
||||
/**
|
||||
* Return an XML representation of this FadeInfo object.
|
||||
* Return an XML representation of this fadeInfo element.
|
||||
*
|
||||
* This is a string containing a single <fadeInfo>
|
||||
* XML element, which is empty, and has a fadeIn and a fadeOut
|
||||
* argument (of format hh:mm:ss.ssssss).
|
||||
*
|
||||
* @return a string representation of the audio clip in XML
|
||||
* The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
|
||||
* time durations have the format "hh:mm:ss.ssssss".
|
||||
*
|
||||
* @return a string representation of the audio clip as an XML element
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlString(void) throw ();
|
||||
Ptr<Glib::ustring>::Ref
|
||||
getXmlElementString(void) throw ();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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/Playable.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -73,7 +73,7 @@ using namespace boost::posix_time;
|
|||
* It contains the methods which are common to these classes.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.7 $
|
||||
* @version $Revision: 1.8 $
|
||||
*/
|
||||
class Playable : public boost::enable_shared_from_this<Playable>
|
||||
{
|
||||
|
@ -213,13 +213,50 @@ class Playable : public boost::enable_shared_from_this<Playable>
|
|||
throw () = 0;
|
||||
|
||||
/**
|
||||
* Return an XML representation of this audio clip or playlist.
|
||||
* This consists of minimal information only, without any metadata.
|
||||
* Return a partial XML representation of this audio clip or playlist.
|
||||
*
|
||||
* This is a string containing a single <audioClip> or <playlist>
|
||||
* XML element, with minimal information (ID, title, playlength)
|
||||
* only, without an XML header or any other metadata.
|
||||
*
|
||||
* @return a string representation of the audio clip in XML
|
||||
* The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
|
||||
* time durations have the format "hh:mm:ss.ssssss".
|
||||
*
|
||||
* @return a string representation of the audio clip as an XML element
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlString(void) throw () = 0;
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlElementString(void) throw () = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Return a complete XML representation of this audio clip or playlist.
|
||||
*
|
||||
* This is a string containing a an XML document with an <audioClip>
|
||||
* or <playlist> root node, together with an XML header and a
|
||||
* <metadata> element (in the case of playlists, for the outermost
|
||||
* playlist only).
|
||||
*
|
||||
* The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
|
||||
* time durations have the format "hh:mm:ss.ssssss".
|
||||
*
|
||||
* The audio clip or playlist can be reconstructed from
|
||||
* the string returned by this method:
|
||||
* <pre><code>
|
||||
* Ptr<AudioClip>::Ref audioClip1 = ... something ...;
|
||||
* Ptr<xmlpp::DomParser>::Ref parser;
|
||||
* parser->parse_memory(*audioClip1->getXmlDocumentString());
|
||||
* const xmlpp::Document* document = parser->get_document();
|
||||
* const xmlpp::Element* root = document->get_root_node();
|
||||
* Ptr<AudioClip>::Ref audioClip2(new AudioClip());
|
||||
* audioClip2->configure(*root);
|
||||
* </code></pre>
|
||||
* results in two identical audio clips (this works for playlists,
|
||||
* too, but see the note at Playlist::getXmlDocumentString()).
|
||||
*
|
||||
* @return a string representation of the audio clip as an XML document
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlDocumentString(void) throw () = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.29 $
|
||||
Version : $Revision: 1.30 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -93,7 +93,7 @@ using namespace boost::posix_time;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.29 $
|
||||
* @version $Revision: 1.30 $
|
||||
*/
|
||||
class Playlist : public Configurable,
|
||||
public Playable
|
||||
|
@ -129,16 +129,6 @@ class Playlist : public Configurable,
|
|||
*/
|
||||
Ptr<const std::string>::Ref token;
|
||||
|
||||
/**
|
||||
* Flag set if playlist is currently playing.
|
||||
*/
|
||||
bool isLockedForPlaying;
|
||||
|
||||
/**
|
||||
* Flag set if playlist is currently being edited.
|
||||
*/
|
||||
bool isLockedForEditing;
|
||||
|
||||
/**
|
||||
* A map type for storing the playlist elements associated with
|
||||
* this playlist, indexed by their relative offsets.
|
||||
|
@ -169,15 +159,30 @@ class Playlist : public Configurable,
|
|||
|
||||
|
||||
/**
|
||||
* The type for storing the metadata.
|
||||
* This playlist in XML format.
|
||||
*/
|
||||
typedef std::map<const std::string, Ptr<const Glib::ustring>::Ref>
|
||||
metadataType;
|
||||
Ptr<xmlpp::Document>::Ref xmlPlaylist;
|
||||
|
||||
/**
|
||||
* The metadata for this playlist.
|
||||
* Set the value of a metadata field in this playlist.
|
||||
*
|
||||
* @param value the new value of the metadata field.
|
||||
* @param name the name of the metadata field (without prefix)
|
||||
* @param prefix the prefix of the metadata field
|
||||
*/
|
||||
metadataType metadata;
|
||||
void
|
||||
setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &name, const std::string &prefix)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Set the total playing length of this playlist.
|
||||
*
|
||||
* @param the playing length in microseconds precision.
|
||||
*/
|
||||
void
|
||||
setPlaylength(Ptr<time_duration>::Ref playlength)
|
||||
throw ();
|
||||
|
||||
|
||||
public:
|
||||
|
@ -221,8 +226,6 @@ class Playlist : public Configurable,
|
|||
: Playable(PlaylistType)
|
||||
{
|
||||
elementList.reset(new PlaylistElementListType);
|
||||
this->isLockedForPlaying = false;
|
||||
this->isLockedForEditing = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,8 +239,6 @@ class Playlist : public Configurable,
|
|||
this->id = id;
|
||||
|
||||
elementList.reset(new PlaylistElementListType);
|
||||
this->isLockedForPlaying = false;
|
||||
this->isLockedForEditing = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,18 +255,7 @@ class Playlist : public Configurable,
|
|||
Playlist(Ptr<UniqueId>::Ref id,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<const std::string>::Ref uri = Ptr<std::string>::Ref())
|
||||
throw ()
|
||||
: Playable(PlaylistType)
|
||||
{
|
||||
this->id = id;
|
||||
this->title.reset(new Glib::ustring(""));
|
||||
this->playlength = playlength;
|
||||
this->uri = uri;
|
||||
|
||||
elementList.reset(new PlaylistElementListType);
|
||||
this->isLockedForPlaying = false;
|
||||
this->isLockedForEditing = false;
|
||||
}
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Create a playlist by specifying all details.
|
||||
|
@ -282,18 +272,7 @@ class Playlist : public Configurable,
|
|||
Ptr<const Glib::ustring>::Ref title,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<const std::string>::Ref uri = Ptr<std::string>::Ref())
|
||||
throw ()
|
||||
: Playable(PlaylistType)
|
||||
{
|
||||
this->id = id;
|
||||
this->title = title;
|
||||
this->playlength = playlength;
|
||||
this->uri = uri;
|
||||
|
||||
elementList.reset(new PlaylistElementListType);
|
||||
this->isLockedForPlaying = false;
|
||||
this->isLockedForEditing = false;
|
||||
}
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
|
@ -339,10 +318,32 @@ class Playlist : public Configurable,
|
|||
return id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the title of this playlist.
|
||||
*
|
||||
* @return the title.
|
||||
*/
|
||||
virtual Ptr<const Glib::ustring>::Ref
|
||||
getTitle(void) const throw ()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title of this playlist.
|
||||
*
|
||||
* @param title a new title.
|
||||
*/
|
||||
virtual void
|
||||
setTitle(Ptr<const Glib::ustring>::Ref title)
|
||||
throw ();
|
||||
|
||||
|
||||
/**
|
||||
* Return the total playing length for this playlist.
|
||||
*
|
||||
* @return the playing length in microseconds.
|
||||
* @return the playing length in microseconds precision.
|
||||
*/
|
||||
virtual Ptr<time_duration>::Ref
|
||||
getPlaylength(void) const throw ()
|
||||
|
@ -400,47 +401,16 @@ class Playlist : public Configurable,
|
|||
}
|
||||
|
||||
/**
|
||||
* Test whether the playlist is locked for editing or playing.
|
||||
* Test whether the playlist is locked for editing.
|
||||
*
|
||||
* @return true if the playlist is currently being edited or
|
||||
* played; false otherwise
|
||||
* @return true if the playlist is currently being edited
|
||||
*/
|
||||
bool
|
||||
isLocked() const throw ()
|
||||
{
|
||||
return isLockedForEditing || isLockedForPlaying;
|
||||
return (token.get() != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the playlist is currently available for editing.
|
||||
*
|
||||
* @return true if the playlist is available, false otherwise
|
||||
*/
|
||||
bool
|
||||
canBeEdited() const throw ()
|
||||
{
|
||||
return isLockedForEditing && !isLockedForPlaying;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock or unlock the playlist for editing.
|
||||
*
|
||||
* @return true if successfully obtained or released lock;
|
||||
* false otherwise.
|
||||
*/
|
||||
bool
|
||||
setLockedForEditing(const bool lockStatus)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Lock or unlock the playlist for playing.
|
||||
*
|
||||
* @return true if successfully obtained or released lock;
|
||||
* false otherwise.
|
||||
*/
|
||||
bool
|
||||
setLockedForPlaying(const bool lockStatus)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* The iterator type for this class. A Playlist::const_iterator
|
||||
|
@ -503,11 +473,11 @@ class Playlist : public Configurable,
|
|||
* @exception std::invalid_argument if the playlist already contains
|
||||
* a playlist element with the same relative offset
|
||||
*/
|
||||
void
|
||||
addAudioClip(Ptr<AudioClip>::Ref audioClip,
|
||||
Ptr<time_duration>::Ref relativeOffset,
|
||||
Ptr<FadeInfo>::Ref fadeInfo
|
||||
= Ptr<FadeInfo>::Ref())
|
||||
void
|
||||
addAudioClip(Ptr<AudioClip>::Ref audioClip,
|
||||
Ptr<time_duration>::Ref relativeOffset,
|
||||
Ptr<FadeInfo>::Ref fadeInfo
|
||||
= Ptr<FadeInfo>::Ref())
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
|
@ -524,11 +494,11 @@ class Playlist : public Configurable,
|
|||
* @exception std::invalid_argument if the playlist already contains
|
||||
* a playlist element with the same relative offset
|
||||
*/
|
||||
void
|
||||
addPlaylist(Ptr<Playlist>::Ref playlist,
|
||||
Ptr<time_duration>::Ref relativeOffset,
|
||||
Ptr<FadeInfo>::Ref fadeInfo
|
||||
= Ptr<FadeInfo>::Ref())
|
||||
void
|
||||
addPlaylist(Ptr<Playlist>::Ref playlist,
|
||||
Ptr<time_duration>::Ref relativeOffset,
|
||||
Ptr<FadeInfo>::Ref fadeInfo
|
||||
= Ptr<FadeInfo>::Ref())
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
|
@ -540,9 +510,9 @@ class Playlist : public Configurable,
|
|||
* @exception std::invalid_argument if there is no playlist element
|
||||
* at the given relative offset
|
||||
*/
|
||||
void
|
||||
setFadeInfo(Ptr<time_duration>::Ref relativeOffset,
|
||||
Ptr<FadeInfo>::Ref fadeInfo)
|
||||
void
|
||||
setFadeInfo(Ptr<time_duration>::Ref relativeOffset,
|
||||
Ptr<FadeInfo>::Ref fadeInfo)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
|
@ -553,8 +523,8 @@ class Playlist : public Configurable,
|
|||
* @exception std::invalid_argument if the playlist does not contain
|
||||
* a playlist element at the specified relative offset
|
||||
*/
|
||||
void
|
||||
removePlaylistElement(Ptr<const time_duration>::Ref relativeOffset)
|
||||
void
|
||||
removePlaylistElement(Ptr<const time_duration>::Ref relativeOffset)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
|
@ -562,56 +532,32 @@ class Playlist : public Configurable,
|
|||
* If the playlength is the only thing amiss, playlist is considered
|
||||
* valid, and the playlength is fixed. (Hence no 'const'.)
|
||||
*/
|
||||
bool
|
||||
valid(void) throw ();
|
||||
bool
|
||||
valid(void) throw ();
|
||||
|
||||
|
||||
/**
|
||||
* Create a saved copy of this playlist. If a saved copy exists
|
||||
* already, it is replaced by the current state.
|
||||
*/
|
||||
void
|
||||
createSavedCopy(void) throw ();
|
||||
void
|
||||
createSavedCopy(void) throw ();
|
||||
|
||||
/**
|
||||
* Delete the saved copy of the playlist, if exists (or do nothing).
|
||||
*/
|
||||
void
|
||||
deleteSavedCopy(void) throw ()
|
||||
{
|
||||
savedCopy.reset();
|
||||
}
|
||||
void
|
||||
deleteSavedCopy(void) throw ()
|
||||
{
|
||||
savedCopy.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert to the saved copy of this playlist. If there is no
|
||||
* saved copy, do nothing and throw an exception.
|
||||
*/
|
||||
void
|
||||
revertToSavedCopy(void) throw (std::invalid_argument);
|
||||
|
||||
|
||||
/**
|
||||
* Return the title of this playlist.
|
||||
*
|
||||
* @return the title.
|
||||
*/
|
||||
virtual Ptr<const Glib::ustring>::Ref
|
||||
getTitle(void) const throw ()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title of this playlist.
|
||||
*
|
||||
* @param title a new title.
|
||||
*/
|
||||
virtual void
|
||||
setTitle(Ptr<const Glib::ustring>::Ref title)
|
||||
throw ()
|
||||
{
|
||||
this->title = title;
|
||||
}
|
||||
void
|
||||
revertToSavedCopy(void) throw (std::invalid_argument);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -638,16 +584,55 @@ class Playlist : public Configurable,
|
|||
|
||||
|
||||
/**
|
||||
* Return an XML representation of this audio clip.
|
||||
* This consists of minimal information (ID and playlength for
|
||||
* playlists; ID, playlength and title
|
||||
* for the audio clips, plus fade in / fade out info)
|
||||
* only, without any metadata.
|
||||
* Return a partial XML representation of this audio clip or playlist.
|
||||
*
|
||||
* This is a string containing a single <playlist>
|
||||
* XML element, with minimal information (ID, title, playlength)
|
||||
* only, without an XML header or any other metadata.
|
||||
*
|
||||
* @return a string representation of the audio clip in XML
|
||||
* The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
|
||||
* time durations have the format "hh:mm:ss.ssssss".
|
||||
*
|
||||
* @return a string representation of the playlist as an XML element
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlString(void) throw ();
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlElementString(void) throw ();
|
||||
|
||||
|
||||
/**
|
||||
* Return a complete XML representation of this playlist.
|
||||
*
|
||||
* This is a string containing a an XML document with a
|
||||
* <playlist> root node, together with an XML header and a
|
||||
* <metadata> element (for the outermost playlist only).
|
||||
*
|
||||
* The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
|
||||
* time durations have the format "hh:mm:ss.ssssss".
|
||||
*
|
||||
* The playlist can be almost completely reconstructed from
|
||||
* the string returned by this method:
|
||||
* <pre><code>
|
||||
* Ptr<Playlist>::Ref playlist1 = ... something ...;
|
||||
* Ptr<xmlpp::DomParser>::Ref parser;
|
||||
* parser->parse_memory(*playlist1->getXmlDocumentString());
|
||||
* const xmlpp::Document* document = parser->get_document();
|
||||
* const xmlpp::Element* root = document->get_root_node();
|
||||
* Ptr<Playlist>::Ref playlist2(new Playlist());
|
||||
* playlist2->configure(*root);
|
||||
* </code></pre>
|
||||
* results in two identical playlists if the audio clips
|
||||
* and sub-playlists inside <i>playlist1</i> do not contain any
|
||||
* metadata other than title and playlength.
|
||||
* All other metadata fields in the audio clips and sub-playlists
|
||||
* will be lost.
|
||||
*
|
||||
* The <i>uri</i> and <i>token</i> fields are currently not part
|
||||
* of the XML document string returned.
|
||||
*
|
||||
* @return a string representation of the playlist as an XML document
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlDocumentString(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -104,7 +104,7 @@ class Playlist;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.10 $
|
||||
* @version $Revision: 1.11 $
|
||||
*/
|
||||
class PlaylistElement : public Configurable
|
||||
{
|
||||
|
@ -369,14 +369,22 @@ class PlaylistElement : public Configurable
|
|||
return fadeInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an XML representation of this playlist element.
|
||||
* This consists of minimal information only, without any metadata.
|
||||
*
|
||||
* This is a string containing a single <playlistElement>
|
||||
* XML element, with its ID and relativeOffset attributes,
|
||||
* plus an <audioClip> or <playlist> XML element,
|
||||
* plus an optional <fadeInfo> element.
|
||||
*
|
||||
* @return a string representation of the audio clip in XML
|
||||
* The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
|
||||
* time durations have the format "hh:mm:ss.ssssss".
|
||||
*
|
||||
* @return a string representation of the audio clip as an XML element
|
||||
*/
|
||||
virtual Ptr<Glib::ustring>::Ref
|
||||
getXmlString(void) throw ();
|
||||
Ptr<Glib::ustring>::Ref
|
||||
getXmlElementString(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.19 $
|
||||
Version : $Revision: 1.20 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -52,9 +52,9 @@ using namespace LiveSupport::Core;
|
|||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
/**
|
||||
* The name of the config element for this class
|
||||
*----------------------------------------------------------------------------*/
|
||||
*/
|
||||
const std::string AudioClip::configElementNameStr = "audioClip";
|
||||
|
||||
/**
|
||||
|
@ -273,8 +273,9 @@ AudioClip :: configure(const xmlpp::Element & element)
|
|||
= dynamic_cast<const xmlpp::Element*> (*it);
|
||||
|
||||
xmlAudioClip.reset(new xmlpp::Document);
|
||||
xmlpp::Element* root = xmlAudioClip->create_root_node("audioClip");
|
||||
root->set_attribute("id", std::string(*id));
|
||||
xmlpp::Element* root = xmlAudioClip->create_root_node(
|
||||
configElementNameStr);
|
||||
root->set_attribute(idAttrName, std::string(*id));
|
||||
root->import_node(metadataElement, true); // true = recursive
|
||||
|
||||
const xmlpp::Node::NodeList dataFieldList
|
||||
|
@ -365,7 +366,8 @@ AudioClip :: getMetadata(const string &key) const
|
|||
if (! rootNode) {
|
||||
return value;
|
||||
}
|
||||
xmlpp::Node::NodeList rootList = rootNode->get_children("metadata");
|
||||
xmlpp::Node::NodeList rootList = rootNode->get_children(
|
||||
metadataElementName);
|
||||
if (rootList.size() == 0) {
|
||||
return value;
|
||||
}
|
||||
|
@ -420,19 +422,24 @@ AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
title = value;
|
||||
}
|
||||
|
||||
// create a new xmlpp::Document for the metadata if necessary
|
||||
if (! xmlAudioClip) {
|
||||
xmlAudioClip.reset(new xmlpp::Document);
|
||||
}
|
||||
xmlpp::Element* rootNode = xmlAudioClip->get_root_node();
|
||||
if (! rootNode) {
|
||||
rootNode = xmlAudioClip->create_root_node("audioClip");
|
||||
rootNode = xmlAudioClip->create_root_node(configElementNameStr);
|
||||
if (id) {
|
||||
rootNode->set_attribute(idAttrName, std::string(*id));
|
||||
}
|
||||
}
|
||||
xmlpp::Node::NodeList rootList = rootNode->get_children("metadata");
|
||||
xmlpp::Node::NodeList rootList = rootNode->get_children(
|
||||
metadataElementName);
|
||||
xmlpp::Element* metadata;
|
||||
if (rootList.size() > 0) {
|
||||
metadata = dynamic_cast<xmlpp::Element*> (rootList.front());
|
||||
} else {
|
||||
metadata = rootNode->add_child("metadata");
|
||||
metadata = rootNode->add_child(metadataElementName);
|
||||
metadata->set_namespace_declaration(defaultPrefixUri);
|
||||
metadata->set_namespace_declaration(titleElementUri,
|
||||
titleElementPrefix);
|
||||
|
@ -440,6 +447,7 @@ AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
extentElementPrefix);
|
||||
}
|
||||
|
||||
// find the element to be modified
|
||||
xmlpp::Node::NodeList nodeList = metadata->get_children(name);
|
||||
xmlpp::Node::NodeList::iterator it = nodeList.begin();
|
||||
xmlpp::Element* element = 0;
|
||||
|
@ -453,6 +461,7 @@ AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
++it;
|
||||
}
|
||||
|
||||
// or add it if it did not exist before
|
||||
if (it == nodeList.end()) {
|
||||
element = metadata->add_child(name);
|
||||
try {
|
||||
|
@ -471,7 +480,7 @@ AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
* Return a string containing the essential fields of this object, in XML.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
AudioClip :: getXmlString(void) throw ()
|
||||
AudioClip :: getXmlElementString(void) throw ()
|
||||
{
|
||||
Ptr<Glib::ustring>::Ref xmlString(new Glib::ustring);
|
||||
|
||||
|
@ -491,19 +500,26 @@ AudioClip :: getXmlString(void) throw ()
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return a string containing the metadata of the audio clip, in XML.
|
||||
* Return a string containing an XML representation of this audio clip.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
AudioClip :: getMetadataString() throw ()
|
||||
AudioClip :: getXmlDocumentString() throw ()
|
||||
{
|
||||
Ptr<Glib::ustring>::Ref metadataString;
|
||||
Ptr<xmlpp::Document>::Ref localDocument;
|
||||
|
||||
if (!xmlAudioClip) {
|
||||
return metadataString;
|
||||
if (xmlAudioClip) {
|
||||
localDocument = xmlAudioClip;
|
||||
} else {
|
||||
localDocument.reset(new xmlpp::Document());
|
||||
xmlpp::Element* rootNode = localDocument->create_root_node(
|
||||
configElementNameStr);
|
||||
if (id) {
|
||||
rootNode->set_attribute(idAttrName, std::string(*id));
|
||||
}
|
||||
}
|
||||
|
||||
metadataString.reset(new Glib::ustring(xmlAudioClip->write_to_string() ));
|
||||
|
||||
Ptr<Glib::ustring>::Ref metadataString(new Glib::ustring(
|
||||
localDocument->write_to_string() ));
|
||||
return metadataString;
|
||||
}
|
||||
|
||||
|
|
|
@ -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/AudioClipTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -131,14 +131,11 @@ AudioClipTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT(*alternativeTitle ==
|
||||
"Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ");
|
||||
|
||||
CPPUNIT_ASSERT(*audioClip->getXmlString() ==
|
||||
CPPUNIT_ASSERT(*audioClip->getXmlElementString() ==
|
||||
"<audioClip id=\"0000000000000001\" "
|
||||
"playlength=\"00:18:30\" "
|
||||
"title=\"File Title txt\"/>");
|
||||
|
||||
//std::cerr << "\nxml: '" << *audioClip->getXmlString() << "'" << std::endl;
|
||||
//std::cerr << "\nmetadata: " << *audioClip->getMetadataString() << std::endl;
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/FadeInfo.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -77,7 +77,7 @@ static const std::string fadeOutAttrName = "fadeOut";
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
FadeInfo :: configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (element.get_name() != configElementNameStr) {
|
||||
std::string eMsg = "bad configuration element ";
|
||||
|
@ -116,7 +116,7 @@ FadeInfo :: configure(const xmlpp::Element & element)
|
|||
* Return a string containing the essential fields of this object, in XML.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
FadeInfo :: getXmlString(void) throw ()
|
||||
FadeInfo :: getXmlElementString(void) throw ()
|
||||
{
|
||||
Ptr<Glib::ustring>::Ref xmlString(new Glib::ustring);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/FadeInfoTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -117,7 +117,7 @@ FadeInfoTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT(fadeOut->seconds() == 1);
|
||||
CPPUNIT_ASSERT(fadeOut->fractional_seconds() == 500);
|
||||
|
||||
CPPUNIT_ASSERT(*fadeInfo->getXmlString() ==
|
||||
CPPUNIT_ASSERT(*fadeInfo->getXmlElementString() ==
|
||||
"<fadeInfo id=\"0000000000009901\" "
|
||||
"fadeIn=\"00:00:02\" "
|
||||
"fadeOut=\"00:00:01.000500\"/>");
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.28 $
|
||||
Version : $Revision: 1.29 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,9 +46,9 @@ using namespace LiveSupport::Core;
|
|||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
/**
|
||||
* The name of the config element for this class
|
||||
*----------------------------------------------------------------------------*/
|
||||
*/
|
||||
const std::string Playlist::configElementNameStr = "playlist";
|
||||
|
||||
/**
|
||||
|
@ -71,12 +71,147 @@ static const std::string titleAttrName = "title";
|
|||
*/
|
||||
static const std::string elementListAttrName = "playlistElement";
|
||||
|
||||
/**
|
||||
* The name of the metadata child element.
|
||||
*/
|
||||
static const std::string metadataElementName = "metadata";
|
||||
|
||||
/**
|
||||
* The prefix of the extent (length) metadata element.
|
||||
*/
|
||||
static const std::string extentElementPrefix = "dcterms";
|
||||
|
||||
/**
|
||||
* The name of the extent (length) metadata element.
|
||||
*/
|
||||
static const std::string extentElementName = "extent";
|
||||
|
||||
/**
|
||||
* The URI identifier for the "dcterms" prefix
|
||||
*/
|
||||
static const std::string extentElementUri = "http://purl.org/dc/terms/";
|
||||
|
||||
/**
|
||||
* The prefix of the title metadata element.
|
||||
*/
|
||||
static const std::string titleElementPrefix = "dc";
|
||||
|
||||
/**
|
||||
* The name of the title metadata element.
|
||||
*/
|
||||
static const std::string titleElementName = "title";
|
||||
|
||||
/**
|
||||
* The URI identifier for the "dc" prefix
|
||||
*/
|
||||
static const std::string titleElementUri ="http://purl.org/dc/elements/1.1/";
|
||||
|
||||
/**
|
||||
* The URI identifier for the default XML namespace
|
||||
*/
|
||||
static const std::string defaultPrefixUri ="http://www.streamonthefly.org/";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Playlist :: Playlist(const Playlist & otherPlaylist)
|
||||
throw ()
|
||||
: Playable(PlaylistType)
|
||||
{
|
||||
id = otherPlaylist.id;
|
||||
title = otherPlaylist.title;
|
||||
playlength = otherPlaylist.playlength;
|
||||
uri = otherPlaylist.uri;
|
||||
token = otherPlaylist.token;
|
||||
|
||||
elementList.reset(new PlaylistElementListType(*otherPlaylist.elementList));
|
||||
|
||||
if (otherPlaylist.savedCopy) {
|
||||
savedCopy.reset(new Playlist(*otherPlaylist.savedCopy));
|
||||
}
|
||||
|
||||
if (otherPlaylist.xmlPlaylist) {
|
||||
xmlPlaylist.reset(new xmlpp::Document);
|
||||
xmlPlaylist->create_root_node_by_import(
|
||||
otherPlaylist.xmlPlaylist->get_root_node(),
|
||||
true); // true == recursive
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test constructor without title.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Playlist :: Playlist(Ptr<UniqueId>::Ref id,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<const std::string>::Ref uri)
|
||||
throw ()
|
||||
: Playable(PlaylistType)
|
||||
{
|
||||
this->id = id;
|
||||
this->title.reset(new Glib::ustring(""));
|
||||
this->playlength = playlength;
|
||||
this->uri = uri;
|
||||
|
||||
elementList.reset(new PlaylistElementListType);
|
||||
|
||||
setTitle(title);
|
||||
setPlaylength(playlength);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test constructor with title.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Playlist :: Playlist(Ptr<UniqueId>::Ref id,
|
||||
Ptr<const Glib::ustring>::Ref title,
|
||||
Ptr<time_duration>::Ref playlength,
|
||||
Ptr<const std::string>::Ref uri)
|
||||
throw ()
|
||||
: Playable(PlaylistType)
|
||||
{
|
||||
this->id = id;
|
||||
this->title = title;
|
||||
this->playlength = playlength;
|
||||
this->uri = uri;
|
||||
|
||||
elementList.reset(new PlaylistElementListType);
|
||||
|
||||
setTitle(title);
|
||||
setPlaylength(playlength);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the value of the title field.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist :: setTitle(Ptr<const Glib::ustring>::Ref title)
|
||||
throw ()
|
||||
{
|
||||
setMetadata(title, titleElementName, titleElementPrefix);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the value of the playlength field (private).
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist :: setPlaylength(Ptr<time_duration>::Ref playlength)
|
||||
throw ()
|
||||
{
|
||||
Ptr<const Glib::ustring>::Ref playlengthString(new const Glib::ustring(
|
||||
to_simple_string(*playlength) ));
|
||||
setMetadata(playlengthString, extentElementName, extentElementPrefix);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Create a playlist object based on an XML element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -92,30 +227,29 @@ Playlist :: configure(const xmlpp::Element & element)
|
|||
|
||||
const xmlpp::Attribute * attribute;
|
||||
|
||||
if (!(attribute = element.get_attribute(idAttrName))) {
|
||||
std::string eMsg = "missing attribute ";
|
||||
eMsg += idAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
if (!id) {
|
||||
if (!(attribute = element.get_attribute(idAttrName))) {
|
||||
std::string eMsg = "missing attribute ";
|
||||
eMsg += idAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
id.reset(new UniqueId(attribute->get_value()));
|
||||
}
|
||||
id.reset(new UniqueId(attribute->get_value()));
|
||||
|
||||
if (!(attribute = element.get_attribute(playlengthAttrName))) {
|
||||
std::string eMsg = "missing attribute ";
|
||||
eMsg += playlengthAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
playlength.reset(new time_duration(
|
||||
duration_from_string(attribute->get_value())));
|
||||
Ptr<Glib::ustring>::Ref playlengthString(new Glib::ustring(
|
||||
attribute->get_value() ));
|
||||
metadata["dcterms:extent"] = playlengthString;
|
||||
|
||||
if ((attribute = element.get_attribute(titleAttrName))) {
|
||||
title.reset(new const Glib::ustring(attribute->get_value()));
|
||||
} else {
|
||||
title.reset(new const Glib::ustring(""));
|
||||
if (!playlength
|
||||
&& (attribute = element.get_attribute(playlengthAttrName))) {
|
||||
playlength.reset(new time_duration(
|
||||
duration_from_string(attribute->get_value())));
|
||||
Ptr<Glib::ustring>::Ref playlengthString(new Glib::ustring(
|
||||
attribute->get_value() ));
|
||||
setMetadata(playlengthString, extentElementName, extentElementPrefix);
|
||||
}
|
||||
|
||||
if (!title
|
||||
&& (attribute = element.get_attribute(titleAttrName))) {
|
||||
title.reset(new const Glib::ustring(attribute->get_value()));
|
||||
setMetadata(title, titleElementName, titleElementPrefix);
|
||||
}
|
||||
metadata["dc:title"] = title;
|
||||
|
||||
xmlpp::Node::NodeList childNodes
|
||||
= element.get_children(elementListAttrName);
|
||||
|
@ -129,35 +263,82 @@ Playlist :: configure(const xmlpp::Element & element)
|
|||
addPlaylistElement(newPlaylistElement);
|
||||
++it;
|
||||
}
|
||||
|
||||
isLockedForPlaying = false;
|
||||
isLockedForEditing = false;
|
||||
}
|
||||
|
||||
childNodes = element.get_children(metadataElementName);
|
||||
it = childNodes.begin();
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Playlist :: Playlist(const Playlist & otherPlaylist)
|
||||
throw ()
|
||||
: Playable(PlaylistType)
|
||||
{
|
||||
id = otherPlaylist.id;
|
||||
title = otherPlaylist.title;
|
||||
playlength = otherPlaylist.playlength;
|
||||
uri = otherPlaylist.uri;
|
||||
token = otherPlaylist.token;
|
||||
if (it != childNodes.end()) {
|
||||
const xmlpp::Element * metadataElement
|
||||
= dynamic_cast<const xmlpp::Element*> (*it);
|
||||
|
||||
isLockedForPlaying = otherPlaylist.isLockedForPlaying;
|
||||
isLockedForEditing = otherPlaylist.isLockedForEditing;
|
||||
xmlPlaylist.reset(new xmlpp::Document);
|
||||
xmlpp::Element* root = xmlPlaylist->create_root_node(
|
||||
configElementNameStr);
|
||||
root->set_attribute(idAttrName, std::string(*id));
|
||||
root->import_node(metadataElement, true); // true = recursive
|
||||
|
||||
elementList.reset(new PlaylistElementListType(*otherPlaylist.elementList));
|
||||
|
||||
if (otherPlaylist.savedCopy) {
|
||||
savedCopy.reset(new Playlist(*otherPlaylist.savedCopy));
|
||||
const xmlpp::Node::NodeList dataFieldList
|
||||
= metadataElement->get_children();
|
||||
xmlpp::Node::NodeList::const_iterator listIt = dataFieldList.begin();
|
||||
|
||||
while (listIt != dataFieldList.end()) {
|
||||
const xmlpp::Node* dataNode = *listIt;
|
||||
std::string prefix = dataNode->get_namespace_prefix();
|
||||
std::string name = dataNode->get_name();
|
||||
const xmlpp::Element*
|
||||
dataElement
|
||||
= dynamic_cast<const xmlpp::Element*> (dataNode);
|
||||
if (!dataElement) {
|
||||
++listIt;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!playlength && prefix == extentElementPrefix
|
||||
&& name == extentElementName) {
|
||||
if (dataElement->has_child_text()) {
|
||||
playlength.reset(new time_duration(duration_from_string(
|
||||
dataElement->get_child_text()->get_content() )));
|
||||
} else { // or just leave blank? bad either way
|
||||
playlength.reset(new time_duration(0,0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
if (!title && prefix == titleElementPrefix
|
||||
&& name == titleElementName) {
|
||||
Glib::ustring value;
|
||||
if (dataElement->has_child_text()) {
|
||||
value = dataElement->get_child_text()->get_content();
|
||||
} else {
|
||||
value = "";
|
||||
}
|
||||
Ptr<const Glib::ustring>::Ref ptrToValue(
|
||||
new const Glib::ustring(value));
|
||||
title = ptrToValue;
|
||||
}
|
||||
|
||||
++listIt;
|
||||
}
|
||||
|
||||
++it;
|
||||
if (it != childNodes.end()) {
|
||||
std::string eMsg = "more than one ";
|
||||
eMsg += metadataElementName;
|
||||
eMsg += " XML element";
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (!playlength) {
|
||||
std::string eMsg = "missing attribute ";
|
||||
eMsg += playlengthAttrName;
|
||||
eMsg += " or metadata element ";
|
||||
eMsg += extentElementPrefix + ":" + extentElementName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
metadata = otherPlaylist.metadata;
|
||||
if (!title) {
|
||||
title.reset(new const Glib::ustring(""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -202,7 +383,7 @@ Playlist::addAudioClip(Ptr<AudioClip>::Ref audioClip,
|
|||
*relativeOffset
|
||||
+ *audioClip->getPlaylength()));
|
||||
if (*endOffset > *playlength) {
|
||||
playlength = endOffset;
|
||||
setPlaylength(endOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +410,7 @@ Playlist::addPlaylist(Ptr<Playlist>::Ref playlist,
|
|||
*relativeOffset
|
||||
+ *playlist->getPlaylength()));
|
||||
if (*endOffset > *playlength) {
|
||||
playlength = endOffset;
|
||||
setPlaylength(endOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,52 +450,6 @@ Playlist::removePlaylistElement(Ptr<const time_duration>::Ref relativeOffset)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Lock or unlock the playlist for editing.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
Playlist::setLockedForEditing(const bool lockStatus)
|
||||
throw ()
|
||||
{
|
||||
if (lockStatus == true) {
|
||||
if (isLockedForPlaying || isLockedForEditing) {
|
||||
return false;
|
||||
} else {
|
||||
isLockedForEditing = true;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (isLockedForPlaying) {
|
||||
return false;
|
||||
} else {
|
||||
isLockedForEditing = false;
|
||||
return true; // returns true also if playlist
|
||||
} // was already unlocked!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Lock or unlock the playlist for playing.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
Playlist::setLockedForPlaying(const bool lockStatus)
|
||||
throw ()
|
||||
{
|
||||
if (lockStatus == true) {
|
||||
if (isLockedForPlaying) {
|
||||
return false;
|
||||
} else {
|
||||
isLockedForPlaying = true; // preserve LockedForEditing state
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
isLockedForPlaying = false; // restore LockedForEditing state;
|
||||
return true; // returns true also if playlist
|
||||
} // was already unlocked!
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Validate the playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -342,12 +477,12 @@ Playlist::valid(void) throw ()
|
|||
return false;
|
||||
}
|
||||
*runningTime += *(playlist->getPlaylength());
|
||||
} else { // this should never happen
|
||||
} else { // this should never happen
|
||||
return false;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
playlength = runningTime; // fix playlength, if everything else is OK
|
||||
setPlaylength(runningTime); // fix playlength, if everything else is OK
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -358,18 +493,7 @@ Playlist::valid(void) throw ()
|
|||
void
|
||||
Playlist::createSavedCopy(void) throw ()
|
||||
{
|
||||
savedCopy = Ptr<Playlist>::Ref(new Playlist);
|
||||
|
||||
savedCopy->id = this->id;
|
||||
savedCopy->playlength = this->playlength;
|
||||
savedCopy->isLockedForPlaying = this->isLockedForPlaying;
|
||||
savedCopy->isLockedForEditing = this->isLockedForEditing;
|
||||
|
||||
// note: we create a new copy of the playlist element map, but not of the
|
||||
// individual playlist elements, which (i think) are immutable
|
||||
savedCopy->elementList.reset(new PlaylistElementListType(*elementList));
|
||||
|
||||
savedCopy->savedCopy.reset();
|
||||
savedCopy = Ptr<Playlist>::Ref(new Playlist(*this));
|
||||
}
|
||||
|
||||
|
||||
|
@ -383,11 +507,13 @@ Playlist::revertToSavedCopy(void) throw (std::invalid_argument)
|
|||
throw (std::invalid_argument("playlist has no saved copy"));
|
||||
}
|
||||
|
||||
this->id = savedCopy->id;
|
||||
this->playlength = savedCopy->playlength;
|
||||
this->isLockedForPlaying = savedCopy->isLockedForPlaying;
|
||||
this->isLockedForEditing = savedCopy->isLockedForEditing;
|
||||
this->elementList = savedCopy->elementList;
|
||||
this->id = savedCopy->id;
|
||||
this->title = savedCopy->title;
|
||||
this->playlength = savedCopy->playlength;
|
||||
this->uri = savedCopy->uri;
|
||||
this->token = savedCopy->token;
|
||||
this->elementList = savedCopy->elementList;
|
||||
this->xmlPlaylist = savedCopy->xmlPlaylist;
|
||||
|
||||
savedCopy.reset();
|
||||
}
|
||||
|
@ -400,35 +526,125 @@ Ptr<Glib::ustring>::Ref
|
|||
Playlist :: getMetadata(const string &key) const
|
||||
throw ()
|
||||
{
|
||||
metadataType::const_iterator it = metadata.find(key);
|
||||
std::string name, prefix;
|
||||
separateNameAndNameSpace(key, name, prefix);
|
||||
|
||||
if (it != metadata.end()) {
|
||||
Ptr<Glib::ustring>::Ref data(new Glib::ustring(*it->second));
|
||||
return data;
|
||||
} else {
|
||||
Ptr<Glib::ustring>::Ref nullPointer;
|
||||
return nullPointer;
|
||||
Ptr<Glib::ustring>::Ref value;
|
||||
|
||||
if (! xmlPlaylist) {
|
||||
return value;
|
||||
}
|
||||
xmlpp::Element* rootNode = xmlPlaylist->get_root_node();
|
||||
if (! rootNode) {
|
||||
return value;
|
||||
}
|
||||
xmlpp::Node::NodeList rootList = rootNode->get_children(
|
||||
metadataElementName);
|
||||
if (rootList.size() == 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
xmlpp::Node* metadata = rootList.front();
|
||||
xmlpp::Node::NodeList nodeList = metadata->get_children(name);
|
||||
xmlpp::Node::NodeList::iterator it = nodeList.begin();
|
||||
|
||||
while (it != nodeList.end()) {
|
||||
xmlpp::Node* node = *it;
|
||||
if (node->get_namespace_prefix() == prefix) {
|
||||
xmlpp::Element* element = dynamic_cast<xmlpp::Element*> (node);
|
||||
value.reset(new Glib::ustring(element->get_child_text()
|
||||
->get_content()));
|
||||
return value;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the value of a metadata field.
|
||||
* Set the value of a metadata field (public).
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const string &key)
|
||||
const std::string &key)
|
||||
throw ()
|
||||
{
|
||||
metadata[key] = value;
|
||||
|
||||
if (key == "dcterms:extent") {
|
||||
playlength.reset(new time_duration(duration_from_string(*value)));
|
||||
std::string name, prefix;
|
||||
separateNameAndNameSpace(key, name, prefix);
|
||||
setMetadata(value, name, prefix);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set the value of a metadata field (private).
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
||||
const std::string &name, const std::string &prefix)
|
||||
throw ()
|
||||
{
|
||||
if (prefix == extentElementPrefix && name == extentElementName) {
|
||||
playlength.reset(new time_duration(
|
||||
duration_from_string(*value) ));
|
||||
}
|
||||
|
||||
if (key == "dc:title") {
|
||||
if (prefix == titleElementPrefix && name == titleElementName) {
|
||||
title = value;
|
||||
}
|
||||
}
|
||||
|
||||
// create a new xmlpp::Document for the metadata if necessary
|
||||
if (! xmlPlaylist) {
|
||||
xmlPlaylist.reset(new xmlpp::Document);
|
||||
}
|
||||
xmlpp::Element* rootNode = xmlPlaylist->get_root_node();
|
||||
if (! rootNode) {
|
||||
rootNode = xmlPlaylist->create_root_node(configElementNameStr);
|
||||
if (id) {
|
||||
rootNode->set_attribute(idAttrName, std::string(*id));
|
||||
}
|
||||
}
|
||||
xmlpp::Node::NodeList rootList = rootNode->get_children(
|
||||
metadataElementName);
|
||||
xmlpp::Element* metadata;
|
||||
if (rootList.size() > 0) {
|
||||
metadata = dynamic_cast<xmlpp::Element*> (rootList.front());
|
||||
} else {
|
||||
metadata = rootNode->add_child(metadataElementName);
|
||||
metadata->set_namespace_declaration(defaultPrefixUri);
|
||||
metadata->set_namespace_declaration(titleElementUri,
|
||||
titleElementPrefix);
|
||||
metadata->set_namespace_declaration(extentElementUri,
|
||||
extentElementPrefix);
|
||||
}
|
||||
|
||||
// find the element to be modified
|
||||
xmlpp::Node::NodeList nodeList = metadata->get_children(name);
|
||||
xmlpp::Node::NodeList::iterator it = nodeList.begin();
|
||||
xmlpp::Element* element = 0;
|
||||
|
||||
while (it != nodeList.end()) {
|
||||
xmlpp::Node* node = *it;
|
||||
if (node->get_namespace_prefix() == prefix) {
|
||||
element = dynamic_cast<xmlpp::Element*> (nodeList.front());
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
// or add it if it did not exist before
|
||||
if (it == nodeList.end()) {
|
||||
element = metadata->add_child(name);
|
||||
try {
|
||||
element->set_namespace(prefix);
|
||||
}
|
||||
catch (xmlpp::exception &e) {
|
||||
// this namespace has not been declared; well OK, do nothing then
|
||||
}
|
||||
}
|
||||
|
||||
element->set_child_text(*value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -436,7 +652,7 @@ Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
* Return a string containing the essential fields of this object, in XML.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
Playlist :: getXmlString(void) throw ()
|
||||
Playlist :: getXmlElementString(void) throw ()
|
||||
{
|
||||
Ptr<Glib::ustring>::Ref xmlString(new Glib::ustring);
|
||||
|
||||
|
@ -451,10 +667,10 @@ Playlist :: getXmlString(void) throw ()
|
|||
xmlString->append(Glib::ustring(titleAttrName) + "=\""
|
||||
+ *getTitle()
|
||||
+ "\">\n");
|
||||
|
||||
|
||||
PlaylistElementListType::const_iterator it = elementList->begin();
|
||||
while (it != elementList->end()) {
|
||||
xmlString->append(*it->second->getXmlString() + "\n");
|
||||
xmlString->append(*it->second->getXmlElementString() + "\n");
|
||||
++it;
|
||||
}
|
||||
|
||||
|
@ -464,3 +680,40 @@ Playlist :: getXmlString(void) throw ()
|
|||
return xmlString;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return a string containing an XML representation of this playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
Playlist :: getXmlDocumentString() throw ()
|
||||
{
|
||||
Ptr<xmlpp::Document>::Ref localDocument;
|
||||
|
||||
if (xmlPlaylist) {
|
||||
localDocument = xmlPlaylist;
|
||||
} else {
|
||||
localDocument.reset(new xmlpp::Document());
|
||||
xmlpp::Element* rootNode = localDocument->create_root_node(
|
||||
configElementNameStr);
|
||||
if (id) {
|
||||
rootNode->set_attribute(idAttrName, std::string(*id));
|
||||
}
|
||||
}
|
||||
|
||||
Glib::ustring playlistElementsXmlString("\n");
|
||||
Playlist::const_iterator it = this->begin();
|
||||
while (it != this->end()) {
|
||||
playlistElementsXmlString += *(it->second->getXmlElementString());
|
||||
playlistElementsXmlString += '\n';
|
||||
++it;
|
||||
}
|
||||
|
||||
Ptr<Glib::ustring>::Ref metadataString(new Glib::ustring(
|
||||
localDocument->write_to_string() ));
|
||||
unsigned int insertPosition = metadataString->find(metadataElementName);
|
||||
insertPosition = metadataString->rfind('<', insertPosition);
|
||||
metadataString->insert(insertPosition, playlistElementsXmlString);
|
||||
|
||||
return metadataString;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistElement.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -189,7 +189,7 @@ PlaylistElement :: configure(const xmlpp::Element & element)
|
|||
* Return a string containing the essential fields of this object, in XML.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Glib::ustring>::Ref
|
||||
PlaylistElement :: getXmlString(void) throw ()
|
||||
PlaylistElement :: getXmlElementString(void) throw ()
|
||||
{
|
||||
Ptr<Glib::ustring>::Ref xmlString(new Glib::ustring);
|
||||
|
||||
|
@ -201,9 +201,9 @@ PlaylistElement :: getXmlString(void) throw ()
|
|||
xmlString->append(relativeOffsetAttrName + "=\""
|
||||
+ to_simple_string(*relativeOffset)
|
||||
+ "\">\n");
|
||||
xmlString->append(*getPlayable()->getXmlString() + "\n");
|
||||
xmlString->append(*getPlayable()->getXmlElementString() + "\n");
|
||||
if (fadeInfo) {
|
||||
xmlString->append(*fadeInfo->getXmlString() + "\n");
|
||||
xmlString->append(*fadeInfo->getXmlElementString() + "\n");
|
||||
}
|
||||
xmlString->append("</");
|
||||
xmlString->append(configElementNameStr + ">");
|
||||
|
|
|
@ -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/src/PlaylistElementTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -148,7 +148,7 @@ PlaylistElementTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT(playlistElement->getType()
|
||||
== PlaylistElement::AudioClipType);
|
||||
|
||||
CPPUNIT_ASSERT(*playlistElement->getXmlString() ==
|
||||
CPPUNIT_ASSERT(*playlistElement->getXmlElementString() ==
|
||||
"<playlistElement id=\"0000000000000111\" "
|
||||
"relativeOffset=\"00:00:00\">\n"
|
||||
"<audioClip id=\"0000000000010003\" "
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.20 $
|
||||
Version : $Revision: 1.21 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -114,8 +114,9 @@ PlaylistTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT(duration->total_seconds() == 34);
|
||||
|
||||
CPPUNIT_ASSERT(playlist->valid());
|
||||
CPPUNIT_ASSERT(*playlist->getXmlString() ==
|
||||
"<playlist id=\"0000000000000001\" playlength=\"00:00:34\" title=\"\">\n"
|
||||
CPPUNIT_ASSERT(*playlist->getXmlElementString() ==
|
||||
"<playlist id=\"0000000000000001\" playlength=\"00:00:34\" "
|
||||
"title=\"My First Playlist\">\n"
|
||||
"<playlistElement id=\"0000000000000101\" relativeOffset=\"00:00:00\">\n"
|
||||
"<audioClip id=\"0000000000010001\" playlength=\"00:00:11\" title=\"one\"/>\n"
|
||||
"</playlistElement>\n"
|
||||
|
@ -144,7 +145,6 @@ PlaylistTest :: firstTest(void)
|
|||
== PlaylistElement::AudioClipType);
|
||||
CPPUNIT_ASSERT(playlistElement->getAudioClip()->getId()->getId()
|
||||
== 0x10001);
|
||||
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it != playlist->end());
|
||||
playlistElement = it->second;
|
||||
|
@ -157,36 +157,8 @@ PlaylistTest :: firstTest(void)
|
|||
== 0x10002);
|
||||
|
||||
++it;
|
||||
// CPPUNIT_ASSERT(it == playlist->end());
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if locking works
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistTest :: lockTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
CPPUNIT_ASSERT(!playlist->isLocked());
|
||||
CPPUNIT_ASSERT(!playlist->canBeEdited());
|
||||
|
||||
CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
|
||||
CPPUNIT_ASSERT(playlist->isLocked());
|
||||
CPPUNIT_ASSERT(playlist->canBeEdited());
|
||||
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
|
||||
|
||||
CPPUNIT_ASSERT(playlist->setLockedForPlaying(true));
|
||||
CPPUNIT_ASSERT(playlist->isLocked());
|
||||
CPPUNIT_ASSERT(!playlist->canBeEdited());
|
||||
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
|
||||
CPPUNIT_ASSERT(!playlist->setLockedForEditing(false));
|
||||
CPPUNIT_ASSERT(!playlist->setLockedForPlaying(true));
|
||||
|
||||
CPPUNIT_ASSERT(playlist->setLockedForPlaying(false));
|
||||
CPPUNIT_ASSERT(playlist->isLocked());
|
||||
CPPUNIT_ASSERT(playlist->canBeEdited());
|
||||
CPPUNIT_ASSERT(playlist->setLockedForEditing(false));
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it == playlist->end());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -58,14 +58,13 @@ namespace Core {
|
|||
* Unit test for the UploadPlaylistMetohd class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.9 $
|
||||
* @version $Revision: 1.10 $
|
||||
* @see Playlist
|
||||
*/
|
||||
class PlaylistTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(PlaylistTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(lockTest);
|
||||
CPPUNIT_TEST(audioClipTest);
|
||||
CPPUNIT_TEST(savedCopyTest);
|
||||
CPPUNIT_TEST(fadeInfoTest);
|
||||
|
@ -89,14 +88,6 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Testing the locks.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
lockTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Trying to add a new audio clip.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.35 $
|
||||
Version : $Revision: 1.36 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -352,12 +352,6 @@ static const std::string editPlaylistTokenParamName = "token";
|
|||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: savePlaylist */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* XML header string
|
||||
*----------------------------------------------------------------------------*/
|
||||
static const Glib::ustring xmlHeaderString
|
||||
= "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the 'save playlist' method on the storage server
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -1054,7 +1048,7 @@ WebStorageClient :: savePlaylist(Ptr<SessionId>::Ref sessionId,
|
|||
parameters[savePlaylistTokenParamName]
|
||||
= *playlist->getToken();
|
||||
parameters[savePlaylistNewPlaylistParamName]
|
||||
= std::string(xmlHeaderString + *playlist->getXmlString());
|
||||
= std::string(*playlist->getXmlDocumentString());
|
||||
|
||||
result.clear();
|
||||
if (!xmlRpcClient.execute(savePlaylistMethodName.c_str(),
|
||||
|
@ -1505,7 +1499,7 @@ WebStorageClient :: storeAudioClip(Ptr<SessionId>::Ref sessionId,
|
|||
= std::string(*audioClip->getId());
|
||||
}
|
||||
parameters[storeAudioClipMetadataParamName]
|
||||
= std::string(*audioClip->getMetadataString());
|
||||
= std::string(*audioClip->getXmlDocumentString());
|
||||
parameters[storeAudioClipFileNameParamName]
|
||||
= std::string(*audioClip->getUri());
|
||||
parameters[storeAudioClipChecksumParamName]
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
<!ELEMENT authenticationClientFactory (testAuthentication|
|
||||
webAuthentication)>
|
||||
|
||||
<!ELEMENT webAuthentication (location) >
|
||||
<!ELEMENT testAuthentication (user) >
|
||||
|
||||
<!ELEMENT user EMPTY >
|
||||
<!ATTLIST user login CDATA #REQUIRED >
|
||||
<!ATTLIST user password CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT location EMPTY >
|
||||
<!ATTLIST location server CDATA #REQUIRED >
|
||||
<!ATTLIST location port NMTOKEN #REQUIRED >
|
||||
<!ATTLIST location path CDATA #REQUIRED >
|
||||
]>
|
||||
<authenticationClientFactory>
|
||||
<webAuthentication>
|
||||
<location server="localhost" port="80"
|
||||
path="/livesupportStorageServer/xmlrpc/xrLocStor.php" />
|
||||
</webAuthentication>
|
||||
<testAuthentication>
|
||||
<user login="root" password="q" />
|
||||
</testAuthentication>
|
||||
</authenticationClientFactory>
|
||||
|
|
|
@ -3,18 +3,48 @@
|
|||
|
||||
<!ELEMENT storageClientFactory (webStorage|testStorage) >
|
||||
|
||||
<!ELEMENT webStorage (location) >
|
||||
<!ATTLIST webStorage tempFiles CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT location EMPTY >
|
||||
<!ATTLIST location server CDATA #REQUIRED >
|
||||
<!ATTLIST location port NMTOKEN #REQUIRED >
|
||||
<!ATTLIST location path CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT testStorage (playlist*, audioClip*) >
|
||||
<!ATTLIST testStorage tempFiles CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement ((audioClip|playlist), fadeInfo?) >
|
||||
<!ATTLIST playlistElement id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT audioClip EMPTY >
|
||||
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip title CDATA #REQUIRED >
|
||||
<!ATTLIST audioClip uri CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT fadeInfo EMPTY >
|
||||
<!ATTLIST fadeInfo id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST fadeInfo fadeIn NMTOKEN #REQUIRED >
|
||||
<!ATTLIST fadeInfo fadeOut NMTOKEN #REQUIRED >
|
||||
]>
|
||||
<storageClientFactory>
|
||||
<webStorage tempFiles="file:///tmp/webStorageClient" >
|
||||
<location server="localhost" port="80"
|
||||
path="/livesupportStorageServer/xmlrpc/xrLocStor.php" />
|
||||
</webStorage>
|
||||
<testStorage tempFiles="file:///tmp/tempPlaylist">
|
||||
<playlist id="0000000000000001" playlength="01:30:00.000">
|
||||
<playlistElement id="0000000000000101" relativeOffset="0" >
|
||||
<audioClip id="0000000000010001" playlength="01:00:00.000"
|
||||
title="one"
|
||||
uri="file:var/test1.mp3" />
|
||||
</playlistElement>
|
||||
<playlistElement id="0000000000000102"
|
||||
relativeOffset="01:00:00.000" >
|
||||
<audioClip id="0000000000010002" playlength="00:30:00.000"
|
||||
title="two"
|
||||
uri="file:var/test2.mp3" />
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
<audioClip id="0000000000010001" playlength="01:00:00.000"
|
||||
title="one"
|
||||
uri="file:var/test1.mp3" />
|
||||
<audioClip id="0000000000010002" playlength="00:30:00.000"
|
||||
title="two"
|
||||
uri="file:var/test2.mp3" />
|
||||
</testStorage>
|
||||
</storageClientFactory>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.14 $
|
||||
Version : $Revision: 1.15 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -158,7 +158,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!playlist->canBeEdited()) {
|
||||
if (!playlist->isLocked()) {
|
||||
XmlRpcTools::markError(errorId+6,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.12 $
|
||||
Version : $Revision: 1.13 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -146,11 +146,5 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!playlist->setLockedForEditing(true)) { // this should never happen
|
||||
XmlRpcTools :: markError(errorId+3,
|
||||
"could not open new playlist for editing",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
XmlRpcTools :: playlistToXmlRpcValue(playlist, returnValue);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -90,12 +90,11 @@ using namespace LiveSupport::Core;
|
|||
* <ul>
|
||||
* <li>201 - invalid argument format</li>
|
||||
* <li>202 - could not create playlist</li>
|
||||
* <li>203 - could not open new playlist for editing</li>
|
||||
* <li>220 - missing session ID argument </li>
|
||||
* </ul>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.7 $
|
||||
* @version $Revision: 1.8 $
|
||||
*/
|
||||
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.15 $
|
||||
Version : $Revision: 1.16 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -142,13 +142,6 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!playlist->setLockedForEditing(true)) {
|
||||
XmlRpcTools::markError(errorId+5,
|
||||
"could not lock playlist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
playlist->createSavedCopy();
|
||||
|
||||
XmlRpcTools::playlistToXmlRpcValue(playlist, returnValue);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.9 $
|
||||
Version : $Revision: 1.10 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -94,11 +94,10 @@ using namespace LiveSupport::Core;
|
|||
* <li>101 - invalid argument format </li>
|
||||
* <li>102 - argument is not a playlist ID </li>
|
||||
* <li>104 - could not open playlist for editing </li>
|
||||
* <li>105 - could not lock playlist </li>
|
||||
* <li>120 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.9 $
|
||||
* @version $Revision: 1.10 $
|
||||
*/
|
||||
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.11 $
|
||||
Version : $Revision: 1.12 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -153,7 +153,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!playlist->canBeEdited()) {
|
||||
if (!playlist->isLocked()) {
|
||||
XmlRpcTools::markError(errorId+5,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.9 $
|
||||
Version : $Revision: 1.10 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -137,13 +137,6 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!playlist->setLockedForEditing(false)) {
|
||||
XmlRpcTools::markError(errorId+4,
|
||||
"could not unlock playlist",
|
||||
returnValue);
|
||||
return;
|
||||
}
|
||||
|
||||
playlist->deleteSavedCopy();
|
||||
|
||||
try {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -87,12 +87,11 @@ using namespace LiveSupport::Core;
|
|||
* <li>701 - invalid argument format </li>
|
||||
* <li>702 - argument is not a playlist ID </li>
|
||||
* <li>703 - playlist not found </li>
|
||||
* <li>704 - could not unlock playlist </li>
|
||||
* <li>705 - could not save playlist </li>
|
||||
* <li>720 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.6 $
|
||||
*/
|
||||
class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.8 $
|
||||
Version : $Revision: 1.9 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -175,7 +175,7 @@ UpdateFadeInFadeOutMethod :: execute(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!playlist->canBeEdited()) {
|
||||
if (!playlist->isLocked()) {
|
||||
XmlRpcTools::markError(errorId+7,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -142,7 +142,7 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!playlist->canBeEdited()) {
|
||||
if (!playlist->isLocked()) {
|
||||
XmlRpcTools::markError(errorId+4,
|
||||
"playlist has not been opened for editing",
|
||||
returnValue);
|
||||
|
|
Loading…
Reference in New Issue