wrote configuration of AudioClip from metafile;

added toXml() method to AudioClip
This commit is contained in:
fgerlits 2004-12-29 10:02:29 +00:00
parent f57fa14fbd
commit 11f46d11ba
17 changed files with 377 additions and 196 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<audioClip id="1" playlength="00:18:30.000" uri="file:var/test1.mp3">
<audioClip id="0000000000000001"
playlength="00:18:30.000000" uri="file:var/test1.mp3">
<metadata
xmlns="http://www.streamonthefly.org/"
xmlns:dc="http://purl.org/dc/elements/1.1/"

View File

@ -20,21 +20,29 @@
<!ATTLIST fadeInfo fadeOut NMTOKEN #REQUIRED >
]>
<playlist id="1" playlength="00:00:34.000" >
<playlist id="0000000000000001"
playlength="00:00:34.000" >
<playlistElement id="101" relativeOffset="0" >
<audioClip id="10001" playlength="00:00:11.000"
uri="file:var/test1.mp3" />
</playlistElement>
<playlistElement id="102" relativeOffset="00:00:11.000000" >
<audioClip id="10002" playlength="00:00:12.000000"
<playlistElement id="0000000000000102"
relativeOffset="00:00:11.000000" >
<audioClip id="0000000000010002"
playlength="00:00:12.000000"
uri="file:var/test2.mp3" />
<fadeInfo id="9901" fadeIn="00:00:02.000000"
fadeOut="00:00:01.500000" />
<fadeInfo id="0000000000009901"
fadeIn="00:00:02.000000"
fadeOut="00:00:01.500000" />
</playlistElement>
<playlistElement id="103" relativeOffset="00:00:23.000000" >
<playlist id="2" playlength="00:00:11.000000" >
<playlistElement id="111" relativeOffset="0" >
<audioClip id="10003" playlength="00:00:11.000"
<playlistElement id="0000000000000103"
relativeOffset="00:00:23.000000" >
<playlist id="0000000000000002"
playlength="00:00:11.000000" >
<playlistElement id="0000000000000111"
relativeOffset="0" >
<audioClip id="0000000000010003"
playlength="00:00:11.000"
uri="file:var/test3.mp3" />
</playlistElement>
</playlist>

View File

