* #23661: daemon: removed callAccountMap

This commit is contained in:
Tristan Matthews
2013-06-03 14:09:48 -04:00
parent 938c60829f
commit 638727aced
13 changed files with 88 additions and 115 deletions

View File

@ -34,7 +34,7 @@
#include "history/historyitem.h" #include "history/historyitem.h"
#include "scoped_lock.h" #include "scoped_lock.h"
Call::Call(const std::string& id, Call::CallType type) Call::Call(const std::string& id, Call::CallType type, const std::string &accountID)
: callMutex_() : callMutex_()
, localIPAddress_("") , localIPAddress_("")
, localAudioPort_(0) , localAudioPort_(0)
@ -42,6 +42,7 @@ Call::Call(const std::string& id, Call::CallType type)
, id_(id) , id_(id)
, confID_() , confID_()
, type_(type) , type_(type)
, accountID_(accountID)
, connectionState_(Call::DISCONNECTED) , connectionState_(Call::DISCONNECTED)
, callState_(Call::INACTIVE) , callState_(Call::INACTIVE)
, isIPToIP_(false) , isIPToIP_(false)
@ -203,7 +204,7 @@ std::map<std::string, std::string> Call::createHistoryEntry() const
using sfl::HistoryItem; using sfl::HistoryItem;
std::map<std::string, std::string> result; std::map<std::string, std::string> result;
result[HistoryItem::ACCOUNT_ID_KEY] = Manager::instance().getAccountFromCall(id_); result[HistoryItem::ACCOUNT_ID_KEY] = accountID_;
result[HistoryItem::CONFID_KEY] = confID_; result[HistoryItem::CONFID_KEY] = confID_;
result[HistoryItem::CALLID_KEY] = id_; result[HistoryItem::CALLID_KEY] = id_;
result[HistoryItem::DISPLAY_NAME_KEY] = displayName_; result[HistoryItem::DISPLAY_NAME_KEY] = displayName_;
@ -230,6 +231,7 @@ Call::getDetails()
details["CALL_STATE"] = getStateStr(); details["CALL_STATE"] = getStateStr();
details["CONF_ID"] = confID_; details["CONF_ID"] = confID_;
details["TIMESTAMP_START"] = timestamp_to_string(timestamp_start_); details["TIMESTAMP_START"] = timestamp_to_string(timestamp_start_);
details["ACCOUNTID"] = accountID_;
return details; return details;
} }

View File

@ -72,7 +72,7 @@ class Call : public Recordable {
* @param id Unique identifier of the call * @param id Unique identifier of the call
* @param type set definitely this call as incoming/outgoing * @param type set definitely this call as incoming/outgoing
*/ */
Call(const std::string& id, Call::CallType type); Call(const std::string& id, Call::CallType type, const std::string &accountID);
virtual ~Call(); virtual ~Call();
/** /**
@ -95,6 +95,10 @@ class Call : public Recordable {
confID_ = id; confID_ = id;
} }
std::string getAccountId() const {
return accountID_;
}
CallType getCallType() const { CallType getCallType() const {
return type_; return type_;
} }
@ -251,6 +255,9 @@ class Call : public Recordable {
/** Type of the call */ /** Type of the call */
CallType type_; CallType type_;
/** Associate account ID */
std::string accountID_;
/** Disconnected/Progressing/Trying/Ringing/Connected */ /** Disconnected/Progressing/Trying/Ringing/Connected */
ConnectionState connectionState_; ConnectionState connectionState_;

View File

@ -60,7 +60,7 @@ int codecToASTFormat(int c)
} }
} }
IAXCall::IAXCall(const std::string& id, Call::CallType type) : Call(id, type), IAXCall::IAXCall(const std::string& id, Call::CallType type, const std::string &account_id) : Call(id, type, account_id),
format(0), session(NULL) format(0), session(NULL)
{} {}

View File

