[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "rtcp" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Jul 12 07:01:45 CDT 2011


branch "rtcp" has been created
        at  8803c0100d1447c35a739a35a0770f6500297175 (commit)

- Log -----------------------------------------------------------------
commit 8803c0100d1447c35a739a35a0770f6500297175
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Jul 12 09:02:22 2011 -0300

    Add support for RFC 3605 and RTCP.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 642b191..48a3a6e 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -30,9 +30,11 @@
 #include <AsteriskSCF/logger.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+#include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
 #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
 
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Media;
 using namespace AsteriskSCF::Media::V1;
 using namespace AsteriskSCF::Media::RTP::V1;
 using namespace AsteriskSCF::Media::SDP::V1;
@@ -1672,6 +1674,16 @@ pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::St
         media->desc.port = (pj_uint16_t) source->getLocalPort();
         media->desc.port_count = 1;
 
+        // Add an RTCP attribute if the RTP session supports RTCP
+        RTCP::V1::RTCPSessionPrx rtcpSession;
+        if ((rtcpSession = RTCP::V1::RTCPSessionPrx::checkedCast(session, RTCP::V1::SessionFacet)))
+        {
+            pjmedia_sdp_attr *attr = allocate_from_pool<pjmedia_sdp_attr>(mImplPriv->mDialog->pool);
+            pj_strdup2(mImplPriv->mDialog->pool, &attr->name, "rtcp");
+            pj_strdup2(mImplPriv->mDialog->pool, &attr->value, boost::lexical_cast<std::string>(rtcpSession->getLocalPort()).c_str());
+            media->attr[media->attr_count++] = attr;
+        }
+
         PayloadMap payloads;
 
         // Add all of the formats to the SDP
@@ -1855,6 +1867,8 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
                                      pj_strlen(&offer->media[stream]->conn->addr));
         }
 
+        RTPSessionPrx session;
+
 	// If no sink and no source is present then this stream has no RTP session yet so find one
 	if (ourStream->sinks.empty() && ourStream->sources.empty())
 	{
@@ -1886,7 +1900,7 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
             }
 
             // Allocate a new RTP session to carry the media formats we have in common
-            RTPSessionPrx session = factory->allocate(params);
+            session = factory->allocate(params);
 
             // Double check to make sure they actually gave us a sesson back... they could have had a problem
             if (session == 0)
@@ -1964,6 +1978,31 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
             ourStream->state = SendAndReceive;
         }
 
+        // If the RTP session supports RTCP determine the connection details for it
+        RTCP::V1::RTCPSessionPrx rtcpSession;
+        if ((rtcpSession = RTCP::V1::RTCPSessionPrx::checkedCast(session, RTCP::V1::SessionFacet)))
+        {
+            // Assume RTCP is destined for the same address and the RTP port + 1 as it probably is
+            std::string rtcpConnection = connection;
+            int rtcpPort = offer->media[stream]->desc.port + 1;
+
+            pjmedia_sdp_attr *attr;
+            pjmedia_sdp_rtcp_attr rtcpAttr;
+
+            if ((attr = pjmedia_sdp_media_find_attr2(offer->media[stream], "rtcp", NULL)) &&
+                (pjmedia_sdp_attr_get_rtcp(attr, &rtcpAttr) == PJ_SUCCESS))
+            {
+                rtcpPort = rtcpAttr.port;
+
+                if (rtcpAttr.addr.slen)
+                {
+                    rtcpConnection = std::string(pj_strbuf(&rtcpAttr.addr), pj_strlen(&rtcpAttr.addr));
+                }
+            }
+
+            rtcpSession->setRemoteDetails(rtcpConnection, rtcpPort);
+        }
+
         // If the state changed we need to notify the controller if one is around
         if (oldState != ourStream->state)
         {

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list