[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "replication" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Dec 10 08:44:51 CST 2010


branch "replication" has been updated
       via  d5c54a40116c2aaaae4e7e64dacc3e87b195caf7 (commit)
       via  c0149a1e38ae531627f2cea10694b56aad2b3101 (commit)
       via  ae2059616aaddb371357469ea953584c38ff2290 (commit)
       via  42664ea659fed952baa5968da29d8da5cbe51eef (commit)
      from  59bd7af369b179b4c6135d92ac7876d992402571 (commit)

Summary of changes:
 config/test_component.config.in |   18 +++-
 src/MediaRTPpjmedia.cpp         |    6 +-
 test/CMakeLists.txt             |    1 +
 test/TestRTPpjmedia.cpp         |  200 ++++++++++++++++++++++++++++++++++++++-
 4 files changed, 216 insertions(+), 9 deletions(-)


- Log -----------------------------------------------------------------
commit d5c54a40116c2aaaae4e7e64dacc3e87b195caf7
Author: Joshua Colp <jcolp at digium.com>
Date:   Fri Dec 10 10:43:44 2010 -0400

    Add tests for confirming that state items are sent out with the proper contents.

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f7150af..b36ae1b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -10,6 +10,7 @@ asterisk_scf_component_init(media_rtp_pjmedia_test CXX)
 asterisk_scf_component_add_file(media_rtp_pjmedia_test TestRTPpjmedia.cpp)
 asterisk_scf_component_add_slice(media_rtp_pjmedia_test MediaIf)
 asterisk_scf_component_add_slice(media_rtp_pjmedia_test MediaRTPIf)
+asterisk_scf_component_add_slice(media_rtp_pjmedia_test RtpStateReplicationIf)
 asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia_test unit_test_framework thread date_time)
 asterisk_scf_component_build_icebox(media_rtp_pjmedia_test)
 #asterisk_scf_component_install(media_rtp_pjmedia_test RUNTIME bin "PJmedia RTP Media Test Driver." Core)
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 4866ed8..3951eb5 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -26,6 +26,7 @@
 #include "Core/Discovery/ServiceLocatorIf.h"
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
+#include "RtpStateReplicationIf.h"
 
 using namespace std;
 using namespace AsteriskSCF::Core::Discovery::V1;
@@ -53,6 +54,52 @@ public:
 };
 static ArgCacheType mCachedArgs;
 
