[asterisk-scf-commits] asterisk-scf/release/media_rtp_pjmedia.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sun Sep 11 22:50:47 CDT 2011


branch "master" has been updated
       via  0eb5fdfd846526651cc995531ce88f213ca91143 (commit)
      from  3d6aa9787716fd74eb6d119966cbf47143441bde (commit)

Summary of changes:
 .../MediaRTPPJMedia/RtpStateReplicationIf.ice      |    1 +
 src/RTPSession.cpp                                 |   90 ++++++++++++++++++++
 test/CMakeLists.txt                                |    4 +
 test/TestRTPpjmedia.cpp                            |   45 ++++++++++
 .../TestRTPpjmediaIf.ice                           |   33 +++++---
 5 files changed, 162 insertions(+), 11 deletions(-)
 copy src/ICEConfiguration.cpp => test/TestRTPpjmediaIf.ice (56%)


- Log -----------------------------------------------------------------
commit 0eb5fdfd846526651cc995531ce88f213ca91143
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Sun Sep 11 22:50:09 2011 -0500

    Media Session cookie support.

diff --git a/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice b/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
index b6f49ad..5e169f4 100644
--- a/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
@@ -88,6 +88,7 @@ module V1
         bool srtp;
         string remoteRtcpAddress;
         int remoteRtcpPort;
+        AsteriskSCF::Media::V1::SessionCookieDict cookies;
     };
 
     class RtpStreamSinkStateItem extends RtpStateItem
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 0d87155..9839a19 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -165,6 +165,15 @@ public:
     AsteriskSCF::Media::V1::StreamSourceSeq getSources(const Ice::Current&);
     AsteriskSCF::Media::V1::StreamSinkSeq getSinks(const Ice::Current&);
     std::string getId(const Ice::Current&);
+    void setCookies(const AsteriskSCF::Media::V1::SessionCookieDict& cookies);
+    void setCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies, 
+                    const Ice::Current&);
+    void getCookies_async(const AsteriskSCF::Media::V1::AMD_Session_getCookiesPtr &cb, 
+                          const AsteriskSCF::Media::V1::SessionCookies& cookiesToGet, 
+                          const Ice::Current&);
+    void removeCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies, 
+                const Ice::Current&);
+
     void useRTCP(bool, const Ice::Current&);
     void release(const Ice::Current&);
     void associatePayloads(const AsteriskSCF::Media::RTP::V1::PayloadMap&, const Ice::Current&);
@@ -554,6 +563,85 @@ std::string RTPSessionImpl::getId(const Ice::Current&)
     return mId;
 }
 
+/** 
+ * Local implementation. 
+ */
+void RTPSessionImpl::setCookies(const AsteriskSCF::Media::V1::SessionCookieDict& cookieMap)
+{
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    mSessionStateItem->cookies = cookieMap;
+}
+
+/** 
+ * Support for the corresponding API call. 
+ */
+void RTPSessionImpl::setCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies, 
+                const Ice::Current&)
+{
+    { // scope the lock
+        boost::unique_lock<boost::shared_mutex> lock(mLock);
+        for (AsteriskSCF::Media::V1::SessionCookies::const_iterator i = cookies.begin();
+             i != cookies.end();  ++i)
+        {
+            mSessionStateItem->cookies[(*i)->ice_id()] = (*i);
+        }
+    }
+
+    if (mReplicationContext->isReplicating() == true)
+    {
+        replicateState(mSessionStateItem, 0, 0);
+    }
+}
+
+/** 
+ * Implementation of the corresponding API call. 
+ */
+void RTPSessionImpl::getCookies_async(
+        const AsteriskSCF::Media::V1::AMD_Session_getCookiesPtr &cb,
+        const AsteriskSCF::Media::V1::SessionCookies& cookiesToGet, 
+        const Ice::Current&)
+{
+    AsteriskSCF::Media::V1::SessionCookies results;
+
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    for (AsteriskSCF::Media::V1::SessionCookies::const_iterator i = cookiesToGet.begin();
+	    i != cookiesToGet.end();
+	    ++i)
+    {
+	AsteriskSCF::Media::V1::SessionCookieDict::const_iterator cookie = mSessionStateItem->cookies.find((*i)->ice_id());
+
+	if (cookie == mSessionStateItem->cookies.end())
+	{
+	    continue;
+	}
+
+	results.push_back(cookie->second);
+    }
+
+    cb->ice_response(results);
+}
+
+/** 
+ * Implementation of the corresponding API call. 
+ */
+void RTPSessionImpl::removeCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies, 
+                const Ice::Current&)
+{
+    { // scope the lock
+        boost::unique_lock<boost::shared_mutex> lock(mLock);
+        for (AsteriskSCF::Media::V1::SessionCookies::const_iterator i = cookies.begin();
+                i != cookies.end(); ++i)
+        {
+            mSessionStateItem->cookies.erase((*i)->ice_id());
+        }
+    }
+
+    if (mReplicationContext->isReplicating() == true)
+    {
+        replicateState(mSessionStateItem, 0, 0);
+    }
+}
+
 /**
  * Implementation of the release method as defined in MediaRTPIf.ice
  */
@@ -908,6 +996,7 @@ public:
     {
         mImpl->associatePayloadsImpl(item->payloadstoFormats);
         mImpl->setRemoteRtcpDetails(item->remoteRtcpAddress, item->remoteRtcpPort);
+        mImpl->setCookies(item->cookies);
     }
 
     void update(const RtpStreamSinkStateItemPtr& item)
