]> sjero.net Git - linphone/blobdiff - coreapi/misc.c
Add ICE failed state.
[linphone] / coreapi / misc.c
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;
+               }
        }
 }