Browse Source

rtp: add support for padding

master
Christophe Massiot 8 years ago
parent
commit
0a31c3554f
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      ietf/rtp.h

+ 20
- 0
ietf/rtp.h View File

@ -71,6 +71,16 @@ static inline bool rtp_check_hdr(const uint8_t *p_rtp)
return (p_rtp[0] & 0xc0) == 0x80; return (p_rtp[0] & 0xc0) == 0x80;
} }
static inline void rtp_set_padding(uint8_t *p_rtp)
{
p_rtp[0] |= 0x20;
}
static inline bool rtp_check_padding(const uint8_t *p_rtp)
{
return !!(p_rtp[0] & 0x20);
}
static inline void rtp_set_extension(uint8_t *p_rtp) static inline void rtp_set_extension(uint8_t *p_rtp)
{ {
p_rtp[0] |= 0x10; p_rtp[0] |= 0x10;
@ -193,6 +203,16 @@ static inline uint8_t *rtp_payload(uint8_t *p_rtp)
return p_rtp + i_size; return p_rtp + i_size;
} }
static inline size_t rtp_payload_size(uint8_t *p_rtp, size_t i_rtp_size)
{
size_t i_payload_size = i_rtp_size - (rtp_payload(p_rtp) - p_rtp);
uint8_t i_padding_size = 0;
if (rtp_check_padding(p_rtp))
i_padding_size = p_rtp[i_rtp_size - 1];
return i_payload_size - i_padding_size;
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

Loading…
Cancel
Save