[#2519] Store default transport (IP2IP) into map

This commit is contained in:
Alexandre Savard
2009-12-16 15:07:37 -05:00
parent 5779603edd
commit 57f8745932
3 changed files with 35 additions and 19 deletions

View File

@ -419,6 +419,7 @@ std::string SIPAccount::getLoginName (void)
std::string SIPAccount::getTransportMapKey(void)
{
/*
std::string mapKey;
std::stringstream out;
@ -436,8 +437,12 @@ std::string SIPAccount::getTransportMapKey(void)
mapKey.append(localPort.c_str());
mapKey.append(publishedAddress.c_str());
mapKey.append(publishedPort.c_str());
*/
std::stringstream out;
out << getLocalPort();
std::string localPort = out.str();
return mapKey;
return localPort;
}

View File

@ -1799,10 +1799,11 @@ bool SIPVoIPLink::pjsip_init()
}
}
// Bind the newly created transport to the ip to ip account
// setAccountTransport
if(account && (errPjsip == PJ_SUCCESS)) {
addTransportToMap(account->getTransportMapKey(), account->getAccountTransport());
}
_debug ("pjsip_init -- listening on port %d\n", port);
// Create a TLS listener meant for Direct IP calls
// if the user did enabled it.
@ -1983,7 +1984,7 @@ bool SIPVoIPLink::acquireTransport(const AccountID& accountID) {
// Transport could not be created, account account already have one set.
// Most likely this is the transport we tried to create.
_debug("Transport (%s) already set for account, use it\n", account->getTransportMapKey().c_str());
_debug("Transport (%s) already set for this account, use it\n", account->getTransportMapKey().c_str());
return true;
}
@ -2075,21 +2076,9 @@ bool SIPVoIPLink::createSipTransport(AccountID id) {
// If Transport created succesfully, store it in the internal map
if(status == PJ_SUCCESS) {
SipTransportMap::iterator iter_transport;
iter_transport = _transportMap.find(account->getTransportMapKey());
addTransportToMap(account->getTransportMapKey(), account->getAccountTransport());
// old transport in transport map, erase it
if(iter_transport != _transportMap.end()){
_transportMap.erase(iter_transport);
}
std::string key = account->getTransportMapKey();
pjsip_transport* transport = account->getAccountTransport();
_debug("Storing the newly created transport in transport map using key %s\n", key.c_str());
_transportMap.insert(pair<std::string, pjsip_transport*>(key, transport));
return true;
return true;
}
else {
@ -2099,6 +2088,25 @@ bool SIPVoIPLink::createSipTransport(AccountID id) {
}
bool SIPVoIPLink::addTransportToMap(std::string key, pjsip_transport* transport)
{
SipTransportMap::iterator iter_transport;
iter_transport = _transportMap.find(key);
// old transport in transport map, erase it
if(iter_transport != _transportMap.end()){
_transportMap.erase(iter_transport);
}
_debug("Storing the newly created transport in transport map using key %s\n", key.c_str());
_transportMap.insert(pair<std::string, pjsip_transport*>(key, transport));
return true;
}
int SIPVoIPLink::createUDPServer (AccountID id)
{

View File

@ -376,6 +376,9 @@ class SIPVoIPLink : public VoIPLink
*/
bool createSipTransport(AccountID id);
bool addTransportToMap(std::string key, pjsip_transport* transport);
/** Create SIP UDP Listener */
int createUDPServer (AccountID = "");