+class TestRtpReplicatorListener : public RtpStateReplicatorListener
+{
+public:
+    void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
+    void stateSet(const RtpStateItemSeq&, const Ice::Current&);
+    
+    RtpGeneralStateItemPtr mGeneral;
+    RtpSessionStateItemPtr mSession;
+    RtpStreamSinkStateItemPtr mSink;
+    RtpStreamSourceStateItemPtr mSource;
+};
+
+typedef IceUtil::Handle<TestRtpReplicatorListener> TestRtpReplicatorListenerPtr;
+
+void TestRtpReplicatorListener::stateRemoved(const Ice::StringSeq& items, const Ice::Current&)
+{
+}
+
+void TestRtpReplicatorListener::stateSet(const RtpStateItemSeq& items, const Ice::Current&)
+{
+    for (RtpStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
+    {
+	RtpGeneralStateItemPtr general;
+	RtpSessionStateItemPtr session;
+	RtpStreamSinkStateItemPtr sink;
+	RtpStreamSourceStateItemPtr source;
+
+        if ((general = RtpGeneralStateItemPtr::dynamicCast((*item))))
+        {
+	    mGeneral = general;
+        }
+	else if ((session = RtpSessionStateItemPtr::dynamicCast((*item))))
+	{
+	    mSession = session;
+	}
+	else if ((sink = RtpStreamSinkStateItemPtr::dynamicCast((*item))))
+	{
+	    mSink = sink;
+	}
+	else if ((source = RtpStreamSourceStateItemPtr::dynamicCast((*item))))
+	{
+	    mSource = source;
+	}
+    }
+}
+
 /**
  * It seems odd that boost doesn't provide an easy way to access the GLOBAL_FIXTURE members.
  * But it doesn't seem to, so I'm sharing global setup stuff here.
@@ -71,6 +118,21 @@ public:
     ServiceLocatorPrx locator;
 
     /**
+     * A proxy to the state replicator.
+     */
+    RtpStateReplicatorPrx mStateReplicator;
+
+    /**
+     * Instance of our test replicator listener.
+     */
+    TestRtpReplicatorListenerPtr mListener;
+    
+    /**
+     * A proxy to our state replicator listener.
+     */
+    RtpStateReplicatorListenerPrx mListenerProxy;
+
+    /**
      * A proxy to the RTP session that we requested.
      */
     RTPSessionPrx session;
@@ -160,12 +222,16 @@ struct GlobalIceFixture
         {
             Testbed.communicator = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
 
-            Testbed.adapter = Testbed.communicator->createObjectAdapterWithEndpoints("SinkAdapter", "default");
+            Testbed.adapter = Testbed.communicator->createObjectAdapterWithEndpoints("Adapter", "default");
 
             StreamSinkPtr sink = new TestStreamSink();
 
             Testbed.sink = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(sink));
 
+	    Testbed.mListener = new TestRtpReplicatorListener();
+
+	    Testbed.mListenerProxy = RtpStateReplicatorListenerPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.mListener));
+
             Testbed.adapter->activate();
 
             Testbed.locator = ServiceLocatorPrx::checkedCast(Testbed.communicator->stringToProxy("LocatorService:tcp -p 4411"));
@@ -210,8 +276,8 @@ BOOST_AUTO_TEST_CASE(ServiceFoundUsingName)
     bool found = false;
 
     try {
-        ServiceLocatorParamsPtr params = new ServiceLocatorParams();
-        params->category = "rtp";
+	ServiceLocatorParamsPtr params = new ServiceLocatorParams();
+	params->category = "rtp";
 
         Testbed.locator->locate(params);
 
@@ -226,6 +292,71 @@ BOOST_AUTO_TEST_CASE(ServiceFoundUsingName)
 }
 
 /**
+ * Confirm that we find the state replicator
+ */
+BOOST_AUTO_TEST_CASE(ReplicatorFound)
+{
+    bool found = false;
+
+    try
+    {
+        RtpStateReplicatorParamsPtr params = new RtpStateReplicatorParams();
+        params->category = StateReplicatorDiscoveryCategory;
+        params->mName = "default";
+
+	Testbed.mStateReplicator = RtpStateReplicatorPrx::uncheckedCast(Testbed.locator->locate(params));
+
+	found = true;
+    }
+    catch (const Ice::Exception &e)
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    }
+    catch (...)
+    {
+    }
+
+    BOOST_CHECK(found);
+}
+
+/**
+ * Confirm that we can add ourselves as a listener to the state replicator.
+ */
+BOOST_AUTO_TEST_CASE(AddListenertoStateReplicator)
+{
+    bool added = false;
+
+    try
+    {
+	Testbed.mStateReplicator->addListener(Testbed.mListenerProxy);
+
+	added = true;
+    }
+    catch (const Ice::Exception &e)
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    }
+    catch (...)
+    {
+    }
+
+    BOOST_CHECK(added);
+}
+
+/**
+ * Confirm that we received the general state replication item.
+ */
+BOOST_AUTO_TEST_CASE(CheckReplicatedGeneralStateItem)
+{
+    // Since the RTP component is using a oneway invocation we wait here to ensure that the packet has been sent and processed
+    boost::this_thread::sleep(boost::posix_time::seconds(1));
+
+    BOOST_CHECK(Testbed.mListener->mGeneral);
+}
+
+/**
  * Attempt to allocate an RTP session using a fake format
  */
 BOOST_AUTO_TEST_CASE(AllocateRTPSession)
