[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "rtp-ipv6" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue May 10 15:33:02 CDT 2011


branch "rtp-ipv6" has been updated
       via  8cdb3db1eba1c453b83e76f776256bf6f69815b1 (commit)
      from  b52922de0cc24d83dbfd8d4368ea1bab3d1ef868 (commit)

Summary of changes:
 config/Sip.config                  |    2 ++
 config/SipConfigurator.py          |    3 +++
 local-slice/SipConfigurationIf.ice |    5 +++++
 src/SipConfiguration.cpp           |    5 +++++
 src/SipEndpoint.cpp                |    9 +++++++--
 src/SipEndpoint.h                  |    4 ++++
 src/SipSession.cpp                 |   30 +++++++++++++++++++++---------
 src/SipSession.h                   |    5 +++--
 8 files changed, 50 insertions(+), 13 deletions(-)


- Log -----------------------------------------------------------------
commit 8cdb3db1eba1c453b83e76f776256bf6f69815b1
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue May 10 17:33:37 2011 -0300

    Add the ability to configure an endpoint to request an RTP media service that is using IPv6.

diff --git a/config/Sip.config b/config/Sip.config
index 048a751..e1f3937 100644
--- a/config/Sip.config
+++ b/config/Sip.config
@@ -75,3 +75,5 @@ targetport=5060
 #sourceport=
 # What directions calls are permitted in. Valid options are inbound, outbound, and both.
 direction=both
+# Whether to use IPv6 for media transport or not
+rtpoveripv6=no
diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
index d04f2ac..3d6c653 100755
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@ -111,6 +111,9 @@ class SipSectionVisitors(Configurator.SectionVisitors):
         transformer = AllowableCallDirectionTransformer(config)
         mapper.map('direction', AsteriskSCF.SIP.V1.SipAllowableCallDirectionItem(), 'callDirection', 'callDirection', transformer.get, None)
 
+        item = AsteriskSCF.SIP.V1.RTPMediaServiceItem()
+        mapper.map('rtpoveripv6', item, 'requireIPv6', 'mediaservice', config.getboolean, None)
+
         item = AsteriskSCF.SIP.V1.SipCryptoCertificateItem()
         mapper.map('certificateauthorityfile', item, 'certificateAuthority', 'cryptocert', config.get, None)
         mapper.map('certificatefile', item, 'certificate', 'cryptocert', config.get, None)
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 58cae24..14f700a 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -241,6 +241,11 @@ module V1
        * Name of the RTP media service to use
        */
       string mediaServiceName;
+
+      /**
+       * Whether to choose an IPv6 RTP media service or not
+       */
+      bool requireIPv6 = false;
    };
 
    /**
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 76fa596..96567fb 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -907,6 +907,11 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
 		{
 		    mEndpoint->setTargetAddress(target->host, target->port);
 		};
+
+		void visitSipRTPMediaServiceItem(const ::AsteriskSCF::SIP::V1::SipRTPMediaServiceItemPtr& service)
+		{
+		    mEndpoint->setRTPOverIPv6(service->requireIPv6);
+		};
             private:
 		SipEndpointPtr& mEndpoint;
             };
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 50d740e..b45272a 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -151,6 +151,11 @@ void SipEndpoint::setCallDirection(enum Direction direction)
     mImplPriv->mConfig.sessionConfig.callDirection = direction;
 }
 
+void SipEndpoint::setRTPOverIPv6(bool enabled)
+{
+    mImplPriv->mConfig.sessionConfig.rtpOverIPv6 = enabled;
+}
+
 void SipEndpoint::setConfiguration(const Ice::PropertyDict& props)
 {
     setTransportConfiguration(props);
@@ -267,7 +272,7 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
     }
 
     SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, listener, mImplPriv->mManager,
-            mImplPriv->mServiceLocator, mImplPriv->mReplica);
+	mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6);
     mImplPriv->mSessions.push_back(session);
     return session->getSessionProxy();
 }
@@ -275,7 +280,7 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
 AsteriskSCF::SipSessionManager::SipSessionPtr SipEndpoint::createSession(const std::string& destination)
 {
     SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, 0, mImplPriv->mManager,
-            mImplPriv->mServiceLocator, mImplPriv->mReplica);
+	mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6);
     mImplPriv->mSessions.push_back(session);
     return session;
 }
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index fc3aa21..6484e38 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -137,6 +137,9 @@ public:
     // The source IP address and port to use
     // when contacting this endpoint.
     std::string sourceAddress;
+    // Whether we are using IPv6 for media transport
+    // or not.
+    bool rtpOverIPv6;
 };
 
 /**
@@ -253,6 +256,7 @@ public:
     void setSourceAddress(std::string, int);
     void setTargetAddress(std::string, int);
     void setCallDirection(enum Direction);
+    void setRTPOverIPv6(bool);
 
 private:
     /**
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index d6ebd33..48e2081 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -173,7 +173,7 @@ public:
 SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPtr& endpoint,
         const std::string& destination,  const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
         PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica)
+    const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool ipv6)
     : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
 {
     if (listener != 0)
@@ -190,7 +190,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
 
     // Get an RTP session capable of handling the formats we are going to offer
     AsteriskSCF::Media::V1::FormatSeq formats;
-    requestRTPSessions(formats);
+    requestRTPSessions(formats, ipv6);
 }
 
 /**
@@ -560,22 +560,33 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
     pj_gettimeofday(&tv);
     sdp->origin.version = sdp->origin.id = (pj_uint32_t) (tv.sec + 2208988800UL);
     pj_strdup2(mImplPriv->mDialog->pool, &sdp->origin.net_type, "IN");
-    pj_strdup2(mImplPriv->mDialog->pool, &sdp->origin.addr_type, "IP4");
+
+    // Right now we only support a single stream so go and get it
+    AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx stream =
+        AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx::uncheckedCast(mImplPriv->mSources.front());
+
+    std::string address = stream->getLocalAddress();
+
+    if (address.find(":") != std::string::npos)
+    {
+	pj_strdup2(mImplPriv->mDialog->pool, &sdp->origin.addr_type, "IP6");
+    }
+    else
+    {
+	pj_strdup2(mImplPriv->mDialog->pool, &sdp->origin.addr_type, "IP4");
+    }
+
     sdp->origin.addr = *pj_gethostname();
     sdp->name = sdp->origin.user;
     sdp->time.start = 0;
     sdp->time.stop = 0;
     sdp->attr_count = 0;
 
-    // Right now we only support a single stream so go and get it
-    AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx stream =
-        AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx::uncheckedCast(mImplPriv->mSources.front());
-
     // Add connection details at the session level since we currently only support one media stream.
     sdp->conn = static_cast<pjmedia_sdp_conn*>(pj_pool_zalloc(mImplPriv->mDialog->pool, sizeof(pjmedia_sdp_conn)));
     sdp->conn->net_type = sdp->origin.net_type;
     sdp->conn->addr_type = sdp->origin.addr_type;
-    pj_strdup2(mImplPriv->mDialog->pool, &sdp->conn->addr, stream->getLocalAddress().c_str());
+    pj_strdup2(mImplPriv->mDialog->pool, &sdp->conn->addr, address.c_str());
 
     // Add a single media stream
     sdp->media_count = 1;
@@ -615,13 +626,14 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
 /**
  * Internal function called to request needed RTP sessions.
  */