@@ -959,6 +1048,7 @@ ReplicationAdapterPtr AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::Obj
                     item->port, item->formats, item->ipv6, item->srtp,
                     replicationContext, 
                     configuration));
+    servant->setCookies(item->cookies);
     servant->activate(item->sessionIdentity, item->sourceIdentity, item->sinkIdentity);
     return ReplicationAdapterPtr(new ReplicationAdapterImpl(servant));
 }
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 192af9b..f5195f5 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,14 +1,18 @@
 include_directories(${astscf-ice-util-cpp_dir}/include)
 astscf_component_init(media_rtp_pjmedia_test)
+astscf_slice_collection(LOCAL PATH  "${CMAKE_CURRENT_SOURCE_DIR}") 
 astscf_component_add_files(media_rtp_pjmedia_test TestRTPpjmedia.cpp)
 astscf_component_add_slices(media_rtp_pjmedia_test PROJECT AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice)
+astscf_component_add_slices(media_rtp_pjmedia_test LOCAL TestRTPpjmediaIf.ice)
 astscf_component_add_boost_libraries(media_rtp_pjmedia_test unit_test_framework thread date_time)
 astscf_component_add_slice_collection_libraries(media_rtp_pjmedia_test ASTSCF)
 astscf_component_build_icebox(media_rtp_pjmedia_test)
 
 astscf_component_init(media_rtp_pjmedia_test_v6)
+astscf_slice_collection(LOCAL PATH  "${CMAKE_CURRENT_SOURCE_DIR}") 
 astscf_component_add_files(media_rtp_pjmedia_test_v6 TestRTPpjmedia.cpp)
 astscf_component_add_slices(media_rtp_pjmedia_test_v6 PROJECT AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice)
+astscf_component_add_slices(media_rtp_pjmedia_test_v6 LOCAL TestRTPpjmediaIf.ice)
 astscf_component_add_boost_libraries(media_rtp_pjmedia_test_v6 unit_test_framework thread date_time)
 astscf_component_add_slice_collection_libraries(media_rtp_pjmedia_test_v6 ASTSCF)
 astscf_component_build_icebox(media_rtp_pjmedia_test_v6)
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 3c4e6d8..7d7b2e2 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -38,6 +38,7 @@
 #include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
 
 #include "RtpStateReplicationIf.h"
+#include "TestRTPpjmediaIf.h"
 
 using namespace std;
 using namespace AsteriskSCF::Core::Discovery::V1;
@@ -675,6 +676,50 @@ BOOST_AUTO_TEST_CASE(VerifyReplicatedRTCPRemoteDetails)
 }
 
 /**
+ * Check that we can set and remove cookies, and that they get replicated.
+ */
+BOOST_AUTO_TEST_CASE(VerifyCookies)
+{
+    boost::mutex::scoped_lock lock(Testbed.mLock);
+
+#ifdef IPV6_TEST
+    std::string address = "::1";
+#else
+    std::string address = "127.0.0.1";
+#endif
+
+    try
+    {
+        AsteriskSCF::MediaRTPpjmediaTest::FooCookiePtr foo = new AsteriskSCF::MediaRTPpjmediaTest::FooCookie();
+        foo->value = "foo";
+
+        AsteriskSCF::MediaRTPpjmediaTest::BarCookiePtr bar = new AsteriskSCF::MediaRTPpjmediaTest::BarCookie();
+        bar->value = "bar";
+
+        AsteriskSCF::Media::V1::SessionCookies cookies;
+        cookies.push_back(foo);
+        cookies.push_back(bar);
+
+         Testbed.session->setCookies(cookies);
+    }
+    catch (const Ice::Exception &e)
+    {
+        BOOST_TEST_MESSAGE(e.ice_name());
+        BOOST_TEST_MESSAGE(e.what());
+    }
+
+    Testbed.mCondition.wait(lock);
+
+    BOOST_CHECK(Testbed.mListener->mSession->cookies.size() == 2);
+    AsteriskSCF::MediaRTPpjmediaTest::FooCookiePtr fooType = new AsteriskSCF::MediaRTPpjmediaTest::FooCookie();
+    AsteriskSCF::Media::V1::SessionCookiePtr cookie = Testbed.mListener->mSession->cookies[fooType->ice_id()];
+    AsteriskSCF::MediaRTPpjmediaTest::FooCookiePtr fooReplica = AsteriskSCF::MediaRTPpjmediaTest::FooCookiePtr::dynamicCast(cookie);
+
+    BOOST_CHECK(fooReplica != 0);
+    BOOST_CHECK(fooReplica->value == "foo");
+}
+
+/**
  * Check that the RTP session has at least one sink
  */
 BOOST_AUTO_TEST_CASE(CheckForSink)
diff --git a/test/TestRTPpjmediaIf.ice b/test/TestRTPpjmediaIf.ice
new file mode 100644
index 0000000..63a6899
--- /dev/null
+++ b/test/TestRTPpjmediaIf.ice
@@ -0,0 +1,43 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <AsteriskSCF/Media/MediaIf.ice>
+
+module AsteriskSCF
+{
+
+module MediaRTPpjmediaTest
+{
+
+    
+    unsliceable class TestCookie extends AsteriskSCF::Media::V1::SessionCookie
+    {
+        string value;
+    };
+
+    unsliceable class FooCookie extends TestCookie 
+    {
+    };
+
+    unsliceable class BarCookie extends TestCookie 
+    {
+    };
+
+}; /*  end module MediaRTPpjmediaTest*/
+
+}; /*  end module AsteriskSCF */

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


-- 
asterisk-scf/release/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list