[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Aug 1 14:12:42 CDT 2011


branch "master" has been updated
       via  50b9944368b79ef6b59fa6a5e488277f744c2389 (commit)
      from  1ac8012e89cb5412937c803dbb6b7451d08b297d (commit)

Summary of changes:
 src/SipSession.cpp |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)


- Log -----------------------------------------------------------------
commit 50b9944368b79ef6b59fa6a5e488277f744c2389
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Aug 1 16:12:55 2011 -0300

    Add support for the rtcp attribute in SDP.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index b354d31..1e494f6 100755
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -32,12 +32,14 @@
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
 #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
+#include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
 #include "NATOptions.h"
 
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::System::NAT::V1;
 using namespace AsteriskSCF::Media::RTP::V1;
 using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::Media;
 using namespace AsteriskSCF::Media::SDP::V1;
 using namespace std;
 
@@ -1919,6 +1921,15 @@ pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::St
         media->desc.port = (pj_uint16_t) source->getLocalPort();
         media->desc.port_count = 1;
 
+        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
@@ -2114,6 +2125,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())
 	{
@@ -2158,7 +2171,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)
@@ -2236,6 +2249,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/release/sip.git



More information about the asterisk-scf-commits mailing list