@@ -248,6 +379,9 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
 
         Testbed.session = service->allocate(formats);
 
+	// Give the RTP component time to replicate this session
+	boost::this_thread::sleep(boost::posix_time::seconds(1));
+
         allocated = true;
     }
     catch (const Ice::Exception &e)
@@ -263,6 +397,44 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
 }
 
 /**
+ * Confirm that we received the inital session replicated item (with proper contents) for the RTP session.
+ */
+BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSession)
+{
+    BOOST_CHECK(Testbed.mListener->mSession);
+    BOOST_CHECK(Testbed.mListener->mSession->mSessionIdentity == Testbed.session->ice_getIdentity());
+
+    StreamSinkSeq sinks = Testbed.session->getSinks();
+    StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
+    BOOST_CHECK(Testbed.mListener->mSession->mSinkIdentity == sink->ice_getIdentity());
+
+    StreamSourceSeq sources = Testbed.session->getSources();
+    StreamSourceRTPPrx source = StreamSourceRTPPrx::uncheckedCast(sources.front());
+    BOOST_CHECK(Testbed.mListener->mSession->mSourceIdentity == source->ice_getIdentity());
+    BOOST_CHECK(Testbed.mListener->mSession->mPort == source->getLocalPort());
+}
+
+/**
+ * Confirm that we received the initial sink replicated item (with proper contents) for the RTP session.
+ */
+BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSink)
+{
+    BOOST_CHECK(Testbed.mListener->mSink);
+    BOOST_CHECK(!Testbed.mListener->mSink->mSource);
+    BOOST_CHECK(!Testbed.mListener->mSink->mRemoteAddress.size());
+    BOOST_CHECK(!Testbed.mListener->mSink->mRemotePort);
+}
+
+/**
+ * Confirm that we received the initial source replicated item (with proper contents) for the RTP session.
+ */
+BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSource)
+{
+    BOOST_CHECK(Testbed.mListener->mSource);
+    BOOST_CHECK(!Testbed.mListener->mSource->mSink);
+}
+
+/**
  * Check that the RTP session has at least one source
  */
 BOOST_AUTO_TEST_CASE(CheckForSource)
@@ -568,6 +740,8 @@ BOOST_AUTO_TEST_CASE(SetupLoopback)
         sink->setRemoteDetails(address, port);
 
         looped = true;
+
+	boost::this_thread::sleep(boost::posix_time::seconds(1));
     }
     catch (const Ice::Exception &e)
     {
@@ -582,6 +756,26 @@ BOOST_AUTO_TEST_CASE(SetupLoopback)
 }
 
 /**
+ * Confirm that we received the populated sink replicated item (with proper contents) for the RTP session.
+ */
+BOOST_AUTO_TEST_CASE(ConfirmPopulatedReplicatedRTPSink)
+{
+    StreamSourceSeq sources = Testbed.session->getSources();
+    StreamSourceRTPPrx source = StreamSourceRTPPrx::uncheckedCast(sources.front());
+
+    BOOST_CHECK(Testbed.mListener->mSink->mRemoteAddress == source->getLocalAddress());
+    BOOST_CHECK(Testbed.mListener->mSink->mRemotePort == source->getLocalPort());
+}
+
+/**
+ * Confirm that we received the populated source replicated item (with proper contents) for the RTP session.
+ */
+BOOST_AUTO_TEST_CASE(ConfirmPopulatedReplicatedRTPSource)
+{
+    BOOST_CHECK(Testbed.mListener->mSource->mSink == Testbed.sink);
+}
+
+/**
  * Actually write a frame out, have it get transmitted via RTP, received via RTP,
  * and then transmogrified back into a frame and written to our sink.
  */

commit c0149a1e38ae531627f2cea10694b56aad2b3101
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Dec 9 16:18:31 2010 -0400

    Add state replicator to the test. Not yet tested, but getting there.

