From d3851711b1dac71f15864b2473f944fd582908f8 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 8 Aug 2012 13:14:06 +0200 Subject: [PATCH] Defer sending of answer of re-invite when there are some ICE losing candidate pairs. --- coreapi/linphonecall.c | 13 +++++++++++-- coreapi/linphonecore.c | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 62f296745..1b926071b 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1785,6 +1785,15 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ } break; } + } else if (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) { + SalMediaDescription *md; + linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session); + sal_call_set_local_media_description(call->op,call->localdesc); + sal_call_accept(call->op); + md=sal_call_get_final_media_description(call->op); + if (md && !sal_media_description_empty(md)) + linphone_core_update_streams (call->core,call,md); + linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)"); } } @@ -1841,7 +1850,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse evd->packet = NULL; if (lc->vtable.call_stats_updated) lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_VIDEO]); - } else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED)) { + } else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) || (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED)) { handle_ice_events(call, ev); } ortp_event_destroy(ev); @@ -1881,7 +1890,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse evd->packet = NULL; if (lc->vtable.call_stats_updated) lc->vtable.call_stats_updated(lc, call, &call->stats[LINPHONE_CALL_STATS_AUDIO]); - } else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED)) { + } else if ((evt == ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED) || (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) || (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED)) { handle_ice_events(call, ev); } ortp_event_destroy(ev); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index c69a42a06..00870f9b2 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2554,6 +2554,10 @@ int linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const update_local_media_description(lc,call); if (call->ice_session != NULL) { linphone_core_update_ice_from_remote_media_description(call, sal_call_get_remote_media_description(call->op)); + if (ice_session_nb_losing_pairs(call->ice_session) > 0) { + /* Defer the sending of the answer until there are no losing pairs left. */ + return 0; + } linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session); } sal_call_set_local_media_description(call->op,call->localdesc);