Commit 845e0cf4 authored by Simon Morlat's avatar Simon Morlat

add support to receive extension headers in RTP packets

parent a56d7f75
......@@ -189,6 +189,7 @@ EXPORTS
......@@ -116,6 +116,7 @@ void rtp_add_csrc(mblk_t *mp ,uint32_t csrc);
#define rtp_get_csrc(mp, idx) (((rtp_header_t*)((mp)->b_rptr))->csrc[idx])
int rtp_get_payload(mblk_t *packet, unsigned char **start);
int rtp_get_extheader(mblk_t *packet, uint16_t *profile, uint8_t **start_ext);
#ifdef __cplusplus
......@@ -1677,10 +1677,47 @@ int rtp_get_payload(mblk_t *packet, unsigned char **start){
ortp_warning("Invalid RTP packet");
return -1;
if (rtp_get_extbit(packet)){
int extsize=rtp_get_extheader(packet,NULL,NULL);
if (extsize>=0){
return packet->b_wptr-tmp;
* Obtain the extension header if any.
* @param packet the RTP packet.
* @param profile the profile field of the extension header
* @param start_ext_header pointer that will be set to the beginning of the payload of the extension header.
* @return the size of the extension in bytes (the payload size, it can be 0), -1 if parsing of the extension header failed or if no extension is present.
int rtp_get_extheader(mblk_t *packet, uint16_t *profile, uint8_t **start_ext){
int size=0;
uint8_t *ext_header;
if (rtp_get_extbit(packet)){
if (ext_header+4 <= packet->b_wptr){
uint32_t h=ntohl(*(uint32_t*)ext_header);
size=(int)(h & 0xFFFF);
if (profile) *profile=(h>>16);
size=(size*4); /*the size is given in the packet as multiple of 32 bit words, excluding the 4 byte header*/
if ((ext_header+4+size)> packet->b_wptr){
ortp_warning("Inconsistent size for rtp extension header");
return -1;
if (start_ext) *start_ext=ext_header+4;
return size;
ortp_warning("Insufficient size for rtp extension header.");
return -1;
return -1;
* Gets last time a valid RTP or RTCP packet was received.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment