[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 09:55:01 CDT 2012


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

Summary of changes:
 src/ICETransport.cpp     |    3 +--
 src/ICETransport.h       |    1 -
 src/PJMEDIATransport.cpp |    5 +++--
 src/PJMEDIATransport.h   |    5 ++++-
 src/RTPSession.cpp       |   10 +++++++---
 src/SRTPTransport.cpp    |    6 +++---
 src/SRTPTransport.h      |    2 +-
 src/UDPTransport.cpp     |    6 +++---
 src/UDPTransport.h       |    2 +-
 9 files changed, 23 insertions(+), 17 deletions(-)


- Log -----------------------------------------------------------------
commit bf9ec7cdc51731b1f13db3421c7ae7f6a20831aa
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Jul 10 12:20:48 2012 -0230

    Altering the concrete transport implementations to own an reference count to
    their parent endpoint. It is cleaner, or at least more clear, for the servant
    to lose its reference to the endpoint when it is destroyed along with references
    to everything else. However, the order of destruction is unclear and the transport
    objects that might still be active still need it to exist. The transports having
    their own reference resolves this issue. The endpoint does not have a reference to them
    so there is no circular reference issue and as long as the transport is cleaned up
    properly (which it should be at the moment), the endpoint will disappear as well.

diff --git a/src/ICETransport.cpp b/src/ICETransport.cpp
index b36c996..36e91a1 100644
--- a/src/ICETransport.cpp
+++ b/src/ICETransport.cpp
@@ -803,8 +803,7 @@ ICETransportPtr ICETransport::create(const PJMEDIAEndpointPtr& ep, const PJMEDIA
 }
 
 ICETransport::ICETransport(const PJMEDIAEndpointPtr& ep, const PJMEDIAEnvironmentPtr& configObject) :
-    PJMEDIATransport(0),
-    mEndpoint(ep),
+    PJMEDIATransport(ep, 0),
     mConfig(configObject),
     mEnableRTCP(false)
 {
diff --git a/src/ICETransport.h b/src/ICETransport.h
index 7a30cca..31d4060 100644
--- a/src/ICETransport.h
+++ b/src/ICETransport.h
@@ -70,7 +70,6 @@ private:
     PJICECallbackPtr mCallback;
     PJSockAddrPtr mLastKnownAddr;
     NATModulePtr mNATModule;
-    PJMEDIAEndpointPtr mEndpoint;
     PJMEDIAEnvironmentPtr mConfig;
     bool mEnableRTCP;
 
diff --git a/src/PJMEDIATransport.cpp b/src/PJMEDIATransport.cpp
index 2546b8b..4b1e9b8 100644
--- a/src/PJMEDIATransport.cpp
+++ b/src/PJMEDIATransport.cpp
@@ -36,8 +36,9 @@ pjmedia_transport* PJMEDIATransport::getTransport() const
     return mTransport;
 }
 
-PJMEDIATransport::PJMEDIATransport(pjmedia_transport* t) :
-    mTransport(t)
+PJMEDIATransport::PJMEDIATransport(const PJMEDIAEndpointPtr& endpoint, pjmedia_transport* t) :
+    mTransport(t),
+    mEndpoint(endpoint)
 {
 }
 
diff --git a/src/PJMEDIATransport.h b/src/PJMEDIATransport.h
index ca4889f..e6e0bcf 100644
--- a/src/PJMEDIATransport.h
+++ b/src/PJMEDIATransport.h
@@ -34,6 +34,8 @@ namespace PJMEDIARTP
 
 class PJMEDIATransport;
 typedef boost::shared_ptr<PJMEDIATransport> PJMEDIATransportPtr;
+class PJMEDIAEndpoint;
+typedef boost::shared_ptr<PJMEDIAEndpoint> PJMEDIAEndpointPtr;
 
 class PJMEDIATransport
 {
@@ -57,8 +59,9 @@ public:
 
 protected:
     pjmedia_transport* mTransport;
+    PJMEDIAEndpointPtr mEndpoint;
 
-    PJMEDIATransport(pjmedia_transport* t);
+    PJMEDIATransport(const PJMEDIAEndpointPtr& endpoint, pjmedia_transport* t);
 
     AsteriskSCF::Helpers::AddressPtr getLocalAddressImpl();
     AsteriskSCF::Helpers::AddressPtr fromInfo(pjmedia_transport_info& info);
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 5c9e3bc..ce5ba9b 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -1205,6 +1205,7 @@ RTPSessionPrx RTPSessionImpl::activate(
                     mStreamSink->getTelephonyEventSinkStateItem(),
                     mStreamSource->getTelephonyEventSourceStateItem());
         }
+
         RTPSessionPrx result = RTPSessionPrx::uncheckedCast(mAdapter->add(this, id));
         mTransport->addFacets(mAdapter, id);
         return result;
@@ -1232,9 +1233,7 @@ void RTPSessionImpl::destroy()
         mAdapter->remove(mTelephonyEventSinkPrx->ice_getIdentity());
     }
 
