Bug 1258753: Base candidate pair priority on controlling/controlled. r=drno

MozReview-Commit-ID: 6RAFaAtBbJq

--HG--
extra : rebase_source : 976b63d44fc7c50efa8f40b067cf45b56c66ed09
extra : source : 7b6263bcd3d7e9148914f5aaace10fc69ea0395d
This commit is contained in:
Byron Campen [:bwc] 2016-03-22 12:22:56 -05:00
Родитель 581a304acb
Коммит 7325e61fd6
2 изменённых файлов: 29 добавлений и 19 удалений

Просмотреть файл

@ -49,10 +49,27 @@ static void nr_ice_candidate_pair_restart_stun_role_change_cb(NR_SOCKET s, int h
static void nr_ice_candidate_pair_compute_codeword(nr_ice_cand_pair *pair,
nr_ice_candidate *lcand, nr_ice_candidate *rcand);
static void nr_ice_candidate_pair_set_priority(nr_ice_cand_pair *pair)
{
/* Priority computation S 5.7.2 */
UINT8 controlling_priority, controlled_priority;
if(pair->pctx->controlling)
{
controlling_priority=pair->local->priority;
controlled_priority=pair->remote->priority;
}
else{
controlling_priority=pair->remote->priority;
controlled_priority=pair->local->priority;
}
pair->priority=(MIN(controlling_priority, controlled_priority))<<32 |
(MAX(controlling_priority, controlled_priority))<<1 |
(controlled_priority > controlling_priority?0:1);
}
int nr_ice_candidate_pair_create(nr_ice_peer_ctx *pctx, nr_ice_candidate *lcand,nr_ice_candidate *rcand,nr_ice_cand_pair **pairp)
{
nr_ice_cand_pair *pair=0;
UINT8 o_priority, a_priority;
int r,_status;
UINT4 RTO;
nr_ice_candidate tmpcand;
@ -73,20 +90,7 @@ int nr_ice_candidate_pair_create(nr_ice_peer_ctx *pctx, nr_ice_candidate *lcand,
pair->local=lcand;
pair->remote=rcand;
/* Priority computation S 5.7.2 */
if(pctx->ctx->flags & NR_ICE_CTX_FLAGS_OFFERER)
{
assert(!(pctx->ctx->flags & NR_ICE_CTX_FLAGS_ANSWERER));
o_priority=lcand->priority;
a_priority=rcand->priority;
}
else{
o_priority=rcand->priority;
a_priority=lcand->priority;
}
pair->priority=(MIN(o_priority, a_priority))<<32 |
(MAX(o_priority, a_priority))<<1 | (o_priority > a_priority?0:1);
nr_ice_candidate_pair_set_priority(pair);
/*
TODO(bcampen@mozilla.com): Would be nice to log why this candidate was
@ -644,6 +648,7 @@ static void nr_ice_candidate_pair_restart_stun_role_change_cb(NR_SOCKET s, int h
void nr_ice_candidate_pair_role_change(nr_ice_cand_pair *pair)
{
pair->stun_client->params.ice_binding_request.control = pair->pctx->controlling ? NR_ICE_CONTROLLING : NR_ICE_CONTROLLED;
nr_ice_candidate_pair_set_priority(pair);
if(pair->state == NR_ICE_PAIR_STATE_IN_PROGRESS) {
/* We could try only restarting in-progress pairs when they receive their

Просмотреть файл

@ -871,13 +871,18 @@ int nr_ice_media_stream_disable_component(nr_ice_media_stream *stream, int compo
void nr_ice_media_stream_role_change(nr_ice_media_stream *stream)
{
nr_ice_cand_pair *pair;
nr_ice_cand_pair *pair,*temp_pair;
/* Changing role causes candidate pair priority to change, which requires
* re-sorting the check list. */
nr_ice_cand_pair_head old_checklist=stream->check_list;
TAILQ_INIT(&stream->check_list);
assert(stream->ice_state != NR_ICE_MEDIA_STREAM_UNPAIRED);
pair=TAILQ_FIRST(&stream->check_list);
while(pair){
TAILQ_FOREACH_SAFE(pair,&old_checklist,check_queue_entry,temp_pair) {
TAILQ_REMOVE(&old_checklist,pair,check_queue_entry);
nr_ice_candidate_pair_role_change(pair);
pair=TAILQ_NEXT(pair,check_queue_entry);
nr_ice_candidate_pair_insert(&stream->check_list,pair);
}
}