-void SipSession::requestRTPSessions(AsteriskSCF::Media::V1::FormatSeq& formats)
+void SipSession::requestRTPSessions(AsteriskSCF::Media::V1::FormatSeq& formats, bool ipv6)
 {
     // TODO: This needs to be improved for multiple streams
     AsteriskSCF::Media::RTP::V1::RTPServiceLocatorParamsPtr params =
         new AsteriskSCF::Media::RTP::V1::RTPServiceLocatorParams();
     params->category = "rtp";
     params->formats = formats;
+    params->ipv6 = ipv6;
 
     AsteriskSCF::Media::RTP::V1::RTPMediaServicePrx factory =
         AsteriskSCF::Media::RTP::V1::RTPMediaServicePrx::uncheckedCast(mImplPriv->mServiceLocator->locate(params));
diff --git a/src/SipSession.h b/src/SipSession.h
index 3596260..aebba90 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -62,7 +62,8 @@ public:
     SipSession(const Ice::ObjectAdapterPtr&, const SipEndpointPtr&, const std::string&,
         const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, PJSipManager *manager,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica);
+        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
+	bool ipv6);
 
     SipSession(const Ice::ObjectAdapterPtr&, const SipEndpointPtr&, const std::string&, const Ice::Identity&,
         const Ice::Identity&, const AsteriskSCF::Media::V1::SessionPrx&,
@@ -133,7 +134,7 @@ public:
 
     AsteriskSCF::Media::V1::SessionPrx getHiddenMediaSession();
 private:
-    void requestRTPSessions(AsteriskSCF::Media::V1::FormatSeq& formats);
+    void requestRTPSessions(AsteriskSCF::Media::V1::FormatSeq& formats, bool ipv6);
 
     /**
      * Private implementation details.

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list