@ -20,12 +20,18 @@
<!ATTLIST fadeInfo fadeOut NMTOKEN #REQUIRED >
]>
<playlistElement id="103" relativeOffset="00:00:11.000000" >
<playlist id="2" playlength="00:00:11.000000" >
<playlistElement id="111" relativeOffset="0" >
<audioClip id="10003" playlength="00:00:11.000"
uri="file:var/test3.mp3" />
<playlistElement id="0000000000000103"
relativeOffset="00:00:11.000000" >
<playlist id="0000000000000002"
playlength="00:00:11.000000" >
<playlistElement id="0000000000000111"
relativeOffset="0" >
<audioClip id="0000000000010003"
playlength="00:00:11.000"
uri="file:var/test3.mp3" />
</playlistElement>
</playlist>
<fadeInfo id="9901" fadeIn="00:00:02.000" fadeOut="00:00:01.500000" />
<fadeInfo id="0000000000009901"
fadeIn="00:00:02.000"
fadeOut="00:00:01.500000" />
</playlistElement>

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.12 $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h,v $
------------------------------------------------------------------------------*/
@ -100,7 +100,15 @@ using namespace boost::posix_time;
* <code>playlength</code> attribute and the
* <code>&lt;dcterms:extent&gt;</code>
* element are present, then the playlength is set from the attribute and
* <code>&lt;dcterms:extent&gt;</code> is ignored.
* <code>&lt;dcterms:extent&gt;</code> is ignored. Embedded XML elements are
* currently ignored: e.g., <pre><code> &lt;group&gt;
* &lt;member1&gt;value1&lt;/member1&gt;
* &lt;member2&gt;value2&lt;/member2&gt;
* &lt;/group&gt;</code></pre> produces a single metadata field
* <code>group</code>
* with an empty value,
* and ignores <code>member1</code> and <code>member2</code>.
* TODO: fix this?
*
* The URI is not normally part of the XML element; it's only included
* as an optional attribute for testing purposes.
@ -116,7 +124,7 @@ using namespace boost::posix_time;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.12 $
* @version $Revision: 1.13 $
*/
class AudioClip : public Configurable,
public Playable
@ -135,7 +143,7 @@ class AudioClip : public Configurable,
/**
* The title of the audio clip.
*/
Ptr<UnicodeString>::Ref title;
Ptr<Glib::ustring>::Ref title;
/**
* The playling length of the audio clip.
@ -145,23 +153,17 @@ class AudioClip : public Configurable,
/**
* The location of the binary audio clip sound file.
*/
Ptr<const string>::Ref uri;
Ptr<const std::string>::Ref uri;
/**
* The identifying token returned by the storage server.
*/
Ptr<const string>::Ref token;
Ptr<const std::string>::Ref token;
/**
* The type for storing the metadata.
* This audio clip in XML format.
*/
typedef std::map<const std::string, Ptr<UnicodeString>::Ref>
metadataType;
/**
* The metadata for this audio clip.
*/
metadataType metadata;
Ptr<xmlpp::Document>::Ref xmlAudioClip;
public:
@ -197,13 +199,7 @@ class AudioClip : public Configurable,
AudioClip(Ptr<UniqueId>::Ref id,
Ptr<time_duration>::Ref playlength,
Ptr<string>::Ref uri = Ptr<string>::Ref())
throw ()
{
this->id = id;
this->title.reset(new UnicodeString(""));
this->playlength = playlength;
this->uri = uri;
}
throw ();
/**
* Create an audio clip by specifying all details.
@ -215,16 +211,10 @@ class AudioClip : public Configurable,
* this audio clip object (optional)
*/
AudioClip(Ptr<UniqueId>::Ref id,
Ptr<UnicodeString>::Ref title,
Ptr<Glib::ustring>::Ref title,
Ptr<time_duration>::Ref playlength,
Ptr<string>::Ref uri = Ptr<string>::Ref())
throw ()
{
this->id = id;
this->title = title;
this->playlength = playlength;
this->uri = uri;
}
throw ();
/**
* A virtual destructor, as this class has virtual functions.
@ -287,7 +277,7 @@ class AudioClip : public Configurable,
*
* @return the URI.
*/
virtual Ptr<const string>::Ref
virtual Ptr<const std::string>::Ref
getUri(void) const throw ()
{
return uri;
@ -300,7 +290,7 @@ class AudioClip : public Configurable,
* @param uri the new URI.
*/
virtual void
setUri(Ptr<const string>::Ref uri) throw ()
setUri(Ptr<const std::string>::Ref uri) throw ()
{
this->uri = uri;
}
@ -311,7 +301,7 @@ class AudioClip : public Configurable,
*
* @return the token.
*/
virtual Ptr<const string>::Ref
virtual Ptr<const std::string>::Ref
getToken(void) const throw ()
{
return token;
@ -324,7 +314,8 @@ class AudioClip : public Configurable,
* @param token a new token.
*/
virtual void
setToken(Ptr<const string>::Ref token) throw ()
setToken(Ptr<const std::string>::Ref token)
throw ()
{
this->token = token;
}
@ -335,7 +326,7 @@ class AudioClip : public Configurable,
*
* @return the title.
*/
virtual Ptr<UnicodeString>::Ref
virtual Ptr<Glib::ustring>::Ref
getTitle(void) const throw ()
{
return title;
@ -347,31 +338,31 @@ class AudioClip : public Configurable,
* @param title a new title.
*/
virtual void
setTitle(Ptr<UnicodeString>::Ref title)
throw ()
{
this->title = title;
}
setTitle(Ptr<Glib::ustring>::Ref title)
throw ();
/**
* Return the value of a metadata field in this audio clip.
*
* @param key the name of the metadata field
* @param ns the namespace of the metadata field (optional)
* @return the value of the metadata field; 0 if there is
* no such field;
*/
virtual Ptr<UnicodeString>::Ref
getMetadata(const string &key) const
virtual Ptr<Glib::ustring>::Ref
getMetadata(const std::string &key, const std::string &ns = "") const
throw ();
/**
* Set the value of a metadata field in this audio clip.
*
* @param key the name of the metadata field.
* @param value the new value of the metadata field.
* @param key the name of the metadata field
* @param ns the namespace of the metadata field (optional)
*/
virtual void
setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
setMetadata(Ptr<Glib::ustring>::Ref value, const std::string &key,
const std::string &ns = "")
throw ();
@ -383,7 +374,10 @@ class AudioClip : public Configurable,
* @return an xmlpp::Document containing the metadata.
*/
Ptr<xmlpp::Document>::Ref
toXml() throw ();
toXml() throw ()
{
return xmlAudioClip;
}
};

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playable.h,v $
------------------------------------------------------------------------------*/
@ -44,7 +44,7 @@
#include <string>
#include <libxml++/libxml++.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <unicode/unistr.h>
#include <glibmm/ustring.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/UniqueId.h"
@ -70,7 +70,7 @@ using namespace boost::posix_time;
* It contains the methods which are common to these classes.
*
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @version $Revision: 1.3 $
*/
class Playable
{
@ -138,7 +138,7 @@ class Playable
*
* @return the title.
*/
virtual Ptr<UnicodeString>::Ref
virtual Ptr<Glib::ustring>::Ref
getTitle(void) const throw () = 0;
/**
@ -147,29 +147,35 @@ class Playable
* @param title a new title.
*/
virtual void
setTitle(Ptr<UnicodeString>::Ref title)
setTitle(Ptr<Glib::ustring>::Ref title)
throw () = 0;
/**
* Return the value of a metadata field in this audio clip or playlist.
*
* @param key the name of the metadata field
* @param ns the namespace of the metadata field (optional)
* @return the value of the metadata field; 0 if there is
* no such field;
*/
virtual Ptr<UnicodeString>::Ref
getMetadata(const string &key) const
virtual Ptr<Glib::ustring>::Ref
getMetadata(const std::string &key, const std::string &ns = "") const
throw () = 0;
/**
* Set the value of a metadata field in this audio clip or playlist.
*
* @param key the name of the metadata field.
* @param value the new value of the metadata field.
* @param key the name of the metadata field
* @param ns the namespace of the metadata field (optional)
*/
virtual void
setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
setMetadata(Ptr<Glib::ustring>::Ref value, const std::string &key,
const std::string &ns = "")
throw () = 0;
};

View File

@ -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/Playlist.h,v $
------------------------------------------------------------------------------*/
@ -93,7 +93,7 @@ using namespace boost::posix_time;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.20 $
* @version $Revision: 1.21 $
*/
class Playlist : public Configurable,
public Playable
@ -112,7 +112,7 @@ class Playlist : public Configurable,
/**
* The title of the playlist.
*/
Ptr<UnicodeString>::Ref title;
Ptr<Glib::ustring>::Ref title;
/**
* The playling length of the playlist.
@ -171,7 +171,7 @@ class Playlist : public Configurable,
/**
* The type for storing the metadata.
*/
typedef std::map<const std::string, Ptr<UnicodeString>::Ref>
typedef std::map<const std::string, Ptr<Glib::ustring>::Ref>
metadataType;
/**
@ -206,7 +206,7 @@ class Playlist : public Configurable,
throw ()
{
this->id = id;
this->title.reset(new UnicodeString(""));
this->title.reset(new Glib::ustring(""));
this->playlength = playlength;
this->uri = uri;
elementList.reset(new PlaylistElementListType);
@ -224,7 +224,7 @@ class Playlist : public Configurable,
* playlist (optional)
*/
Playlist(Ptr<UniqueId>::Ref id,
Ptr<UnicodeString>::Ref title,
Ptr<Glib::ustring>::Ref title,
Ptr<time_duration>::Ref playlength,
Ptr<std::string>::Ref uri = Ptr<std::string>::Ref())
throw ()
@ -541,7 +541,7 @@ class Playlist : public Configurable,
*
* @return the title.
*/
virtual Ptr<UnicodeString>::Ref
virtual Ptr<Glib::ustring>::Ref
getTitle(void) const throw ()
{
return title;
@ -553,7 +553,7 @@ class Playlist : public Configurable,
* @param title a new title.
*/
virtual void
setTitle(Ptr<UnicodeString>::Ref title)
setTitle(Ptr<Glib::ustring>::Ref title)
throw ()
{
this->title = title;
@ -563,26 +563,29 @@ class Playlist : public Configurable,
/**
* Return the value of a metadata field in this playlist.
*
* Currently, this always returns a null pointer.
*
* @param key the name of the metadata field
* @param ns the namespace of the metadata field (optional)
* @return the value of the metadata field; 0 if there is
* no such field;
*/
virtual Ptr<UnicodeString>::Ref
getMetadata(const string &key) const
virtual Ptr<Glib::ustring>::Ref
getMetadata(const std::string &key, const std::string &ns = "") const
throw ();
/**
* Set the value of a metadata field in this playlist.
*
* Currently, this does not do anything.
*
* @param key the name of the metadata field.
* @param value the new value of the metadata field.
* @param key the name of the metadata field
* @param ns the namespace of the metadata field (optional)
*/
virtual void
setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
setMetadata(Ptr<Glib::ustring>::Ref value, const std::string &key,
const std::string &ns = "")
throw ();
};

View File

@ -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/AudioClip.cxx,v $
------------------------------------------------------------------------------*/
@ -51,21 +51,6 @@ using namespace LiveSupport::Core;
*----------------------------------------------------------------------------*/
const std::string AudioClip::configElementNameStr = "audioClip";
/**
* 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 name of the attribute to get the id of the audio clip.
*/
@ -81,12 +66,104 @@ static const std::string uriAttrName = "uri";
*/
static const std::string playlengthAttrName = "playlength";
/**
* 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 URI identifier for the "dcterms" prefix
*/
static const std::string extentElementUri = "http://purl.org/dc/terms/";
/**
* The name of the extent (length) metadata element.
*/
static const std::string extentElementName = "extent";
/**
* The prefix of the title metadata element.
*/
static const std::string titleElementPrefix = "dc";
/**
* The URI identifier for the "dc" prefix
*/
static const std::string titleElementUri ="http://purl.org/dc/elements/1.1/";
/**
* The name of the title metadata element.
*/
static const std::string titleElementName = "title";
/**
* The URI identifier for the default XML namespace
*/
static const std::string defaultPrefixUri ="http://www.streamonthefly.org/";
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Test constructor without title.
*----------------------------------------------------------------------------*/
AudioClip :: AudioClip(Ptr<UniqueId>::Ref id,
Ptr<time_duration>::Ref playlength,
Ptr<std::string>::Ref uri)
throw ()
{
this->id = id;
this->title.reset(new Glib::ustring(""));
this->playlength = playlength;
this->uri = uri;
Ptr<Glib::ustring>::Ref playlengthString(new Glib::ustring(
to_simple_string(*playlength) ));
setMetadata(playlengthString, extentElementName, extentElementPrefix);
}
/*------------------------------------------------------------------------------
* Test constructor with title.
*----------------------------------------------------------------------------*/
AudioClip :: AudioClip(Ptr<UniqueId>::Ref id,
Ptr<Glib::ustring>::Ref title,
Ptr<time_duration>::Ref playlength,
Ptr<std::string>::Ref uri)
throw ()
{
this->id = id;
this->title = title;
this->playlength = playlength;
this->uri = uri;
Ptr<Glib::ustring>::Ref playlengthString(new Glib::ustring(
to_simple_string(*playlength) ));
setMetadata(playlengthString, extentElementName, extentElementPrefix);
setMetadata(title, titleElementName, titleElementPrefix);
}
/*------------------------------------------------------------------------------
* Set the value of the title field.
*----------------------------------------------------------------------------*/
void
AudioClip :: setTitle(Ptr<Glib::ustring>::Ref title)
throw ()
{
this->title = title;
setMetadata(title, titleElementName, titleElementPrefix);
}
/*------------------------------------------------------------------------------
* Create an audio clip object based on an XML element.
*----------------------------------------------------------------------------*/
@ -108,9 +185,9 @@ AudioClip :: configure(const xmlpp::Element & element)
eMsg += idAttrName;
throw std::invalid_argument(eMsg);
}
std::stringstream strStr(attribute->get_value());
UniqueId::IdType idValue;
strStr >> idValue;
std::stringstream idStream(attribute->get_value());
UniqueId::IdType idValue;
idStream >> idValue;
id.reset(new UniqueId(idValue));
}
@ -133,26 +210,43 @@ AudioClip :: configure(const xmlpp::Element & element)
const xmlpp::Element * metadataElement
= dynamic_cast<const xmlpp::Element*> (*it);
xmlpp::Node::NodeList dataFieldList
= metadataElement->get_children();
xmlpp::Node::NodeList::iterator listIt = dataFieldList.begin();
xmlAudioClip.reset(new xmlpp::Document);
xmlpp::Element* root = xmlAudioClip->create_root_node("audioClip");
root->set_attribute("id", std::string(*id));
root->import_node(metadataElement, true); // true = recursive
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;
if (!playlength
&& dataNode->get_namespace_prefix() == extentElementPrefix
&& dataNode->get_name() == extentElementName) {
const xmlpp::Element
* dataElement
= dynamic_cast<const xmlpp::Element*> (dataNode);
if (dataElement->has_child_text()) {
std::stringstream strStr(dataElement->get_child_text()
->get_content());
unsigned long int seconds;
strStr >> seconds;
playlength.reset(new time_duration(0,0,seconds,0));
}
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
&& dataElement->has_child_text()) {
playlength.reset(new time_duration(duration_from_string(
dataElement->get_child_text()->get_content() )));
}
if (!title && prefix == titleElementPrefix
&& name == titleElementName
&& dataElement->has_child_text()) {
Glib::ustring value = dataElement->get_child_text()
->get_content();
Ptr<Glib::ustring>::Ref ptrToValue(new Glib::ustring(value));
title = ptrToValue;
}
++listIt;
}
@ -168,27 +262,54 @@ AudioClip :: configure(const xmlpp::Element & element)
if (!playlength) {
std::string eMsg = "missing attribute ";
eMsg += playlengthAttrName;
eMsg += " or metadata element ";
eMsg += extentElementPrefix + ":" + extentElementName;
throw std::invalid_argument(eMsg);
}
Ptr<Glib::ustring>::Ref playlengthString(new Glib::ustring(
to_simple_string(*playlength) ));
setMetadata(playlengthString, extentElementName, extentElementPrefix);
}
/*------------------------------------------------------------------------------
* Return the value of a metadata field.
*----------------------------------------------------------------------------*/
Ptr<UnicodeString>::Ref
AudioClip :: getMetadata(const string &key) const
Ptr<Glib::ustring>::Ref
AudioClip :: getMetadata(const string &key, const std::string &ns) const
throw ()
{
metadataType::const_iterator it = metadata.find(key);
Ptr<Glib::ustring>::Ref value;
if (it != metadata.end()) {
return it->second;
if (! xmlAudioClip) {
return value;
}
else {
Ptr<UnicodeString>::Ref nullPointer;
return nullPointer;
xmlpp::Element* rootNode = xmlAudioClip->get_root_node();
if (! rootNode) {
return value;
}
xmlpp::Node::NodeList rootList = rootNode->get_children("metadata");
if (rootList.size() == 0) {
return value;
}
xmlpp::Node* metadata = rootList.front();
xmlpp::Node::NodeList nodeList = metadata->get_children(key);
xmlpp::Node::NodeList::iterator it = nodeList.begin();
while (it != nodeList.end()) {
xmlpp::Node* node = *it;
if (node->get_namespace_prefix() == ns) {
xmlpp::Element* element = dynamic_cast<xmlpp::Element*> (node);
value.reset(new Glib::ustring(element->get_child_text()
->get_content()));
return value;
}
++it;
}
return value;
}
@ -196,23 +317,63 @@ AudioClip :: getMetadata(const string &key) const
* Set the value of a metadata field.
*----------------------------------------------------------------------------*/
void
AudioClip :: setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
AudioClip :: setMetadata(Ptr<Glib::ustring>::Ref value, const std::string &key,
const std::string &ns)
throw ()
{
metadata[key] = value;
}
/*------------------------------------------------------------------------------
* Create an XML document from this audio clip.
*----------------------------------------------------------------------------*/
Ptr<xmlpp::Document>::Ref
AudioClip :: toXml()
throw ()
{
Ptr<xmlpp::Document>::Ref metadata(new xmlpp::Document);
metadata->create_root_node("metadata");
metadata->add_comment("some data will come here");
return metadata;
if (ns == extentElementPrefix && key == extentElementName) {
playlength.reset(new time_duration(
duration_from_string(*value) ));
}
if (ns == titleElementPrefix && key == titleElementName) {
title = value;
}
if (! xmlAudioClip) {
xmlAudioClip.reset(new xmlpp::Document);
}
xmlpp::Element* rootNode = xmlAudioClip->get_root_node();
if (! rootNode) {
rootNode = xmlAudioClip->create_root_node("audioClip");
}
xmlpp::Node::NodeList rootList = rootNode->get_children("metadata");
xmlpp::Element* metadata;
if (rootList.size() > 0) {
metadata = dynamic_cast<xmlpp::Element*> (rootList.front());
}
else {
metadata = rootNode->add_child("metadata");
metadata->set_namespace_declaration(defaultPrefixUri);
metadata->set_namespace_declaration(titleElementUri,
titleElementPrefix);
metadata->set_namespace_declaration(extentElementUri,
extentElementPrefix);
}
xmlpp::Node::NodeList nodeList = metadata->get_children(key);
xmlpp::Node::NodeList::iterator it = nodeList.begin();
xmlpp::Element* element;
while (it != nodeList.end()) {
xmlpp::Node* node = *it;
if (node->get_namespace_prefix() == ns) {
element = dynamic_cast<xmlpp::Element*> (nodeList.front());
break;
}
++it;
}
if (it == nodeList.end()) {
element = metadata->add_child(key);
try {
element->set_namespace(ns);
}
catch (xmlpp::exception &e) {
// this namespace has not been declared; well OK, do nothing then
}
}
element->set_child_text(*value);
}

View File

@ -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/AudioClipTest.cxx,v $
------------------------------------------------------------------------------*/
@ -95,7 +95,7 @@ AudioClipTest :: firstTest(void)
{
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(configFileName, false));
new xmlpp::DomParser(configFileName, false));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
Ptr<AudioClip>::Ref audioClip(new AudioClip());
@ -103,13 +103,27 @@ AudioClipTest :: firstTest(void)
audioClip->configure(*root);
CPPUNIT_ASSERT(audioClip->getId()->getId() == 1);
Ptr<const boost::posix_time::time_duration>::Ref duration
= audioClip->getPlaylength();
CPPUNIT_ASSERT(duration->hours() == 0);
CPPUNIT_ASSERT(duration->minutes() == 18);
CPPUNIT_ASSERT(duration->seconds() == 30);
Ptr<Glib::ustring>::Ref title = audioClip->getTitle();
CPPUNIT_ASSERT(title);
CPPUNIT_ASSERT(*title == "File Title txt");
Ptr<Glib::ustring>::Ref subject = audioClip
->getMetadata("subject", "dc");
CPPUNIT_ASSERT(subject);
CPPUNIT_ASSERT(*subject == "Keywords: qwe, asd, zcx");
Ptr<Glib::ustring>::Ref alternativeTitle = audioClip
->getMetadata("alternative", "dcterms");
CPPUNIT_ASSERT(alternativeTitle);
CPPUNIT_ASSERT(*alternativeTitle ==
"Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ");
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/FadeInfo.cxx,v $
------------------------------------------------------------------------------*/
@ -86,16 +86,15 @@ FadeInfo :: configure(const xmlpp::Element & element)
}
const xmlpp::Attribute * attribute;
std::stringstream strStr;
unsigned long int idValue;
if (!(attribute = element.get_attribute(idAttrName))) {
std::string eMsg = "missing attribute ";
eMsg += idAttrName;
throw std::invalid_argument(eMsg);
}
strStr.str(attribute->get_value());
strStr >> idValue;
std::stringstream idStream(attribute->get_value());
UniqueId::IdType idValue;
idStream >> idValue;
id.reset(new UniqueId(idValue));
if (!(attribute = element.get_attribute(fadeInAttrName))) {

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.16 $
Version : $Revision: 1.17 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
------------------------------------------------------------------------------*/
@ -86,16 +86,15 @@ Playlist :: configure(const xmlpp::Element & element)
}
const xmlpp::Attribute * attribute;
std::stringstream strStr;
unsigned long int idValue;
if (!(attribute = element.get_attribute(idAttrName))) {
std::string eMsg = "missing attribute ";
eMsg += idAttrName;
throw std::invalid_argument(eMsg);
}
strStr.str(attribute->get_value());
strStr >> idValue;
std::stringstream idStream(attribute->get_value());
UniqueId::IdType idValue;
idStream >> idValue;
id.reset(new UniqueId(idValue));
if (!(attribute = element.get_attribute(playlengthAttrName))) {
@ -369,17 +368,18 @@ Playlist::revertToSavedCopy(void) throw (std::invalid_argument)
/*------------------------------------------------------------------------------
* Return the value of a metadata field.
*----------------------------------------------------------------------------*/
Ptr<UnicodeString>::Ref
Playlist :: getMetadata(const string &key) const
Ptr<Glib::ustring>::Ref
Playlist :: getMetadata(const string &key, const string &ns) const
throw ()
{
metadataType::const_iterator it = metadata.find(key);
std::string completeKey = key + ns;
metadataType::const_iterator it = metadata.find(completeKey);
if (it != metadata.end()) {
return it->second;
}
else {
Ptr<UnicodeString>::Ref nullPointer;
Ptr<Glib::ustring>::Ref nullPointer;
return nullPointer;
}
}
@ -389,9 +389,11 @@ Playlist :: getMetadata(const string &key) const
* Set the value of a metadata field.
*----------------------------------------------------------------------------*/
void
Playlist :: setMetadata(const string &key, Ptr<UnicodeString>::Ref value)
Playlist :: setMetadata(Ptr<Glib::ustring>::Ref value, const string &key,
const string &ns)
throw ()
{
metadata[key] = value;
std::string completeKey = key + ns;
metadata[completeKey] = value;
}

View File

@ -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/PlaylistElement.cxx,v $
------------------------------------------------------------------------------*/
@ -97,17 +97,16 @@ PlaylistElement :: configure(const xmlpp::Element & element)
}
// set id
const xmlpp::Attribute * attribute;
std::stringstream strStr;
UniqueId::IdType idValue;
const xmlpp::Attribute* attribute;
if (!(attribute = element.get_attribute(idAttrName))) {
std::string eMsg = "missing attribute ";
eMsg += idAttrName;
throw std::invalid_argument(eMsg);
}
strStr.str(attribute->get_value());
strStr >> idValue;
std::stringstream idStream(attribute->get_value());
UniqueId::IdType idValue;
idStream >> idValue;
id.reset(new UniqueId(idValue));
// set relative offset

