Finally got reading from the storage server to work. Yippee!

This commit is contained in:
fgerlits 2004-12-21 21:00:37 +00:00
parent 48be2884b4
commit 288ad456be
9 changed files with 241 additions and 64 deletions

View file

@ -1,9 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE audioClip [
<!ELEMENT audioClip EMPTY >
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
<!ATTLIST audioClip uri CDATA #IMPLIED >
]>
<audioClip id="1" playlength="00:18:30.000" uri="file:var/test1.mp3" />
<audioClip id="1" playlength="00:18:30.000" uri="file:var/test1.mp3">
<metadata
xmlns="http://www.streamonthefly.org/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xbmf="http://www.streamonthefly.org/xbmf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<dc:title >File Title txt</dc:title>
<dcterms:alternative >Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ</dcterms:alternative>
<dc:subject >Keywords: qwe, asd, zcx</dc:subject>
<dc:description >Abstract txt</dc:description>
<dc:date >2004-05-21</dc:date>
<dcterms:available >2004-05-22</dcterms:available>
<dcterms:issued >2004-05-23</dcterms:issued>
<dcterms:modified >2004-05-24</dcterms:modified>
<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:medium >online</dcterms:medium>
<dc:identifier >streamonthefly:</dc:identifier>
<dc:identifier >http://some.url.mdlf.org/</dc:identifier>
<dcterms:spatial >Spatial Coverage</dcterms:spatial>
<dcterms:temporal >Temporal Covarage</dcterms:temporal>
<xbmf:episodetitle >Episode Title txt</xbmf:episodetitle>
<xbmf:episodesequence >Episode sequence</xbmf:episodesequence>
<xbmf:contributor>
<xbmf:role>Editor</xbmf:role>
<xbmf:name>John X</xbmf:name>
<xbmf:phone>123456789</xbmf:phone>
</xbmf:contributor>
</metadata>
</audioClip>

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/include/LiveSupport/Core/AudioClip.h,v $
------------------------------------------------------------------------------*/
@ -78,24 +78,43 @@ using namespace boost::posix_time;
* <pre><code>
* &lt;audioClip id="1"
* playlength="00:18:30.000000"
* uri="file:var/test1.mp3"
* uri="file:var/test1.mp3" &gt;
* &lt;metadata
* xmlns="http://www.streamonthefly.org/"
* xmlns:dc="http://purl.org/dc/elements/1.1/"
* xmlns:dcterms="http://purl.org/dc/terms/"
* xmlns:xbmf="http://www.streamonthefly.org/xbmf"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" &gt;
* &lt;dc:title &gt;File Title txt&lt;/dc:title&gt;
* &lt;dcterms:extent &gt;123&lt;/dcterms:extent&gt;
* ...
* &lt;/metadata&gt;
* &lt;/audioClip&gt;
* </code></pre>
*
* The metadata element is optional. The <code>configure()</code> method
* sets only those fields which had not been set previously: e.g., if we set
* some or all fields of the AudioClip in the constructor, then these fields
* in the XML element will be ignored by <code>configure()</code>. If both the
* <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.
*
* The URI is not normally part of the XML element; it's only included
* as an optional attribute for testing purposes.
*
* The DTD for the above element is:
*
* <pre><code>
* &lt;!ELEMENT audioClip EMPTY &gt;
* &lt;!ELEMENT audioClip (metadata?) &gt;
* &lt;!ATTLIST audioClip id NMTOKEN #REQUIRED &gt;
* &lt;!ATTLIST audioClip playlength NMTOKEN #REQUIRED &gt;
* &lt;!ATTLIST audioClip uri CDATA #IMPLIED &gt;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.10 $
* @version $Revision: 1.11 $
*/
class AudioClip : public Configurable,
public Playable
@ -135,6 +154,18 @@ class AudioClip : public Configurable,
{
}
/**
* Create an audio clip by specifying its unique ID.
* The other fields will be filled in by configure().
*
* @param id the id of the audio clip.
*/
AudioClip(Ptr<UniqueId>::Ref id)
throw ()
{
this->id = id;
}
/**
* Create an audio clip by specifying all details.
* This is used for testing purposes.

View file

@ -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/TimeConversion.h,v $
------------------------------------------------------------------------------*/
@ -71,7 +71,7 @@ using namespace LiveSupport;
* A helper object holding static time conversion functions.
*
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class TimeConversion
{
@ -115,7 +115,8 @@ class TimeConversion
* Convert a boost::posix_time::ptime to a struct tm,
* with second precision.
*
* @param time the boost::posix_time::ptime to convert.
* @param convertFrom the boost::posix_time::ptime to convert.
* @param convertTo holds the result of the conversion
* @return a struct tm, holding the same time.
*/
static void

View file

@ -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/AudioClip.cxx,v $
------------------------------------------------------------------------------*/
@ -51,6 +51,21 @@ 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.
*/
@ -66,6 +81,7 @@ static const std::string uriAttrName = "uri";
*/
static const std::string playlengthAttrName = "playlength";
/* =============================================== local function prototypes */
@ -83,31 +99,76 @@ AudioClip :: configure(const xmlpp::Element & element)
eMsg += element.get_name();
throw std::invalid_argument(eMsg);
}
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);
if (!id) {
if (!(attribute = element.get_attribute(idAttrName))) {
std::string eMsg = "missing attribute ";
eMsg += idAttrName;
throw std::invalid_argument(eMsg);
}
std::stringstream strStr(attribute->get_value());
UniqueId::IdType idValue;
strStr >> idValue;
id.reset(new UniqueId(idValue));
}
strStr.str(attribute->get_value());
strStr >> idValue;
id.reset(new UniqueId(idValue));
if (!(attribute = element.get_attribute(playlengthAttrName))) {
std::string eMsg = "missing attribute ";
eMsg += idAttrName;
throw std::invalid_argument(eMsg);
if (!playlength
&& (attribute = element.get_attribute(playlengthAttrName))) {
playlength.reset(new time_duration(
duration_from_string(attribute->get_value())));
}
playlength.reset(new time_duration(
duration_from_string(attribute->get_value())));
if ((attribute = element.get_attribute(uriAttrName))) {
std::string uriValue = attribute->get_value();
uri.reset(new std::string(uriValue));
if (!uri
&& (attribute = element.get_attribute(uriAttrName))) {
uri.reset(new std::string(attribute->get_value()));
}
xmlpp::Node::NodeList childNodes
= element.get_children(metadataElementName);
xmlpp::Node::NodeList::iterator it = childNodes.begin();
if (it != childNodes.end()) {
const xmlpp::Element * metadataElement
= dynamic_cast<const xmlpp::Element*> (*it);
xmlpp::Node::NodeList dataFieldList
= metadataElement->get_children();
xmlpp::Node::NodeList::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));
}
}
++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;
throw std::invalid_argument(eMsg);
}
}

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/src/AudioClipTest.cxx,v $
------------------------------------------------------------------------------*/
@ -95,7 +95,7 @@ AudioClipTest :: firstTest(void)
{
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(configFileName, true));
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());