Commit 8006ef67 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#5211] Refactor call deletion

parent 8c7d9821
......@@ -71,11 +71,18 @@ AudioRecord::AudioRecord() : fp (NULL)
AudioRecord::~AudioRecord()
{
delete [] mixBuffer_;
delete [] micBuffer_;
delete [] spkBuffer_;
}
if (mixBuffer_) {
delete [] mixBuffer_;
}
if (micBuffer_) {
delete [] micBuffer_;
}
if (spkBuffer_) {
delete [] spkBuffer_;
}
}
void AudioRecord::setSndSamplingRate (int smplRate)
{
......
......@@ -191,7 +191,7 @@ void AudioRtpFactory::stop (void)
_info ("AudioRtpFactory: Stopping audio rtp session");
if (_rtpSession == NULL) {
_debugException ("AudioRtpFactory: Error: _rtpSession is null when trying to stop. Returning.");
_debugException ("AudioRtpFactory: Rtp session already deleted");
return;
}
......
......@@ -227,12 +227,12 @@ IAXVoIPLink::terminateIAXCall()
_callMap.clear();
}
void IAXVoIPLink::terminateOneCall (const CallID& id)
void IAXVoIPLink::terminateCall (const CallID& id)
{
IAXCall* call = getIAXCall (id);
if (call) {
_debug ("IAXVoIPLink::terminateOneCall()::the call is deleted, should close recording file ");
_debug ("IAXVoIPLink: Terminate call");
delete call;
call = 0;
}
......@@ -563,8 +563,6 @@ IAXVoIPLink::hangup (const CallID& id)
// audiolayer->stopStream();
}
terminateOneCall (id);
removeCall (id);
return true;
}
......@@ -590,8 +588,6 @@ IAXVoIPLink::peerHungup (const CallID& id)
// audiolayer->stopStream();
}
terminateOneCall (id);
removeCall (id);
return true;
}
......@@ -667,8 +663,6 @@ IAXVoIPLink::refuse (const CallID& id)
iax_reject (call->getSession(), (char*) reason.c_str());
_mutexIAX.leaveMutex();
// terminateOneCall(id);
removeCall (id);
return true;
......@@ -812,7 +806,6 @@ IAXVoIPLink::iaxHandleCallEvent (iax_event* event, IAXCall* call)
_mutexIAX.leaveMutex();
call->setSession(NULL);
audiolayer->stopStream();
terminateOneCall(id);
*/
removeCall (id);
break;
......@@ -829,7 +822,6 @@ IAXVoIPLink::iaxHandleCallEvent (iax_event* event, IAXCall* call)
call->setState (Call::Error);
Manager::instance().callFailure (id);
// terminateOneCall(id);
removeCall (id);
break;
......@@ -884,7 +876,6 @@ IAXVoIPLink::iaxHandleCallEvent (iax_event* event, IAXCall* call)
call->setConnectionState (Call::Connected);
call->setState (Call::Busy);
Manager::instance().callBusy (id);
// terminateOneCall(id);
removeCall (id);
break;
......
......@@ -89,7 +89,7 @@ class IAXVoIPLink : public VoIPLink
/**
* Terminate on call
*/
void terminateOneCall (const CallID& id);
void terminateCall (const CallID& id);
/**
* Send out registration
......
......@@ -84,7 +84,7 @@ ManagerImpl::ManagerImpl (void) :
_telephoneTone (NULL), _audiofile (NULL), _spkr_volume (0),
_mic_volume (0), _mutex(), _dbus (NULL), _waitingCall(),
_waitingCallMutex(), _nbIncomingWaitingCall (0), _path (""),
_exist (0), _setupLoaded (false), _callAccountMap(),
_setupLoaded (false), _callAccountMap(),
_callAccountMapMutex(), _callConfigMap(), _accountMap(),
_directIpAccount (NULL), _cleaner (NULL), _history (NULL)
{
......@@ -136,13 +136,7 @@ void ManagerImpl::init ()
_debug ("Manager: account map loaded");
initVolume();
if (_exist == 0) {
_warn ("Manager: Cannot create config file in your home directory");
}
initAudioDriver();
selectAudioDriver();
// Initialize the list of supported audio codecs
......
......@@ -1243,7 +1243,7 @@ class ManagerImpl
* Path of the ConfigFile
*/
std::string _path;
int _exist;
int _setupLoaded;
#ifdef USE_ZEROCONF
......
......@@ -260,7 +260,6 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event);
void xfer_svr_cb (pjsip_evsub *sub, pjsip_event *event);
void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata);
/*************************************************************************************************/
SIPVoIPLink* SIPVoIPLink::_instance = NULL;
......@@ -357,29 +356,7 @@ SIPVoIPLink::terminate()
}
void
SIPVoIPLink::terminateSIPCall()
{
ost::MutexLock m (_callMapMutex);
CallMap::iterator iter = _callMap.begin();
SIPCall *call;
while (iter != _callMap.end()) {
call = dynamic_cast<SIPCall*> (iter->second);
if (call) {
// terminate the sip call
delete call;
call = 0;
}
iter++;
}
_callMap.clear();
}
void
SIPVoIPLink::terminateOneCall (const CallID& id)
SIPVoIPLink::terminateCall (const CallID& id)
{
_debug ("UserAgent: Terminate call %s", id.c_str());
......@@ -910,8 +887,6 @@ SIPVoIPLink::answer (const CallID& id)
if (call->getAudioRtp())
call->getAudioRtp()->stop ();
terminateOneCall (call->getCallId());
removeCall (call->getCallId());
return false;
......@@ -959,8 +934,6 @@ SIPVoIPLink::hangup (const CallID& id)
call->getAudioRtp()->stop();
}
terminateOneCall (id);
removeCall (id);
return true;
......@@ -1005,9 +978,6 @@ SIPVoIPLink::peerHungup (const CallID& id)
call->getAudioRtp()->stop();
}
terminateOneCall (id);
removeCall (id);
return true;
......@@ -1025,7 +995,6 @@ SIPVoIPLink::cancel (const CallID& id)
return false;
}
terminateOneCall (id);
removeCall (id);
return true;
......@@ -1340,8 +1309,6 @@ SIPVoIPLink::refuse (const CallID& id)
removeCall (id);
terminateOneCall (id);
_debug ("UserAgent: Refuse call completed");
return true;
......@@ -1622,7 +1589,6 @@ SIPVoIPLink::SIPCallServerFailure (SIPCall *call)
_error ("UserAgent: Error: Server error!");
CallID id = call->getCallId();
Manager::instance().callFailure (id);
terminateOneCall (id);
removeCall (id);
if (call->getAudioRtp ()) {
......@@ -1650,7 +1616,6 @@ SIPVoIPLink::SIPCallClosed (SIPCall *call)
}
Manager::instance().peerHungupCall (id);
terminateOneCall (id);
removeCall (id);
}
......@@ -1669,8 +1634,6 @@ SIPVoIPLink::SIPCallReleased (SIPCall *call)
Manager::instance().callFailure (id);
terminateOneCall (id);
removeCall (id);
}
......
......@@ -223,15 +223,10 @@ class SIPVoIPLink : public VoIPLink
*/
bool dtmfOverRtp (SIPCall* call, char code);
/**
* Terminate every call not hangup | brutal | Protected by mutex
*/
void terminateSIPCall();
/**
* Terminate only one call
*/
void terminateOneCall (const CallID& id);
virtual void terminateCall (const CallID& id);
/**
* Send an outgoing call invite
......
......@@ -60,6 +60,11 @@ bool VoIPLink::removeCall (const CallID& id)
{
ost::MutexLock m (_callMapMutex);
_debug ("VoipLink: delete call");
terminateCall (id);
_debug ("VoipLink: removing call from list");
if (_callMap.erase (id)) {
return true;
}
......
......@@ -83,6 +83,12 @@ class VoIPLink
*/
virtual void terminate (void) = 0;
/**
* Virtual method
* Delete calls
*/
virtual void terminateCall (const CallID& id) = 0;
/**
* Virtual method
* Build and send account registration request
......
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