[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "configuration-replication" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon May 23 09:57:44 CDT 2011


branch "configuration-replication" has been updated
       via  6e45f7d7d7ec3e8be48c53e0b581a946171b1c59 (commit)
       via  5e0a6d5fd9e409306d77ec066506a8de6afa6be4 (commit)
       via  98584e0f7b7db43e806c59053c5c3df397152521 (commit)
       via  8eb9a6461494bff1489e01b5541b569e7ecef3bc (commit)
       via  40f2cf7feed6d313e0f59a3188906960ea0eb84c (commit)
       via  958eccbe685be31e05b8651dd7bc3a72a3d11c99 (commit)
       via  a4f034dcfb22c527a701dc32eb24df15faf38622 (commit)
      from  5c696c9882975b9feb11c4ea2d535378e77bcd04 (commit)

Summary of changes:
 config/Sip.config                     |    2 ++
 config/SipConfigurator.py             |    3 +++
 local-slice/SipConfigurationIf.ice    |    5 +++++
 local-slice/SipStateReplicationIf.ice |    1 -
 src/PJSipManager.cpp                  |    8 +++++++-
 src/SipConfiguration.cpp              |   16 +++++++++++-----
 src/SipEndpoint.cpp                   |    9 +++++++--
 src/SipEndpoint.h                     |    4 ++++
 src/SipSession.cpp                    |   33 +++++++++++++++++++++++----------
 src/SipSession.h                      |    5 +++--
 src/SipSessionManagerApp.cpp          |    4 +++-
 src/SipStateReplicatorApp.cpp         |   15 +++++++++++----
 12 files changed, 79 insertions(+), 26 deletions(-)


- Log -----------------------------------------------------------------
commit 6e45f7d7d7ec3e8be48c53e0b581a946171b1c59
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon May 23 11:59:33 2011 -0300

    Use configuration replicator interface.

diff --git a/local-slice/SipStateReplicationIf.ice b/local-slice/SipStateReplicationIf.ice
index 28f7c1e..aae6991 100644
--- a/local-slice/SipStateReplicationIf.ice
+++ b/local-slice/SipStateReplicationIf.ice
@@ -59,7 +59,6 @@ module V1
       void removeState(Ice::StringSeq items);
       idempotent SipStateItemSeq getState(Ice::StringSeq itemKeys);
       idempotent SipStateItemSeq getAllState();
-      void registerConfigurationService(AsteriskSCF::System::Configuration::V1::ConfigurationService *service);
    };
    class SipDialogStateItem extends SipStateItem
    {
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 1db81f4..5500578 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -462,7 +462,9 @@ void SipSessionManager::registerWithStateReplicator()
 	    mLocalAdapter->createDirectProxy(mCommunicator->stringToIdentity(ConfigurationServiceId));
 	ConfigurationServicePrx configurationServicePrx = ConfigurationServicePrx::uncheckedCast(
 	    configurationServiceObjectPrx);
-	mStateReplicator->registerConfigurationService(configurationServicePrx);
+	ConfigurationReplicatorPrx configurationReplicator = ConfigurationReplicatorPrx::checkedCast(
+	    mStateReplicator.initialize(), ReplicatorFacet);
+	configurationReplicator->registerConfigurationService(configurationServicePrx);
     }
 
     if (mCommunicator->getProperties()->getPropertyWithDefault("Sip.StateReplicatorListener", "no") == "yes")
diff --git a/src/SipStateReplicatorApp.cpp b/src/SipStateReplicatorApp.cpp
index 09eb741..a93b109 100644
--- a/src/SipStateReplicatorApp.cpp
+++ b/src/SipStateReplicatorApp.cpp
@@ -26,6 +26,7 @@
 #include <AsteriskSCF/logger.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
 #include <AsteriskSCF/CollocatedIceStorm/CollocatedIceStorm.h>
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
 
 #include <SipIf.h>
 
@@ -39,6 +40,7 @@ using namespace AsteriskSCF::System::Component::V1;
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::SipSessionManager;
 using namespace AsteriskSCF::CollocatedIceStorm;
+using namespace AsteriskSCF::System::Configuration::V1;
 
 namespace
 {
@@ -54,6 +56,7 @@ public:
         mComponentService = 0;
         mAdapter = 0;
         mStateReplicator = 0;
+	mConfigurationReplicator = 0;
     };
     virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
     virtual void stop();
@@ -70,6 +73,7 @@ private:
     ConfiguredIceLoggerPtr mIceLogger;
     ComponentServicePtr mComponentService;
     SipStateReplicatorIPtr mStateReplicator;
+    ConfigurationReplicatorPtr mConfigurationReplicator;
     CollocatedIceStormPtr mIceStorm;
     Ice::ObjectPrx mConfigurationPublisher;
     Discovery::V1::ServiceManagementPrx mConfigurationManagement;
@@ -146,16 +150,16 @@ private:
 
 typedef IceUtil::Handle<SipConfigurationCompare> SipConfigurationComparePtr;
 
-class SipStateReplicatorConfigI : public SipStateReplicatorI
+class ConfigurationReplicatorI : public ConfigurationReplicator
 {
 public:
-    SipStateReplicatorConfigI(const IceStorm::TopicPrx& topic) : mConfigurationReplicationTopic(topic) { };
+    ConfigurationReplicatorI(const IceStorm::TopicPrx& topic) : mConfigurationReplicationTopic(topic) { };
     void registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx&, const Ice::Current&);
 private:
     IceStorm::TopicPrx mConfigurationReplicationTopic;
 };
 
