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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Jul 25 15:22:02 CDT 2012


branch "thread_reduction" has been updated
       via  d35deff9771baf9a17cee0cc10ffb1eb286c5d5e (commit)
      from  78dd865f792d26aa6e750f6d19f6153211c3282b (commit)

Summary of changes:
 src/PJMEDIAEnvironment.cpp |    5 +++--
 src/PJMEDIAEnvironment.h   |    7 +++++++
 src/RTPSession.cpp         |    3 ++-
 src/RTPSource.cpp          |   23 +++++++++--------------
 src/RTPSource.h            |    4 +++-
 5 files changed, 24 insertions(+), 18 deletions(-)


- Log -----------------------------------------------------------------
commit d35deff9771baf9a17cee0cc10ffb1eb286c5d5e
Author: Brent Eagles <beagles at digium.com>
Date:   Wed Jul 25 17:48:29 2012 -0230

    The component now uses a single timer object for all rtp sources. This
    shouldn't be a huge issue... the timer worker thread will be very busy on rtp
    components with lots of sessions. An improvement would be to have a pool of
    timer instances and round-robin through them.

diff --git a/src/PJMEDIAEnvironment.cpp b/src/PJMEDIAEnvironment.cpp
index 89f7059..5fe25dc 100644
--- a/src/PJMEDIAEnvironment.cpp
+++ b/src/PJMEDIAEnvironment.cpp
@@ -48,8 +48,9 @@ PJMEDIAEnvironment::PJMEDIAEnvironment(const PJLIBConfigurationPtr& libCfg,
         const RTPConfigurationPtr& configObject) :
     mPJLIBConfig(libCfg),
     mConfiguration(configObject),
-    mCachingPool(new pj_caching_pool),
-    mIOQueue(0)
+    mIOQueue(0),
+    mTimer(new IceUtil::Timer),
+    mCachingPool(new pj_caching_pool)
 {
     //
     // I find this practice a little sketchy since the pointers that might be retrieve through the accessors *must*
diff --git a/src/PJMEDIAEnvironment.h b/src/PJMEDIAEnvironment.h
index 418d48e..774b17f 100644
--- a/src/PJMEDIAEnvironment.h
+++ b/src/PJMEDIAEnvironment.h
@@ -19,6 +19,7 @@
 #include "Configuration.h"
 
 #include <Ice/PropertiesF.h>
+#include <IceUtil/Timer.h>
 #include <string>
 #include <boost/shared_ptr.hpp>
 
@@ -117,6 +118,11 @@ public:
         return mIOQueue;
     }
 
+    IceUtil::TimerPtr timer() 
+    { 
+        return mTimer;
+    }
+
     /**
      * Create an instance of the object based on the Ice properties.
      */
@@ -130,6 +136,7 @@ private:
     pj_pool_factory* mPoolFactory;
     pj_pool_t* mMemoryPool;
     pj_ioqueue_t* mIOQueue;
+    IceUtil::TimerPtr mTimer;
     boost::shared_ptr<pj_caching_pool> mCachingPool;
 
     PJMEDIAEnvironment(const PJLIBConfigurationPtr& libConfig,
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index fca1d53..17bbd93 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -1153,7 +1153,8 @@ RTPSessionPrx RTPSessionImpl::activate(
                 mTransport,
                 mId,
                 StreamSourceRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sourceId)),
-                StreamSinkRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sinkId)));
+                StreamSinkRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sinkId)),
+                mEnvironment->timer());
 
         mStreamSink = new StreamSinkRTPImpl(
                 mSessionAdapter,
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index fbae703..2502806 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -201,7 +201,8 @@ public:
                             const PJMEDIATransportPtr& transport,
                             const string& parentSessionId,
                             const StreamSourceRTPPrx& source,
-                            const StreamSinkRTPPrx& sink
+                            const StreamSinkRTPPrx& sink,
+                            const IceUtil::TimerPtr& timer
         );
 
     /**
@@ -277,10 +278,12 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const SessionAdapterPtr& sessio
                                                  const PJMEDIATransportPtr& transport,
                                                  const string& sessionId,
                                                  const StreamSourceRTPPrx& source,
-                                                 const StreamSinkRTPPrx& sink) :
+                                                 const StreamSinkRTPPrx& sink,
+                                                 const IceUtil::TimerPtr& timer) :
     mSessionAdapter(session), mTransport(transport),
     mSourceStateItem(new RTPStreamSourceStateItem),
     mSessionId(sessionId),
+    mTimer(timer),
     mSource(source),
     mSink(sink),
     mThreadDescriptor(new ThreadDescWrapper),
@@ -296,10 +299,6 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const SessionAdapterPtr& sessio
  */
 StreamSourceRTPImplPriv::~StreamSourceRTPImplPriv()
 {
-    if (mTimer)
-    {
-        mTimer->destroy();
-    }
 }
 
 /**
@@ -308,8 +307,9 @@ StreamSourceRTPImplPriv::~StreamSourceRTPImplPriv()
 StreamSourceRTPImpl::StreamSourceRTPImpl(const SessionAdapterPtr& session,
                                          const PJMEDIATransportPtr& transport, const string& sessionId,
                                          const StreamSourceRTPPrx& source,
-                                         const StreamSinkRTPPrx& sink) :
-    mImpl(new StreamSourceRTPImplPriv(session, transport, sessionId, source, sink))
+                                         const StreamSinkRTPPrx& sink,
+                                         const IceUtil::TimerPtr& timer) :
+    mImpl(new StreamSourceRTPImplPriv(session, transport, sessionId, source, sink, timer))
 {
 }
 
@@ -483,7 +483,7 @@ void StreamSourceRTPImpl::setRemoteRtcpDetails(const std::string& address, Ice::
 {
     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()))
+    if (mImpl->mTimer)
     {
         if (mImpl->mTransmission) 
         {
@@ -564,11 +564,6 @@ void StreamSourceRTPImpl::destroy()
         mImpl->mTelephonyEventSource = 0;
         mImpl->mSessionAdapter.reset();
         // Destroy the RTCP transmission timer if it exists
-        if (mImpl->mTimer)
-        {
-            mImpl->mTimer->destroy();
-            mImpl->mTimer = 0;
-        }
         if (mImpl->mTransmission)
         {
             mImpl->mTransmission->shutdown();
diff --git a/src/RTPSource.h b/src/RTPSource.h
index e84029b..8c4ef63 100644
--- a/src/RTPSource.h
+++ b/src/RTPSource.h
@@ -12,6 +12,7 @@
 #include "SessionAdapter.h"
 #include <boost/shared_ptr.hpp>
 #include <IceUtil/Handle.h>
+#include <IceUtil/Timer.h>
 #include "RTPTelephonyEventSource.h"
 
 /**
@@ -29,7 +30,8 @@ public:
                         const AsteriskSCF::PJMEDIARTP::PJMEDIATransportPtr& transport,
                         const std::string& parentSessionId,
                         const AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx& source,
-                        const AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx& sink);
+                        const AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx& sink,
+                        const IceUtil::TimerPtr& mTimer);
 
     void addSink(const AsteriskSCF::System::V1::OperationContextPtr&, const AsteriskSCF::Media::V1::StreamSinkPrx&, const Ice::Current&);
     void removeSink(const AsteriskSCF::System::V1::OperationContextPtr&, const AsteriskSCF::Media::V1::StreamSinkPrx&, const Ice::Current&);

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list