]> sjero.net Git - linphone/commitdiff
Some fixes of bugs introduced with redesign of interaction between ICE and media...
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Mon, 6 Aug 2012 15:08:06 +0000 (17:08 +0200)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Mon, 6 Aug 2012 15:08:06 +0000 (17:08 +0200)
coreapi/linphonecore.c
coreapi/misc.c
coreapi/offeranswer.c

index 1a0a857529474b66fe3015216220e4b1663881c5..c69a42a0677c52d19cdb685603a08e9c1fa9b8f1 100644 (file)
@@ -2553,8 +2553,8 @@ int linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const
        call->camera_active=call->params.has_video;
        update_local_media_description(lc,call);
        if (call->ice_session != NULL) {
-               linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
                linphone_core_update_ice_from_remote_media_description(call, sal_call_get_remote_media_description(call->op));
+               linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
        }
        sal_call_set_local_media_description(call->op,call->localdesc);
        sal_call_accept(call->op);
index 81db63ad0274485ae70f54b4140ccbc350ca06b4..e97b1b06dd47db586011136c6e674614224f92ef 100644 (file)
@@ -608,6 +608,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
 void linphone_core_update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session)
 {
        IceSessionState session_state = ice_session_state(session);
+       int nb_candidates;
        int i, j;
 
        if (session_state == IS_Completed) desc->ice_completed = TRUE;
@@ -617,6 +618,7 @@ void linphone_core_update_local_media_description_from_ice(SalMediaDescription *
        for (i = 0; i < desc->nstreams; i++) {
                SalStreamDescription *stream = &desc->streams[i];
                IceCheckList *cl = ice_session_check_list(session, i);
+               nb_candidates = 0;
                if (cl == NULL) continue;
                if ((strlen(ice_check_list_local_pwd(cl)) != strlen(desc->ice_pwd)) || (strcmp(ice_check_list_local_pwd(cl), desc->ice_pwd)))
                        strncpy(stream->ice_pwd, ice_check_list_local_pwd(cl), sizeof(stream->ice_pwd));
@@ -629,7 +631,7 @@ void linphone_core_update_local_media_description_from_ice(SalMediaDescription *
                if ((cl->state == ICL_Running) || (cl->state == ICL_Completed)) {
                        memset(stream->ice_candidates, 0, sizeof(stream->ice_candidates));
                        for (j = 0; j < ms_list_size(cl->local_candidates); j++) {
-                               SalIceCandidate *sal_candidate = &stream->ice_candidates[j];
+                               SalIceCandidate *sal_candidate = &stream->ice_candidates[nb_candidates];
                                IceCandidate *ice_candidate = ms_list_nth_data(cl->local_candidates, j);
                                const char *default_addr = NULL;
                                int default_port = 0;
@@ -655,6 +657,7 @@ void linphone_core_update_local_media_description_from_ice(SalMediaDescription *
                                        strncpy(sal_candidate->raddr, ice_candidate->base->taddr.ip, sizeof(sal_candidate->raddr));
                                        sal_candidate->rport = ice_candidate->base->taddr.port;
                                }
+                               nb_candidates++;
                        }
                }
                if ((cl->state == ICL_Completed) && (ice_session_role(session) == IR_Controlling)) {
@@ -706,16 +709,32 @@ void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call,
                                        if (candidate->componentID == 1) {
                                                addr = stream->rtp_addr;
                                                port = stream->rtp_port;
-                                       }
-                                       else if (candidate->componentID == 2) {
+                                       } else if (candidate->componentID == 2) {
                                                addr = stream->rtcp_addr;
                                                port = stream->rtcp_port;
-                                       }
+                                       } else continue;
                                        if (addr && (candidate->port == port) && (strlen(candidate->addr) == strlen(addr)) && (strcmp(candidate->addr, addr) == 0))
                                                default_candidate = TRUE;
                                        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;
+                                       ms_error("handle remote-candidates attribute");
+                                       if (componentID == 1) {
+                                               addr = stream->rtp_addr;
+                                               port = stream->rtp_port;
+                                       } else if (componentID == 2) {
+                                               addr = stream->rtcp_addr;
+                                               port = stream->rtcp_port;
+                                       } else continue;
+                                       if (addr[0] == '\0') addr = md->addr;
+                                       ice_add_losing_pair(ice_session_check_list(call->ice_session, i), j + 1, candidate->addr, candidate->port, addr, port);
+                               }
                        }
                }
                for (i = ice_session_nb_check_lists(call->ice_session); i > md->nstreams; i--) {
index 1d4ce1b9fcee0f7c2ff53398ae44c5a609ecfa17..51773d3249e65e505b1adc2d28514519065095c0 100644 (file)
@@ -329,6 +329,6 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities
        strcpy(result->ice_pwd, local_capabilities->ice_pwd);
        strcpy(result->ice_ufrag, local_capabilities->ice_ufrag);
        result->ice_lite = local_capabilities->ice_lite;
-       result->ice_completed = local_capabilities->ice_lite;
+       result->ice_completed = local_capabilities->ice_completed;
        return 0;
 }