@ -47,7 +47,7 @@ class IAXCall : public Call {
* @param id The unique ID of the call * @param id The unique ID of the call
* @param type The type of the call * @param type The type of the call
*/ */
IAXCall(const std::string& id, Call::CallType type); IAXCall(const std::string& id, Call::CallType type, const std::string &account_id);
/** /**
* @return int The bitwise list of supported formats * @return int The bitwise list of supported formats

View File

@ -96,6 +96,13 @@ IAXVoIPLink::init()
} }
} }
bool
IAXVoIPLink::hasCalls()
{
sfl::ScopedLock m(iaxCallMapMutex_);
return not iaxCallMap_.empty();
}
void void
IAXVoIPLink::terminate() IAXVoIPLink::terminate()
{ {
@ -271,9 +278,9 @@ IAXVoIPLink::sendUnregister(Account *a)
} }
Call* Call*
IAXVoIPLink::newOutgoingCall(const std::string& id, const std::string& toUrl) IAXVoIPLink::newOutgoingCall(const std::string& id, const std::string& toUrl, const std::string &account_id)
{ {
IAXCall* call = new IAXCall(id, Call::OUTGOING); IAXCall* call = new IAXCall(id, Call::OUTGOING, account_id);
call->setPeerNumber(toUrl); call->setPeerNumber(toUrl);
call->initRecFilename(toUrl); call->initRecFilename(toUrl);
@ -696,7 +703,7 @@ void IAXVoIPLink::iaxHandlePrecallEvent(iax_event* event)
case IAX_EVENT_CONNECT: case IAX_EVENT_CONNECT:
id = Manager::instance().getNewCallID(); id = Manager::instance().getNewCallID();
call = new IAXCall(id, Call::INCOMING); call = new IAXCall(id, Call::INCOMING, accountID_);
call->session = event->session; call->session = event->session;
call->setConnectionState(Call::PROGRESSING); call->setConnectionState(Call::PROGRESSING);

View File

@ -72,6 +72,8 @@ class IAXVoIPLink : public VoIPLink {
*/ */
virtual bool getEvent(); virtual bool getEvent();
bool hasCalls();
/** /**
* Return the internal account map for all VOIP links * Return the internal account map for all VOIP links
*/ */
@ -110,7 +112,7 @@ class IAXVoIPLink : public VoIPLink {
* @param toUrl The address to call * @param toUrl The address to call
* @return Call* A pointer on the call * @return Call* A pointer on the call
*/ */
virtual Call* newOutgoingCall(const std::string& id, const std::string& toUrl); virtual Call* newOutgoingCall(const std::string& id, const std::string& toUrl, const std::string &account_id);
/** /**
* Answer a call * Answer a call

View File

@ -91,8 +91,7 @@ ManagerImpl::ManagerImpl() :
currentCallId_(), currentCallMutex_(), audiodriver_(0), dtmfKey_(), currentCallId_(), currentCallMutex_(), audiodriver_(0), dtmfKey_(),
toneMutex_(), telephoneTone_(), audiofile_(), audioLayerMutex_(), toneMutex_(), telephoneTone_(), audiofile_(), audioLayerMutex_(),
waitingCall_(), waitingCallMutex_(), nbIncomingWaitingCall_(0), path_(), waitingCall_(), waitingCallMutex_(), nbIncomingWaitingCall_(0), path_(),
callAccountMap_(), callAccountMapMutex_(), IPToIPMap_(), IPToIPMap_(), mainBuffer_(), conferenceMap_(), history_(), finished_(false)
mainBuffer_(), conferenceMap_(), history_(), finished_(false)
{ {
pthread_mutex_init(&currentCallMutex_, NULL); pthread_mutex_init(&currentCallMutex_, NULL);
pthread_mutex_init(&toneMutex_, NULL); pthread_mutex_init(&toneMutex_, NULL);
@ -294,14 +293,12 @@ bool ManagerImpl::outgoingCall(const std::string& account_id,
use_account_id = account_id; use_account_id = account_id;
} }
associateCallToAccount(call_id, use_account_id);
try { try {
Call *call = getAccountLink(account_id)->newOutgoingCall(call_id, to_cleaned); Call *call = getAccountLink(account_id)->newOutgoingCall(call_id, to_cleaned, use_account_id);
// try to reverse match the peer name using the cache // try to reverse match the peer name using the cache
if (call->getDisplayName().empty()) { if (call->getDisplayName().empty()) {
const std::string pseudo_contact_name(HistoryNameCache::getInstance().getNameFromHistory(call->getPeerNumber(), getAccountFromCall(call_id))); const std::string pseudo_contact_name(HistoryNameCache::getInstance().getNameFromHistory(call->getPeerNumber(), call->getAccountId()));
if (not pseudo_contact_name.empty()) if (not pseudo_contact_name.empty())
call->setDisplayName(pseudo_contact_name); call->setDisplayName(pseudo_contact_name);
} }
@ -359,8 +356,7 @@ bool ManagerImpl::answerCall(const std::string& call_id)
} }
try { try {
const std::string account_id = getAccountFromCall(call_id); VoIPLink *link = getAccountLink(call->getAccountId());
VoIPLink *link = getAccountLink(account_id);
if (link) if (link)
link->answer(call); link->answer(call);
} catch (const std::runtime_error &e) { } catch (const std::runtime_error &e) {
@ -438,13 +434,11 @@ bool ManagerImpl::hangupCall(const std::string& callId)
return false; return false;
} }
} else { } else {
std::string accountId(getAccountFromCall(callId));
Call * call = getCallFromCallID(callId); Call * call = getCallFromCallID(callId);
if (call) { if (call) {
history_.addCall(call, preferences.getHistoryLimit()); history_.addCall(call, preferences.getHistoryLimit());
VoIPLink *link = getAccountLink(accountId); VoIPLink *link = getAccountLink(call->getAccountId());
link->hangup(callId, 0); link->hangup(callId, 0);
removeCallAccount(callId);
saveHistory(); saveHistory();
} }
} }
@ -551,12 +545,10 @@ bool ManagerImpl::offHoldCall(const std::string& callId)
SIPVoIPLink::instance()->offhold(callId); SIPVoIPLink::instance()->offhold(callId);
else { else {
/* Classic call, attached to an account */ /* Classic call, attached to an account */
const std::string accountId(getAccountFromCall(callId));
DEBUG("Setting offhold, Account %s, callid %s", accountId.c_str(), callId.c_str());
Call * call = getCallFromCallID(callId); Call * call = getCallFromCallID(callId);
if (call) if (call)
getAccountLink(accountId)->offhold(callId); getAccountLink(call->getAccountId())->offhold(callId);
else else
result = false; result = false;
} }
@ -656,8 +648,6 @@ bool ManagerImpl::refuseCall(const std::string& id)
return false; return false;
getAccountLink(accountid)->refuse(id); getAccountLink(accountid)->refuse(id);
removeCallAccount(id);
} }
removeWaitingCall(id); removeWaitingCall(id);
@ -1458,8 +1448,6 @@ void ManagerImpl::incomingCall(Call &call, const std::string& accountId)
stopTone(); stopTone();
const std::string callID(call.getCallId()); const std::string callID(call.getCallId());
associateCallToAccount(callID, accountId);
if (accountId.empty()) if (accountId.empty())
setIPToIPForCall(callID, true); setIPToIPForCall(callID, true);
else { else {
@ -1673,7 +1661,6 @@ void ManagerImpl::peerHungupCall(const std::string& call_id)
dbus_.getCallManager()->callStateChanged(call_id, "HUNGUP"); dbus_.getCallManager()->callStateChanged(call_id, "HUNGUP");
removeWaitingCall(call_id); removeWaitingCall(call_id);
removeCallAccount(call_id);
removeStream(call_id); removeStream(call_id);
if (getCallList().empty()) { if (getCallList().empty()) {
@ -1694,7 +1681,6 @@ void ManagerImpl::callBusy(const std::string& id)
unsetCurrentCall(); unsetCurrentCall();
} }
removeCallAccount(id);
removeWaitingCall(id); removeWaitingCall(id);
} }
@ -1714,7 +1700,6 @@ void ManagerImpl::callFailure(const std::string& call_id)
removeParticipant(call_id); removeParticipant(call_id);
} }
removeCallAccount(call_id);
removeWaitingCall(call_id); removeWaitingCall(call_id);
} }
@ -2524,42 +2509,21 @@ void ManagerImpl::removeAccount(const std::string& accountID)
dbus_.getConfigurationManager()->accountsChanged(); dbus_.getConfigurationManager()->accountsChanged();
} }
// ACCOUNT handling
void ManagerImpl::associateCallToAccount(const std::string& callID,
const std::string& accountID)
{
sfl::ScopedLock m(callAccountMapMutex_);
callAccountMap_[callID] = accountID;
DEBUG("Associate Call %s with Account %s", callID.data(), accountID.data());
}
std::string ManagerImpl::getAccountFromCall(const std::string& callID) std::string ManagerImpl::getAccountFromCall(const std::string& callID)
{ {
sfl::ScopedLock m(callAccountMapMutex_); Call *call = getCallFromCallID(callID);
CallAccountMap::iterator iter = callAccountMap_.find(callID); if (call)
return call->getAccountId();
return (iter == callAccountMap_.end()) ? "" : iter->second; else
} return "";
void ManagerImpl::removeCallAccount(const std::string& callID)
{
sfl::ScopedLock m(callAccountMapMutex_);
callAccountMap_.erase(callID);
// Stop audio layer if there is no call anymore
if (callAccountMap_.empty()) {
sfl::ScopedLock lock(audioLayerMutex_);
if (audiodriver_)
audiodriver_->stopStream();
}
} }
// FIXME: get rid of this, there's no guarantee that
// a Call will still exist after this has been called.
bool ManagerImpl::isValidCall(const std::string& callID) bool ManagerImpl::isValidCall(const std::string& callID)
{ {
sfl::ScopedLock m(callAccountMapMutex_); Call *call = getCallFromCallID(callID);
return callAccountMap_.find(callID) != callAccountMap_.end(); return call != 0;
} }
std::string ManagerImpl::getNewCallID() std::string ManagerImpl::getNewCallID()
@ -2837,16 +2801,11 @@ std::map<std::string, std::string> ManagerImpl::getCallDetails(const std::string
// To achieve that, we need to get the voip link attached to the call // To achieve that, we need to get the voip link attached to the call
// But to achieve that, we need to get the account the call was made with // But to achieve that, we need to get the account the call was made with
// So first we fetch the account
const std::string accountid(getAccountFromCall(callID));
// Then the VoIP link this account is linked with (IAX2 or SIP) // Then the VoIP link this account is linked with (IAX2 or SIP)
Call *call = getCallFromCallID(callID); Call *call = getCallFromCallID(callID);
if (call) { if (call) {
std::map<std::string, std::string> details(call->getDetails()); return call->getDetails();
details["ACCOUNTID"] = accountid;
return details;
} else { } else {
ERROR("Call is NULL"); ERROR("Call is NULL");
// FIXME: is this even useful? // FIXME: is this even useful?
@ -2868,10 +2827,11 @@ void vectorFromMapKeys(const M &m, V &v)
} }
} }
// FIXME: get call ids from voiplinks
std::vector<std::string> ManagerImpl::getCallList() const std::vector<std::string> ManagerImpl::getCallList() const
{ {
std::vector<std::string> v; std::vector<std::string> v;
vectorFromMapKeys(callAccountMap_, v); // vectorFromMapKeys(callAccountMap_, v);
return v; return v;
} }

