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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Jul 10 11:33:03 CDT 2012


branch "alternate_source_cleanup" has been updated
       via  15a6cae74e650fdeec8945b283f5205410b7481f (commit)
      from  bf9ec7cdc51731b1f13db3421c7ae7f6a20831aa (commit)

Summary of changes:
 src/RTPSource.cpp |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit 15a6cae74e650fdeec8945b283f5205410b7481f
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Jul 10 14:02:11 2012 -0230

    Add timer and timer task to the cleanup process.

diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index c4900d9..eddd36e 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -105,6 +105,13 @@ public:
 
     void runTimerTask()
     {
+        if (isShutdown())
+        {
+            mSessionAdapter.reset();
+            mTransport.reset();
+            return;
+        }
+
         if (pj_thread_is_registered() == PJ_FALSE)
         {
             pj_thread_t *thread;
@@ -115,13 +122,6 @@ public:
         void *packet;
         int packet_size;
 
-        if (isShutdown())
-        {
-            mSessionAdapter.reset();
-            mTransport.reset();
-            return;
-        }
-
         pjmedia_rtcp_build_rtcp(mSessionAdapter->getRtcpSession(), &packet, &packet_size);
         pjmedia_transport_send_rtcp(mTransport->getTransport(), packet, packet_size);
 
@@ -244,6 +244,8 @@ public:
      */
     RTPTelephonyEventSourcePtr mTelephonyEventSource;
 
+    RtcpTransmissionPtr mTransmission;
+
     /**
      * Lock that protects information contained.
      */
@@ -474,12 +476,16 @@ void StreamSourceRTPImpl::setRemoteDetails(const string& address, Ice::Int port)
 void StreamSourceRTPImpl::setRemoteRtcpDetails(const std::string& address, Ice::Int port)
 {
     TransportMap::instance().addTransport(MapRecord(mImpl->mTransport, this), address, port, true);
+    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
     if (!mImpl->mTimer && (mImpl->mTimer = new IceUtil::Timer()))
     {
-        RtcpTransmissionPtr transmission;
-        if ((transmission = new RtcpTransmission(mImpl->mSessionAdapter, mImpl->mSink, mImpl->mTransport, mImpl->mThreadDescriptor)))
+        if (mImpl->mTransmission) 
+        {
+            mImpl->mTransmission->shutdown();
+        }
+        if ((mImpl->mTransmission = new RtcpTransmission(mImpl->mSessionAdapter, mImpl->mSink, mImpl->mTransport, mImpl->mThreadDescriptor)))
         {
-            mImpl->mTimer->scheduleRepeated(transmission, IceUtil::Time::milliSeconds(PJMEDIA_RTCP_INTERVAL));
+            mImpl->mTimer->scheduleRepeated(mImpl->mTransmission, IceUtil::Time::milliSeconds(PJMEDIA_RTCP_INTERVAL));
         }
     }
 }
@@ -557,6 +563,10 @@ void StreamSourceRTPImpl::destroy()
             mImpl->mTimer->destroy();
             mImpl->mTimer = 0;
         }
+        if (mImpl->mTransmission)
+        {
+            mImpl->mTransmission->shutdown();
+        } 
     }
     TransportMap::instance().removeTransport(MapRecord(transport, this));
 }

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list