-    /* Since both the source and sink have a pointer back to the session we need to get rid of them,
-     * which will in turn get rid of ourselves once we are removed from the ASM.
-     */
+     PJMEDIAEndpointPtr tempEndpoint;
     {
         boost::unique_lock<boost::shared_mutex> lock(mLock);
         if (mStreamSource)
@@ -1253,8 +1252,13 @@ void RTPSessionImpl::destroy()
         mSessionAdapter.reset();
         mTransport.reset();
         mRtcpSessionInterface = 0;
+        tempEndpoint = mEndpoint;
         mEndpoint.reset();
     }
+    //
+    // The session's copy of the endpoint needs to be cleaned up here. 
+    //
+    tempEndpoint.reset();
 
     /* All we have to do is remove ourselves from the ASM, our smart pointerness will cause us to
      * destruct and then cleanup will occur.
diff --git a/src/SRTPTransport.cpp b/src/SRTPTransport.cpp
index c646a07..6a0230f 100644
--- a/src/SRTPTransport.cpp
+++ b/src/SRTPTransport.cpp
@@ -97,11 +97,11 @@ SRTPTransportPtr SRTPTransport::create(const PJMEDIATransportPtr& transport, con
     {
         throw InternalInitializationException("Unable to create new ICE media transport");
     }
-    return SRTPTransportPtr(new SRTPTransport(t, transport));
+    return SRTPTransportPtr(new SRTPTransport(ep, t, transport));
 }
 
-SRTPTransport::SRTPTransport(pjmedia_transport* t, const PJMEDIATransportPtr& origTransport) :
-    PJMEDIATransport(t),
+SRTPTransport::SRTPTransport(const PJMEDIAEndpointPtr& endpoint, pjmedia_transport* t, const PJMEDIATransportPtr& origTransport) :
+    PJMEDIATransport(endpoint, t),
     mMainTransport(origTransport),
     mEnableAuthentication(true),
     mEnableEncryption(true),
diff --git a/src/SRTPTransport.h b/src/SRTPTransport.h
index 9e3c25a..1411a63 100644
--- a/src/SRTPTransport.h
+++ b/src/SRTPTransport.h
@@ -55,7 +55,7 @@ private:
     bool mEnableEncryption;
     bool mStarted;
 
-    SRTPTransport(pjmedia_transport* t, const PJMEDIATransportPtr& origTransport);
+    SRTPTransport(const PJMEDIAEndpointPtr& endpoint, pjmedia_transport* t, const PJMEDIATransportPtr& origTransport);
 
     //
     // Hidden and unimplemented.
diff --git a/src/UDPTransport.cpp b/src/UDPTransport.cpp
index 605e613..27a28ad 100644
--- a/src/UDPTransport.cpp
+++ b/src/UDPTransport.cpp
@@ -75,13 +75,13 @@ UDPTransportPtr AsteriskSCF::PJMEDIARTP::UDPTransport::createImpl(const PJMEDIAE
             port, 0, &transport);
         if (success(result))
         {
-            return UDPTransportPtr(new UDPTransport(transport));
+            return UDPTransportPtr(new UDPTransport(ep, transport));
         }
     }
     throw InternalInitializationException("Unable to initialize UDP media transport");
 }
 
-UDPTransport::UDPTransport(pjmedia_transport* t) :
-    PJMEDIATransport(t)
+UDPTransport::UDPTransport(const PJMEDIAEndpointPtr& endpoint, pjmedia_transport* t) :
+    PJMEDIATransport(endpoint, t)
 {
 }
diff --git a/src/UDPTransport.h b/src/UDPTransport.h
index 09cd779..86c61b4 100644
--- a/src/UDPTransport.h
+++ b/src/UDPTransport.h
@@ -61,7 +61,7 @@ private:
         const RTPConfigurationPtr& configObject,
         unsigned minPort, unsigned maxPort, bool expectIPv6);
 
-    UDPTransport(pjmedia_transport* t);
+    UDPTransport(const PJMEDIAEndpointPtr& endpoint, pjmedia_transport* t);
 };
 
 } /* End of namespace PJMEDIARTP */

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list