diff --git a/campcaster/src/modules/core/etc/rdsContainer.xml b/campcaster/src/modules/core/etc/rdsContainer.xml index ac4d45d26..5a9023024 100644 --- a/campcaster/src/modules/core/etc/rdsContainer.xml +++ b/campcaster/src/modules/core/etc/rdsContainer.xml @@ -11,4 +11,8 @@ + + diff --git a/campcaster/src/modules/core/include/LiveSupport/Core/OptionsContainer.h b/campcaster/src/modules/core/include/LiveSupport/Core/OptionsContainer.h index 7cbee8a87..5d9f622ce 100644 --- a/campcaster/src/modules/core/include/LiveSupport/Core/OptionsContainer.h +++ b/campcaster/src/modules/core/include/LiveSupport/Core/OptionsContainer.h @@ -271,6 +271,20 @@ class OptionsContainer getRdsEnabled(Ptr::Ref key) throw (std::invalid_argument); + /** + * Get a string containing all the RDS values. + * This string can be sent to the RDS encoder. + * + * @return a string which can be sent to the RDS encoder; + * a 0 pointer if no RDS options have been defined. + */ + Ptr::Ref + getCompleteRdsString(void) throw () + { + return rdsContainer ? rdsContainer->toString() + : Ptr::Ref(); + } + /** * Save the options to a file. * diff --git a/campcaster/src/modules/core/include/LiveSupport/Core/RdsContainer.h b/campcaster/src/modules/core/include/LiveSupport/Core/RdsContainer.h index 772c50e10..3c82678f9 100644 --- a/campcaster/src/modules/core/include/LiveSupport/Core/RdsContainer.h +++ b/campcaster/src/modules/core/include/LiveSupport/Core/RdsContainer.h @@ -201,6 +201,14 @@ class RdsContainer : public Configurable getRdsEnabled(Ptr::Ref key) throw (std::invalid_argument); + /** + * Convert the object to a string. + * + * @return a string which can be sent to the RDS encoder. + */ + Ptr::Ref + toString(void) throw (); + /** * Convert the object to XML. * diff --git a/campcaster/src/modules/core/include/LiveSupport/Core/RdsItem.h b/campcaster/src/modules/core/include/LiveSupport/Core/RdsItem.h index ed707e6a5..5587bbcbc 100644 --- a/campcaster/src/modules/core/include/LiveSupport/Core/RdsItem.h +++ b/campcaster/src/modules/core/include/LiveSupport/Core/RdsItem.h @@ -241,6 +241,14 @@ class RdsItem : public Configurable touched = true; } + /** + * Convert the object to a string. + * + * @return a string which can be sent to the RDS encoder. + */ + Ptr::Ref + toString(void) throw (); + /** * Convert the object to XML. * diff --git a/campcaster/src/modules/core/src/RdsContainer.cxx b/campcaster/src/modules/core/src/RdsContainer.cxx index 7ad9e429a..68e8186a8 100644 --- a/campcaster/src/modules/core/src/RdsContainer.cxx +++ b/campcaster/src/modules/core/src/RdsContainer.cxx @@ -155,6 +155,24 @@ RdsContainer :: getRdsEnabled(Ptr::Ref key) } +/*------------------------------------------------------------------------------ + * Convert the object to a string. + *----------------------------------------------------------------------------*/ +Ptr::Ref +RdsContainer :: toString(void) throw () +{ + Ptr::Ref rdsString(new Glib::ustring); + + RdsItemListType::const_iterator it; + for(it = rdsItemList.begin(); it != rdsItemList.end(); ++it) { + Ptr::Ref rdsItem = *it; + rdsString->append(*rdsItem->toString()); + } + + return rdsString; +} + + /*------------------------------------------------------------------------------ * Convert the object to XML. *----------------------------------------------------------------------------*/ diff --git a/campcaster/src/modules/core/src/RdsContainerTest.cxx b/campcaster/src/modules/core/src/RdsContainerTest.cxx index f3a48412c..5359f0dfa 100644 --- a/campcaster/src/modules/core/src/RdsContainerTest.cxx +++ b/campcaster/src/modules/core/src/RdsContainerTest.cxx @@ -40,6 +40,7 @@ #endif #include +#include #include "RdsContainerTest.h" @@ -133,3 +134,17 @@ RdsContainerTest :: firstTest(void) CPPUNIT_ASSERT(enabled); } + +/*------------------------------------------------------------------------------ + * Test the toString() method. + *----------------------------------------------------------------------------*/ +void +RdsContainerTest :: toStringTest(void) + throw (CPPUNIT_NS::Exception) +{ + Ptr::Ref string = rdsContainer->toString(); + CPPUNIT_ASSERT(string); + CPPUNIT_ASSERT(*string == "PS=BBC Four\n" + "RT=C. Monster - Monsterpiece Theater\n"); +} + diff --git a/campcaster/src/modules/core/src/RdsContainerTest.h b/campcaster/src/modules/core/src/RdsContainerTest.h index 136c885ca..a120698ca 100644 --- a/campcaster/src/modules/core/src/RdsContainerTest.h +++ b/campcaster/src/modules/core/src/RdsContainerTest.h @@ -72,6 +72,7 @@ class RdsContainerTest : public BaseTestMethod { CPPUNIT_TEST_SUITE(RdsContainerTest); CPPUNIT_TEST(firstTest); + CPPUNIT_TEST(toStringTest); CPPUNIT_TEST_SUITE_END(); private: @@ -91,6 +92,14 @@ class RdsContainerTest : public BaseTestMethod void firstTest(void) throw (CPPUNIT_NS::Exception); + /** + * Test the toString() method. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + toStringTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/campcaster/src/modules/core/src/RdsItem.cxx b/campcaster/src/modules/core/src/RdsItem.cxx index 9dd0331af..192435e38 100644 --- a/campcaster/src/modules/core/src/RdsItem.cxx +++ b/campcaster/src/modules/core/src/RdsItem.cxx @@ -122,6 +122,25 @@ RdsItem :: configure(const xmlpp::Element & element) } +/*------------------------------------------------------------------------------ + * Convert the object to a string. + *----------------------------------------------------------------------------*/ +Ptr::Ref +RdsItem :: toString(void) throw () +{ + Ptr::Ref rdsString(new Glib::ustring); + + if (enabled) { + rdsString->append(*key); + rdsString->append("="); + rdsString->append(*value); + rdsString->append("\n"); + } + + return rdsString; +} + + /*------------------------------------------------------------------------------ * Convert the object to XML. *----------------------------------------------------------------------------*/