diff --git a/livesupport/modules/core/etc/Makefile.in b/livesupport/modules/core/etc/Makefile.in index 28fa8e3cf..2acb46dcc 100644 --- a/livesupport/modules/core/etc/Makefile.in +++ b/livesupport/modules/core/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: fgerlits $ -# Version : $Revision: 1.24 $ +# Version : $Revision: 1.25 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/etc/Makefile.in,v $ # # @configure_input@ @@ -73,6 +73,9 @@ LIBXMLPP_LIBS=@LIBXMLPP_LIBS@ ICU_CFLAGS= ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags --ldflags-toolutil --ldflags-icuio` +TAGLIB_CFLAGS =`${USR_DIR}/bin/taglib-config --cflags` +TAGLIB_LIBS =`${USR_DIR}/bin/taglib-config --libs` + TEST_RESULTS = ${DOC_DIR}/testResults.xml # the text result XSLT has to be relative to the test result file, e.g. TMP_DIR TEST_XSLT = ../etc/testResultToHtml.xsl @@ -93,12 +96,14 @@ CPPFLAGS = @CPPFLAGS@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \ -pedantic -Wall -Wno-long-long \ ${ICU_CFLAGS} \ + ${TAGLIB_CFLAGS} \ ${LIBXMLPP_CFLAGS} \ -I${USR_INCLUDE_DIR} \ -I${BOOST_INCLUDE_DIR} \ -I${INCLUDE_DIR} -I${TMP_DIR} LDFLAGS = @LDFLAGS@ -pthread \ ${ICU_LIBS} \ + ${TAGLIB_LIBS} \ ${LIBXMLPP_LIBS} \ -L${USR_LIB_DIR} \ -L${LIB_DIR} @@ -142,8 +147,8 @@ TEST_RUNNER_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \ ${TMP_DIR}/${PACKAGE_NAME}_hu.res \ ${TMP_DIR}/${PACKAGE_NAME}_jp.res -TEST_RUNNER_LIBS = -l${CORE_LIB} ${ICU_LIBS} -lboost_date_time-gcc \ - -lcppunit -ldl -lxmlrpc++ +TEST_RUNNER_LIBS = -l${CORE_LIB} ${ICU_LIBS} \ + -lboost_date_time-gcc -lcppunit -ldl -lxmlrpc++ #------------------------------------------------------------------------------- diff --git a/livesupport/modules/core/etc/tagConversionTable.xml b/livesupport/modules/core/etc/tagConversionTable.xml index c426e8746..4be6aee16 100644 --- a/livesupport/modules/core/etc/tagConversionTable.xml +++ b/livesupport/modules/core/etc/tagConversionTable.xml @@ -1,7 +1,7 @@ - + ]> @@ -9,14 +9,22 @@ Title + TIT2 dc:title + TPE1 Artist dc:creator Length + TLEN dcterms:extent + + + TBPM + ourdcextension:bpm + diff --git a/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h b/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h index 54081205b..3df47cabe 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h +++ b/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.18 $ + Version : $Revision: 1.19 $ 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; * * * @author $Author: fgerlits $ - * @version $Revision: 1.18 $ + * @version $Revision: 1.19 $ */ class AudioClip : public Configurable, public Playable @@ -165,6 +165,18 @@ class AudioClip : public Configurable, */ Ptr::Ref xmlAudioClip; + /** + * Set the value of a metadata field in this audio clip. + * + * @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 + */ + virtual void + setMetadata(Ptr::Ref value, + const std::string &name, const std::string &prefix) + throw (); + public: /** @@ -424,25 +436,23 @@ class AudioClip : public Configurable, /** * 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) + * @param key the name of the metadata field * @return the value of the metadata field; 0 if there is * no such field; */ virtual Ptr::Ref - getMetadata(const std::string &key, const std::string &ns = "") const + getMetadata(const std::string &key) const throw (); /** * Set the value of a metadata field in this audio clip. * * @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) + * @param key the name of the metadata field */ virtual void setMetadata(Ptr::Ref value, - const std::string &key, const std::string &ns = "") + const std::string &key) throw (); @@ -478,6 +488,30 @@ class AudioClip : public Configurable, */ Ptr::Ref getMetadataString() throw (); + + + /** + * Read the metadata contained in the id3v2 tag of the mp3 sound + * file. The id3v1 tag is also read; if a field is present in both, + * the id3v2 tag is used. + * + * Ogg Vorbis sound files are not supported yet. If the + * sound file is not in mp3 format, the method returns normally + * and does not do anything; however, some junk is printed on + * the standard error. + * + * The tags are processed and translated into Dublin Core + * metadata fields using the TagConversion class. Only those fields + * are processed which have a Dublin Core equivalent listed in the + * xml element used for configuring TagConversion. + * + * @exception std::invalid_argument if TagConversion has not been + * configured yet, or if the AudioClip instance does not + * have a uri field, or the file name contained in the uri + * field is invalid + */ + void + readTag() throw (std::invalid_argument); }; @@ -487,6 +521,15 @@ class AudioClip : public Configurable, /* ====================================================== function prototypes */ + /** + * Auxilliary method used by satisfiesCondition(). + */ + void + separateNameAndNameSpace(const std::string & key, + std::string & name, + std::string & nameSpace) + throw (); + } // namespace Core } // namespace LiveSupport diff --git a/livesupport/modules/core/include/LiveSupport/Core/Playable.h b/livesupport/modules/core/include/LiveSupport/Core/Playable.h index 8ce3d3846..a54d8fd04 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/Playable.h +++ b/livesupport/modules/core/include/LiveSupport/Core/Playable.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/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.6 $ + * @version $Revision: 1.7 $ */ class Playable : public boost::enable_shared_from_this { @@ -194,12 +194,11 @@ class Playable : public boost::enable_shared_from_this * 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::Ref - getMetadata(const std::string &key, const std::string &ns = "") const + getMetadata(const std::string &key) const throw () = 0; /** @@ -207,12 +206,10 @@ class Playable : public boost::enable_shared_from_this * * @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(Ptr::Ref value, - const std::string &key, - const std::string &ns = "") + const std::string &key) throw () = 0; /** diff --git a/livesupport/modules/core/include/LiveSupport/Core/Playlist.h b/livesupport/modules/core/include/LiveSupport/Core/Playlist.h index ddaaf6764..f6c13117a 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/Playlist.h +++ b/livesupport/modules/core/include/LiveSupport/Core/Playlist.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.28 $ + Version : $Revision: 1.29 $ 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; * * * @author $Author: fgerlits $ - * @version $Revision: 1.28 $ + * @version $Revision: 1.29 $ */ class Playlist : public Configurable, public Playable @@ -618,12 +618,11 @@ class Playlist : public Configurable, * Return the value of a metadata field in this 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::Ref - getMetadata(const std::string &key, const std::string &ns = "") const + getMetadata(const std::string &key) const throw (); /** @@ -631,11 +630,10 @@ class Playlist : public Configurable, * * @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(Ptr::Ref value, - const std::string &key, const std::string &ns = "") + const std::string &key) throw (); diff --git a/livesupport/modules/core/include/LiveSupport/Core/TagConversion.h b/livesupport/modules/core/include/LiveSupport/Core/TagConversion.h index 6a987d3c0..c58113150 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/TagConversion.h +++ b/livesupport/modules/core/include/LiveSupport/Core/TagConversion.h @@ -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/include/LiveSupport/Core/Attic/TagConversion.h,v $ ------------------------------------------------------------------------------*/ @@ -77,15 +77,27 @@ using namespace LiveSupport::Core; * <dc>dc:title</dc> * </tag> * <tag> - * <id3>Length</id3> + * <id3>Artist</id3> + * <id3>TPE1</id3> * <dc>dcterms:extent</dc> * </tag> * ... * </tagConversionTable> * * + * Note that more than one id3 tag name can map to the same dc tag name. + * + * The DTD for the above element is: + * + *

