From 4b8a215735463944ab8d32fcc264c583f505f830 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 9 Aug 2012 15:45:22 +0200 Subject: [PATCH] Can now use ICE and ping OPTIONS in parallel. --- coreapi/callbacks.c | 3 ++- coreapi/linphonecall.c | 2 +- coreapi/linphonecore.c | 33 ++++++++++++++++++++++++++++----- coreapi/private.h | 2 ++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index ba278923..ab8f10f1 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -755,7 +755,8 @@ static void ping_reply(SalOp *op){ ms_message("ping reply !"); if (call){ if (call->state==LinphoneCallOutgoingInit){ - linphone_core_start_invite(call->core,call,NULL); + call->ping_replied=TRUE; + linphone_core_proceed_with_invite_if_ready(call->core,call,NULL); } } else diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 36ffc4f8..c5300bf9 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1732,7 +1732,7 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ break; case LinphoneCallOutgoingInit: linphone_call_stop_media_streams(call); - linphone_core_start_invite(call->core, call, NULL); + linphone_core_proceed_with_invite_if_ready(call->core, call, NULL); break; default: linphone_call_stop_media_streams(call); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 3b8a274b..9ba19020 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2105,6 +2105,27 @@ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphonePr return NULL; } +int linphone_core_proceed_with_invite_if_ready(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy){ + bool_t ice_ready = FALSE; + bool_t ping_ready = FALSE; + + if (call->ice_session != NULL) { + if (ice_session_candidates_gathered(call->ice_session)) ice_ready = TRUE; + } else { + ice_ready = TRUE; + } + if (call->ping_op != NULL) { + if (call->ping_replied == TRUE) ping_ready = TRUE; + } else { + ping_ready = TRUE; + } + + if ((ice_ready == TRUE) && (ping_ready == TRUE)) { + return linphone_core_start_invite(lc, call, dest_proxy); + } + return 0; +} + int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy){ int err; char *contact; @@ -2247,6 +2268,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const char *real_url=NULL; LinphoneProxyConfig *dest_proxy=NULL; LinphoneCall *call; + bool_t use_ice = FALSE; linphone_core_preempt_sound_resources(lc); @@ -2298,18 +2320,19 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const linphone_call_delete_ice_session(call); linphone_call_stop_media_streams(call); } else { - if (real_url!=NULL) ms_free(real_url); - return call; + use_ice = TRUE; } } - if (dest_proxy!=NULL || lc->sip_conf.ping_with_options==FALSE){ - linphone_core_start_invite(lc,call,dest_proxy); - }else{ + + if (dest_proxy==NULL && lc->sip_conf.ping_with_options==TRUE){ /*defer the start of the call after the OPTIONS ping*/ + call->ping_replied=FALSE; call->ping_op=sal_op_new(lc->sal); sal_ping(call->ping_op,from,real_url); sal_op_set_user_pointer(call->ping_op,call); call->start_time=time(NULL); + }else{ + if (use_ice==FALSE) linphone_core_start_invite(lc,call,dest_proxy); } if (real_url!=NULL) ms_free(real_url); diff --git a/coreapi/private.h b/coreapi/private.h index 05d5c3f1..5c253b76 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -134,6 +134,7 @@ struct _LinphoneCall bool_t auth_token_verified; bool_t defer_update; bool_t was_automatically_paused; + bool_t ping_replied; CallCallbackObj nextVideoFrameDecoded; LinphoneCallStats stats[2]; IceSession *ice_session; @@ -260,6 +261,7 @@ void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose); void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses); void linphone_core_stop_waiting(LinphoneCore *lc); +int linphone_core_proceed_with_invite_if_ready(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy); int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy); int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call); int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call); -- 2.39.2