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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Jul 11 18:55:56 CDT 2011


branch "rtcp" has been updated
       via  46db38a456e824b4e1be7b26f5eff3888b2de8ff (commit)
      from  a71f813b8429a763e49f6124d054e70814990c12 (commit)

Summary of changes:
 src/RTPSession.cpp |   48 ----------------------------------
 src/RTPSource.cpp  |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 49 deletions(-)


- Log -----------------------------------------------------------------
commit 46db38a456e824b4e1be7b26f5eff3888b2de8ff
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jul 11 20:56:36 2011 -0300

    Initialize the RTCP session and schedule sending of RTCP packets.

diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 43a774d..976100c 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -19,7 +19,6 @@
 
 #include <Ice/Ice.h>
 #include <IceUtil/UUID.h>
-#include <IceUtil/Timer.h>
 
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
@@ -54,53 +53,6 @@ using namespace AsteriskSCF::Discovery;
 #define DEFAULT_RTP_PORT_MAXIMUM 20000
 
 /**
- * TimerTask implementation which sends RTCP at a defined interval.
- */
-class RtcpTransmission : public IceUtil::TimerTask
-{
-public:
-    RtcpTransmission(const RTPSessionImplPtr& session) : mSession(session) { }
-
-    void runTimerTask()
-    {
-        void *packet;
-        int packet_size;
-
-        pjmedia_rtcp_build_rtcp(mSession->getRtcpSession(), &packet, &packet_size);
-        pjmedia_transport_send_rtcp(mSession->getTransport(), packet, packet_size);
-
-        std::vector<RTCP::V1::InformationListenerPrx> listeners = mSession->getSenderReportListeners();
-
-        // If no listeners exist don't bother getting the statistics
-        if (listeners.empty())
-        {
-            return;
-        }
-
-        RTCP::V1::StatisticsPtr statistics = mSession->getSenderReportStatistics();
-        StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(mSession->getSinks(Ice::Current()).front());
-
-        for (std::vector<RTCP::V1::InformationListenerPrx>::const_iterator listener = listeners.begin();
-             listener != listeners.end();
-             ++listener)
-        {
-            (*listener)->sinkStatisticsUpdated(sink, statistics);
-        }
-    }
-
-private:
-    /**
-     * A pointer to the RTP session we are associated with.
-     */
-    RTPSessionImplPtr mSession;
-};
-
-/**
- * Smart pointer for the above RtcpTransmission class.
- */
-typedef IceUtil::Handle<RtcpTransmission> RtcpTransmissionPtr;
-
-/**
  * RTCP Information Interface implementation.
  */
 class RTCPInformationImpl : public RTCP::V1::Information
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index 0078b32..fba5983 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -19,6 +19,7 @@
 
 #include <Ice/Ice.h>
 #include <IceUtil/UUID.h>
+#include <IceUtil/Timer.h>
 
 #include <boost/thread.hpp>
 
@@ -35,6 +36,7 @@
 
 using namespace std;
 using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::Media;
 using namespace AsteriskSCF::Media::V1;
 using namespace AsteriskSCF::Media::RTP::V1;
 using namespace AsteriskSCF::Replication::MediaRTPPJMedia::V1;
@@ -46,6 +48,53 @@ Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
 }
 
 /**
+ * TimerTask implementation which sends RTCP at a defined interval.
+ */
+class RtcpTransmission : public IceUtil::TimerTask
+{
+public:
+    RtcpTransmission(const RTPSessionImplPtr& session) : mSession(session) { }
+
+    void runTimerTask()
+    {
+        void *packet;
+        int packet_size;
+
+        pjmedia_rtcp_build_rtcp(mSession->getRtcpSession(), &packet, &packet_size);
+        pjmedia_transport_send_rtcp(mSession->getTransport(), packet, packet_size);
+
+	std::vector<RTCP::V1::InformationListenerPrx> listeners = mSession->getSenderReportListeners();
+
+        // If no listeners exist don't bother getting the statistics
+        if (listeners.empty())
+        {
+            return;
+        }
+
+	RTCP::V1::StatisticsPtr statistics = mSession->getSenderReportStatistics();
+        StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(mSession->getSinks(Ice::Current()).front());
+
+        for (std::vector<RTCP::V1::InformationListenerPrx>::const_iterator listener = listeners.begin();
+             listener != listeners.end();
+             ++listener)
+        {
+            (*listener)->sinkStatisticsUpdated(sink, statistics);
+        }
+    }
+
+private:
+    /**
+     * A pointer to the RTP session we are associated with.
+     */
+    RTPSessionImplPtr mSession;
+};
+
+/**
+ * Smart pointer for the above RtcpTransmission class.
+ */
+typedef IceUtil::Handle<RtcpTransmission> RtcpTransmissionPtr;
+
+/**
  * Private implementation details for the StreamSourceRTPImpl class.
  */
 class StreamSourceRTPImplPriv
@@ -72,6 +121,11 @@ public:
     RtpStreamSourceStateItemPtr mSourceStateItem;
 
     /**
+     * Timer used for sending RTCP reports.
+     */
+    IceUtil::TimerPtr mTimer;
+
+    /**
      * Lock that protects information contained.
      */
     boost::shared_mutex mLock;
@@ -86,7 +140,7 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const RTPSessionImplPtr& sessio
     pjmedia_rtp_session_init(&mIncomingSession, 0, 0);
     mSourceStateItem->mSessionId = sessionId;
     mSourceStateItem->key = IceUtil::generateUUID();
-};
+}
 
 /**
  * Constructor for the StreamSourceRTPImpl class.
@@ -429,6 +483,22 @@ void StreamSourceRTPImpl::setRemoteRtcpDetails(const std::string& address, Ice::
     {
         throw InvalidAddress();
     }
+
+    // Since the RTCP is going to a new destination initialize the session to a fresh state
+
+    // TODO - The clock rate and samples per frame will need to change, along with SSRC
+    pjmedia_rtcp_init(mImpl->mSession->getRtcpSession(), NULL, 8000, 160, 0);
+
+    // If RTCP is not already being sent start sending it
+    if (!mImpl->mTimer && (mImpl->mTimer = new IceUtil::Timer()))
+    {
+        RtcpTransmissionPtr transmission;
+
+        if ((transmission = new RtcpTransmission(mImpl->mSession)))
+        {
+            mImpl->mTimer->scheduleRepeated(transmission, IceUtil::Time::milliSeconds(PJMEDIA_RTCP_INTERVAL));
+        }
+    }
 }
 
 /**

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list