Fork me on GitHub
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Functions
rtp.h File Reference

RTP processing (headers) More...

#include <arpa/inet.h>
#include <endian.h>
#include <inttypes.h>
#include <string.h>
#include <glib.h>
Include dependency graph for rtp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rtp_header
 RTP Header (http://tools.ietf.org/html/rfc3550#section-5.1) More...
 
struct  janus_rtp_packet
 RTP packet. More...
 
struct  janus_rtp_header_extension
 RTP extension. More...
 
struct  janus_rtp_switching_context
 RTP context, in order to make sure SSRC changes result in coherent seq/ts increases. More...
 

Macros

#define RTP_HEADER_SIZE   12
 
#define JANUS_RTP_EXTMAP_AUDIO_LEVEL   "urn:ietf:params:rtp-hdrext:ssrc-audio-level"
 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level More...
 
#define JANUS_RTP_EXTMAP_TOFFSET   "urn:ietf:params:rtp-hdrext:toffset"
 a=extmap:2 urn:ietf:params:rtp-hdrext:toffset More...
 
#define JANUS_RTP_EXTMAP_ABS_SEND_TIME   "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"
 a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time More...
 
#define JANUS_RTP_EXTMAP_VIDEO_ORIENTATION   "urn:3gpp:video-orientation"
 a=extmap:4 urn:3gpp:video-orientation More...
 
#define JANUS_RTP_EXTMAP_TRANSPORT_WIDE_CC   "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
 a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 More...
 
#define JANUS_RTP_EXTMAP_PLAYOUT_DELAY   "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"
 a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay More...
 
#define JANUS_RTP_EXTMAP_RTP_STREAM_ID   "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"
 a=extmap:3/sendonly urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id More...
 
#define RTP_AUDIO_SKEW_TH_MS   40
 
#define RTP_VIDEO_SKEW_TH_MS   40
 
#define SKEW_DETECTION_WAIT_TIME_SECS   15
 

Typedefs

typedef struct rtp_header rtp_header
 RTP Header (http://tools.ietf.org/html/rfc3550#section-5.1) More...
 
typedef rtp_header janus_rtp_header
 
typedef struct janus_rtp_packet janus_rtp_packet
 RTP packet. More...
 
typedef struct
janus_rtp_header_extension 
janus_rtp_header_extension
 RTP extension. More...
 
typedef struct
janus_rtp_switching_context 
janus_rtp_switching_context
 RTP context, in order to make sure SSRC changes result in coherent seq/ts increases. More...
 

Functions

char * janus_rtp_payload (char *buf, int len, int *plen)
 Helper to quickly access the RTP payload, skipping header and extensions. More...
 
int janus_rtp_header_extension_get_id (const char *sdp, const char *extension)
 Ugly and dirty helper to quickly get the id associated with an RTP extension (extmap) in an SDP. More...
 
const char * janus_rtp_header_extension_get_from_id (const char *sdp, int id)
 Ugly and dirty helper to quickly get the RTP extension namespace associated with an id (extmap) in an SDP. More...
 
int janus_rtp_header_extension_parse_audio_level (char *buf, int len, int id, int *level)
 Helper to parse a ssrc-audio-level RTP extension (https://tools.ietf.org/html/rfc6464) More...
 
int janus_rtp_header_extension_parse_video_orientation (char *buf, int len, int id, gboolean *c, gboolean *f, gboolean *r1, gboolean *r0)
 Helper to parse a video-orientation RTP extension (http://www.3gpp.org/ftp/Specs/html-info/26114.htm) More...
 
int janus_rtp_header_extension_parse_playout_delay (char *buf, int len, int id, uint16_t *min_delay, uint16_t *max_delay)
 Helper to parse a playout-delay RTP extension (https://webrtc.org/experiments/rtp-hdrext/playout-delay) More...
 
int janus_rtp_header_extension_parse_rtp_stream_id (char *buf, int len, int id, char *sdes_item, int sdes_len)
 Helper to parse a rtp-stream-id RTP extension (https://tools.ietf.org/html/draft-ietf-avtext-rid-09) More...
 
int janus_rtp_header_extension_parse_transport_wide_cc (char *buf, int len, int id, uint16_t *transSeqNum)
 Helper to parse a rtp-stream-id RTP extension (https://tools.ietf.org/html/draft-ietf-avtext-rid-09) More...
 
void janus_rtp_switching_context_reset (janus_rtp_switching_context *context)
 Set (or reset) the context fields to their default values. More...
 
void janus_rtp_header_update (janus_rtp_header *header, janus_rtp_switching_context *context, gboolean video, int step)
 Use the context info to update the RTP header of a packet, if needed. More...
 
int janus_rtp_skew_compensate_audio (janus_rtp_header *header, janus_rtp_switching_context *context, gint64 now)
 Use the context info to compensate for audio source skew, if needed. More...
 
int janus_rtp_skew_compensate_video (janus_rtp_header *header, janus_rtp_switching_context *context, gint64 now)
 Use the context info to compensate for video source skew, if needed. More...
 

Detailed Description

RTP processing (headers)

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Implementation of the RTP header. Since the gateway does not much more than relaying frames around, the only thing we're interested in is the RTP header and how to get its payload, and parsing extensions.

Protocols

Macro Definition Documentation

#define JANUS_RTP_EXTMAP_ABS_SEND_TIME   "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"
#define JANUS_RTP_EXTMAP_AUDIO_LEVEL   "urn:ietf:params:rtp-hdrext:ssrc-audio-level"

a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level

#define JANUS_RTP_EXTMAP_PLAYOUT_DELAY   "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"
#define JANUS_RTP_EXTMAP_RTP_STREAM_ID   "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"

a=extmap:3/sendonly urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id

#define JANUS_RTP_EXTMAP_TOFFSET   "urn:ietf:params:rtp-hdrext:toffset"

a=extmap:2 urn:ietf:params:rtp-hdrext:toffset

#define JANUS_RTP_EXTMAP_TRANSPORT_WIDE_CC   "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
#define JANUS_RTP_EXTMAP_VIDEO_ORIENTATION   "urn:3gpp:video-orientation"

a=extmap:4 urn:3gpp:video-orientation

#define RTP_AUDIO_SKEW_TH_MS   40
#define RTP_HEADER_SIZE   12
#define RTP_VIDEO_SKEW_TH_MS   40
#define SKEW_DETECTION_WAIT_TIME_SECS   15

Typedef Documentation

RTP extension.

RTP packet.

RTP context, in order to make sure SSRC changes result in coherent seq/ts increases.

typedef struct rtp_header rtp_header

Function Documentation

const char* janus_rtp_header_extension_get_from_id ( const char *  sdp,
int  id 
)

Ugly and dirty helper to quickly get the RTP extension namespace associated with an id (extmap) in an SDP.

Note
This only looks for the extensions we know about, those defined in rtp.h
Parameters
sdpThe SDP to parse
idThe extension id to look for
Returns
The extension namespace, if found, NULL otherwise
int janus_rtp_header_extension_get_id ( const char *  sdp,
const char *  extension 
)

Ugly and dirty helper to quickly get the id associated with an RTP extension (extmap) in an SDP.

Parameters
sdpThe SDP to parse
extensionThe extension namespace to look for
Returns
The extension id, if found, -1 otherwise
int janus_rtp_header_extension_parse_audio_level ( char *  buf,
int  len,
int  id,
int *  level 
)

Helper to parse a ssrc-audio-level RTP extension (https://tools.ietf.org/html/rfc6464)

Parameters
[in]bufThe packet data
[in]lenThe packet data length in bytes
[in]idThe extension ID to look for
[out]levelThe level value in dBov (0=max, 127=min)
Returns
0 if found, -1 otherwise
int janus_rtp_header_extension_parse_playout_delay ( char *  buf,
int  len,
int  id,
uint16_t *  min_delay,
uint16_t *  max_delay 
)

Helper to parse a playout-delay RTP extension (https://webrtc.org/experiments/rtp-hdrext/playout-delay)

Parameters
[in]bufThe packet data
[in]lenThe packet data length in bytes
[in]idThe extension ID to look for
[out]min_delayThe minimum delay value
[out]max_delayThe maximum delay value
Returns
0 if found, -1 otherwise
int janus_rtp_header_extension_parse_rtp_stream_id ( char *  buf,
int  len,
int  id,
char *  sdes_item,
int  sdes_len 
)

Helper to parse a rtp-stream-id RTP extension (https://tools.ietf.org/html/draft-ietf-avtext-rid-09)

Parameters
[in]bufThe packet data
[in]lenThe packet data length in bytes
[in]idThe extension ID to look for
[out]sdes_itemBuffer where the RTP stream ID will be written
[in]sdes_lenSize of the input/output buffer
Returns
0 if found, -1 otherwise
int janus_rtp_header_extension_parse_transport_wide_cc ( char *  buf,
int  len,
int  id,
uint16_t *  transSeqNum 
)

Helper to parse a rtp-stream-id RTP extension (https://tools.ietf.org/html/draft-ietf-avtext-rid-09)

Parameters
[in]bufThe packet data
[in]lenThe packet data length in bytes
[in]idThe extension ID to look for
[out]transportwide sequence number
Returns
0 if found, -1 otherwise
int janus_rtp_header_extension_parse_video_orientation ( char *  buf,
int  len,
int  id,
gboolean *  c,
gboolean *  f,
gboolean *  r1,
gboolean *  r0 
)

Helper to parse a video-orientation RTP extension (http://www.3gpp.org/ftp/Specs/html-info/26114.htm)

Parameters
[in]bufThe packet data
[in]lenThe packet data length in bytes
[in]idThe extension ID to look for
[out]cThe value of the Camera (C) bit
[out]fThe value of the Flip (F) bit
[out]r1The value of the first Rotation (R1) bit
[out]r0The value of the second Rotation (R0) bit
Returns
0 if found, -1 otherwise
void janus_rtp_header_update ( janus_rtp_header header,
janus_rtp_switching_context context,
gboolean  video,
int  step 
)

Use the context info to update the RTP header of a packet, if needed.

Parameters
[in]headerThe RTP header to update
[in]contextThe context to use as a reference
[in]videoWhether this is an audio or a video packet
[in]stepdeprecated The expected timestamp step
char* janus_rtp_payload ( char *  buf,
int  len,
int *  plen 
)

Helper to quickly access the RTP payload, skipping header and extensions.

Parameters
[in]bufThe packet data
[in]lenThe packet data length in bytes
[out]plenThe payload data length in bytes
Returns
A pointer to where the payload data starts, or NULL otherwise; plen is also set accordingly
int janus_rtp_skew_compensate_audio ( janus_rtp_header header,
janus_rtp_switching_context context,
gint64  now 
)

Use the context info to compensate for audio source skew, if needed.

Parameters
[in]headerThe RTP header to update
[in]contextThe context to use as a reference
[in]nowThe packet arrival monotonic time
Returns
0 if no compensation is needed, -N if a N packets drop must be performed, N if a N sequence numbers jump has been performed
int janus_rtp_skew_compensate_video ( janus_rtp_header header,
janus_rtp_switching_context context,
gint64  now 
)

Use the context info to compensate for video source skew, if needed.

Parameters
[in]headerThe RTP header to update
[in]contextThe context to use as a reference
[in]nowThe packet arrival monotonic time
Returns
0 if no compensation is needed, -N if a N packets drop must be performed, N if a N sequence numbers jump has been performed
void janus_rtp_switching_context_reset ( janus_rtp_switching_context context)

Set (or reset) the context fields to their default values.

Parameters
[in]contextThe context to (re)set