View File

@ -84,10 +84,6 @@ class Account;
class SIPAccount; class SIPAccount;
class IAXAccount; class IAXAccount;
/** Define a type for a std::string to std::string Map inside ManagerImpl */
typedef std::map<std::string, std::string> CallAccountMap;
/** To send multiple string */ /** To send multiple string */
typedef std::list<std::string> TokenList; typedef std::list<std::string> TokenList;
@ -359,8 +355,7 @@ class ManagerImpl {
void stopTone(); void stopTone();
/** /**
* When receiving a new incoming call, add it to the callaccount map * Handle incoming call and notify user
* and notify user
* @param call A call pointer * @param call A call pointer
* @param accountId an account id * @param accountId an account id
*/ */
@ -926,12 +921,6 @@ class ManagerImpl {
DNSService *DNSService_; DNSService *DNSService_;
#endif #endif
/** Map to associate a CallID to the good account */
CallAccountMap callAccountMap_;
/** Mutex to lock the call account map (main thread + voiplink thread) */
pthread_mutex_t callAccountMapMutex_;
std::map<std::string, bool> IPToIPMap_; std::map<std::string, bool> IPToIPMap_;
bool isIPToIP(const std::string& callID) const; bool isIPToIP(const std::string& callID) const;
@ -958,14 +947,6 @@ class ManagerImpl {
void setIPToIPForCall(const std::string& callID, bool IPToIP); void setIPToIPForCall(const std::string& callID, bool IPToIP);
/** Associate a new std::string to a std::string
* 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
*/
void associateCallToAccount(const std::string& callID, const std::string& accountID);
/** /**
* Test if call is a valid call, i.e. have been created and stored in * Test if call is a valid call, i.e. have been created and stored in
* call-account map * call-account map

View File

@ -45,7 +45,8 @@ namespace {
} }
SIPCall::SIPCall(const std::string& id, Call::CallType type, SIPCall::SIPCall(const std::string& id, Call::CallType type,
pj_caching_pool *caching_pool) : Call(id, type) pj_caching_pool *caching_pool, const std::string &account_id) :
Call(id, type, account_id)
, inv(NULL) , inv(NULL)
, audiortp_(this) , audiortp_(this)
#ifdef SFL_VIDEO #ifdef SFL_VIDEO

View File

@ -63,7 +63,8 @@ class SIPCall : public Call {
* @param type The type of the call. Could be Incoming * @param type The type of the call. Could be Incoming
* Outgoing * Outgoing
*/ */
SIPCall(const std::string& id, Call::CallType type, pj_caching_pool *caching_pool); SIPCall(const std::string& id, Call::CallType type,
pj_caching_pool *caching_pool, const std::string &account_id);
/** /**
* Destructor * Destructor

View File

@ -271,8 +271,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
Manager::instance().hookPreference.runHook(rdata->msg_info.msg); Manager::instance().hookPreference.runHook(rdata->msg_info.msg);
SIPCall* call = new SIPCall(Manager::instance().getNewCallID(), Call::INCOMING, cp_); SIPCall* call = new SIPCall(Manager::instance().getNewCallID(), Call::INCOMING, cp_, account_id);
Manager::instance().associateCallToAccount(call->getCallId(), account_id);
// May use the published address as well // May use the published address as well
std::string addrToUse = SipTransport::getInterfaceAddrFromName(account->getLocalInterface()); std::string addrToUse = SipTransport::getInterfaceAddrFromName(account->getLocalInterface());
@ -786,7 +785,7 @@ bool isValidIpAddress(const std::string &address)
} }
Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toUrl) Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toUrl, const std::string &account_id)
{ {
DEBUG("New outgoing call to %s", toUrl.c_str()); DEBUG("New outgoing call to %s", toUrl.c_str());
std::string toCpy = toUrl; std::string toCpy = toUrl;
@ -797,10 +796,9 @@ Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toU
Manager::instance().setIPToIPForCall(id, IPToIP); Manager::instance().setIPToIPForCall(id, IPToIP);
if (IPToIP) { if (IPToIP) {
Manager::instance().associateCallToAccount(id, SIPAccount::IP2IP_PROFILE);
return SIPNewIpToIpCall(id, toUrl); return SIPNewIpToIpCall(id, toUrl);
} else { } else {
return newRegisteredAccountCall(id, toUrl); return newRegisteredAccountCall(id, toUrl, account_id);
} }
} }
@ -813,7 +811,7 @@ Call *SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to
if (!account) if (!account)
throw VoipLinkException("Could not retrieve default account for IP2IP call"); throw VoipLinkException("Could not retrieve default account for IP2IP call");
SIPCall *call = new SIPCall(id, Call::OUTGOING, cp_); SIPCall *call = new SIPCall(id, Call::OUTGOING, cp_, SIPAccount::IP2IP_PROFILE);
call->setIPToIP(true); call->setIPToIP(true);
call->initRecFilename(to); call->initRecFilename(to);
@ -854,16 +852,16 @@ Call *SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to
return call; return call;
} }
Call *SIPVoIPLink::newRegisteredAccountCall(const std::string& id, const std::string& toUrl) Call *SIPVoIPLink::newRegisteredAccountCall(const std::string& id, const std::string& toUrl, const std::string &account_id)
{ {
DEBUG("UserAgent: New registered account call to %s", toUrl.c_str()); DEBUG("UserAgent: New registered account call to %s", toUrl.c_str());
SIPAccount *account = Manager::instance().getSipAccount(Manager::instance().getAccountFromCall(id)); SIPAccount *account = Manager::instance().getSipAccount(account_id);
if (account == NULL) // TODO: We should investigate how we could get rid of this error and create a IP2IP call instead if (account == NULL) // TODO: We should investigate how we could get rid of this error and create a IP2IP call instead
throw VoipLinkException("Could not get account for this call"); throw VoipLinkException("Could not get account for this call");
SIPCall* call = new SIPCall(id, Call::OUTGOING, cp_); SIPCall* call = new SIPCall(id, Call::OUTGOING, cp_, account->getAccountID());
// If toUri is not a well formatted sip URI, use account information to process it // If toUri is not a well formatted sip URI, use account information to process it
std::string toUri; std::string toUri;
@ -954,7 +952,7 @@ SIPVoIPLink::hangup(const std::string& id, int reason)
if (!call) if (!call)
return; return;
std::string account_id(Manager::instance().getAccountFromCall(id)); std::string account_id(call->getAccountId());
SIPAccount *account = Manager::instance().getSipAccount(account_id); SIPAccount *account = Manager::instance().getSipAccount(account_id);
if (account == NULL) if (account == NULL)
@ -1176,6 +1174,13 @@ void SIPVoIPLink::removeSipCall(const std::string& id)
sipCallMap_.erase(id); sipCallMap_.erase(id);
} }
bool
SIPVoIPLink::hasCalls()
{
sfl::ScopedLock m(sipCallMapMutex_);
return not sipCallMap_.empty();
}
SIPCall* SIPCall*
SIPVoIPLink::getSipCall(const std::string& id) SIPVoIPLink::getSipCall(const std::string& id)
{ {
@ -1257,7 +1262,7 @@ SIPVoIPLink::transfer(const std::string& id, const std::string& to)
call->stopRecording(); call->stopRecording();
std::string account_id(Manager::instance().getAccountFromCall(id)); std::string account_id(call->getAccountId());
SIPAccount *account = Manager::instance().getSipAccount(account_id); SIPAccount *account = Manager::instance().getSipAccount(account_id);
if (account == NULL) if (account == NULL)
@ -1449,14 +1454,15 @@ SIPVoIPLink::requestKeyframe(const std::string &callID)
void void
SIPVoIPLink::carryingDTMFdigits(const std::string& id, char code) SIPVoIPLink::carryingDTMFdigits(const std::string& id, char code)
{ {
std::string accountID(Manager::instance().getAccountFromCall(id)); SIPCall *call = getSipCall(id);
if (!call)
return;
const std::string accountID(call->getAccountId());
SIPAccount *account = Manager::instance().getSipAccount(accountID); SIPAccount *account = Manager::instance().getSipAccount(accountID);
if (!account) if (!account)
return; return;
SIPCall *call = getSipCall(id);
if (!call)
return;
dtmfSend(*call, code, account->getDtmfType()); dtmfSend(*call, code, account->getDtmfType());
} }
@ -1464,8 +1470,8 @@ SIPVoIPLink::carryingDTMFdigits(const std::string& id, char code)
bool bool
SIPVoIPLink::SIPStartCall(SIPCall *call) SIPVoIPLink::SIPStartCall(SIPCall *call)
{ {
std::string id(Manager::instance().getAccountFromCall(call->getCallId())); std::string account_id(call->getAccountId());
SIPAccount *account = Manager::instance().getSipAccount(id); SIPAccount *account = Manager::instance().getSipAccount(account_id);
if (account == NULL) { if (account == NULL) {
ERROR("Account is NULL in SIPStartCall"); ERROR("Account is NULL in SIPStartCall");
@ -1614,7 +1620,7 @@ void invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *ev)
// After we sent or received a ACK - The connection is established // After we sent or received a ACK - The connection is established
link->SIPCallAnswered(call, ev->body.tsx_state.src.rdata); link->SIPCallAnswered(call, ev->body.tsx_state.src.rdata);
} else if (inv->state == PJSIP_INV_STATE_DISCONNECTED) { } else if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
std::string accId(Manager::instance().getAccountFromCall(call->getCallId())); std::string accId(call->getAccountId());
switch (inv->cause) { switch (inv->cause) {
// The call terminates normally - BYE / CANCEL // The call terminates normally - BYE / CANCEL
@ -1651,7 +1657,7 @@ void sdp_request_offer_cb(pjsip_inv_session *inv, const pjmedia_sdp_session *off
if (!call) if (!call)
return; return;
std::string accId(Manager::instance().getAccountFromCall(call->getCallId())); std::string accId(call->getAccountId());
SIPAccount *account = Manager::instance().getSipAccount(accId); SIPAccount *account = Manager::instance().getSipAccount(accId);
if (!account) if (!account)
return; return;
@ -1669,7 +1675,7 @@ void sdp_create_offer_cb(pjsip_inv_session *inv, pjmedia_sdp_session **p_offer)
SIPCall *call = static_cast<SIPCall*>(inv->mod_data[mod_ua_.id]); SIPCall *call = static_cast<SIPCall*>(inv->mod_data[mod_ua_.id]);
if (!call) if (!call)
return; return;
std::string accountid(Manager::instance().getAccountFromCall(call->getCallId())); std::string accountid(call->getAccountId());
SIPAccount *account = Manager::instance().getSipAccount(accountid); SIPAccount *account = Manager::instance().getSipAccount(accountid);
if (!account) if (!account)
@ -1813,7 +1819,7 @@ void sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
call->getAudioRtp().stop(); call->getAudioRtp().stop();
call->getAudioRtp().setSrtpEnabled(false); call->getAudioRtp().setSrtpEnabled(false);
std::string accountID = Manager::instance().getAccountFromCall(call->getCallId()); const std::string accountID = call->getAccountId();
SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID); SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID);
if (sipaccount and sipaccount->getSrtpFallback()) if (sipaccount and sipaccount->getSrtpFallback())
@ -2141,7 +2147,8 @@ void onCallTransfered(pjsip_inv_session *inv, pjsip_rx_data *rdata)
} }
try { try {
SIPVoIPLink::instance()->newOutgoingCall(Manager::instance().getNewCallID(), std::string(refer_to->hvalue.ptr, refer_to->hvalue.slen)); SIPVoIPLink::instance()->newOutgoingCall(Manager::instance().getNewCallID(),
std::string(refer_to->hvalue.ptr, refer_to->hvalue.slen), currentCall->getAccountId());
Manager::instance().hangupCall(currentCall->getCallId()); Manager::instance().hangupCall(currentCall->getCallId());
} catch (const VoipLinkException &e) { } catch (const VoipLinkException &e) {
ERROR("%s", e.what()); ERROR("%s", e.what());
@ -2230,7 +2237,7 @@ namespace {
void setCallMediaLocal(SIPCall* call, const std::string &localIP) void setCallMediaLocal(SIPCall* call, const std::string &localIP)
{ {
std::string account_id(Manager::instance().getAccountFromCall(call->getCallId())); std::string account_id(call->getAccountId());
SIPAccount *account = Manager::instance().getSipAccount(account_id); SIPAccount *account = Manager::instance().getSipAccount(account_id);
if (!account) if (!account)
return; return;

View File

@ -128,7 +128,7 @@ class SIPVoIPLink : public VoIPLink {
* @param toUrl The Sip address of the recipient of the call * @param toUrl The Sip address of the recipient of the call
* @return Call* The current call * @return Call* The current call
*/ */
virtual Call* newOutgoingCall(const std::string& id, const std::string& toUrl); virtual Call* newOutgoingCall(const std::string& id, const std::string& toUrl, const std::string &account_id);
/** /**
* Start a new SIP call using the IP2IP profile * Start a new SIP call using the IP2IP profile
@ -142,7 +142,7 @@ class SIPVoIPLink : public VoIPLink {
* @param The call id * @param The call id
* @param The target sip uri * @param The target sip uri
*/ */
Call *newRegisteredAccountCall(const std::string& id, const std::string& toUrl); Call *newRegisteredAccountCall(const std::string& id, const std::string& toUrl, const std::string &account_id);
/** /**
* Answer the call * Answer the call
@ -268,6 +268,8 @@ class SIPVoIPLink : public VoIPLink {
#endif #endif
void clearSipCallMap(); void clearSipCallMap();
void addSipCall(SIPCall* call); void addSipCall(SIPCall* call);
bool hasCalls();
SIPCall* getSipCall(const std::string& id); SIPCall* getSipCall(const std::string& id);
SIPCall* tryGetSipCall(const std::string& id); SIPCall* tryGetSipCall(const std::string& id);
void removeSipCall(const std::string &id); void removeSipCall(const std::string &id);

View File

@ -80,7 +80,8 @@ class VoIPLink {
* @return Call* The current call * @return Call* The current call
*/ */
virtual Call* newOutgoingCall(const std::string &id, virtual Call* newOutgoingCall(const std::string &id,
const std::string &toUrl) = 0; const std::string &toUrl,
const std::string &account_id) = 0;
/** /**
* Answer the call * Answer the call
@ -149,6 +150,8 @@ class VoIPLink {
virtual std::string getCurrentVideoCodecName(Call *call) const = 0; virtual std::string getCurrentVideoCodecName(Call *call) const = 0;
virtual std::string getCurrentAudioCodecNames(Call *call) const = 0; virtual std::string getCurrentAudioCodecNames(Call *call) const = 0;
virtual bool hasCalls() = 0;
/** /**
* Send a message to a call identified by its callid * Send a message to a call identified by its callid
* *