]> sjero.net Git - linphone/commitdiff
Can now use ICE and ping OPTIONS in parallel.
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Thu, 9 Aug 2012 13:45:22 +0000 (15:45 +0200)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Thu, 9 Aug 2012 13:45:22 +0000 (15:45 +0200)
coreapi/callbacks.c
coreapi/linphonecall.c
coreapi/linphonecore.c
coreapi/private.h

index ba2789235fef620d05ea3679f3e91b4a4ca11eee..ab8f10f10fa4f0f6bc46a5b2d7ea87d9b88730d3 100644 (file)
@@ -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
index 36ffc4f8190ad0f8c9fe029df7094cc71c89663c..c5300bf99394dbe37696788d599546772ce0c1f2 100644 (file)
@@ -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);
index 3b8a274b7c6adff5ad3700b8cd18c0c00ed2395d..9ba19020b9f9d2d17bbd38ef4c9991679caeb7fb 100644 (file)
@@ -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);
index 05d5c3f13961a747d07f4d95dc67ad7ed1428e5a..5c253b765be2282da6ccd867b3209b861ec73a02 100644 (file)
@@ -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);