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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 18 14:18:47 CDT 2011


branch "nat-traversal" has been updated
       via  81eeaf63ea0ea62d61d6a88da91a4b2d7dfd3826 (commit)
      from  c1c28bf4b3163bddbcc5a9bf7723f7597b76926e (commit)

Summary of changes:
 src/ICEConfiguration.cpp   |    2 +-
 src/NATConfig.cpp          |    7 ++++-
 src/PJLibConfiguration.cpp |    2 +-
 src/RTPICESession.cpp      |   55 +++++++++++++++++++++++++++++++++++++++++--
 src/SRTPConfiguration.cpp  |    2 +-
 5 files changed, 61 insertions(+), 7 deletions(-)


- Log -----------------------------------------------------------------
commit 81eeaf63ea0ea62d61d6a88da91a4b2d7dfd3826
Author: Brent Eagles <beagles at digium.com>
Date:   Wed May 18 16:47:28 2011 -0230

    Fix some bogus string code.
    Fixup replicant specific constructor to handle UDP based sessions correctly (still need to straighten
    out replication of other transport types).
    Fix some silly activation bugs.

diff --git a/src/ICEConfiguration.cpp b/src/ICEConfiguration.cpp
index 52cc51b..d59996c 100644
--- a/src/ICEConfiguration.cpp
+++ b/src/ICEConfiguration.cpp
@@ -24,7 +24,7 @@ ICEConfigurationPtr AsteriskSCF::PJMediaRTP::ICEConfiguration::create(const Ice:
         const string& propertyPrefix)
 {
     string prefix(propertyPrefix);
-    if (!prefix.empty() && *prefix.end() != '.')
+    if (!prefix.empty() && *(--prefix.end()) != '.')
     {
         prefix += '.';
     }
diff --git a/src/NATConfig.cpp b/src/NATConfig.cpp
index 75b35a6..cab495d 100644
--- a/src/NATConfig.cpp
+++ b/src/NATConfig.cpp
@@ -36,10 +36,15 @@ NATConfigPtr AsteriskSCF::PJMediaRTP::NATConfig::create(const Ice::PropertiesPtr
         const string& propertyPrefix)
 {
     string prefix(propertyPrefix);
-    if (!prefix.empty() && *prefix.end() != '.')
+    if (!prefix.empty() && *(--prefix.end()) != '.')
     {
         prefix += '.';
     }
+    Ice::Int isEnabled = props->getPropertyAsIntWithDefault(prefix + "Media.ICE.Enable", 0);
+    if (isEnabled == 0)
+    {
+        return NATConfigPtr(new NATConfig(AddressPtr(), AddressPtr(), false, false));
+    }
 
     string hostname = props->getProperty(prefix + "Media.STUN.Server");
     //
diff --git a/src/PJLibConfiguration.cpp b/src/PJLibConfiguration.cpp
index d8eeb49..ae25b7d 100644
--- a/src/PJLibConfiguration.cpp
+++ b/src/PJLibConfiguration.cpp
@@ -24,7 +24,7 @@ PJLibConfigurationPtr AsteriskSCF::PJMediaRTP::PJLibConfiguration::create(const
         const string& propertyPrefix)
 {
     string prefix(propertyPrefix);
-    if (!prefix.empty() && *prefix.end() != '.')
+    if (!prefix.empty() && *(--prefix.end()) != '.')
     {
         prefix  += '.';
     }
diff --git a/src/RTPICESession.cpp b/src/RTPICESession.cpp
index e7498f8..5aa4e74 100644
--- a/src/RTPICESession.cpp
+++ b/src/RTPICESession.cpp
@@ -78,6 +78,19 @@ public:
       const ReplicaPrx& replicaControl);
 
     /**
+     * Replicant version 
+     * TODO: this is a bit of a hack because the state replication doesn't take into
+     * account different transport configurations as yet. Also, afaict, the in the version this was
+     * built off of, the replicants don't seem to replicate once they become active. This needs to 
+     * be fixed.
+     **/
+    RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const FormatSeq& formats, 
+      const PJMediaEnvironmentPtr& environment,
+      const StateReplicatorPrx& replicator, const string& id, const Ice::PropertiesPtr& properties,
+      const ReplicaPrx& replicaControl,
+      unsigned port);
+
+    /**
      * Instantiate the object by way of normal session creation. 
      **/
     RTPSessionPrx activate(const string& id);
@@ -262,6 +275,41 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const Forma
     mSink.servant = new StreamSinkRTPImpl(sessionAdapter, mTransport, mId); 
 }
 
+RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const FormatSeq& formats, 
+  const PJMediaEnvironmentPtr& environment,
+  const StateReplicatorPrx& replicator, const string& id, const Ice::PropertiesPtr& properties, 
+  const ReplicaPrx& replicaControl, unsigned port) :
+    mAdapter(adapter),
+    mFormats(formats),
+    mMediaEnvironment(environment),
+    mEndpoint(PJMediaEndpoint::create(environment)),
+    mReplicator(replicator),
+    mReplicaControl(replicaControl),
+    mId(id),
+    mSessionStateItem(new RtpSessionStateItem)
+{
+#if 0 // XXX
+    if (environment->natConfig() && environment->natConfig()->isSTUNEnabled())
+    {
+        mTransport = ICETransport::create(mEndpoint);
+    }
+    else
+    {
+        mTransport = UDPTransport::create(mEndpoint, port);
+    }
+
+    if (environment->srtpConfig() && environment->srtpConfig()->isSRTPEnabled())
+    {
+        mTransport = SRTPTransport::create(mTransport, mEndpoint, properties);
+    }
+#endif
+    mTransport = UDPTransport::create(mEndpoint, port);
+    SessionAdapterPtr sessionAdapter(new SessionAdapterImpl(this));
+    mSource.servant = new StreamSourceRTPImpl(sessionAdapter, mTransport, mId);
+    mSink.servant = new StreamSinkRTPImpl(sessionAdapter, mTransport, mId); 
+}
+
+
 RTPSessionPrx RTPSessionImpl::activate(const string& id)
 {
     Ice::Identity sourceId(mAdapter->getCommunicator()->stringToIdentity(IceUtil::generateUUID()));
@@ -272,14 +320,15 @@ RTPSessionPrx RTPSessionImpl::activate(const string& id)
 RTPSessionPrx RTPSessionImpl::activate(const Ice::Identity& id,
         const Ice::Identity& sourceId, const Ice::Identity& sinkId)
 {
-    mSource.proxy = StreamSourcePrx::uncheckedCast(mAdapter->add(this, sourceId));
-    mSink.proxy = StreamSinkPrx::uncheckedCast(mAdapter->add(this, sourceId));
+    mSource.proxy = StreamSourcePrx::uncheckedCast(mAdapter->add(mSource.servant, sourceId));
+    mSink.proxy = StreamSinkPrx::uncheckedCast(mAdapter->add(mSink.servant, sinkId));
 
     mSessionStateItem->key = mSessionStateItem->mSessionId = mId;
     mSessionStateItem->mSessionIdentity = id;
     mSessionStateItem->mFormats = mFormats;
     mSessionStateItem->mSourceIdentity = sourceId;
     mSessionStateItem->mSinkIdentity = sinkId;
+    mSessionStateItem->mPort = mTransport->localAddress()->port();
     replicateState(mSessionStateItem, mSink.servant->getStateItem(), mSource.servant->getStateItem());
 
     return RTPSessionPrx::uncheckedCast(mAdapter->add(this, id));
@@ -514,7 +563,7 @@ ReplicationAdapterPtr AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::Obj
     RTPSessionImplPtr servant(new RTPSessionImpl(adapter, item->mFormats, environment,
                     AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>(), 
                     adapter->getCommunicator()->identityToString(item->mSessionIdentity), 
-                    adapter->getCommunicator()->getProperties(), 0));
+                    adapter->getCommunicator()->getProperties(), 0, item->mPort));
     servant->activate(item->mSessionIdentity, item-> mSourceIdentity, item->mSinkIdentity);
     servant->associatePayloadsImpl(item->mPayloadstoFormats);
     return ReplicationAdapterPtr(new ReplicationAdapterImpl(servant));
diff --git a/src/SRTPConfiguration.cpp b/src/SRTPConfiguration.cpp
index 6b8e5a7..a13e699 100644
--- a/src/SRTPConfiguration.cpp
+++ b/src/SRTPConfiguration.cpp
@@ -24,7 +24,7 @@ SRTPConfigurationPtr AsteriskSCF::PJMediaRTP::SRTPConfiguration::create(const Ic
         const string& propertyPrefix)
 {
     string prefix(propertyPrefix);
-    if (!prefix.empty() && *prefix.end() != '.')
+    if (!prefix.empty() && *(--prefix.end()) != '.')
     {
         prefix += '.';
     }

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list