Commit 94589243 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#4243] Associate callid to accountid for incoming calls

parent 036368da
......@@ -3925,18 +3925,22 @@ ManagerImpl::getAccount (const AccountID& accountID)
{
// In our definition,
// this is the "direct ip calls account"
/*
if (accountID == AccountNULL) {
_debug ("Returns the direct IP account");
_debug ("Manager: Returns the direct IP account");
return _directIpAccount;
}
*/
AccountMap::iterator iter = _accountMap.find (accountID);
if (iter == _accountMap.end()) {
return NULL;
if (iter != _accountMap.end()) {
_debug ("Manager: Found account %s", iter->first.c_str());
return iter->second;
}
return iter->second;
_debug ("Manager: Did not found account %s, returning IP2IP account");
return _directIpAccount;
}
AccountID ManagerImpl::getAccountIdFromNameAndServer (
......
......@@ -1271,21 +1271,6 @@ class ManagerImpl
bool removeCallConfig (const CallID& callID);
/** Associate a new CallID to a AccountID
* Protected by mutex
* @param callID the new CallID not in the list yet
* @param accountID the known accountID present in accountMap
* @return bool True if the new association is create
*/
bool associateCallToAccount (const CallID& callID, const AccountID& accountID);
/** Remove a CallID/AccountID association
* Protected by mutex
* @param callID the CallID to remove
* @return bool True if association is removed
*/
bool removeCallAccount (const CallID& callID);
/**
*Contains a list of account (sip, aix, etc) and their respective voiplink/calls */
AccountMap _accountMap;
......@@ -1325,6 +1310,21 @@ class ManagerImpl
public:
/** Associate a new CallID to a AccountID
* Protected by mutex
* @param callID the new CallID not in the list yet
* @param accountID the known accountID present in accountMap
* @return bool True if the new association is create
*/
bool associateCallToAccount (const CallID& callID, const AccountID& accountID);
/** Remove a CallID/AccountID association
* Protected by mutex
* @param callID the CallID to remove
* @return bool True if association is removed
*/
bool removeCallAccount (const CallID& callID);
/**
* Return a pointer to the instance of the mainbuffer
*/
......
......@@ -3703,6 +3703,8 @@ mod_on_rx_request (pjsip_rx_data *rdata)
// Get the account id of callee from username and server
account_id = Manager::instance().getAccountIdFromNameAndServer (userName, server);
_debug ("UserAgent: Account ID for this call, %s", account_id.c_str());
/* If we don't find any account to receive the call */
if (account_id == AccountNULL) {
_debug ("UserAgent: Username %s doesn't match any account, using IP2IP!",userName.c_str());
......@@ -3863,6 +3865,9 @@ mod_on_rx_request (pjsip_rx_data *rdata)
return false;
}
Manager::instance().associateCallToAccount (call->getCallId(), account_id);
std::string addrToUse, addrSdp ="0.0.0.0";
pjsip_tpselector *tp;
......@@ -3910,6 +3915,7 @@ mod_on_rx_request (pjsip_rx_data *rdata)
call->getLocalSDP()->set_ip_address (addrSdp);
try {
_debug ("UserAgent: Create RTP session for this call");
call->getAudioRtp()->initAudioRtpConfig (call);
call->getAudioRtp()->initAudioRtpSession (call);
} catch (...) {
......@@ -4551,8 +4557,15 @@ bool setCallAudioLocal (SIPCall* call, std::string localIP)
{
SIPAccount *account = NULL;
_debug ("UserAgent: Set local media information for this call");
if (call) {
account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (Manager::instance().getAccountFromCall (call->getCallId ())));
AccountID account_id = Manager::instance().getAccountFromCall (call->getCallId ());
account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id));
// Setting Audio
unsigned int callLocalAudioPort = RANDOM_LOCAL_PORT;
......@@ -4564,10 +4577,9 @@ bool setCallAudioLocal (SIPCall* call, std::string localIP)
//localIP = account->getPublishedAddress ();
}
_debug (" Setting local ip address: %s", localIP.c_str());
_debug (" Setting local audio port to: %d", callLocalAudioPort);
_debug (" Setting local audio port (external) to: %d", callLocalExternAudioPort);
_debug ("UserAgent: Setting local ip address: %s", localIP.c_str());
_debug ("UserAgent: Setting local audio port to: %d", callLocalAudioPort);
_debug ("UserAgent: Setting local audio port (external) to: %d", callLocalExternAudioPort);
// Set local audio port for SIPCall(id)
call->setLocalIp (localIP);
......@@ -4577,9 +4589,13 @@ bool setCallAudioLocal (SIPCall* call, std::string localIP)
call->getLocalSDP()->attribute_port_to_all_media (callLocalExternAudioPort);
return true;
}
} else {
_error ("UserAgent: Error: No call found while setting media information for this call");
return false;
return false;
}
}
std::string fetch_header_value (pjsip_msg *msg, std::string field)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment