[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
Wed Apr 13 20:46:25 CDT 2011


branch "master" has been updated
       via  70bd6106cdd277a8994b27d62c836deb2c83ed81 (commit)
      from  7e3d172b518669dff018e3177ceb2b13cf80a3b8 (commit)

Summary of changes:
 src/RtpStateReplicatorListener.cpp |    8 ++--
 test/TestRTPpjmedia.cpp            |   62 +++++++++++++++++++++---------------
 2 files changed, 40 insertions(+), 30 deletions(-)


- Log -----------------------------------------------------------------
commit 70bd6106cdd277a8994b27d62c836deb2c83ed81
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Apr 13 22:46:52 2011 -0300

    Fix RTP state replication and unit test.

diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index b342b7f..a42c7b5 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -80,12 +80,12 @@ public:
 	private:
 	    RtpStateReplicatorListenerImpl *mImpl;
 
-	    void visitGeneral(const RtpGeneralStateItemPtr &item, const Ice::Current &)
+	    void visitRtpGeneralStateItem(const RtpGeneralStateItemPtr &item)
 	    {
 		mImpl->mGeneralState->mServiceManagement = item->mServiceManagement;
 	    }
 		    
-	    void visitSession(const RtpSessionStateItemPtr &item, const Ice::Current &)
+	    void visitRtpSessionStateItem(const RtpSessionStateItemPtr &item)
 	    {
 		map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = mImpl->mStateItems.find(item->mSessionId);
 		boost::shared_ptr<RtpStateReplicatorItem> localitem;
@@ -109,7 +109,7 @@ public:
 	        localitem->getSession()->associatePayloads(item->mPayloadstoFormats, Ice::Current());
 	    }
 		    
-	    void visitStreamSink(const RtpStreamSinkStateItemPtr &item, const Ice::Current &)
+	    void visitRtpStreamSinkStateItem(const RtpStreamSinkStateItemPtr &item)
 	    {
 		map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i =
                     mImpl->mStateItems.find(item->mSessionId);
@@ -121,7 +121,7 @@ public:
 		}
 	    }
 		    
-	    void visitStreamSource(const RtpStreamSourceStateItemPtr &item, const Ice::Current &)
+	    void visitRtpStreamSourceStateItem(const RtpStreamSourceStateItemPtr &item)
 	    {
 		map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i =
                     mImpl->mStateItems.find(item->mSessionId);
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 2195a90..7432c04 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -151,32 +151,32 @@ void TestRtpReplicatorListener::stateSet(const RtpStateItemSeq& items, const Ice
     private:
 	TestRtpReplicatorListener *mListener;
 
-	void visitGeneral(const RtpGeneralStateItemPtr &item, const Ice::Current &)
+	void visitRtpGeneralStateItem(const RtpGeneralStateItemPtr &item)
 	{
-            mListener->mGeneral = item;
-			boost::mutex::scoped_lock lock(Testbed.mLock);
-			Testbed.mCondition.notify_one();
+	    boost::mutex::scoped_lock lock(Testbed.mLock);
+	    mListener->mGeneral = item;
+	    Testbed.mCondition.notify_one();
 	}
 
-	void visitSession(const RtpSessionStateItemPtr &item, const Ice::Current &)
+	void visitRtpSessionStateItem(const RtpSessionStateItemPtr &item)
 	{
-            mListener->mSession = item;
-			boost::mutex::scoped_lock lock(Testbed.mLock);
-			Testbed.mCondition.notify_one();
+	    boost::mutex::scoped_lock lock(Testbed.mLock);
+	    mListener->mSession = item;
+	    Testbed.mCondition.notify_one();
 	}
 
-	void visitStreamSink(const RtpStreamSinkStateItemPtr &item, const Ice::Current &)
+	void visitRtpStreamSinkStateItem(const RtpStreamSinkStateItemPtr &item)
 	{
-            mListener->mSink = item;
-			boost::mutex::scoped_lock lock(Testbed.mLock);
-			Testbed.mCondition.notify_one();
+	    boost::mutex::scoped_lock lock(Testbed.mLock);
+	    mListener->mSink = item;
+	    Testbed.mCondition.notify_one();
 	}
 
-	void visitStreamSource(const RtpStreamSourceStateItemPtr &item, const Ice::Current &)
+	void visitRtpStreamSourceStateItem(const RtpStreamSourceStateItemPtr &item)
 	{
-            mListener->mSource = item;
-			boost::mutex::scoped_lock lock(Testbed.mLock);
-			Testbed.mCondition.notify_one();
+	    boost::mutex::scoped_lock lock(Testbed.mLock);
+	    mListener->mSource = item;
+	    Testbed.mCondition.notify_one();
 	}
     };
 
@@ -197,9 +197,9 @@ public:
      */
     void write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&)
     {
-        Testbed.frames = frames;
-		boost::mutex::scoped_lock lock(Testbed.mLock);
-		Testbed.mCondition.notify_one();
+	boost::mutex::scoped_lock lock(Testbed.mLock);
+	Testbed.frames = frames;
+	Testbed.mCondition.notify_one();
     }
 
     /**
@@ -388,8 +388,12 @@ BOOST_AUTO_TEST_CASE(AddListenertoStateReplicator)
 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::mutex::scoped_lock lock(Testbed.mLock);
+    boost::mutex::scoped_lock lock(Testbed.mLock);
+
+    if (!Testbed.mListener->mGeneral)
+    {
 	Testbed.mCondition.wait(lock);
+    }
 
     BOOST_CHECK(Testbed.mListener->mGeneral);
 }
@@ -415,11 +419,13 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
         FormatSeq formats;
         formats.push_back(format);
 
+	// You might think "geez, this should deadlock due to state replication" but no, we use one ways for that
+	boost::mutex::scoped_lock lock(Testbed.mLock);
+
         Testbed.session = service->allocate(formats);
 
 	// Give the RTP component time to replicate this session
-		boost::mutex::scoped_lock lock(Testbed.mLock);
-		Testbed.mCondition.wait(lock);
+	Testbed.mCondition.wait(lock);
 
         allocated = true;
     }
@@ -776,12 +782,14 @@ BOOST_AUTO_TEST_CASE(SetupLoopback)
         /* Okay, changing the remote details of the first sink should have it send media to the above. */
         StreamSinkSeq sinks = Testbed.session->getSinks();
         StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
+
+	boost::mutex::scoped_lock lock(Testbed.mLock);
+
         sink->setRemoteDetails(address, port);
 
         looped = true;
 
-		boost::mutex::scoped_lock lock(Testbed.mLock);
-		Testbed.mCondition.wait(lock);
+	Testbed.mCondition.wait(lock);
     }
     catch (const Ice::Exception &e)
     {
@@ -849,12 +857,14 @@ BOOST_AUTO_TEST_CASE(TransmitandReceiveFrame)
 
         StreamSinkSeq sinks = Testbed.session->getSinks();
         StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
+
+	boost::mutex::scoped_lock lock(Testbed.mLock);
+
         sink->write(frames);
 
         /* It takes time for the packet to get sent and received so we wait until we get it here.
          */
-		boost::mutex::scoped_lock lock(Testbed.mLock);
-		Testbed.mCondition.wait(lock);
+	Testbed.mCondition.wait(lock);
 
         /* We only sent a single frame, so we should only get a single frame. */
         AudioFramePtr received_frame;

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


-- 
asterisk-scf/release/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list