Skip to content

Commit

Permalink
Fixed bug in SRTP ROC checkingwhen using ICE
Browse files Browse the repository at this point in the history
  • Loading branch information
sauwming committed Oct 9, 2023
1 parent 4f8b751 commit 93785a3
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions pjsip/src/pjsua-lib/pjsua_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -3400,8 +3400,9 @@ static pj_bool_t is_ice_running(pjmedia_transport *tp)
static void check_srtp_roc(pjsua_call *call,
unsigned med_idx,
const pjsua_stream_info *new_si_,
const pjmedia_sdp_media *local_sdp,
const pjmedia_sdp_media *remote_sdp)
const pjmedia_sdp_media *local_m,
const pjmedia_sdp_session *rem_sdp,
const pjmedia_sdp_media *rem_m)
{
pjsua_call_media *call_med = &call->media[med_idx];
pjmedia_transport_info tpinfo;
Expand Down Expand Up @@ -3528,8 +3529,8 @@ static void check_srtp_roc(pjsua_call *call,
pjmedia_sdp_attr *attr;

if (local_change) {
attr = pjmedia_sdp_attr_find(local_sdp->attr_count,
local_sdp->attr, &STR_ICE_UFRAG,
attr = pjmedia_sdp_attr_find(local_m->attr_count,
local_m->attr, &STR_ICE_UFRAG,
NULL);
if (!pj_strcmp(&call_med->prev_ice_info.loc_ufrag,
&attr->value))
Expand All @@ -3541,11 +3542,17 @@ static void check_srtp_roc(pjsua_call *call,
}

if (rem_change) {
attr = pjmedia_sdp_attr_find(remote_sdp->attr_count,
remote_sdp->attr, &STR_ICE_UFRAG,
attr = pjmedia_sdp_attr_find(rem_m->attr_count,
rem_m->attr, &STR_ICE_UFRAG,
NULL);
if (!pj_strcmp(&call_med->prev_ice_info.rem_ufrag,
&attr->value))
if (attr == NULL) {
/* Find ice-ufrag attribute in session descriptor */
attr = pjmedia_sdp_attr_find(rem_sdp->attr_count,
rem_sdp->attr, &STR_ICE_UFRAG,
NULL);
}
if (attr && !pj_strcmp(&call_med->prev_ice_info.rem_ufrag,
&attr->value))
{
PJ_LOG(4, (THIS_FILE, "ICE unchanged, SRTP RX ROC "
"maintained"));
Expand Down Expand Up @@ -4003,8 +4010,8 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id,
#if PJSUA_MEDIA_HAS_PJMEDIA || PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO
#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
/* Check if we need to reset or maintain SRTP ROC */
check_srtp_roc(call, mi, &stream_info,
local_sdp->media[mi], remote_sdp->media[mi]);
check_srtp_roc(call, mi, &stream_info, local_sdp->media[mi],
remote_sdp, remote_sdp->media[mi]);
#endif
#endif

Expand Down Expand Up @@ -4260,8 +4267,8 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id,
#if PJSUA_MEDIA_HAS_PJMEDIA || PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO
#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
/* Check if we need to reset or maintain SRTP ROC */
check_srtp_roc(call, mi, &stream_info,
local_sdp->media[mi], remote_sdp->media[mi]);
check_srtp_roc(call, mi, &stream_info, local_sdp->media[mi],
remote_sdp, remote_sdp->media[mi]);
#endif
#endif

Expand Down

0 comments on commit 93785a3

Please sign in to comment.