Correctly handle content of SDP when ICE has completed for a specific media stream.

This commit is contained in:
Ghislain MARY 2012-08-07 11:45:47 +02:00
parent 7baeffbff4
commit aef56a9c3a
4 changed files with 22 additions and 3 deletions

View 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);

View 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));
}

View 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

View 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 {