diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index e903d15b016c2f98fcc30403168e38607b9fb833..6e6a1fc6c0b1939154ce82ec2b4a00a139aa9d18 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -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 ( diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 3c8be5e9eec5d50ddf3a640a3100618e12e74dce..72f3d27c75903a9f082eb641057864b8803b4423 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -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 */ diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 4691dfc74e9cb9318f5508e48d614561c8a8f1c7..0004594b629bd6d1c0c1afb8f4fc8b2512013169 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -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)