]> sjero.net Git - linphone/commitdiff
Add ICE failed state.
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Wed, 19 Sep 2012 15:58:05 +0000 (17:58 +0200)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Wed, 19 Sep 2012 15:59:48 +0000 (17:59 +0200)
coreapi/linphonecall.c
coreapi/linphonecore.h
coreapi/misc.c

index a714ad7f73beccacff8aa95dd7c8d67d40d26ae7..7166d1c13a8de1801397f9fd735a1952eb305cd2 100644 (file)
@@ -1774,7 +1774,6 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){
                                if (ice_session_role(call->ice_session) == IR_Controlling) {
                                        ice_session_select_candidates(call->ice_session);
                                        linphone_core_update_call(call->core, call, &call->current_params);
-                                       linphone_core_update_ice_state_in_call_stats(call);
                                }
                                break;
                        case IS_Failed:
@@ -1783,13 +1782,13 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){
                                                /* At least one ICE session has succeeded, so perform a call update. */
                                                ice_session_select_candidates(call->ice_session);
                                                linphone_core_update_call(call->core, call, &call->current_params);
-                                               linphone_core_update_ice_state_in_call_stats(call);
                                        }
                                }
                                break;
                        default:
                                break;
                }
+               linphone_core_update_ice_state_in_call_stats(call);
        } else if (evt == ORTP_EVENT_ICE_GATHERING_FINISHED) {
                int ping_time = -1;
                if (evd->info.ice_processing_successful==TRUE) {
index 9a5792a75e63e61fc25866f0d69a5a384bcd5648..583d66356d9bf1e48c6a9226901762e42a6c0056 100644 (file)
@@ -267,6 +267,7 @@ typedef struct _LinphoneCall LinphoneCall;
 **/
 enum _LinphoneIceState{
        LinphoneIceStateNotActivated, /**< ICE has not been activated for this call */
+       LinphoneIceStateFailed, /**< ICE processing has failed */
        LinphoneIceStateInProgress, /**< ICE process is in progress */
        LinphoneIceStateHostConnection, /**< ICE has established a direct connection to the remote host */
        LinphoneIceStateReflexiveConnection, /**< ICE has established a connection to the remote host through one or several NATs */
index b4a8479c58864e7623030f809d05916a54ab6582..6da750a0d91a8b049e55a4b5e7e64b6707e93bad 100644 (file)
@@ -641,37 +641,46 @@ void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call)
 {
        IceCheckList *audio_check_list;
        IceCheckList *video_check_list;
+       IceSessionState session_state;
 
        if (call->ice_session == NULL) return;
        audio_check_list = ice_session_check_list(call->ice_session, 0);
        video_check_list = ice_session_check_list(call->ice_session, 1);
        if (audio_check_list == NULL) return;
 
-       switch (ice_check_list_selected_valid_candidate_type(audio_check_list)) {
-               case ICT_HostCandidate:
-                       call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateHostConnection;
-                       break;
-               case ICT_ServerReflexiveCandidate:
-               case ICT_PeerReflexiveCandidate:
-                       call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateReflexiveConnection;
-                       break;
-               case ICT_RelayedCandidate:
-                       call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateRelayConnection;
-                       break;
-       }
-       if (call->params.has_video && (video_check_list != NULL)) {
-               switch (ice_check_list_selected_valid_candidate_type(video_check_list)) {
+       session_state = ice_session_state(call->ice_session);
+       if ((session_state == IS_Completed) || ((session_state == IS_Failed) && (ice_session_has_completed_check_list(call->ice_session) == TRUE))) {
+               switch (ice_check_list_selected_valid_candidate_type(audio_check_list)) {
                        case ICT_HostCandidate:
-                               call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateHostConnection;
+                               call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateHostConnection;
                                break;
                        case ICT_ServerReflexiveCandidate:
                        case ICT_PeerReflexiveCandidate:
-                               call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateReflexiveConnection;
+                               call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateReflexiveConnection;
                                break;
                        case ICT_RelayedCandidate:
-                               call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateRelayConnection;
+                               call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateRelayConnection;
                                break;
                }
+               if (call->params.has_video && (video_check_list != NULL)) {
+                       switch (ice_check_list_selected_valid_candidate_type(video_check_list)) {
+                               case ICT_HostCandidate:
+                                       call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateHostConnection;
+                                       break;
+                               case ICT_ServerReflexiveCandidate:
+                               case ICT_PeerReflexiveCandidate:
+                                       call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateReflexiveConnection;
+                                       break;
+                               case ICT_RelayedCandidate:
+                                       call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateRelayConnection;
+                                       break;
+                       }
+               }
+       } else {
+               call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateFailed;
+               if (call->params.has_video && (video_check_list != NULL)) {
+                       call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateFailed;
+               }
        }
 }