Loading...
Searching...
No Matches
rtp.h File Reference
Core » Protocols

RTP processing (headers). More...

`#include <arpa/inet.h>`
`#include <endian.h>`
`#include <inttypes.h>`
`#include <string.h>`
`#include <glib.h>`
`#include <jansson.h>`
`#include "plugins/plugin.h"`
`#include "utils.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_rfc2833_payload
| RTP RFC2833 payload. More...
struct | janus_rtp_switching_context
| RTP context, in order to make sure SSRC changes result in coherent seq/ts increases. More...
struct | janus_av1_svc_context
| Helper struct for processing and tracking AV1-SVC streams. More...
struct | janus_av1_svc_template
| Helper struct to track SVC templates. More...
struct | janus_rtp_simulcasting_context
| Helper struct for processing and tracking simulcast streams. More...
struct | janus_rtp_svc_context
| Helper struct for processing and tracking VP9-SVC streams. 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
#define | JANUS_RTP_EXTMAP_TOFFSET "urn:ietf:params:rtp-hdrext:toffset"
| a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
#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
#define | JANUS_RTP_EXTMAP_ABS_CAPTURE_TIME "http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time"
| a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time
#define | JANUS_RTP_EXTMAP_VIDEO_ORIENTATION "urn:3gpp:video-orientation"
| a=extmap:4 urn:3gpp:video-orientation
#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
#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
#define | JANUS_RTP_EXTMAP_MID "urn:ietf:params:rtp-hdrext:sdes:mid"
| a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid
#define | JANUS_RTP_EXTMAP_RID "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"
| a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
#define | JANUS_RTP_EXTMAP_REPAIRED_RID "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"
| a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
#define | JANUS_RTP_EXTMAP_DEPENDENCY_DESC "https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"
| a=extmap:10 https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension
#define | JANUS_RTP_EXTMAP_VIDEO_LAYERS "http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00"
| a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00
#define | JANUS_RTP_EXTMAP_ENCRYPTED "urn:ietf:params:rtp-hdrext:encrypt"
#define | RTP_AUDIO_SKEW_TH_MS 120
#define | RTP_VIDEO_SKEW_TH_MS 120
#define | SKEW_DETECTION_WAIT_TIME_SECS 10

## Typedefs

typedef struct rtp_header | rtp_header
| RTP Header (http://tools.ietf.org/html/rfc3550#section-5.1).
typedef rtp_header | janus_rtp_header
typedef struct janus_rtp_packet | janus_rtp_packet
| RTP packet.
typedef struct janus_rtp_header_extension | janus_rtp_header_extension
| RTP extension.
typedef struct janus_rtp_rfc2833_payload | janus_rtp_rfc2833_payload
| RTP RFC2833 payload.
typedef enum janus_audiocodec | janus_audiocodec
typedef enum janus_videocodec | janus_videocodec
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.

## Enumerations

enum | janus_audiocodec { JANUS_AUDIOCODEC_NONE , JANUS_AUDIOCODEC_OPUS , JANUS_AUDIOCODEC_MULTIOPUS , JANUS_AUDIOCODEC_OPUSRED , JANUS_AUDIOCODEC_PCMU , JANUS_AUDIOCODEC_PCMA , JANUS_AUDIOCODEC_G722 , JANUS_AUDIOCODEC_ISAC_32K , JANUS_AUDIOCODEC_ISAC_16K , JANUS_AUDIOCODEC_L16_48K , JANUS_AUDIOCODEC_L16_16K }
enum | janus_videocodec { JANUS_VIDEOCODEC_NONE , JANUS_VIDEOCODEC_VP8 , JANUS_VIDEOCODEC_VP9 , JANUS_VIDEOCODEC_H264 , JANUS_VIDEOCODEC_AV1 , JANUS_VIDEOCODEC_H265 }

## Functions

int | janus_rtp_extension_id (const char *type)
const char * | janus_audiocodec_name (janus_audiocodec acodec)
janus_audiocodec | janus_audiocodec_from_name (const char *name)
int | janus_audiocodec_pt (janus_audiocodec acodec)
const char * | janus_videocodec_name (janus_videocodec vcodec)
janus_videocodec | janus_videocodec_from_name (const char *name)
int | janus_videocodec_pt (janus_videocodec vcodec)
gboolean | janus_is_rtp (char *buf, guint len)
| Helper method to demultiplex RTP from other protocols.
char * | janus_rtp_payload (char *buf, int len, int *plen)
| Helper to quickly access the RTP payload, skipping header and extensions.
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.
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.
int | janus_rtp_header_extension_parse_audio_level (char *buf, int len, int id, gboolean *vad, int *level)
| Helper to parse a ssrc-audio-level RTP extension (https://tools.ietf.org/html/rfc6464).
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).
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).
int | janus_rtp_header_extension_parse_mid (char *buf, int len, int id, char *sdes_item, int sdes_len)
| Helper to parse a sdes-mid RTP extension (https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-54).
int | janus_rtp_header_extension_parse_rid (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).
int | janus_rtp_header_extension_parse_dependency_desc (char *buf, int len, int id, uint8_t *dd_item, int *dd_len)
| Helper to parse a dependency descriptor RTP extension (https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension).
int | janus_rtp_header_extension_parse_abs_send_time (char *buf, int len, int id, uint32_t *abs_ts)
| Helper to parse an abs-send-time RTP extension (http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time).
int | janus_rtp_header_extension_set_abs_send_time (char *buf, int len, int id, uint32_t abs_ts)
| Helper to set an abs-send-time RTP extension (http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time).
int | janus_rtp_header_extension_parse_abs_capture_time (char *buf, int len, int id, uint64_t *abs_ts)
| Helper to parse an abs-capture-time RTP extension (http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time).
int | janus_rtp_header_extension_set_abs_capture_time (char *buf, int len, int id, uint64_t abs_ts)
| Helper to set an abs-capture-time RTP extension (http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time).
int | janus_rtp_header_extension_parse_transport_wide_cc (char *buf, int len, int id, uint16_t *transSeqNum)
| Helper to parse a transport wide sequence number (https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01).
int | janus_rtp_header_extension_set_transport_wide_cc (char *buf, int len, int id, uint16_t transSeqNum)
| Helper to set a transport wide sequence number (https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01).
int | janus_rtp_header_extension_parse_video_layers_allocation (char *buf, int len, int id, int8_t *spatial_layers, int8_t *temporal_layers)
| Helper to parse a video layers allocation (http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00).
int | janus_rtp_header_extension_replace_id (char *buf, int len, int id, int new_id)
| Helper to replace the ID of an RTP extension with a different one (e.g., to turn a repaired-rtp-stream-id into a rtp-stream-id after a successful rtx).
void | janus_rtp_switching_context_reset (janus_rtp_switching_context *context)
| Set (or reset) the context fields to their default values.
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.
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.
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.

## Janus AV1-SVC processing methods

typedef struct janus_av1_svc_context | janus_av1_svc_context
| Helper struct for processing and tracking AV1-SVC streams.
typedef struct janus_av1_svc_template | janus_av1_svc_template
| Helper struct to track SVC templates.
void | janus_av1_svc_context_reset (janus_av1_svc_context *context)
| Set (or reset) the context fields to their default values.
gboolean | janus_av1_svc_context_process_dd (janus_av1_svc_context *context, uint8_t *dd, int dd_len, uint8_t *template_id, uint8_t *ebit)
| Process a Dependency Descriptor payload, updating the SVC context accordingly.

## Janus simulcast processing methods

typedef struct janus_rtp_simulcasting_context | janus_rtp_simulcasting_context
| Helper struct for processing and tracking simulcast streams.
void | janus_rtp_simulcasting_context_reset (janus_rtp_simulcasting_context *context)
| Set (or reset) the context fields to their default values.
void | janus_rtp_simulcasting_prepare (json_t *simulcast, int *rid_ext_id, uint32_t *ssrcs, char **rids)
| Helper method to prepare the simulcasting info (rids and/or SSRCs) from the simulcast object the core passes to plugins for new PeerConnections.
void | janus_rtp_simulcasting_cleanup (int *rid_ext_id, uint32_t *ssrcs, char **rids, janus_mutex *rid_mutex)
| Helper method to cleanup some or all of the simulcasting info (rids and/or SSRCs) we may have prepared before via janus_rtp_simulcasting_prepare.
gboolean | janus_rtp_simulcasting_context_process_rtp (janus_rtp_simulcasting_context *context, char *buf, int len, uint8_t *dd_content, int dd_len, uint32_t *ssrcs, char **rids, janus_videocodec vcodec, janus_rtp_switching_context *sc, janus_mutex *rid_mutex)
| Process an RTP packet, and decide whether this should be relayed or not, updating the context accordingly.

## Janus SVC processing methods

typedef struct janus_rtp_svc_context | janus_rtp_svc_context
| Helper struct for processing and tracking VP9-SVC streams.
void | janus_rtp_svc_context_reset (janus_rtp_svc_context *context)
| Set (or reset) the context fields to their default values.
gboolean | janus_rtp_svc_context_process_rtp (janus_rtp_svc_context *context, char *buf, int len, uint8_t *dd_content, int dd_len, janus_videocodec vcodec, janus_vp9_svc_info *info, janus_rtp_switching_context *sc)
| Process an RTP packet, and decide whether this should be relayed or not, updating the context accordingly.

## Detailed Description

RTP processing (headers).

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

Copyright
  GNU General Public License v3

Implementation of the RTP header. Since the server 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

## JANUS_RTP_EXTMAP_ABS_CAPTURE_TIME

#define JANUS_RTP_EXTMAP_ABS_CAPTURE_TIME "http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time"

a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time

## JANUS_RTP_EXTMAP_ABS_SEND_TIME

#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

## JANUS_RTP_EXTMAP_AUDIO_LEVEL

#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

## JANUS_RTP_EXTMAP_DEPENDENCY_DESC

#define JANUS_RTP_EXTMAP_DEPENDENCY_DESC "https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"

a=extmap:10 https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension

## JANUS_RTP_EXTMAP_ENCRYPTED

#define JANUS_RTP_EXTMAP_ENCRYPTED "urn:ietf:params:rtp-hdrext:encrypt"

Note
  Note: We don't support encrypted extensions yet

## JANUS_RTP_EXTMAP_MID

#define JANUS_RTP_EXTMAP_MID "urn:ietf:params:rtp-hdrext:sdes:mid"

a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid

## JANUS_RTP_EXTMAP_PLAYOUT_DELAY

#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

## JANUS_RTP_EXTMAP_REPAIRED_RID

#define JANUS_RTP_EXTMAP_REPAIRED_RID "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"

a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id

## JANUS_RTP_EXTMAP_RID

#define JANUS_RTP_EXTMAP_RID "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"

a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id

## JANUS_RTP_EXTMAP_TOFFSET

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

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

## JANUS_RTP_EXTMAP_TRANSPORT_WIDE_CC

#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

## JANUS_RTP_EXTMAP_VIDEO_LAYERS

#define JANUS_RTP_EXTMAP_VIDEO_LAYERS "http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00"

a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00

## JANUS_RTP_EXTMAP_VIDEO_ORIENTATION

#define JANUS_RTP_EXTMAP_VIDEO_ORIENTATION "urn:3gpp:video-orientation"

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

## RTP_AUDIO_SKEW_TH_MS

#define RTP_AUDIO_SKEW_TH_MS 120

## RTP_HEADER_SIZE

#define RTP_HEADER_SIZE 12

## RTP_VIDEO_SKEW_TH_MS

#define RTP_VIDEO_SKEW_TH_MS 120

## SKEW_DETECTION_WAIT_TIME_SECS

#define SKEW_DETECTION_WAIT_TIME_SECS 10

## Typedef Documentation

## janus_audiocodec

typedef enum janus_audiocodec janus_audiocodec

## janus_av1_svc_context

typedef struct janus_av1_svc_context janus_av1_svc_context

Helper struct for processing and tracking AV1-SVC streams.

## janus_av1_svc_template

typedef struct janus_av1_svc_template janus_av1_svc_template

Helper struct to track SVC templates.

Note
  This is very incomplete, since we only track the spatial and temporal layer associated with a specific template ID for now

## janus_rtp_header

typedef rtp_header janus_rtp_header

## janus_rtp_header_extension

typedef struct janus_rtp_header_extension janus_rtp_header_extension

RTP extension.

## janus_rtp_packet

typedef struct janus_rtp_packet janus_rtp_packet

RTP packet.

## janus_rtp_rfc2833_payload

typedef struct janus_rtp_rfc2833_payload janus_rtp_rfc2833_payload

RTP RFC2833 payload.

## janus_rtp_simulcasting_context

typedef struct janus_rtp_simulcasting_context janus_rtp_simulcasting_context

Helper struct for processing and tracking simulcast streams.

## janus_rtp_svc_context

typedef struct janus_rtp_svc_context janus_rtp_svc_context

Helper struct for processing and tracking VP9-SVC streams.

## janus_rtp_switching_context

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.

## janus_videocodec

typedef enum janus_videocodec janus_videocodec

## rtp_header

typedef struct rtp_header rtp_header

RTP Header (http://tools.ietf.org/html/rfc3550#section-5.1).

## Enumeration Type Documentation

## janus_audiocodec

enum janus_audiocodec

Enumerator
JANUS_AUDIOCODEC_NONE |
JANUS_AUDIOCODEC_OPUS |
JANUS_AUDIOCODEC_MULTIOPUS |
JANUS_AUDIOCODEC_OPUSRED |
JANUS_AUDIOCODEC_PCMU |
JANUS_AUDIOCODEC_PCMA |
JANUS_AUDIOCODEC_G722 |
JANUS_AUDIOCODEC_ISAC_32K |
JANUS_AUDIOCODEC_ISAC_16K |
JANUS_AUDIOCODEC_L16_48K |
JANUS_AUDIOCODEC_L16_16K |

## janus_videocodec

enum janus_videocodec

Enumerator
JANUS_VIDEOCODEC_NONE |
JANUS_VIDEOCODEC_VP8 |
JANUS_VIDEOCODEC_VP9 |
JANUS_VIDEOCODEC_H264 |
JANUS_VIDEOCODEC_AV1 |
JANUS_VIDEOCODEC_H265 |

## Function Documentation

## janus_audiocodec_from_name()

janus_audiocodec janus_audiocodec_from_name | ( | const char * | name | ) |

## janus_audiocodec_name()

const char * janus_audiocodec_name | ( | janus_audiocodec | acodec | ) |

## janus_audiocodec_pt()

int janus_audiocodec_pt | ( | janus_audiocodec | acodec | ) |

## janus_av1_svc_context_process_dd()

gboolean janus_av1_svc_context_process_dd | ( | janus_av1_svc_context * | context,
|  | uint8_t * | dd,
|  | int | dd_len,
|  | uint8_t * | template_id,
|  | uint8_t * | ebit )

Process a Dependency Descriptor payload, updating the SVC context accordingly.

Note
  At the moment, this code is quite naive, as it mostly looks at the target spatial/temporal layers, and the one written in the Dependency Descriptor data. In the future, this should become more sophisticated, and use additional information like dependency chains and stuff like that

Parameters

  [in] | context | The av1svc context to use
  [in] | dd | Pointer to the Dependency Descriptor data
  [in] | dd_len | The length of the Dependendy Descriptor data
  [out] | template_id | Pointer to the ID of the template referenced in this packet
  [out] | ebit | Whether this packet is an end of frame or not

Returns
  TRUE if the packet is valid, FALSE if it should be dropped instead

## janus_av1_svc_context_reset()

void janus_av1_svc_context_reset | ( | janus_av1_svc_context * | context | ) |

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

Parameters

  [in] | context | The context to (re)set

## janus_is_rtp()

gboolean janus_is_rtp | ( | char * | buf,
|  | guint | len )

Helper method to demultiplex RTP from other protocols.

Parameters

  [in] | buf | Buffer to inspect
  [in] | len | Length of the buffer to inspect

## janus_rtp_extension_id()

int janus_rtp_extension_id | ( | const char * | type | ) |

## janus_rtp_header_extension_get_from_id()

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

  sdp | The SDP to parse
  id | The extension id to look for

Returns
  The extension namespace, if found, NULL otherwise

## janus_rtp_header_extension_get_id()

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

  sdp | The SDP to parse
  extension | The extension namespace to look for

Returns
  The extension id, if found, -1 otherwise

## janus_rtp_header_extension_parse_abs_capture_time()

int janus_rtp_header_extension_parse_abs_capture_time | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | uint64_t * | abs_ts )

Helper to parse an abs-capture-time RTP extension (http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | abs_ts | Variable where the parsed abs-capture-time value will be stored

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_abs_send_time()

int janus_rtp_header_extension_parse_abs_send_time | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | uint32_t * | abs_ts )

Helper to parse an abs-send-time RTP extension (http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | abs_ts | Variable where the parsed abs-send-time value will be stored

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_audio_level()

int janus_rtp_header_extension_parse_audio_level | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | gboolean * | vad,
|  | int * | level )

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

Note
  Browsers apparently always set the VAD to 1, so it's unreliable and should be ignored: only use this method if you're interested in the audio-level value itself.

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | vad | Whether the encoder thinks there's voice activity
  [out] | level | The level value in dBov (0=max, 127=min)

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_dependency_desc()

int janus_rtp_header_extension_parse_dependency_desc | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | uint8_t * | dd_item,
|  | int * | dd_len )

Helper to parse a dependency descriptor RTP extension (https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | dd_item | Buffer where the dependency descriptor will be written
  [out] | dd_len | Size of the input/output buffer, will be updated with the size of the data

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_mid()

int janus_rtp_header_extension_parse_mid | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | char * | sdes_item,
|  | int | sdes_len )

Helper to parse a sdes-mid RTP extension (https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-54).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | sdes_item | Buffer where the RTP stream ID will be written
  [in] | sdes_len | Size of the input/output buffer

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_playout_delay()

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] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | min_delay | The minimum delay value
  [out] | max_delay | The maximum delay value

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_rid()

int janus_rtp_header_extension_parse_rid | ( | 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] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | sdes_item | Buffer where the RTP stream ID will be written
  [in] | sdes_len | Size of the input/output buffer

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_transport_wide_cc()

int janus_rtp_header_extension_parse_transport_wide_cc | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | uint16_t * | transSeqNum )

Helper to parse a transport wide sequence number (https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | transSeqNum | Variable to read the transport wide sequence number in

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_video_layers_allocation()

int janus_rtp_header_extension_parse_video_layers_allocation | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | int8_t * | spatial_layers,
|  | int8_t * | temporal_layers )

Helper to parse a video layers allocation (http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | spatial_layers | Variable where the parsed spatial layers value will be stored
  [out] | temporal_layers | Variable where the parsed temporal layers value will be stored

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_parse_video_orientation()

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] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | c | The value of the Camera (C) bit
  [out] | f | The value of the Flip (F) bit
  [out] | r1 | The value of the first Rotation (R1) bit
  [out] | r0 | The value of the second Rotation (R0) bit

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_replace_id()

int janus_rtp_header_extension_replace_id | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | int | new_id )

Helper to replace the ID of an RTP extension with a different one (e.g., to turn a repaired-rtp-stream-id into a rtp-stream-id after a successful rtx).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for and replace
  [in] | new_id | The new value for the extension ID

Returns
  0 if found, a negative integer otherwise

## janus_rtp_header_extension_set_abs_capture_time()

int janus_rtp_header_extension_set_abs_capture_time | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | uint64_t | abs_ts )

Helper to set an abs-capture-time RTP extension (http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | abs_ts | Absolute Send Time value to set

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_set_abs_send_time()

int janus_rtp_header_extension_set_abs_send_time | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | uint32_t | abs_ts )

Helper to set an abs-send-time RTP extension (http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | abs_ts | Absolute Send Time value to set

Returns
  0 if found, -1 otherwise

## janus_rtp_header_extension_set_transport_wide_cc()

int janus_rtp_header_extension_set_transport_wide_cc | ( | char * | buf,
|  | int | len,
|  | int | id,
|  | uint16_t | transSeqNum )

Helper to set a transport wide sequence number (https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01).

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [in] | id | The extension ID to look for
  [out] | transSeqNum | Transport wide sequence number to set

Returns
  0 if found, -1 otherwise

## janus_rtp_header_update()

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] | header | The RTP header to update
  [in] | context | The context to use as a reference
  [in] | video | Whether this is an audio or a video packet
  [in] | step | deprecated The expected timestamp step

## janus_rtp_payload()

char * janus_rtp_payload | ( | char * | buf,
|  | int | len,
|  | int * | plen )

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

Parameters

  [in] | buf | The packet data
  [in] | len | The packet data length in bytes
  [out] | plen | The payload data length in bytes

Returns
  A pointer to where the payload data starts, or NULL otherwise; plen is also set accordingly

## janus_rtp_simulcasting_cleanup()

void janus_rtp_simulcasting_cleanup | ( | int * | rid_ext_id,
|  | uint32_t * | ssrcs,
|  | char ** | rids,
|  | janus_mutex * | rid_mutex )

Helper method to cleanup some or all of the simulcasting info (rids and/or SSRCs) we may have prepared before via janus_rtp_simulcasting_prepare.

Parameters

  [in] | rid_ext_id | The rid RTP extension ID to cleanup, if any
  [in] | ssrcs | The list of simulcast SSRCs to cleanup, if any
  [in] | rids | The list of rids to cleanup, if any (items will be freed and NULL-ed)
  [in] | rid_mutex | A mutex that must be acquired before cleaning up, if any

## janus_rtp_simulcasting_context_process_rtp()

gboolean janus_rtp_simulcasting_context_process_rtp | ( | janus_rtp_simulcasting_context * | context,
|  | char * | buf,
|  | int | len,
|  | uint8_t * | dd_content,
|  | int | dd_len,
|  | uint32_t * | ssrcs,
|  | char ** | rids,
|  | janus_videocodec | vcodec,
|  | janus_rtp_switching_context * | sc,
|  | janus_mutex * | rid_mutex )

Process an RTP packet, and decide whether this should be relayed or not, updating the context accordingly.

Note
  Calling this method resets the `changed_substream` , `changed_temporal` and `need_pli` properties, and updates them according to the decisions made after processing the packet

Parameters

  [in] | context | The simulcasting context to use
  [in] | buf | The RTP packet to process
  [in] | len | The length of the RTP packet (header, extension and payload)
  [in] | dd_content | The Dependency Descriptor RTP extension data, if available
  [in] | dd_len | Length of the Dependency Descriptor data, if available
  [in] | ssrcs | The simulcast SSRCs to refer to (may be updated if rids are involved)
  [in] | rids | The simulcast rids to refer to, if any
  [in] | vcodec | Video codec of the RTP payload
  [in] | sc | RTP switching context to refer to, if any (only needed for VP8 and dropping temporal layers)
  [in] | rid_mutex | A mutex that must be acquired before reading the rids array, if any

Returns
  TRUE if the packet should be relayed, FALSE if it should be dropped instead

## janus_rtp_simulcasting_context_reset()

void janus_rtp_simulcasting_context_reset | ( | janus_rtp_simulcasting_context * | context | ) |

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

Parameters

  [in] | context | The context to (re)set

## janus_rtp_simulcasting_prepare()

void janus_rtp_simulcasting_prepare | ( | json_t * | simulcast,
|  | int * | rid_ext_id,
|  | uint32_t * | ssrcs,
|  | char ** | rids )

Helper method to prepare the simulcasting info (rids and/or SSRCs) from the simulcast object the core passes to plugins for new PeerConnections.

Parameters

  [in] | simulcast | JSON object containing SSRCs and rids
  [in] | rid_ext_id | The rid RTP extension ID to set, if any
  [in] | ssrcs | The list of simulcast SSRCs to update, if any
  [in] | rids | The list of rids to update, if any (items will be allocated)

## janus_rtp_skew_compensate_audio()

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] | header | The RTP header to update
  [in] | context | The context to use as a reference
  [in] | now | The 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

## janus_rtp_skew_compensate_video()

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] | header | The RTP header to update
  [in] | context | The context to use as a reference
  [in] | now | The 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

## janus_rtp_svc_context_process_rtp()

gboolean janus_rtp_svc_context_process_rtp | ( | janus_rtp_svc_context * | context,
|  | char * | buf,
|  | int | len,
|  | uint8_t * | dd_content,
|  | int | dd_len,
|  | janus_videocodec | vcodec,
|  | janus_vp9_svc_info * | info,
|  | janus_rtp_switching_context * | sc )

Process an RTP packet, and decide whether this should be relayed or not, updating the context accordingly.

Note
  Calling this method resets the `changed_spatial` , `changed_temporal` and `need_pli` properties, and updates them according to the decisions made after processing the packet

Parameters

  [in] | context | The VP9 SVC context to use
  [in] | buf | The RTP packet to process
  [in] | len | The length of the RTP packet (header, extension and payload)
  [in] | dd_content | The Dependency Descriptor RTP extension data, if available
  [in] | dd_len | Length of the Dependency Descriptor data, if available
  [in] | vcodec | Video codec of the RTP payload
  [in] | info | Parsed info on VP9-SVC, if any
  [in] | sc | RTP switching context to refer to, if any

Returns
  TRUE if the packet should be relayed, FALSE if it should be dropped instead

## janus_rtp_svc_context_reset()

void janus_rtp_svc_context_reset | ( | janus_rtp_svc_context * | context | ) |

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

Parameters

  [in] | context | The context to (re)set

## janus_rtp_switching_context_reset()

void janus_rtp_switching_context_reset | ( | janus_rtp_switching_context * | context | ) |

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

Parameters

  [in] | context | The context to (re)set

## janus_videocodec_from_name()

janus_videocodec janus_videocodec_from_name | ( | const char * | name | ) |

## janus_videocodec_name()

const char * janus_videocodec_name | ( | janus_videocodec | vcodec | ) |

## janus_videocodec_pt()

int janus_videocodec_pt | ( | janus_videocodec | vcodec | ) |