-void SipStateReplicatorConfigI::registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx& service, const Ice::Current&)
+void ConfigurationReplicatorI::registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx& service, const Ice::Current&)
 {
     if (mConfigurationReplicationTopic)
     {
@@ -319,8 +323,11 @@ void SipStateReplicatorService::initialize(const std::string& appName, const Ice
     // Create and publish our ComponentService interface support.
     mComponentService = new ComponentServiceImpl(*this);
     mAdapter->add(mComponentService, ic->stringToIdentity(ComponentServiceId));
-    mStateReplicator = new SipStateReplicatorConfigI(topic);
+    mStateReplicator = new SipStateReplicatorI();
     mAdapter->add(mStateReplicator, ic->stringToIdentity(ServiceDiscoveryId));
+    mConfigurationReplicator = new ConfigurationReplicatorI(topic);
+    mAdapter->addFacet(mConfigurationReplicator, ic->stringToIdentity(ServiceDiscoveryId),
+	ReplicatorFacet);
 
     mAdapter->activate();
 }

commit 5e0a6d5fd9e409306d77ec066506a8de6afa6be4
Merge: 5c696c9 98584e0
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon May 23 11:45:35 2011 -0300

    Merge branch 'master' into configuration-replication


commit 98584e0f7b7db43e806c59053c5c3df397152521
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu May 19 19:07:35 2011 -0300

    The act of pushing configuration for an endpoint is what ends up creating it.

diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 1b40dad..055f7b1 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -1045,11 +1045,7 @@ private:
         SipEndpointPtr endpoint = mEndpointFactory->findByName(group->name);
         if (!endpoint)
         {
-            //
-            // XXX - something better to do than just ignore?
-            // Should never happen, and we can't do anything else without really messing things up.
-            //
-            return 0;
+	    endpoint = mEndpointFactory->createEndpoint(group->name);
         }
         return boost::shared_ptr<EndpointConfigHelper>(
             new EndpointConfigHelper(endpoint, mEndpointFactory, mRoutingServiceLocatorRegistry, mRoutingId))->getVisitor();

commit 8eb9a6461494bff1489e01b5541b569e7ecef3bc
Merge: 958eccb 40f2cf7
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu May 19 13:59:10 2011 -0300

    Merge branch 'rtp-ipv6'


commit 40f2cf7feed6d313e0f59a3188906960ea0eb84c
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue May 17 14:02:32 2011 -0300

    Add support for RTP over 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..4b820f2 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)
@@ -161,6 +164,10 @@ class SipSectionVisitors(Configurator.SectionVisitors):
         elif config.get(section, 'type') == 'endpoint':
             self.visit_endpoint(config, section)
 
+# In order to do service locator based lookup we need to pass in a params object
+serviceLocatorParams = AsteriskSCF.SIP.V1.SipConfigurationParams()
+serviceLocatorParams.category = AsteriskSCF.SIP.V1.ConfigurationDiscoveryCategory
+
 # Make a configurator application and let it run
-app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors())
+app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors(), None, serviceLocatorParams)
 sys.exit(app.main(sys.argv))
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 bfd715d..1b40dad 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -194,6 +194,11 @@ class EndpointConfigHelper : public boost::enable_shared_from_this<EndpointConfi
             mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateTarget, mConfig, target));
         };
 
+	void visitSipRTPMediaServiceItem(const SipRTPMediaServiceItemPtr& service)
+	{
+	    mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateMediaService, mConfig, service));
+	};
+
     private:
 
         UpdateCommandList mUpdates;;
@@ -258,6 +263,11 @@ public:
         mEndpoint->setTargetAddress(target->host, target->port);
     }
 
+    void updateMediaService(const SipRTPMediaServiceItemPtr& service)
+    {
+	mEndpoint->setRTPOverIPv6(service->requireIPv6);
+    }
+
     void updated(const UpdateCommandList& updates)
     {
         //
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index e066cd4..c130685 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -149,6 +149,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);
@@ -265,7 +270,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();
 }
@@ -273,7 +278,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 1eb9680..2f5e011 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -138,6 +138,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;
 };
 
 /**
@@ -254,6 +257,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 2b36d1f..6f06e3f 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,16 +626,18 @@ 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));
-    AsteriskSCF::Media::RTP::V1::RTPSessionPrx session = factory->allocate(formats);
+    AsteriskSCF::Media::RTP::V1::RTPSessionPrx session = factory->allocate(params);
     mImplPriv->mRTPSessions.push_back(session);
 
     // Create a local copy of the sources, this won't get changed by the RTP session so it's all good
diff --git a/src/SipSession.h b/src/SipSession.h
index 643e70e..e18c480 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.

commit 958eccbe685be31e05b8651dd7bc3a72a3d11c99
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue May 17 14:02:32 2011 -0300

    Update configurator so it can use the service locator functionality.

diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
index d04f2ac..9d7ed3e 100755
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@ -161,6 +161,10 @@ class SipSectionVisitors(Configurator.SectionVisitors):
         elif config.get(section, 'type') == 'endpoint':
             self.visit_endpoint(config, section)
 
+# In order to do service locator based lookup we need to pass in a params object
+serviceLocatorParams = AsteriskSCF.SIP.V1.SipConfigurationParams()
+serviceLocatorParams.category = AsteriskSCF.SIP.V1.ConfigurationDiscoveryCategory
+
 # Make a configurator application and let it run
-app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors())
+app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors(), None, serviceLocatorParams)
 sys.exit(app.main(sys.argv))

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list