mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
[#2519] Store default transport (IP2IP) into map
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -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 = "");
|
||||
|
||||
|
Reference in New Issue
Block a user