Commit b689c4bc authored by François Grisez's avatar François Grisez
Browse files

Unref calls after removing them from a conference or after conference termination

parent 4655240e
......@@ -162,6 +162,7 @@ private:
void onFocusCallSateChanged(LinphoneCallState state);
void onPendingCallStateChanged(LinphoneCall *call, LinphoneCallState state);
void onTransferingCallStateChanged(LinphoneCall *transfered, LinphoneCallState newCallState);
static void callStateChangedCb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
static void transferStateChanged(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state);
......@@ -233,6 +234,14 @@ int Conference::removeParticipant(LinphoneCall *call) {
return 0;
}
int Conference::terminate() {
for(list<Participant>::iterator it = m_participants.begin(); it!=m_participants.end(); it++) {
it->getCall()->conf_ref = NULL;
}
m_participants.clear();
return 0;
}
int Conference::removeParticipant(const LinphoneAddress *uri) {
const Participant *participant = findParticipant(uri);
if(participant == NULL) return -1;
......@@ -291,7 +300,8 @@ LocalConference::LocalConference(LinphoneCore *core, const Conference::Params *p
}
LocalConference::~LocalConference() {
if(m_conf) terminate();
terminate();
ms_audio_conference_destroy(m_conf);
}
RtpProfile *LocalConference::sMakeDummyProfile(int samplerate){
......@@ -470,6 +480,9 @@ int LocalConference::terminate() {
linphone_core_terminate_call(m_core, call);
}
}
Conference::terminate();
return 0;
}
......@@ -563,11 +576,6 @@ void LocalConference::onCallTerminating(LinphoneCall *call) {
ms_audio_endpoint_destroy(m_recordEndpoint);
}
}
if (ms_audio_conference_get_size(m_conf)==0){
ms_audio_conference_destroy(m_conf);
m_core->conf_ctx = NULL;
delete this;
}
}
......@@ -610,7 +618,7 @@ int RemoteConference::addParticipant(LinphoneCall *call) {
m_focusCall = linphone_call_ref(linphone_core_invite_address_with_params(m_core, addr, params));
m_focusCall->conf_ref = (LinphoneConference *)this;
m_localParticipantStream = m_focusCall->audiostream;
m_pendingCalls = ms_list_append(m_pendingCalls, linphone_call_ref(call));
m_pendingCalls = ms_list_append(m_pendingCalls, call);
m_state = ConnectingToFocus;
LinphoneCallLog *callLog = linphone_call_get_call_log(m_focusCall);
callLog->was_conference = TRUE;
......@@ -621,12 +629,12 @@ int RemoteConference::addParticipant(LinphoneCall *call) {
case ConnectingToFocus:
Conference::addParticipant(call);
m_pendingCalls = ms_list_append(m_pendingCalls, linphone_call_ref(call));
m_pendingCalls = ms_list_append(m_pendingCalls, call);
return 0;
case ConnectedToFocus:
Conference::addParticipant(call);
m_transferingCalls = ms_list_append(m_transferingCalls, linphone_call_ref(call));
m_transferingCalls = ms_list_append(m_transferingCalls, call);
linphone_core_transfer_call(m_core, call, m_focusContact);
return 0;
......@@ -661,12 +669,12 @@ int RemoteConference::terminate() {
switch(m_state) {
case ConnectingToFocus:
case ConnectedToFocus:
Conference::removeParticipant(m_focusCall);
linphone_core_terminate_call(m_core, m_focusCall);
break;
default:
break;
}
Conference::terminate();
return 0;
}
......@@ -746,7 +754,6 @@ void RemoteConference::onFocusCallSateChanged(LinphoneCallState state) {
case LinphoneCallError:
case LinphoneCallEnd:
Conference::removeParticipant(m_focusCall);
m_state = NotConnectedToFocus;
linphone_call_unref(m_focusCall);
m_focusCall = NULL;
......@@ -755,8 +762,9 @@ void RemoteConference::onFocusCallSateChanged(LinphoneCallState state) {
ms_free(m_focusContact);
m_focusContact = NULL;
}
m_pendingCalls = ms_list_free_with_data(m_pendingCalls, (void (*)(void *))linphone_call_unref);
m_transferingCalls = ms_list_free_with_data(m_transferingCalls, (void (*)(void *))linphone_call_unref);
m_pendingCalls = ms_list_free(m_pendingCalls);
m_transferingCalls = ms_list_free(m_transferingCalls);
Conference::terminate();
break;
default: break;
......@@ -776,15 +784,27 @@ void RemoteConference::onPendingCallStateChanged(LinphoneCall *call, LinphoneCal
case LinphoneCallError:
case LinphoneCallEnd:
Conference::removeParticipant(call);
m_pendingCalls = ms_list_remove(m_pendingCalls, call);
linphone_call_unref(call);
Conference::removeParticipant(call);
break;
default: break;
}
}
void RemoteConference::onTransferingCallStateChanged(LinphoneCall* transfered, LinphoneCallState newCallState) {
switch (newCallState) {
case LinphoneCallConnected:
case LinphoneCallError:
m_transferingCalls = ms_list_remove(m_transferingCalls, transfered);
if(newCallState == LinphoneCallError) Conference::removeParticipant(transfered);
break;
default:
break;
}
}
void RemoteConference::callStateChangedCb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message) {
LinphoneCoreVTable *vtable = linphone_core_get_current_vtable(lc);
RemoteConference *conf = (RemoteConference *)linphone_core_v_table_get_user_data(vtable);
......@@ -799,16 +819,7 @@ void RemoteConference::transferStateChanged(LinphoneCore *lc, LinphoneCall *tran
LinphoneCoreVTable *vtable = linphone_core_get_current_vtable(lc);
RemoteConference *conf = (RemoteConference *)linphone_core_v_table_get_user_data(vtable);
if (ms_list_find(conf->m_transferingCalls, transfered)) {
switch (new_call_state) {
case LinphoneCallConnected:
case LinphoneCallError:
conf->m_transferingCalls = ms_list_remove(conf->m_transferingCalls, transfered);
linphone_call_unref(transfered);
break;
default:
break;
}
conf->onTransferingCallStateChanged(transfered, new_call_state);
}
}
......
Markdown is supported
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