Commit 1789adc9 authored by Ghislain MARY's avatar Ghislain MARY

Improve handling of ICE losing pairs.

parent 77d4dc42
...@@ -1611,8 +1611,11 @@ static IceCandidatePair * ice_construct_valid_pair(IceCheckList *cl, RtpSession ...@@ -1611,8 +1611,11 @@ static IceCandidatePair * ice_construct_valid_pair(IceCheckList *cl, RtpSession
elem = ms_list_find_custom(cl->losing_pairs, (MSCompareFunc)ice_find_pair_from_candidates, &candidates); elem = ms_list_find_custom(cl->losing_pairs, (MSCompareFunc)ice_find_pair_from_candidates, &candidates);
if (elem != NULL) { if (elem != NULL) {
cl->losing_pairs = ms_list_remove_link(cl->losing_pairs, elem); cl->losing_pairs = ms_list_remove_link(cl->losing_pairs, elem);
/* Select the losing pair that has just become a valid pair. */
valid_pair->selected = TRUE;
if (ice_session_nb_losing_pairs(cl->session) == 0) { if (ice_session_nb_losing_pairs(cl->session) == 0) {
/* Notify the application that the checks for losing pairs have completed. The answer can now be sent. */ /* Notify the application that the checks for losing pairs have completed. The answer can now be sent. */
ice_check_list_set_state(cl, ICL_Completed);
ev = ortp_event_new(ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED); ev = ortp_event_new(ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED);
ortp_event_get_data(ev)->info.ice_processing_successful = TRUE; ortp_event_get_data(ev)->info.ice_processing_successful = TRUE;
rtp_session_dispatch_event(rtp_session, ev); rtp_session_dispatch_event(rtp_session, ev);
...@@ -1996,6 +1999,7 @@ void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *loc ...@@ -1996,6 +1999,7 @@ void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *loc
LocalCandidate_RemoteCandidate lr; LocalCandidate_RemoteCandidate lr;
IceCandidatePair *pair; IceCandidatePair *pair;
IceValidCandidatePair *valid_pair; IceValidCandidatePair *valid_pair;
bool_t added_missing_relay_candidate = FALSE;
snprintf(taddr.ip, sizeof(taddr.ip), "%s", local_addr); snprintf(taddr.ip, sizeof(taddr.ip), "%s", local_addr);
taddr.port = local_port; taddr.port = local_port;
...@@ -2010,6 +2014,8 @@ void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *loc ...@@ -2010,6 +2014,8 @@ void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *loc
srflx_elem = ms_list_find_custom(cl->remote_candidates, (MSCompareFunc)ice_find_candidate_from_type_and_componentID, &tc); srflx_elem = ms_list_find_custom(cl->remote_candidates, (MSCompareFunc)ice_find_candidate_from_type_and_componentID, &tc);
} }
if (srflx_elem != NULL) { if (srflx_elem != NULL) {
ms_message("ice: Add missing local candidate %s:%u:relay", local_addr, local_port);
added_missing_relay_candidate = TRUE;
lr.local = ice_add_local_candidate(cl, "relay", local_addr, local_port, componentID, srflx_elem->data); lr.local = ice_add_local_candidate(cl, "relay", local_addr, local_port, componentID, srflx_elem->data);
ice_compute_candidate_foundation(lr.local, cl); ice_compute_candidate_foundation(lr.local, cl);
} else { } else {
...@@ -2027,9 +2033,14 @@ void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *loc ...@@ -2027,9 +2033,14 @@ void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *loc
return; return;
} }
lr.remote = (IceCandidate *)elem->data; lr.remote = (IceCandidate *)elem->data;
if (added_missing_relay_candidate == TRUE) {
/* If we just added a missing relay candidate, also add the candidate pair. */
pair = ice_pair_new(cl, lr.local, lr.remote);
cl->pairs = ms_list_append(cl->pairs, pair);
}
elem = ms_list_find_custom(cl->pairs, (MSCompareFunc)ice_find_pair_from_candidates, &lr); elem = ms_list_find_custom(cl->pairs, (MSCompareFunc)ice_find_pair_from_candidates, &lr);
if (elem == NULL) { if (elem == NULL) {
ms_warning("ice: Candidate pair should have been found"); ms_warning("ice: Candidate pair [0x%p,0x%p] should have been found", lr.local, lr.remote);
return; return;
} }
pair = (IceCandidatePair *)elem->data; pair = (IceCandidatePair *)elem->data;
...@@ -2058,6 +2069,7 @@ void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *loc ...@@ -2058,6 +2069,7 @@ void ice_add_losing_pair(IceCheckList *cl, uint16_t componentID, const char *loc
} else { } else {
valid_pair = (IceValidCandidatePair *)elem->data; valid_pair = (IceValidCandidatePair *)elem->data;
valid_pair->selected = TRUE; valid_pair->selected = TRUE;
ms_message("ice: Select losing valid pair");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment