Skip to content

Commit

Permalink
document xtn helper functions
Browse files Browse the repository at this point in the history
srtp_get_rtp_xtn_hdr & srtp_get_rtp_xtn_hdr_len both
assume that the caller has verified that the input arguments
are valid, ie that there is an extension present by previously
checking the x bit of the RTP header.
  • Loading branch information
pabuhler committed Dec 20, 2023
1 parent 8f10fac commit d30461e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions srtp/srtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,24 @@ static uint32_t srtp_get_rtp_hdr_len(const srtp_hdr_t *hdr)
return octets_in_rtp_header + 4 * hdr->cc;
}

/*
* Returns the location of the header extention cast too a srtp_hdr_xtnd_t
* struct. Will always return a value and assumes that the caller has already
* verified that a header extension is present by checking the x bit of
* srtp_hdr_t.
*/
static srtp_hdr_xtnd_t *srtp_get_rtp_xtn_hdr(srtp_hdr_t *hdr)
{
uint32_t rtp_xtn_hdr_start = srtp_get_rtp_hdr_len(hdr);
return (srtp_hdr_xtnd_t *)((uint8_t *)hdr + rtp_xtn_hdr_start);
}

/*
* Returns the length of the extension header including the extension header
* header so will return a minium of 4. Assumes the srtp_hdr_xtnd_t is a valid
* pointer and that the caller has already verified that a header extension is
* valid by checking the x bit of the RTP header.
*/
static uint32_t srtp_get_rtp_xtn_hdr_len(const srtp_hdr_xtnd_t *xtn_hdr)
{
return (ntohs(xtn_hdr->length) + 1) * 4;
Expand Down

0 comments on commit d30461e

Please sign in to comment.