[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
Tue Aug 9 14:50:47 CDT 2011


branch "master" has been updated
       via  67faf7d901a446943516e0d76583f666d2a4a199 (commit)
      from  8dde821ebd1f512fe493da504e5c93d7c71403fb (commit)

Summary of changes:
 src/RTPSource.cpp |   50 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 44 insertions(+), 6 deletions(-)


- Log -----------------------------------------------------------------
commit 67faf7d901a446943516e0d76583f666d2a4a199
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Aug 9 14:50:20 2011 -0500

    Register the timer thread with pjlib (if needed). Fixes the test execution for Windows.

diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index c9592b1..23dae4f 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -47,23 +47,56 @@ Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
 }
 
 /**
+ * Wrapper class around pj_thread_desc.
+ */
+class ThreadDescWrapper
+{
+public:
+    /**
+     * pjthread thread description information, must persist for the life of the thread
+     */
+    pj_thread_desc mDesc;
+};
+
+/**
+ * Type definition used to create a smart pointer for the above.
+ */
+typedef boost::shared_ptr<ThreadDescWrapper> ThreadDescWrapperPtr;
+
+
+/**
  * TimerTask implementation which sends RTCP at a defined interval.
  */
 class RtcpTransmission : public IceUtil::TimerTask
 {
 public:
-    RtcpTransmission(const SessionAdapterPtr& sessionAdapter, const StreamSinkRTPPrx& sink, const PJMediaTransportPtr& transport) :
-        mSessionAdapter(sessionAdapter), mSink(sink), mTransport(transport) { }
+    RtcpTransmission(const SessionAdapterPtr& sessionAdapter, 
+                     const StreamSinkRTPPrx& sink, 
+                     const PJMediaTransportPtr& transport,
+                     const ThreadDescWrapperPtr& threadDesciptor) 
+                     : mSessionAdapter(sessionAdapter), 
+                       mSink(sink), 
+                       mTransport(transport),
+                       mThreadDescriptor(threadDesciptor)
+    { 
+    }
 
     void runTimerTask()
     {
+        if (pj_thread_is_registered() == PJ_FALSE)
+        {
+            pj_thread_t *thread;
+            pj_status_t status = pj_thread_register("ICE Thread", mThreadDescriptor->mDesc, &thread);
+            assert(status == PJ_SUCCESS);
+        }
+
         void *packet;
         int packet_size;
 
         pjmedia_rtcp_build_rtcp(mSessionAdapter->getRtcpSession(), &packet, &packet_size);
         pjmedia_transport_send_rtcp(mTransport->getTransport(), packet, packet_size);
 
-	std::vector<RTCP::V1::InformationListenerPrx> listeners = mSessionAdapter->getSenderReportListeners();
+        std::vector<RTCP::V1::InformationListenerPrx> listeners = mSessionAdapter->getSenderReportListeners();
 
         // If no listeners exist don't bother getting the statistics
         if (listeners.empty())
@@ -71,7 +104,7 @@ public:
             return;
         }
 
-	RTCP::V1::StatisticsPtr statistics = mSessionAdapter->getSenderReportStatistics();
+        RTCP::V1::StatisticsPtr statistics = mSessionAdapter->getSenderReportStatistics();
 
         for (std::vector<RTCP::V1::InformationListenerPrx>::const_iterator listener = listeners.begin();
              listener != listeners.end();
@@ -96,6 +129,8 @@ private:
      * Pointer to the transport used for communication.
      */
     PJMediaTransportPtr mTransport;
+
+    ThreadDescWrapperPtr mThreadDescriptor;
 };
 
 /**
@@ -164,6 +199,8 @@ public:
      * Lock that protects information contained.
      */
     boost::shared_mutex mLock;
+
+    ThreadDescWrapperPtr mThreadDescriptor;
 };
 
 /**
@@ -178,7 +215,8 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const SessionAdapterPtr& sessio
     mSourceStateItem(new RtpStreamSourceStateItem), 
     mSessionId(sessionId),
     mSource(source),
-    mSink(sink)
+    mSink(sink),
+    mThreadDescriptor(new ThreadDescWrapper)
 {
     pjmedia_rtp_session_init(&mIncomingSession, 0, 0);
     mSourceStateItem->sessionId = sessionId;
@@ -552,7 +590,7 @@ void StreamSourceRTPImpl::setRemoteRtcpDetails(const std::string& address, Ice::
     {
         RtcpTransmissionPtr transmission;
 
-        if ((transmission = new RtcpTransmission(mImpl->mSessionAdapter, mImpl->mSink, mImpl->mTransport)))
+        if ((transmission = new RtcpTransmission(mImpl->mSessionAdapter, mImpl->mSink, mImpl->mTransport, mImpl->mThreadDescriptor)))
         {
             mImpl->mTimer->scheduleRepeated(transmission, IceUtil::Time::milliSeconds(PJMEDIA_RTCP_INTERVAL));
         }

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


-- 
asterisk-scf/release/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list