Commit 02e20501 authored by Ghislain MARY's avatar Ghislain MARY

Improve conditions about STUN being activated or not when gathering ICE candidates.

parent 2f9760c6
......@@ -616,9 +616,6 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){
IceCheckList *video_cl;
IceCheckList *text_cl;
LinphoneNatPolicy *nat_policy = call->nat_policy;
const char *server = NULL;
if (nat_policy != NULL) server = linphone_nat_policy_get_stun_server(nat_policy);
if (call->ice_session == NULL) return -1;
audio_cl = ice_session_check_list(call->ice_session, call->main_audio_stream_index);
......@@ -626,7 +623,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){
text_cl = ice_session_check_list(call->ice_session, call->main_text_stream_index);
if ((audio_cl == NULL) && (video_cl == NULL) && (text_cl == NULL)) return -1;
if ((nat_policy != NULL) && (server != NULL) && (server[0] != '\0')) {
if ((nat_policy != NULL) && linphone_nat_policy_stun_server_activated(nat_policy)) {
ai=linphone_nat_policy_get_stun_server_addrinfo(nat_policy);
if (ai==NULL){
ms_warning("Fail to resolve STUN server for ICE gathering, continuing without stun.");
......@@ -658,9 +655,9 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){
} else {
linphone_core_add_local_ice_candidates(call, AF_INET, local_addr, audio_cl, video_cl, text_cl);
}
if ((ai != NULL) && (nat_policy != NULL)
&& (linphone_nat_policy_stun_enabled(nat_policy) || linphone_nat_policy_turn_enabled(nat_policy))) {
if ((ai != NULL) && (nat_policy != NULL) && linphone_nat_policy_stun_server_activated(nat_policy)) {
bool_t gathering_in_progress;
const char *server = linphone_nat_policy_get_stun_server(nat_policy);
ms_message("ICE: gathering candidate from [%s] using %s", server, linphone_nat_policy_turn_enabled(nat_policy) ? "TURN" : "STUN");
/* Gather local srflx candidates. */
ice_session_enable_turn(call->ice_session, linphone_nat_policy_turn_enabled(nat_policy));
......
......@@ -45,7 +45,7 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) {
}
}
static bool_t linphone_nat_policy_stun_server_activated(LinphoneNatPolicy *policy) {
bool_t linphone_nat_policy_stun_server_activated(LinphoneNatPolicy *policy) {
const char *server = linphone_nat_policy_get_stun_server(policy);
return (server != NULL) && (server[0] != '\0')
&& ((linphone_nat_policy_stun_enabled(policy) == TRUE) || (linphone_nat_policy_turn_enabled(policy) == TRUE));
......
......@@ -1371,6 +1371,7 @@ struct _LinphoneNatPolicy {
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneNatPolicy);
bool_t linphone_nat_policy_stun_server_activated(LinphoneNatPolicy *policy);
void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy);
struct _LinphoneImNotifPolicy {
......
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