From 884cc808098c8ec1ac0c1ed1eb3764a50c5b4069 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 18 Oct 2016 14:14:39 +0200 Subject: [PATCH] fix issue with video stream not started if ICE gathering is not performed. --- coreapi/linphonecall.c | 10 ++++++---- coreapi/misc.c | 5 +++++ tester/call_video_tester.c | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index e9cd52ecb..0d37317f9 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2370,11 +2370,13 @@ int linphone_call_prepare_ice(LinphoneCall *call, bool_t incoming_offer){ if (call->params->realtimetext_enabled && call->textstream->ms.state==MSStreamInitialized) { text_stream_prepare_text(call->textstream); } - - if ((err=linphone_core_gather_ice_candidates(call->core,call))<0) { - /* Ice candidates gathering failed, proceed with the call anyway. */ - linphone_call_delete_ice_session(call); + err = linphone_core_gather_ice_candidates(call->core,call); + if (err == 0) { + /* Ice candidates gathering wasn't started, but we can proceed with the call anyway. */ linphone_call_stop_media_streams_for_ice_gathering(call); + }else if (err == -1) { + linphone_call_stop_media_streams_for_ice_gathering(call); + linphone_call_delete_ice_session(call); } return err;/* 1= gathering in progress, wait; 0=proceed*/ } diff --git a/coreapi/misc.c b/coreapi/misc.c index 7b16e4f91..7613698ed 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -726,6 +726,11 @@ static const struct addrinfo * get_preferred_stun_server_addrinfo(const struct a return preferred_ai; } +/* Return values: + * 1 : STUN gathering is started + * 0 : no STUN gathering is started, but it's ok to proceed with ICE anyway (with local candidates only or because STUN gathering was already done before) + * -1: no gathering started and something went wrong with local candidates. There is no way to start the ICE session. + */ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ char local_addr[64]; const struct addrinfo *ai = NULL; diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index 03e631207..3c511c9c8 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -883,6 +883,9 @@ static void _call_with_ice_video(LinphoneVideoPolicy caller_policy, LinphoneVide linphone_core_set_video_policy(marie->lc, &callee_policy); linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + + linphone_core_manager_wait_for_stun_resolution(marie); + linphone_core_manager_wait_for_stun_resolution(pauline); /* This is to activate media relay on Flexisip server. * Indeed, we want to test ICE with relay candidates as well, even though