[WebRTC] Make candidate pair insertion code easier to read/understand.

master
Fedor 2020-07-16 03:53:54 +03:00
parent 136ab69fb3
commit 3dd6ea0a5d
3 changed files with 7 additions and 14 deletions

View File

@ -418,8 +418,7 @@ static int nr_ice_candidate_copy_for_triggered_check(nr_ice_cand_pair *pair)
copy->nominated = pair->nominated;
r_log(LOG_ICE,LOG_INFO,"CAND-PAIR(%s): Adding pair to check list and trigger check queue: %s",pair->codeword,pair->as_string);
if(r=nr_ice_candidate_pair_insert(&pair->remote->stream->check_list,copy))
ABORT(r);
nr_ice_candidate_pair_insert(&pair->remote->stream->check_list,copy);
nr_ice_candidate_pair_trigger_check_append(&pair->remote->stream->trigger_check_queue,copy);
copy->triggered = 1;
@ -601,7 +600,7 @@ int nr_ice_candidate_pair_trigger_check_append(nr_ice_cand_pair_head *head,nr_ic
return(0);
}
int nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair)
void nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair)
{
nr_ice_cand_pair *c1;
@ -615,8 +614,6 @@ int nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *p
c1=TAILQ_NEXT(c1,check_queue_entry);
}
if(!c1) TAILQ_INSERT_TAIL(head,pair,check_queue_entry);
return(0);
}
void nr_ice_candidate_pair_restart_stun_nominated_cb(NR_SOCKET s, int how, void *cb_arg)

View File

@ -82,7 +82,7 @@ int nr_ice_candidate_pair_dump_state(nr_ice_cand_pair *pair, FILE *out);
int nr_ice_candidate_pair_cancel(nr_ice_peer_ctx *pctx,nr_ice_cand_pair *pair, int move_to_wait_state);
int nr_ice_candidate_pair_select(nr_ice_cand_pair *pair);
int nr_ice_candidate_pair_do_triggered_check(nr_ice_peer_ctx *pctx, nr_ice_cand_pair *pair);
int nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair);
void nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair);
int nr_ice_candidate_pair_trigger_check_append(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair);
void nr_ice_candidate_pair_restart_stun_nominated_cb(NR_SOCKET s, int how, void *cb_arg);
int nr_ice_candidate_pair_destroy(nr_ice_cand_pair **pairp);

View File

@ -1613,8 +1613,7 @@ int nr_ice_component_finalize(nr_ice_component *lcomp, nr_ice_component *rcomp)
int nr_ice_component_insert_pair(nr_ice_component *pcomp, nr_ice_cand_pair *pair)
{
int r,_status;
int pair_inserted=0;
int _status;
/* Pairs for peer reflexive are marked SUCCEEDED immediately */
if (pair->state != NR_ICE_PAIR_STATE_FROZEN &&
@ -1623,10 +1622,8 @@ int nr_ice_component_insert_pair(nr_ice_component *pcomp, nr_ice_cand_pair *pair
ABORT(R_BAD_ARGS);
}
if(r=nr_ice_candidate_pair_insert(&pair->remote->stream->check_list,pair))
ABORT(r);
pair_inserted=1;
/* We do not throw an error after this, because we've inserted the pair. */
nr_ice_candidate_pair_insert(&pair->remote->stream->check_list,pair);
/* Make sure the check timer is running, if the stream was previously
* started. We will not start streams just because a pair was created,
@ -1638,13 +1635,12 @@ int nr_ice_component_insert_pair(nr_ice_component *pcomp, nr_ice_cand_pair *pair
!pair->remote->stream->pctx->checks_started)){
if(nr_ice_media_stream_start_checks(pair->remote->stream->pctx, pair->remote->stream)) {
r_log(LOG_ICE,LOG_WARNING,"ICE-PEER(%s)/CAND-PAIR(%s): Could not restart checks for new pair %s.",pair->remote->stream->pctx->label, pair->codeword, pair->as_string);
ABORT(R_INTERNAL);
}
}
_status=0;
abort:
if (_status && !pair_inserted) {
if (_status) {
nr_ice_candidate_pair_destroy(&pair);
}
return(_status);