Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
sorooshm78 committed Dec 16, 2024
1 parent a6c1414 commit ad5aec9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
19 changes: 0 additions & 19 deletions pjsip/include/pjsip-ua/sip_siprec.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,6 @@ PJ_DECL(pj_status_t)
pjsip_siprec_verify_require_hdr(pjsip_require_hdr *req_hdr);


/**
* Checks if there is an attribute label for each media in the SDP.
*
* @param media The SDP media.
*
* @return PJ_TRUE if a label exists in the SDP.
*/
PJ_INLINE(pj_status_t)
pjsip_siprec_verify_sdp_attr_label(pjmedia_sdp_session *sdp)
{
const pj_str_t STR_LABEL = {"label", 5};
for (unsigned mi=0; mi<sdp->media_count; ++mi) {
if(!pjmedia_sdp_media_find_attr(sdp->media[mi], &STR_LABEL, NULL))
return PJ_FALSE;
}
return PJ_TRUE;
}


/**
* Verifies that the incoming request has the siprec value
* in the Require header and "+sip.src" parameter exist in the Contact header.
Expand Down
14 changes: 9 additions & 5 deletions pjsip/src/pjsip-ua/sip_siprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@


static const pj_str_t STR_SIPREC = {"siprec", 6};
static const pj_str_t STR_LABEL = {"label", 5};


/* Deinitialize siprec */
Expand Down Expand Up @@ -94,7 +95,7 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_require_hdr(pjsip_require_hdr *req_hdr)
*/
PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
pj_str_t *metadata,
pjmedia_sdp_session *sdp_offer,
pjmedia_sdp_session *sdp_offer,
unsigned *options,
pjsip_dialog *dlg,
pjsip_endpoint *endpt,
Expand Down Expand Up @@ -152,10 +153,13 @@ PJ_DEF(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
}

/* Check that the media attribute label exist in the SDP */
if(pjsip_siprec_verify_sdp_attr_label(sdp_offer) == PJ_FALSE){
code = PJSIP_SC_BAD_REQUEST;
warn_text = "SDP must have label media attribute";
goto on_return;
for (unsigned mi=0; mi<sdp_offer->media_count; ++mi) {
if (!pjmedia_sdp_media_find_attr(sdp_offer->media[mi],
&STR_LABEL, NULL)){
code = PJSIP_SC_BAD_REQUEST;
warn_text = "SDP must have label media attribute";
goto on_return;
}
}

status = pjsip_siprec_get_metadata(rdata->tp_info.pool,
Expand Down

0 comments on commit ad5aec9

Please sign in to comment.