]> sjero.net Git - linphone/commitdiff
Restart ICE if the c= line is set to 0.0.0.0.
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Mon, 13 Aug 2012 12:28:31 +0000 (14:28 +0200)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Mon, 13 Aug 2012 12:28:31 +0000 (14:28 +0200)
coreapi/callbacks.c
coreapi/linphonecore.c
coreapi/misc.c

index ab8f10f10fa4f0f6bc46a5b2d7ea87d9b88730d3..584191cc49772347109da77bfbb7c749afc44eb5 100644 (file)
@@ -359,6 +359,11 @@ static void call_ack(SalOp *op){
 
 static void call_accept_update(LinphoneCore *lc, LinphoneCall *call){
        SalMediaDescription *md;
+       SalMediaDescription *rmd=sal_call_get_remote_media_description(call->op);
+       if ((rmd!=NULL) && (call->ice_session!=NULL)) {
+               linphone_core_update_ice_from_remote_media_description(call,rmd);
+               linphone_core_update_local_media_description_from_ice(call->localdesc,call->ice_session);
+       }
        sal_call_accept(call->op);
        md=sal_call_get_final_media_description(call->op);
        if (md && !sal_media_description_empty(md))
index 35e158f740bacae56947bcdefafc1235c89de82e..4b6c02c935b38589e36684e18a0dfe8823767dc3 100644 (file)
@@ -2897,6 +2897,8 @@ int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call)
                return -1;
        }
        update_local_media_description(lc,call);
+       if (call->ice_session != NULL)
+               linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
        if (sal_media_description_has_dir(call->resultdesc,SalStreamSendRecv)){
                sal_media_description_set_dir(call->localdesc,SalStreamSendOnly);
                subject="Call on hold";
@@ -2974,6 +2976,8 @@ int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *the_call)
        if (call->audiostream) audio_stream_play(call->audiostream, NULL);
 
        update_local_media_description(lc,the_call);
+       if (call->ice_session != NULL)
+               linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
        sal_call_set_local_media_description(call->op,call->localdesc);
        sal_media_description_set_dir(call->localdesc,SalStreamSendRecv);
        if (call->params.in_conference && !call->current_params.in_conference) subject="Conference";
index 5d56c9b51edd46d1978f9bb6898a98889d6c098a..3d3cb447789bef793aa6712d0cff9e753e841c54 100644 (file)
@@ -703,14 +703,33 @@ static void get_default_addr_and_port(uint16_t componentID, const SalMediaDescri
 
 void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call, const SalMediaDescription *md)
 {
+       bool_t ice_restarted = FALSE;
+
        if ((md->ice_pwd[0] != '\0') && (md->ice_ufrag[0] != '\0')) {
                int i, j;
 
                /* Check for ICE restart and set remote credentials. */
+               if ((strcmp(md->addr, "0.0.0.0") == 0) || (strcmp(md->addr, "::0") == 0)) {
+                       ice_session_restart(call->ice_session);
+                       ice_restarted = TRUE;
+               } else {
+                       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 && (strcmp(stream->rtp_addr, "0.0.0.0") == 0)) {
+                                       ice_session_restart(call->ice_session);
+                                       ice_restarted = TRUE;
+                                       break;
+                               }
+                       }
+               }
                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);
+                       if (ice_restarted == FALSE) {
+                               ice_session_restart(call->ice_session);
+                               ice_restarted = TRUE;
+                       }
                        ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd);
                }
                for (i = 0; i < md->nstreams; i++) {
@@ -718,7 +737,10 @@ void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call,
                        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);
+                                       if (ice_restarted == FALSE) {
+                                               ice_session_restart(call->ice_session);
+                                               ice_restarted = TRUE;
+                                       }
                                        ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd);
                                        break;
                                }
@@ -761,14 +783,16 @@ void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call,
                                        ice_add_remote_candidate(cl, candidate->type, candidate->addr, candidate->port, candidate->componentID,
                                                candidate->priority, candidate->foundation, default_candidate);
                                }
-                               for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) {
-                                       const SalIceRemoteCandidate *candidate = &stream->ice_remote_candidates[j];
-                                       const char *addr = NULL;
-                                       int port = 0;
-                                       int componentID = j + 1;
-                                       if (candidate->addr[0] == '\0') break;
-                                       get_default_addr_and_port(componentID, md, stream, &addr, &port);
-                                       ice_add_losing_pair(ice_session_check_list(call->ice_session, i), j + 1, candidate->addr, candidate->port, addr, port);
+                               if (ice_restarted == FALSE) {
+                                       for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) {
+                                               const SalIceRemoteCandidate *candidate = &stream->ice_remote_candidates[j];
+                                               const char *addr = NULL;
+                                               int port = 0;
+                                               int componentID = j + 1;
+                                               if (candidate->addr[0] == '\0') break;
+                                               get_default_addr_and_port(componentID, md, stream, &addr, &port);
+                                               ice_add_losing_pair(ice_session_check_list(call->ice_session, i), j + 1, candidate->addr, candidate->port, addr, port);
+                                       }
                                }
                        }
                }