View File

@ -21,7 +21,7 @@
#
#
# Author : $Author: fgerlits $
# Version : $Revision: 1.13 $
# Version : $Revision: 1.14 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/etc/Makefile.in,v $
#
# @configure_input@
@ -73,10 +73,6 @@ VPATH = ${SRC_DIR}
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
# TODO: move ICU flag determination to configure script
ICU_CFLAGS=
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags --ldflags-toolutil --ldflags-icuio`
CURL_LIBS=`${USR_DIR}/bin/curl-config --libs`
TEST_RESULTS = ${DOC_DIR}/testResults.xml
@ -97,14 +93,12 @@ CPPFLAGS = @CPPFLAGS@
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
-pedantic -Wall -Wno-long-long \
-I${USR_INCLUDE_DIR} \
${ICU_CFLAGS} \
${LIBXMLPP_CFLAGS} \
-I${BOOST_INCLUDE_DIR} \
-I${CORE_INCLUDE_DIR} \
-I${AUTHENTICATION_INCLUDE_DIR} \
-I${INCLUDE_DIR} -I${TMP_DIR}
LDFLAGS = @LDFLAGS@ -pthread \
${ICU_LIBS} \
${LIBXMLPP_LIBS} \
${CURL_LIBS} \
-L${USR_LIB_DIR} \
@ -126,7 +120,7 @@ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
${TMP_DIR}/WebStorageClientTest.o
TEST_RUNNER_LIBS = -l${STORAGE_LIB} -l${CORE_LIB} -l${AUTHENTICATION_LIB} \
${ICU_LIBS} -lcppunit -ldl -lxmlrpc++ -lssl
-lcppunit -ldl -lxmlrpc++ -lssl
#-------------------------------------------------------------------------------

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.13 $
Version : $Revision: 1.14 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
------------------------------------------------------------------------------*/
@ -588,6 +588,7 @@ WebStorageClient :: getAudioClip(Ptr<SessionId>::Ref sessionId,
const xmlpp::Element * root = document->get_root_node();
audioClip->configure(*root);
} catch (std::invalid_argument &e) {
throw XmlRpcMethodResponseException(
"semantic error in audio clip metafile");

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.15 $
Version : $Revision: 1.16 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -247,19 +247,18 @@ WebStorageClientTest :: audioClipTest(void)
CPPUNIT_FAIL(e.what());
}
/* this doesn't work yet
Ptr<AudioClip>::Ref newAudioClip;
try {
newAudioClip = wsc->getAudioClip(sessionId, id01);
newAudioClip = wsc->getAudioClip(sessionId, id02);
}
catch (StorageException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(std::string(*newAudioClip->getId()) == std::string(*id01));
CPPUNIT_ASSERT(std::string(*newAudioClip->getId()) == std::string(*id02));
CPPUNIT_ASSERT(newAudioClip->getPlaylength()->total_seconds()
== audioClip->getPlaylength()->total_seconds());
*/
try{
authentication->logout(sessionId);
}

View File

@ -18,7 +18,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 >0:2:3</dcterms:extent>
<dcterms:medium >online</dcterms:medium>
<dc:identifier >streamonthefly:</dc:identifier>
<dc:identifier >http://some.url.mdlf.org/</dc:identifier>

View File

@ -17,7 +17,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:02:03</dcterms:extent>
<dcterms:medium >online</dcterms:medium>
<dc:identifier >streamonthefly:</dc:identifier>
<dc:identifier >http://some.url.mdlf.org/</dc:identifier>
@ -30,4 +30,4 @@
<xbmf:name>John X</xbmf:name>
<xbmf:phone>123456789</xbmf:phone>
</xbmf:contributor>
</metadata>
</metadata>

View File

@ -21,7 +21,7 @@
#
#
# Author : $Author: fgerlits $
# Version : $Revision: 1.36 $
# Version : $Revision: 1.37 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
#
# @configure_input@
@ -65,10 +65,6 @@ VPATH = ${SRC_DIR}
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
# TODO: move ICU flag determination to configure script
ICU_CFLAGS=
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags --ldflags-toolutil --ldflags-icuio`
CURL_LIBS=`${USR_DIR}/bin/curl-config --libs`
MODULES_DIR = ${BASE_DIR}/../../modules
@ -130,7 +126,6 @@ export LD_LIBRARY_PATH=${USR_LIB_DIR}
CPPFLAGS = @CPPFLAGS@
CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
-pedantic -Wall -Wno-long-long \
${ICU_CFLAGS} \
${LIBXMLPP_CFLAGS} \
-I${USR_INCLUDE_DIR} \
-I${BOOST_INCLUDE_DIR} \
@ -143,7 +138,6 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
-I${TMP_DIR}
LDFLAGS = @LDFLAGS@ -pthread \
${LIBXMLPP_LIBS} \
${ICU_LIBS} \
${CURL_LIBS} \
-L${USR_LIB_DIR} \
-L${HELIX_LIB_DIR} \
@ -235,7 +229,7 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
${TMP_DIR}/UpdateFadeInFadeOutMethodTest.o \
${TMP_DIR}/PlaylistEventContainerTest.o \
${TMP_DIR}/PlaylistEventTest.o
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} ${ICU_LIBS} -lcppunit -ldl
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl
#-------------------------------------------------------------------------------