diff options
-rw-r--r-- | pjnath/src/pjnath/ice_session.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c index c63e6cd4..8bce5a82 100644 --- a/pjnath/src/pjnath/ice_session.c +++ b/pjnath/src/pjnath/ice_session.c @@ -1195,6 +1195,7 @@ pj_ice_sess_create_check_list(pj_ice_sess *ice, pj_str_t username; timer_data *td; unsigned i, j; + unsigned highest_comp = 0; pj_status_t status; PJ_ASSERT_RETURN(ice && rem_ufrag && rem_passwd && rcand_cnt && rcand, @@ -1232,6 +1233,9 @@ pj_ice_sess_create_check_list(pj_ice_sess *ice, continue; } + if (rcand[i].comp_id > highest_comp) + highest_comp = rcand[i].comp_id; + pj_memcpy(cn, &rcand[i], sizeof(pj_ice_sess_cand)); pj_strdup(ice->pool, &cn->foundation, &rcand[i].foundation); ice->rcand_cnt++; @@ -1282,6 +1286,11 @@ pj_ice_sess_create_check_list(pj_ice_sess *ice, return status; } + /* Disable our components which don't have matching component */ + if (ice->comp_cnt==2 && highest_comp==1) { + ice->comp_cnt = 1; + } + /* Init timer entry in the checklist. Initially the timer ID is FALSE * because timer is not running. */ @@ -2254,8 +2263,15 @@ PJ_DEF(pj_status_t) pj_ice_sess_send_data(pj_ice_sess *ice, pj_status_t status = PJ_SUCCESS; pj_ice_sess_comp *comp; - PJ_ASSERT_RETURN(ice && comp_id && comp_id <= ice->comp_cnt, PJ_EINVAL); + PJ_ASSERT_RETURN(ice && comp_id, PJ_EINVAL); + /* It is possible that comp_cnt is less than comp_id, when remote + * doesn't support all the components that we have. + */ + if (comp_id > ice->comp_cnt) { + return PJNATH_EICEINCOMPID; + } + pj_mutex_lock(ice->mutex); comp = find_comp(ice, comp_id); |