]> sjero.net Git - linphone/commitdiff
Restart ICE if remote credentials have changed.
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Wed, 8 Aug 2012 13:18:04 +0000 (15:18 +0200)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Wed, 8 Aug 2012 14:29:54 +0000 (16:29 +0200)
coreapi/misc.c

index 90380beab3ebdb4b308182c3a40b455cd2dd2f8f..52278686665debce097d9fe5c9761176027f1bb7 100644 (file)
@@ -691,7 +691,27 @@ void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call,
 {
        if ((md->ice_pwd[0] != '\0') && (md->ice_ufrag[0] != '\0')) {
                int i, j;
-               ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd);
+
+               /* Check for ICE restart and set remote credentials. */
+               if ((ice_session_remote_ufrag(call->ice_session) == NULL) && (ice_session_remote_pwd(call->ice_session) == NULL)) {
+                       ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd);
+               } else if (ice_session_remote_credentials_changed(call->ice_session, md->ice_ufrag, md->ice_pwd)) {
+                       ice_session_restart(call->ice_session);
+                       ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd);
+               }
+               for (i = 0; i < md->nstreams; i++) {
+                       const SalStreamDescription *stream = &md->streams[i];
+                       IceCheckList *cl = ice_session_check_list(call->ice_session, i);
+                       if (cl && (stream->ice_pwd[0] != '\0') && (stream->ice_ufrag[0] != '\0')) {
+                               if (ice_check_list_remote_credentials_changed(cl, stream->ice_ufrag, stream->ice_pwd)) {
+                                       ice_session_restart(call->ice_session);
+                                       ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd);
+                                       break;
+                               }
+                       }
+               }
+
+               /* Create ICE check lists if needed and parse ICE attributes. */
                for (i = 0; i < md->nstreams; i++) {
                        const SalStreamDescription *stream = &md->streams[i];
                        IceCheckList *cl = ice_session_check_list(call->ice_session, i);