[asterisk-scf-commits] asterisk-scf/release/media_rtp_pjmedia.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Aug 2 13:14:01 CDT 2011
branch "master" has been updated
via 2c243e51b0c9f544fd44ecc83d7cc69ac1e98ebf (commit)
from 879bde1285172d86e0e5e2873d52dd67681bfb12 (commit)
Summary of changes:
config/test_rtp_ice.config | 4 +-
src/ICETransport.cpp | 89 +++++++++++++++++++++++++++++---------------
test/TestRTPICE.cpp | 2 +-
3 files changed, 62 insertions(+), 33 deletions(-)
- Log -----------------------------------------------------------------
commit 2c243e51b0c9f544fd44ecc83d7cc69ac1e98ebf
Author: Brent Eagles <beagles at digium.com>
Date: Tue Aug 2 11:46:54 2011 -0230
Fixing some test suite issues that appeared after merges. It would
appear that something has changed with the startup sequence that
affected the availability of the ICE candidates. In any case, I
came across some other bugs so perhaps it is just as well.
diff --git a/config/test_rtp_ice.config b/config/test_rtp_ice.config
index adb150b..f672a04 100644
--- a/config/test_rtp_ice.config
+++ b/config/test_rtp_ice.config
@@ -69,6 +69,6 @@ ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
LocatorService.Proxy=LocatorService:tcp -p 4411
LoggerAdapter.Endpoints=default
-Ice.ThreadPool.Client.Size=4
-Ice.ThreadPool.Server.Size=4
+Ice.ThreadPool.Client.Size=6
+Ice.ThreadPool.Server.Size=6
Rtp.Standalone=true
diff --git a/src/ICETransport.cpp b/src/ICETransport.cpp
index b1ef798..9afc319 100644
--- a/src/ICETransport.cpp
+++ b/src/ICETransport.cpp
@@ -52,12 +52,15 @@ class ICEAgentImpl : public InteractiveConnectionAgent
{
public:
- ICEAgentImpl(const Ice::ObjectAdapterPtr& adapter, const Ice::Identity& id) :
+ ICEAgentImpl(const Ice::ObjectAdapterPtr& adapter, const Ice::Identity& id, const PJMediaEnvironmentPtr& env,
+ const PJMediaEndpointPtr& ep) :
mAdapter(adapter),
mId(id),
mShuttingDown(false),
mNATType(AsteriskSCF::System::NAT::V1::Unknown),
mRole(UndefinedRole),
+ mEnv(env),
+ mEndpoint(ep),
mTransport(0)
{
}
@@ -259,6 +262,13 @@ public:
if (iceInfo)
{
boost::unique_lock<boost::shared_mutex> lock(mLock);
+ if (mTransport)
+ {
+ //
+ // duplicate call.
+ //
+ return;
+ }
mTransport = transport;
if (iceInfo->role == PJ_ICE_SESS_ROLE_CONTROLLING)
{
@@ -269,17 +279,21 @@ public:
setRole(Controlled);
}
+ pjmedia_transport_media_create(mTransport, mEnv->memoryPool(), 0, 0, 0);
+
//
// Ok, so the pjmedia ice transport won't let use get at the actual
// candidate structures, so what we have to do is get the SDP from
// the transport and convert what we find there to our Ice structures.
//
- pjmedia_sdp_session sdpSession;
- pjmedia_transport_encode_sdp(mTransport, mEnv->memoryPool(), &sdpSession, 0, 0);
- for (size_t i = 0; i < sdpSession.media_count; ++i)
+ pjmedia_sdp_session* sdpSession;
+ unsigned streamCount = 1; // The 1 doesn't matter, this is just to initialize the basic structure.
+ pjmedia_endpt_create_sdp(mEndpoint->endpoint(), mEnv->memoryPool(), streamCount, &info.sock_info, &sdpSession);
+ pjmedia_transport_encode_sdp(mTransport, mEnv->memoryPool(), sdpSession, 0, 0);
+ for (size_t i = 0; i < sdpSession->media_count; ++i)
{
const string candidateName("candidate");
- pjmedia_sdp_media* media = sdpSession.media[i];
+ pjmedia_sdp_media* media = sdpSession->media[i];
ostringstream errorMessage;
for (size_t j = 0; j < media->attr_count; ++j)
{
@@ -408,13 +422,15 @@ public:
errorMessage << "Unable to parse ICE candidate value (rel-port) : " << value;
break;
}
+ candidateObj->mappedAddress = candidateObj->baseAddress;
+ candidateObj->mappedPort = candidateObj->basePort;
candidateObj->baseAddress = baseAddress;
candidateObj->basePort = basePort;
}
else
{
- candidateObj->baseAddress = candidateObj->mappedAddress;
- candidateObj->basePort = candidateObj->mappedPort;
+ candidateObj->mappedAddress = "";
+ candidateObj->mappedPort = 0;
}
//
// And we ignore the rest.
@@ -472,7 +488,6 @@ public:
void setRole(Role role)
{
- boost::unique_lock<boost::shared_mutex> lock(mLock);
mRole = role;
}
@@ -513,8 +528,13 @@ public:
bool connected;
ICETransportPtr transport;
ICEAgentImplPtr agent;
+
+ CallbackRecord() :
+ connected(false)
+ {
+ }
};
- typedef std::map<pjmedia_transport*, CallbackRecord> TransportMap;
+ typedef std::map<unsigned long long, CallbackRecord> TransportMap;
private:
static TransportMap mTransportMap;
@@ -536,31 +556,40 @@ boost::shared_mutex ICECallbackAdapter::mLock;
//
void ICECallbackAdapter::addEntry(pjmedia_transport* transport, const ICETransportPtr& callback)
{
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- TransportMap::iterator i = mTransportMap.find(transport);
- if (i != mTransportMap.end())
- {
- i->second.transport = callback;
- callback->onSetupComplete(transport, PJ_SUCCESS);
- }
- else
+ bool alreadyKnown = false;
{
- CallbackRecord r;
- r.connected = false;
- r.transport = callback;
- mTransportMap.insert(make_pair(transport, r));
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ TransportMap::iterator i = mTransportMap.find(reinterpret_cast<unsigned long long>(transport));
+ if (i != mTransportMap.end())
+ {
+ i->second.transport = callback;
+ alreadyKnown = true;
+ callback->onSetupComplete(transport, PJ_SUCCESS);
+
+ if (i->second.agent)
+ {
+ i->second.agent->onSetupComplete(transport, PJ_SUCCESS);
+ }
+ }
+ else
+ {
+ CallbackRecord r;
+ r.connected = false;
+ r.transport = callback;
+ mTransportMap.insert(make_pair(reinterpret_cast<unsigned long long>(transport), r));
+ }
}
}
void ICECallbackAdapter::addAgent(pjmedia_transport* transport, const ICEAgentImplPtr& agent)
{
boost::unique_lock<boost::shared_mutex> lock(mLock);
- TransportMap::iterator i = mTransportMap.find(transport);
+ TransportMap::iterator i = mTransportMap.find(reinterpret_cast<unsigned long long>(transport));
if (i != mTransportMap.end())
{
i->second.agent = agent;
- if (i->second.connected)
+ if (i->second.connected == true && i->second.transport.get() != 0)
{
try
{
@@ -582,7 +611,7 @@ void ICECallbackAdapter::addAgent(pjmedia_transport* transport, const ICEAgentIm
void ICECallbackAdapter::removeEntry(pjmedia_transport* t)
{
boost::unique_lock<boost::shared_mutex> lock(mLock);
- TransportMap::iterator i = mTransportMap.find(t);
+ TransportMap::iterator i = mTransportMap.find(reinterpret_cast<unsigned long long>(t));
if (i != mTransportMap.end())
{
if (i->second.agent)
@@ -606,12 +635,12 @@ void ICECallbackAdapter::onICEComplete(pjmedia_transport* transport, pj_ice_stra
//
{
boost::unique_lock<boost::shared_mutex> lock(mLock);
- TransportMap::iterator i = mTransportMap.find(transport);
+ TransportMap::iterator i = mTransportMap.find(reinterpret_cast<unsigned long long>(transport));
if (i == mTransportMap.end())
{
CallbackRecord r;
r.connected = success(status);
- mTransportMap.insert(make_pair(transport, r));
+ mTransportMap.insert(make_pair(reinterpret_cast<unsigned long long>(transport), r));
}
else
{
@@ -630,7 +659,7 @@ void ICECallbackAdapter::onICEComplete(pjmedia_transport* transport, pj_ice_stra
//
{
boost::unique_lock<boost::shared_mutex> lock(mLock);
- TransportMap::iterator i = mTransportMap.find(transport);
+ TransportMap::iterator i = mTransportMap.find(reinterpret_cast<unsigned long long>(transport));
if (i == mTransportMap.end())
{
assert(false);
@@ -704,7 +733,7 @@ void ICETransport::onSetupComplete(pjmedia_transport* transport, int status)
pj_memcpy(mLastKnownAddr.get(), &info.sock_info.rtp_addr_name, sizeof(pj_sockaddr));
}
}
- boost::unique_lock<boost::mutex> lock(mLock);
+ boost::lock_guard<boost::mutex> lock(mLock);
mLocalAddress = fromInfo(info);
mMonitor.notify_one();
}
@@ -731,7 +760,7 @@ AddressPtr ICETransport::remoteAddress()
void ICETransport::addFacets(const Ice::ObjectAdapterPtr& adapter, const Ice::Identity& id)
{
- ICEAgentImplPtr agent = new ICEAgentImpl(adapter, id);
+ ICEAgentImplPtr agent = new ICEAgentImpl(adapter, id, mConfig, mEndpoint);
ICECallbackAdapter::addAgent(mTransport, agent);
adapter->addFacet(agent, id, InteractiveConnectionAgentFacetName);
}
@@ -758,7 +787,7 @@ ICETransport::ICETransport(const PJMediaEndpointPtr& ep, const PJMediaEnvironmen
void ICETransport::start()
{
- pjmedia_transport* t;
+ pjmedia_transport* t = 0;
PJICECallbackPtr callback(new pjmedia_ice_cb);
callback->on_ice_complete = &ICECallbackAdapter::onICEComplete;
NATModulePtr natModule = NATModule::create(mConfig, mEndpoint);
diff --git a/test/TestRTPICE.cpp b/test/TestRTPICE.cpp
index 77393a9..03dd495 100644
--- a/test/TestRTPICE.cpp
+++ b/test/TestRTPICE.cpp
@@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(RtpSessionWithICEEnabled)
RTPICEConfigurationGroupPtr iceGroup = new RTPICEConfigurationGroup;
STUNServerItemPtr stunServerCfg = new STUNServerItem;
- stunServerCfg->address = "stun.ekiga.net";
+ stunServerCfg->address = "stun.xten.com";
stunServerCfg->port = 3478;
iceGroup->configurationItems[STUNServerItemName] = stunServerCfg;
-----------------------------------------------------------------------
--
asterisk-scf/release/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list