]> sjero.net Git - linphone/commitdiff
Correctly handle content of SDP when ICE has completed for a specific media stream.
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Tue, 7 Aug 2012 09:45:47 +0000 (11:45 +0200)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Tue, 7 Aug 2012 09:45:47 +0000 (11:45 +0200)
coreapi/misc.c
coreapi/offeranswer.c
coreapi/sal.h
coreapi/sal_eXosip2_sdp.c

index e97b1b06dd47db586011136c6e674614224f92ef..a43451036258ca8dde0f407193e6b03eecbbc0c5 100644 (file)
@@ -607,12 +607,19 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
 
 void linphone_core_update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session)
 {
+       const char *rtp_addr, *rtcp_addr;
        IceSessionState session_state = ice_session_state(session);
        int nb_candidates;
        int i, j;
 
-       if (session_state == IS_Completed) desc->ice_completed = TRUE;
-       else desc->ice_completed = FALSE;
+       if (session_state == IS_Completed) {
+               desc->ice_completed = TRUE;
+               ice_check_list_nominated_valid_local_candidate(ice_session_check_list(session, 0), &rtp_addr, NULL, NULL, NULL);
+               strncpy(desc->addr, rtp_addr, sizeof(desc->addr));
+       }
+       else {
+               desc->ice_completed = FALSE;
+       }
        strncpy(desc->ice_pwd, ice_session_local_pwd(session), sizeof(desc->ice_pwd));
        strncpy(desc->ice_ufrag, ice_session_local_ufrag(session), sizeof(desc->ice_ufrag));
        for (i = 0; i < desc->nstreams; i++) {
@@ -620,6 +627,14 @@ void linphone_core_update_local_media_description_from_ice(SalMediaDescription *
                IceCheckList *cl = ice_session_check_list(session, i);
                nb_candidates = 0;
                if (cl == NULL) continue;
+               if (cl->state == ICL_Completed) {
+                       stream->ice_completed = TRUE;
+                       ice_check_list_nominated_valid_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port);
+                       strncpy(stream->rtp_addr, rtp_addr, sizeof(stream->rtp_addr));
+                       strncpy(stream->rtcp_addr, rtcp_addr, sizeof(stream->rtcp_addr));
+               } else {
+                       stream->ice_completed = FALSE;
+               }
                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));
                else
@@ -661,7 +676,6 @@ void linphone_core_update_local_media_description_from_ice(SalMediaDescription *
                        }
                }
                if ((cl->state == ICL_Completed) && (ice_session_role(session) == IR_Controlling)) {
-                       const char *rtp_addr, *rtcp_addr;
                        int rtp_port, rtcp_port;
                        memset(stream->ice_remote_candidates, 0, sizeof(stream->ice_remote_candidates));
                        ice_check_list_nominated_valid_remote_candidate(cl, &rtp_addr, &rtp_port, &rtcp_addr, &rtcp_port);
index 51773d3249e65e505b1adc2d28514519065095c0..c935699763461de617afb9f6791036ee088411b3 100644 (file)
@@ -256,6 +256,7 @@ static void initiate_incoming(const SalStreamDescription *local_cap,
        strcpy(result->ice_pwd, local_cap->ice_pwd);
        strcpy(result->ice_ufrag, local_cap->ice_ufrag);
        result->ice_mismatch = local_cap->ice_mismatch;
+       result->ice_completed = local_cap->ice_completed;
        memcpy(result->ice_candidates, local_cap->ice_candidates, sizeof(result->ice_candidates));
        memcpy(result->ice_remote_candidates, local_cap->ice_remote_candidates, sizeof(result->ice_remote_candidates));
 }
index dfb5604721450967b2755792ee19d600036cd893..0d2b631d8781f730384ab1657256ea94e0554c11 100644 (file)
@@ -169,6 +169,7 @@ typedef struct SalStreamDescription{
        char ice_ufrag[SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN];
        char ice_pwd[SAL_MEDIA_DESCRIPTION_MAX_ICE_PWD_LEN];
        bool_t ice_mismatch;
+       bool_t ice_completed;
 } SalStreamDescription;
 
 #define SAL_MEDIA_DESCRIPTION_MAX_STREAMS 4
index e03e65bae95864c4aa1db4b8816eadc1aea334dd..8c917570fbf0fee07d86c38f2f0f000cf28859bd 100644 (file)
@@ -377,6 +377,9 @@ static void add_line(sdp_message_t *msg, int lineno, const SalStreamDescription
                        }
                }
        }
+       if (desc->ice_completed == TRUE) {
+               sdp_message_a_attribute_add(msg, lineno, osip_strdup("nortpproxy"), osip_strdup("yes"));
+       }
        if (desc->ice_mismatch == TRUE) {
                sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-mismatch"), NULL);
        } else {