From 1ed0fa066e2c2c2502c3f45de742df5b78f75aef Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 23 Jul 2012 10:52:53 +0200 Subject: [PATCH] Re-Invite when ICE processing is finished successfully. --- coreapi/linphonecall.c | 4 +++- coreapi/sal_eXosip2_sdp.c | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index a3e5a5781..1ca85fa53 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1438,7 +1438,9 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut /*also reflect the change if the "wished" params, in order to avoid to propose SAVP or video again * further in the call, for example during pause,resume, conferencing reINVITEs*/ linphone_call_fix_call_parameters(call); - if (sal_op_get_ice_session(call->op) != NULL) ice_session_pair_candidates(sal_op_get_ice_session(call->op)); + if ((sal_op_get_ice_session(call->op) != NULL) && (ice_session_state(sal_op_get_ice_session(call->op)) != IS_Completed)) { + ice_session_pair_candidates(sal_op_get_ice_session(call->op)); + } goto end; end: diff --git a/coreapi/sal_eXosip2_sdp.c b/coreapi/sal_eXosip2_sdp.c index 17e1428e1..c7e80d4ca 100644 --- a/coreapi/sal_eXosip2_sdp.c +++ b/coreapi/sal_eXosip2_sdp.c @@ -145,7 +145,13 @@ static sdp_message_t *create_generic_sdp(const SalMediaDescription *desc, const osip_strdup (desc->addr)); sdp_message_s_name_set (local, osip_strdup ("Talk")); if ((ice_session != NULL) && (ice_session_check_list(ice_session, 0) != NULL)) { - const IceCandidate *candidate = ice_check_list_default_local_candidate(ice_session_check_list(ice_session, 0)); + const IceCandidate *candidate = NULL; + if (ice_session_state(ice_session) == IS_Completed) { + candidate = ice_check_list_nominated_valid_local_candidate(ice_session_check_list(ice_session, 0)); + } + else { + candidate = ice_check_list_default_local_candidate(ice_session_check_list(ice_session, 0)); + } if (candidate != NULL) { addr=candidate->taddr.ip; } @@ -167,10 +173,20 @@ static sdp_message_t *create_generic_sdp(const SalMediaDescription *desc, const int_2char(desc->bandwidth)); if ((ice_session != NULL) && (ice_session_check_list(ice_session, 0) != NULL)) { char buffer[512]; - snprintf(buffer ,sizeof(buffer), "%s", ice_session_local_pwd(ice_session)); - sdp_message_a_attribute_add(local, -1, osip_strdup("ice-pwd"), osip_strdup(buffer)); - snprintf(buffer ,sizeof(buffer), "%s", ice_session_local_ufrag(ice_session)); - sdp_message_a_attribute_add(local, -1, osip_strdup("ice-ufrag"), osip_strdup(buffer)); + switch (ice_session_state(ice_session)) { + case IS_Running: + case IS_Stopped: + snprintf(buffer, sizeof(buffer), "%s", ice_session_local_pwd(ice_session)); + sdp_message_a_attribute_add(local, -1, osip_strdup("ice-pwd"), osip_strdup(buffer)); + snprintf(buffer, sizeof(buffer), "%s", ice_session_local_ufrag(ice_session)); + sdp_message_a_attribute_add(local, -1, osip_strdup("ice-ufrag"), osip_strdup(buffer)); + break; + case IS_Completed: + sdp_message_a_attribute_add(local, -1, osip_strdup("nortpproxy"), osip_strdup("yes")); + break; + default: + break; + } } return local; @@ -251,7 +267,12 @@ static void add_line(sdp_message_t *msg, int lineno, const SalStreamDescription addr=desc->addr; port=desc->port; if (ice_cl != NULL) { - const IceCandidate *candidate = ice_check_list_default_local_candidate(ice_cl); + const IceCandidate *candidate = NULL; + if (ice_check_list_state(ice_cl) == ICL_Completed) { + candidate = ice_check_list_nominated_valid_local_candidate(ice_cl); + } else { + candidate = ice_check_list_default_local_candidate(ice_cl); + } if (candidate != NULL) { addr=candidate->taddr.ip; port=candidate->taddr.port; @@ -343,7 +364,9 @@ static void add_line(sdp_message_t *msg, int lineno, const SalStreamDescription break; } if (dir) sdp_message_a_attribute_add (msg, lineno, osip_strdup (dir),NULL); - add_ice_candidates(msg, lineno, desc, ice_cl); + if (ice_check_list_state(ice_cl) == ICL_Running) { + add_ice_candidates(msg, lineno, desc, ice_cl); + } }