From bbf8b49e03b46a9ad6b1e7f32e6d48b0836aa6e3 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 20 Nov 2017 15:47:00 +0100 Subject: [PATCH] Deactivate ICE when it takes too long to conclude. --- coreapi/linphonecall.c | 12 +++++++++++- coreapi/misc.c | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 94cbde82f..36b829b2c 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -4710,6 +4710,15 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ } else if (evt == ORTP_EVENT_ICE_RESTART_NEEDED) { ice_session_restart(call->ice_session, IR_Controlling); linphone_call_update(call, call->current_params); + } else if (evt == ORTP_EVENT_ICE_DEACTIVATION_NEEDED) { + if (ice_session_role(call->ice_session) == IR_Controlling) { + ice_session_destroy(call->ice_session); + call->ice_session = NULL; + LinphoneCallParams *params = linphone_core_create_call_params(call->core, call); + params->internal_call_update = TRUE; + linphone_call_update(call, params); + linphone_call_params_unref(params); + } } } @@ -4875,7 +4884,8 @@ void linphone_call_handle_stream_events(LinphoneCall *call, int stream_index){ else if (stream_index == call->main_video_stream_index) propagate_encryption_changed(call); }else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) - || (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) || (evt == ORTP_EVENT_ICE_RESTART_NEEDED)) { + || (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) || (evt == ORTP_EVENT_ICE_RESTART_NEEDED) + || (evt == ORTP_EVENT_ICE_DEACTIVATION_NEEDED)) { if (ms) handle_ice_events(call, ev); } else if (evt==ORTP_EVENT_TELEPHONE_EVENT){ linphone_core_dtmf_received(call,evd->info.telephone_event); diff --git a/coreapi/misc.c b/coreapi/misc.c index 61a59a4c8..3586cd6c7 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -698,7 +698,12 @@ void linphone_call_update_ice_state_in_call_stats(LinphoneCall *call) { IceCheckList *text_check_list; IceSessionState session_state; - if (call->ice_session == NULL) return; + if (call->ice_session == NULL) { + call->audio_stats->ice_state = LinphoneIceStateNotActivated; + call->video_stats->ice_state = LinphoneIceStateNotActivated; + call->text_stats->ice_state = LinphoneIceStateNotActivated; + return; + } audio_check_list = ice_session_check_list(call->ice_session, call->main_audio_stream_index); video_check_list = ice_session_check_list(call->ice_session, call->main_video_stream_index); text_check_list = ice_session_check_list(call->ice_session, call->main_text_stream_index);