diff --git a/config/test_component.config.in b/config/test_component.config.in
index dad52ba..f4c470d 100644
--- a/config/test_component.config.in
+++ b/config/test_component.config.in
@@ -5,7 +5,19 @@
 #
 
 IceBox.InheritProperties=1
-IceBox.LoadOrder=ServiceDiscovery,MediaRTPpjmedia,MediaRTPpjmediaTest
+IceBox.LoadOrder=ServiceDiscovery,RtpStateReplicator,MediaRTPpjmedia,MediaRTPpjmediaTest
+
+# RtpStateReplicator Configuration
+IceBox.Service.RtpStateReplicator=../src at RtpStateReplicator:create
+
+# Adapter parameters for this component
+RtpStateReplicator.Endpoints=tcp:udp
+
+# A proxy to the service locator management service
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
+
+# A proxy to the service locator service
+LocatorService.Proxy=LocatorService:tcp -p 4411
 
 #
 # media_rtp_pjmedia Configuration

commit ae2059616aaddb371357469ea953584c38ff2290
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Dec 9 16:18:13 2010 -0400

    Fix a namespace collision in a slightly foul manner.

diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index 05801c5..1e7c30b 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -219,13 +219,13 @@ private:
 /**
  * Implementation of the ComponentService interface as defined in ComponentServiceIf.ice
  */
-class ComponentServiceImpl : public ComponentService
+class ComponentServicepjmediaImpl : public ComponentService
 {
 public:
     /**
      * A constructor for this implementation which just sets a few variables, nothing extreme.
      */
-    ComponentServiceImpl(MediaRTPpjmediaApp& app, RtpGeneralStateItemPtr generalState) : mApplication(app), mGeneralState(generalState) { };
+    ComponentServicepjmediaImpl(MediaRTPpjmediaApp& app, RtpGeneralStateItemPtr generalState) : mApplication(app), mGeneralState(generalState) { };
 
     /**
      * An implementation of the suspend method which actually suspends ourselves
@@ -440,7 +440,7 @@ void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorP
     }
 
     /* One must provide a component service to manage us, if someone wants to */
-    ComponentServicePtr ComponentService = new ComponentServiceImpl(*this, mGeneralState);
+    ComponentServicePtr ComponentService = new ComponentServicepjmediaImpl(*this, mGeneralState);
     ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(mLocalAdapter->addWithUUID(ComponentService));
 
     /* Let's add the component service to the service locator first */

commit 42664ea659fed952baa5968da29d8da5cbe51eef
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Dec 9 15:47:31 2010 -0400

    Update test configuration file.

diff --git a/config/test_component.config.in b/config/test_component.config.in
index cf051a4..dad52ba 100644
--- a/config/test_component.config.in
+++ b/config/test_component.config.in
@@ -15,8 +15,8 @@ IceBox.Service.MediaRTPpjmedia=../src at media_rtp_pjmedia:create
 
 # Adapter parameters for this component
 MediaRTPpjmediaAdapter.Endpoints=default
-
 MediaRTPpjmediaAdapterLocal.Endpoints=default
+MediaRTPpjmediaAdapterLogger.Endpoints=default
 
 # A proxy to the service locator management service
 ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
@@ -28,7 +28,7 @@ ServiceLocatorProxy=LocatorService:tcp -p 4411
 # media_rtp_pjmedia_test Configuration
 #
 
-IceBox.Service.MediaRTPpjmediaTest=media_rtp_pjmedia_test:create --report_sink=${CMAKE_BINARY_DIR}/media_rtp_pjmedia_test-result.xml --report_format=XML --report_level=detailed
+IceBox.Service.MediaRTPpjmediaTest=../test at media_rtp_pjmedia_test:create --report_sink=${CMAKE_BINARY_DIR}/media_rtp_pjmedia_test-result.xml --report_format=XML --report_level=detailed
 
 #
 # Service Locator Configuration

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list