+ *  <!ELEMENT tagConversionTable (tag*) >
+ *  <!ATTLIST tag    (id3+, dc) >
+ *  <!ATTLIST id3    (#CDATA) >
+ *  <!ATTLIST dc     (#CDATA) >
+ *  
+ * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class TagConversion { @@ -155,6 +167,8 @@ class TagConversion * Check whether a given id3v2 tag is listed in the table. * * @return true or false + * @exception std::invalid_argument if the conversion table has not + * not been configured yet */ static bool existsId3Tag(const std::string &id3Tag) throw (std::invalid_argument) @@ -171,6 +185,9 @@ class TagConversion * Convert an id3v2 tag to a Dublin Core tag (with namespace). * * @return the converted tag + * @exception std::invalid_argument if the conversion table has not + * not been configured yet, or if the id3Tag name does + * not exist in the table */ static const std::string & id3ToDublinCore(const std::string &id3Tag) diff --git a/livesupport/modules/core/src/AudioClip.cxx b/livesupport/modules/core/src/AudioClip.cxx index 2fa65266e..616aada33 100644 --- a/livesupport/modules/core/src/AudioClip.cxx +++ b/livesupport/modules/core/src/AudioClip.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.18 $ + Version : $Revision: 1.19 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $ ------------------------------------------------------------------------------*/ @@ -34,7 +34,13 @@ #endif #include +#include +#include // for TagLib +#include // for TagLib +#include // for TagLib +#include // for TagLib +#include "LiveSupport/Core/TagConversion.h" #include "LiveSupport/Core/AudioClip.h" using namespace boost::posix_time; @@ -344,9 +350,12 @@ AudioClip :: configure(const xmlpp::Element & element) * Return the value of a metadata field. *----------------------------------------------------------------------------*/ Ptr::Ref -AudioClip :: getMetadata(const string &key, const std::string &ns) const +AudioClip :: getMetadata(const string &key) const throw () { + std::string name, prefix; + separateNameAndNameSpace(key, name, prefix); + Ptr::Ref value; if (! xmlAudioClip) { @@ -362,12 +371,12 @@ AudioClip :: getMetadata(const string &key, const std::string &ns) const } xmlpp::Node* metadata = rootList.front(); - xmlpp::Node::NodeList nodeList = metadata->get_children(key); + 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() == ns) { + if (node->get_namespace_prefix() == prefix) { xmlpp::Element* element = dynamic_cast (node); value.reset(new Glib::ustring(element->get_child_text() ->get_content())); @@ -381,20 +390,33 @@ AudioClip :: getMetadata(const string &key, const std::string &ns) const /*------------------------------------------------------------------------------ - * Set the value of a metadata field. + * Set the value of a metadata field (public). *----------------------------------------------------------------------------*/ void AudioClip :: setMetadata(Ptr::Ref value, - const std::string &key, - const std::string &ns) + const std::string &key) throw () { - if (ns == extentElementPrefix && key == extentElementName) { + std::string name, prefix; + separateNameAndNameSpace(key, name, prefix); + setMetadata(value, name, prefix); +} + + +/*------------------------------------------------------------------------------ + * Set the value of a metadata field (private). + *----------------------------------------------------------------------------*/ +void +AudioClip :: setMetadata(Ptr::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 (ns == titleElementPrefix && key == titleElementName) { + if (prefix == titleElementPrefix && name == titleElementName) { title = value; } @@ -418,13 +440,13 @@ AudioClip :: setMetadata(Ptr::Ref value, extentElementPrefix); } - xmlpp::Node::NodeList nodeList = metadata->get_children(key); + 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() == ns) { + if (node->get_namespace_prefix() == prefix) { element = dynamic_cast (nodeList.front()); break; } @@ -432,9 +454,9 @@ AudioClip :: setMetadata(Ptr::Ref value, } if (it == nodeList.end()) { - element = metadata->add_child(key); + element = metadata->add_child(name); try { - element->set_namespace(ns); + element->set_namespace(prefix); } catch (xmlpp::exception &e) { // this namespace has not been declared; well OK, do nothing then @@ -485,3 +507,112 @@ AudioClip :: getMetadataString() throw () return metadataString; } + +/*------------------------------------------------------------------------------ + * Read the metadata contained in the id3v2 tag of the binary sound file. + *----------------------------------------------------------------------------*/ +void +AudioClip :: readTag() throw (std::invalid_argument) +{ + if (!TagConversion::isConfigured()) { + throw std::invalid_argument("tag conversion table not loaded"); + } + + if (!getUri()) { + throw std::invalid_argument("audio clip has no uri field"); + } + + if (!TagLib::File::isReadable(getUri()->c_str())) { + throw std::invalid_argument("binary sound file not found"); + } + + TagLib::FileRef genericFileRef(getUri()->c_str()); + TagLib::Tag* tag = genericFileRef.tag(); + if (!tag) { + return; + } + + Ptr::Ref value; // true = unicode + if (TagConversion::existsId3Tag("Artist")) { + value.reset(new const Glib::ustring(tag->artist().to8Bit(true))); + setMetadata(value, TagConversion::id3ToDublinCore("Artist")); + } + + if (TagConversion::existsId3Tag("Title")) { + value.reset(new const Glib::ustring(tag->title().to8Bit(true))); + setMetadata(value, TagConversion::id3ToDublinCore("Title")); + } + + if (TagConversion::existsId3Tag("Album")) { + value.reset(new const Glib::ustring(tag->album().to8Bit(true))); + setMetadata(value, TagConversion::id3ToDublinCore("Album")); + } + + if (TagConversion::existsId3Tag("Comment")) { + value.reset(new const Glib::ustring(tag->comment().to8Bit(true))); + setMetadata(value, TagConversion::id3ToDublinCore("Comment")); + } + + if (TagConversion::existsId3Tag("Genre")) { + value.reset(new const Glib::ustring(tag->genre().to8Bit(true))); + setMetadata(value, TagConversion::id3ToDublinCore("Genre")); + } + + if (TagConversion::existsId3Tag("Year")) { + std::stringstream yearString; + yearString << tag->year(); + value.reset(new const Glib::ustring(yearString.str())); + setMetadata(value, TagConversion::id3ToDublinCore("Year")); + } + + if (TagConversion::existsId3Tag("Track")) { + std::stringstream trackString; + trackString << tag->track(); + value.reset(new const Glib::ustring(trackString.str())); + setMetadata(value, TagConversion::id3ToDublinCore("Track")); + } + + TagLib::MPEG::File mpegFile(getUri()->c_str()); + TagLib::ID3v2::Tag* id3v2Tag = mpegFile.ID3v2Tag(); + if (!id3v2Tag) { + return; + } + + TagLib::ID3v2::FrameListMap frameListMap = id3v2Tag->frameListMap(); + TagLib::ID3v2::FrameListMap::ConstIterator it = frameListMap.begin(); + while (it != frameListMap.end()) { + const char* keyBuffer = it->first.data(); + std::string keyString(keyBuffer, 4); + if (TagConversion::existsId3Tag(keyString)) { + TagLib::ID3v2::FrameList frameList = it->second; + if (!frameList.isEmpty()) { + value.reset(new const Glib::ustring(frameList.front() + ->toString().to8Bit(true))); + setMetadata(value, TagConversion::id3ToDublinCore(keyString)); + } + } + ++it; + } +} + + +/*------------------------------------------------------------------------------ + * Separate a key into the metadata name and its namespace + *----------------------------------------------------------------------------*/ +void +LiveSupport::Core :: separateNameAndNameSpace(const std::string & key, + std::string & name, + std::string & prefix) + throw () +{ + unsigned int colonPosition = key.find(':'); + + if (colonPosition != std::string::npos) { // there is a colon + prefix = key.substr(0, colonPosition); + name = key.substr(colonPosition+1); + } else { // no colon found + prefix = ""; + name = key; + } +} + diff --git a/livesupport/modules/core/src/AudioClipTest.cxx b/livesupport/modules/core/src/AudioClipTest.cxx index 5fc9d7294..fe69a4599 100644 --- a/livesupport/modules/core/src/AudioClipTest.cxx +++ b/livesupport/modules/core/src/AudioClipTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClipTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ #include "LiveSupport/Core/AudioClip.h" #include "LiveSupport/Core/Playlist.h" +#include "LiveSupport/Core/TagConversion.h" #include "AudioClipTest.h" @@ -63,6 +64,11 @@ CPPUNIT_TEST_SUITE_REGISTRATION(AudioClipTest); */ static const std::string configFileName = "etc/audioClip.xml"; +/** + * The name of the configuration file for the tag conversion table. + */ +static const std::string tagConversionConfig = "etc/tagConversionTable.xml"; + /* =============================================== local function prototypes */ @@ -115,12 +121,12 @@ AudioClipTest :: firstTest(void) CPPUNIT_ASSERT(*title == "File Title txt"); Ptr::Ref subject = audioClip - ->getMetadata("subject", "dc"); + ->getMetadata("dc:subject"); CPPUNIT_ASSERT(subject); CPPUNIT_ASSERT(*subject == "Keywords: qwe, asd, zcx"); Ptr::Ref alternativeTitle = audioClip - ->getMetadata("alternative", "dcterms"); + ->getMetadata("dcterms:alternative"); CPPUNIT_ASSERT(alternativeTitle); CPPUNIT_ASSERT(*alternativeTitle == "Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ"); @@ -177,3 +183,42 @@ AudioClipTest :: conversionTest(void) CPPUNIT_ASSERT(!playlist); } + +/*------------------------------------------------------------------------------ + * Test id3v2 tag extraction + *----------------------------------------------------------------------------*/ +void +AudioClipTest :: tagTest(void) + throw (CPPUNIT_NS::Exception) +{ + try { + Ptr::Ref parser( + new xmlpp::DomParser(tagConversionConfig, false)); + const xmlpp::Document * document = parser->get_document(); + const xmlpp::Element * root = document->get_root_node(); + TagConversion::configure(*root); + } catch (std::invalid_argument &e) { + CPPUNIT_FAIL(e.what()); + } catch (xmlpp::exception &e) { + CPPUNIT_FAIL(e.what()); + } + + Ptr::Ref audioClip(new AudioClip()); + + Ptr::Ref uri(new std::string("var/test10001.mp3")); + audioClip->setUri(uri); + try { + audioClip->readTag(); + } catch (std::invalid_argument &e) { + CPPUNIT_FAIL(e.what()); + } + + Ptr::Ref title + = audioClip->getMetadata("dc:title"); + CPPUNIT_ASSERT(*title == "Theme Song"); + + Ptr::Ref artist + = audioClip->getMetadata("dc:creator"); + CPPUNIT_ASSERT(*artist == "The Muppets"); +} + diff --git a/livesupport/modules/core/src/AudioClipTest.h b/livesupport/modules/core/src/AudioClipTest.h index a9b033e60..15b40c59f 100644 --- a/livesupport/modules/core/src/AudioClipTest.h +++ b/livesupport/modules/core/src/AudioClipTest.h @@ -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.h,v $ ------------------------------------------------------------------------------*/ @@ -58,7 +58,7 @@ namespace Core { * Unit test for the AudioClip class. * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @see AudioClip */ class AudioClipTest : public CPPUNIT_NS::TestFixture @@ -66,6 +66,7 @@ class AudioClipTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST_SUITE(AudioClipTest); CPPUNIT_TEST(firstTest); CPPUNIT_TEST(conversionTest); + CPPUNIT_TEST(tagTest); CPPUNIT_TEST_SUITE_END(); protected: @@ -86,6 +87,14 @@ class AudioClipTest : public CPPUNIT_NS::TestFixture void conversionTest(void) throw (CPPUNIT_NS::Exception); + /** + * Id3v2 tag extraction test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + tagTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/livesupport/modules/core/src/Playlist.cxx b/livesupport/modules/core/src/Playlist.cxx index 35c9dc014..2362ec94e 100644 --- a/livesupport/modules/core/src/Playlist.cxx +++ b/livesupport/modules/core/src/Playlist.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.27 $ + Version : $Revision: 1.28 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $ ------------------------------------------------------------------------------*/ @@ -397,11 +397,10 @@ Playlist::revertToSavedCopy(void) throw (std::invalid_argument) * Return the value of a metadata field. *----------------------------------------------------------------------------*/ Ptr::Ref -Playlist :: getMetadata(const string &key, const string &ns) const +Playlist :: getMetadata(const string &key) const throw () { - std::string completeKey = ns + ":" + key; - metadataType::const_iterator it = metadata.find(completeKey); + metadataType::const_iterator it = metadata.find(key); if (it != metadata.end()) { Ptr::Ref data(new Glib::ustring(*it->second)); @@ -418,17 +417,16 @@ Playlist :: getMetadata(const string &key, const string &ns) const *----------------------------------------------------------------------------*/ void Playlist :: setMetadata(Ptr::Ref value, - const string &key, const string &ns) + const string &key) throw () { - std::string completeKey = ns + ":" + key; - metadata[completeKey] = value; + metadata[key] = value; - if (completeKey == "dcterms:extent") { + if (key == "dcterms:extent") { playlength.reset(new time_duration(duration_from_string(*value))); } - if (completeKey == "dc:title") { + if (key == "dc:title") { title = value; } } diff --git a/livesupport/modules/core/src/TagConversion.cxx b/livesupport/modules/core/src/TagConversion.cxx index b7c611cfc..e9547f1a5 100644 --- a/livesupport/modules/core/src/TagConversion.cxx +++ b/livesupport/modules/core/src/TagConversion.cxx @@ -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/Attic/TagConversion.cxx,v $ ------------------------------------------------------------------------------*/ @@ -100,19 +100,23 @@ TagConversion :: configure(const xmlpp::Element & element) Node::NodeList id3Tags = (*listIt)->get_children(id3TagElementName); Node::NodeList dcTags = (*listIt)->get_children(dcTagElementName); - if (id3Tags.size() != 1 || dcTags.size() != 1) { + if (id3Tags.size() < 1 || dcTags.size() != 1) { std::string eMsg = "bad <"; eMsg += tagElementName; eMsg += "> element found"; throw std::invalid_argument(eMsg); } - Element* id3Element = dynamic_cast (id3Tags.front()); Element* dcElement = dynamic_cast (dcTags.front()); - - table->insert(std::make_pair( + Node::NodeList::iterator + id3Iterator = id3Tags.begin(); + while (id3Iterator != id3Tags.end()) { + Element* id3Element = dynamic_cast (*id3Iterator); + table->insert(std::make_pair( id3Element->get_child_text()->get_content(), dcElement ->get_child_text()->get_content() )); + ++id3Iterator; + } ++listIt; } } diff --git a/livesupport/modules/core/src/TagConversionTest.cxx b/livesupport/modules/core/src/TagConversionTest.cxx index 31ecb2f39..dc06db2fe 100644 --- a/livesupport/modules/core/src/TagConversionTest.cxx +++ b/livesupport/modules/core/src/TagConversionTest.cxx @@ -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/Attic/TagConversionTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -85,19 +85,6 @@ void TagConversionTest :: firstTest(void) throw (CPPUNIT_NS::Exception) { - try { - TagConversion::existsId3Tag("Title"); - CPPUNIT_FAIL("allowed to use class before configuration"); - } catch (std::invalid_argument &e) { - } - - try { - TagConversion::id3ToDublinCore("Title"); - CPPUNIT_FAIL("allowed to use class before configuration"); - } catch (std::invalid_argument &e) { - } - - CPPUNIT_ASSERT(!TagConversion::isConfigured()); try { Ptr::Ref parser( new xmlpp::DomParser(configFileName, false)); @@ -126,6 +113,14 @@ TagConversionTest :: firstTest(void) CPPUNIT_FAIL(e.what()); } + try { + CPPUNIT_ASSERT(TagConversion::id3ToDublinCore("TIT2") == "dc:title"); + std::string dcTag = TagConversion::id3ToDublinCore("TBPM"); + CPPUNIT_ASSERT(dcTag == "ourdcextension:bpm"); + } catch (std::invalid_argument &e) { + CPPUNIT_FAIL(e.what()); + } + try { std::string dcTag = TagConversion::id3ToDublinCore("Boringness"); CPPUNIT_FAIL("allowed to convert non-existent tag"); diff --git a/livesupport/modules/core/var/test10001.mp3 b/livesupport/modules/core/var/test10001.mp3 new file mode 100644 index 000000000..a469931db Binary files /dev/null and b/livesupport/modules/core/var/test10001.mp3 differ diff --git a/livesupport/modules/storage/etc/Makefile.in b/livesupport/modules/storage/etc/Makefile.in index 57b66fc36..5c5c52ea1 100644 --- a/livesupport/modules/storage/etc/Makefile.in +++ b/livesupport/modules/storage/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: fgerlits $ -# Version : $Revision: 1.18 $ +# Version : $Revision: 1.19 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/etc/Makefile.in,v $ # # @configure_input@ @@ -75,6 +75,8 @@ LIBXMLPP_LIBS=@LIBXMLPP_LIBS@ CURL_LIBS=`${USR_DIR}/bin/curl-config --libs` +TAGLIB_LIBS =`${USR_DIR}/bin/taglib-config --libs` + TEST_RESULTS = ${DOC_DIR}/testResults.xml # the text result XSLT has to be relative to the test result file, e.g. TMP_DIR TEST_XSLT = ../etc/testResultToHtml.xsl @@ -103,6 +105,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \ LDFLAGS = @LDFLAGS@ -pthread \ ${LIBXMLPP_LIBS} \ ${CURL_LIBS} \ + ${TAGLIB_LIBS} \ -L${USR_LIB_DIR} \ -L${CORE_LIB_DIR} \ -L${AUTHENTICATION_LIB_DIR} \ diff --git a/livesupport/modules/storage/src/TestStorageClient.cxx b/livesupport/modules/storage/src/TestStorageClient.cxx index cf72b32d8..8bc3b93ca 100644 --- a/livesupport/modules/storage/src/TestStorageClient.cxx +++ b/livesupport/modules/storage/src/TestStorageClient.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.33 $ + Version : $Revision: 1.34 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $ ------------------------------------------------------------------------------*/ @@ -817,10 +817,7 @@ TestStorageClient :: satisfiesCondition( const SearchCriteria::SearchConditionType & condition) throw (XmlRpcException) { - std::string name, nameSpace; - separateNameAndNameSpace(condition.key, name, nameSpace); - - Ptr::Ref value = playable->getMetadata(name, nameSpace); + Ptr::Ref value = playable->getMetadata(condition.key); if (!value) { return false; } @@ -855,16 +852,16 @@ TestStorageClient :: satisfiesCondition( void LiveSupport::Storage :: separateNameAndNameSpace(const std::string & key, std::string & name, - std::string & nameSpace) + std::string & prefix) throw () { unsigned int colonPosition = key.find(':'); if (colonPosition != std::string::npos) { // there is a colon - nameSpace = key.substr(0, colonPosition); + prefix = key.substr(0, colonPosition); name = key.substr(colonPosition+1); } else { // no colon found - nameSpace = ""; + prefix = ""; name = key; } } diff --git a/livesupport/modules/storage/src/TestStorageClient.h b/livesupport/modules/storage/src/TestStorageClient.h index c98d683d1..e3e8a5ea7 100644 --- a/livesupport/modules/storage/src/TestStorageClient.h +++ b/livesupport/modules/storage/src/TestStorageClient.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.27 $ + Version : $Revision: 1.28 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $ ------------------------------------------------------------------------------*/ @@ -86,7 +86,7 @@ using namespace LiveSupport::Core; * * * @author $Author: fgerlits $ - * @version $Revision: 1.27 $ + * @version $Revision: 1.28 $ */ class TestStorageClient : virtual public Configurable, @@ -556,7 +556,7 @@ class TestStorageClient : void separateNameAndNameSpace(const std::string & key, std::string & name, - std::string & nameSpace) + std::string & prefix) throw (); } // namespace Storage diff --git a/livesupport/products/gLiveSupport/etc/Makefile.in b/livesupport/products/gLiveSupport/etc/Makefile.in index 7a044325b..e7b8a1893 100644 --- a/livesupport/products/gLiveSupport/etc/Makefile.in +++ b/livesupport/products/gLiveSupport/etc/Makefile.in @@ -20,8 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -# Author : $Author: maroy $ -# Version : $Revision: 1.21 $ +# Author : $Author: fgerlits $ +# Version : $Revision: 1.22 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $ # # @configure_input@ @@ -119,6 +119,8 @@ GTKMM_LIBS=@GTKMM_LIBS@ ICU_CFLAGS= ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags-toolutil --ldflags-icuio` +TAGLIB_LIBS=`${USR_DIR}/bin/taglib-config --libs` + TEST_RESULTS = ${DOC_DIR}/testResults.xml # the text result XSLT has to be relative to the test result file, e.g. TMP_DIR TEST_XSLT = ../etc/testResultToHtml.xsl @@ -155,6 +157,7 @@ LDFLAGS = @LDFLAGS@ -pthread \ ${LIBXMLPP_LIBS} \ ${CURL_LIBS} \ ${GTKMM_LIBS} \ + ${TAGLIB_LIBS} \ -L${USR_LIB_DIR} \ -L${HELIX_LIB_DIR} \ -L${CORE_LIB_DIR} \ diff --git a/livesupport/products/scheduler/etc/Makefile.in b/livesupport/products/scheduler/etc/Makefile.in index 17cb61a56..d7bb9d02b 100644 --- a/livesupport/products/scheduler/etc/Makefile.in +++ b/livesupport/products/scheduler/etc/Makefile.in @@ -20,8 +20,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -# Author : $Author: maroy $ -# Version : $Revision: 1.43 $ +# Author : $Author: fgerlits $ +# Version : $Revision: 1.44 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $ # # @configure_input@ @@ -67,6 +67,8 @@ LIBXMLPP_LIBS=@LIBXMLPP_LIBS@ CURL_LIBS=`${USR_DIR}/bin/curl-config --libs` +TAGLIB_LIBS =`${USR_DIR}/bin/taglib-config --libs` + MODULES_DIR = ${BASE_DIR}/../../modules CORE_DIR = ${MODULES_DIR}/core @@ -140,6 +142,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \ LDFLAGS = @LDFLAGS@ -pthread \ ${LIBXMLPP_LIBS} \ ${CURL_LIBS} \ + ${TAGLIB_LIBS} \ -L${USR_LIB_DIR} \ -L${HELIX_LIB_DIR} \ -L${CORE_LIB_DIR} \ diff --git a/livesupport/products/scheduler/src/PlaylistEventTest.cxx b/livesupport/products/scheduler/src/PlaylistEventTest.cxx index cc401787f..d9b80c291 100644 --- a/livesupport/products/scheduler/src/PlaylistEventTest.cxx +++ b/livesupport/products/scheduler/src/PlaylistEventTest.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -231,6 +231,8 @@ PlaylistEventTest :: playTest(void) playlistEvent->deInitialize(); } catch (std::logic_error &e) { CPPUNIT_FAIL(e.what()); + } catch (std::exception &e) { + CPPUNIT_FAIL(e.what()); } }