16 #include <arpa/inet.h>
18 #include <machine/endian.h>
19 #define __BYTE_ORDER BYTE_ORDER
20 #define __BIG_ENDIAN BIG_ENDIAN
21 #define __LITTLE_ENDIAN LITTLE_ENDIAN
30 #define RTP_HEADER_SIZE 12
35 #if __BYTE_ORDER == __BIG_ENDIAN
42 #elif __BYTE_ORDER == __LITTLE_ENDIAN
72 #define JANUS_RTP_EXTMAP_AUDIO_LEVEL "urn:ietf:params:rtp-hdrext:ssrc-audio-level"
74 #define JANUS_RTP_EXTMAP_TOFFSET "urn:ietf:params:rtp-hdrext:toffset"
76 #define JANUS_RTP_EXTMAP_ABS_SEND_TIME "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"
78 #define JANUS_RTP_EXTMAP_VIDEO_ORIENTATION "urn:3gpp:video-orientation"
80 #define JANUS_RTP_EXTMAP_TRANSPORT_WIDE_CC "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
82 #define JANUS_RTP_EXTMAP_PLAYOUT_DELAY "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"
84 #define JANUS_RTP_EXTMAP_MID "urn:ietf:params:rtp-hdrext:sdes:mid"
86 #define JANUS_RTP_EXTMAP_RID "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"
88 #define JANUS_RTP_EXTMAP_REPAIRED_RID "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"
90 #define JANUS_RTP_EXTMAP_FRAME_MARKING "http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07"
92 #define JANUS_RTP_EXTMAP_ENCRYPTED "urn:ietf:params:rtp-hdrext:encrypt"
162 gboolean *c, gboolean *f, gboolean *r1, gboolean *r0);
172 uint16_t *min_delay, uint16_t *max_delay);
182 char *sdes_item,
int sdes_len);
192 char *sdes_item,
int sdes_len);
211 uint16_t *transSeqNum);
242 #define RTP_AUDIO_SKEW_TH_MS 120
243 #define RTP_VIDEO_SKEW_TH_MS 120
244 #define SKEW_DETECTION_WAIT_TIME_SECS 10
310 char *buf,
int len, uint32_t *ssrcs,
char **rids,
gboolean changed_temporal
Whether the temporal layer has changed after processing a packet.
Definition: rtp.h:279
int templayer_target
As above, but to handle transitions (e.g., wait for keyframe)
Definition: rtp.h:273
gint64 evaluating_start_time
Definition: rtp.h:229
gboolean new_ssrc
Definition: rtp.h:226
uint32_t base_ts_prev
Definition: rtp.h:224
struct json_t json_t
Definition: plugin.h:225
void janus_rtp_simulcasting_prepare(json_t *simulcast, int *rid_ext_id, int *framemarking_ext_id, uint32_t *ssrcs, char **rids)
Helper method to prepare the simulcasting info (rids and/or SSRCs) from the simulcast object the core...
Definition: rtp.c:847
gint64 created
Definition: rtp.h:61
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-ne...
Definition: rtp.c:228
gint64 last_relayed
When we relayed the last packet (used to detect when substreams become unavailable) ...
Definition: rtp.h:275
gint rid_ext_id
RTP Stream extension ID, if any.
Definition: rtp.h:263
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-strea...
Definition: rtp.c:312
int janus_videocodec_pt(janus_videocodec vcodec)
Definition: rtp.c:821
int templayer
Which simulcast temporal layer we should forward back.
Definition: rtp.h:271
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.
Definition: rtp.c:479
uint32_t prev_ts
Definition: rtp.h:224
gboolean changed_substream
Whether the substream has changed after processing a packet.
Definition: rtp.h:277
gboolean seq_reset
Definition: rtp.h:226
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)
Definition: rtp.c:190
uint16_t base_seq_prev
Definition: rtp.h:225
janus_videocodec
Definition: rtp.h:108
uint32_t last_ts
Definition: rtp.h:224
struct janus_rtp_header_extension janus_rtp_header_extension
RTP extension.
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) ...
Definition: rtp.c:249
char * janus_rtp_payload(char *buf, int len, int *plen)
Helper to quickly access the RTP payload, skipping header and extensions.
Definition: rtp.c:26
gint32 active_delay
Definition: rtp.h:228
gint32 ts_offset
Definition: rtp.h:228
const char * janus_videocodec_name(janus_videocodec vcodec)
Definition: rtp.c:794
gint16 seq_offset
Definition: rtp.h:227
uint32_t base_ts
Definition: rtp.h:224
gboolean janus_is_rtp(char *buf, guint len)
Helper method to demultiplex RTP from other protocols.
Definition: rtp.c:19
struct rtp_header rtp_header
RTP Header (http://tools.ietf.org/html/rfc3550#section-5.1)
struct janus_rtp_simulcasting_context janus_rtp_simulcasting_context
Helper struct for processing and tracking simulcast streams.
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-tran...
Definition: rtp.c:291
uint32_t start_ts
Definition: rtp.h:224
janus_audiocodec
Definition: rtp.h:95
RTP packet.
Definition: rtp.h:58
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.
Definition: rtp.c:363
janus_videocodec janus_videocodec_from_name(const char *name)
Definition: rtp.c:809
RTP context, in order to make sure SSRC changes result in coherent seq/ts increases.
Definition: rtp.h:223
gboolean need_pli
Whether we need to send the user a keyframe request (PLI)
Definition: rtp.h:281
int substream
Which simulcast substream we should forward back.
Definition: rtp.h:267
gint64 start_time
Definition: rtp.h:229
void janus_rtp_header_update(janus_rtp_header *header, janus_rtp_switching_context *context, gboolean video)
Use the context info to update the RTP header of a packet, if needed.
Definition: rtp.c:593
gint64 last_retransmit
Definition: rtp.h:62
uint16_t prev_seq
Definition: rtp.h:225
gint framemarking_ext_id
Frame marking extension ID, if any.
Definition: rtp.h:265
gint64 reference_time
Definition: rtp.h:229
struct janus_rtp_packet janus_rtp_packet
RTP packet.
janus_audiocodec janus_audiocodec_from_name(const char *name)
Definition: rtp.c:754
int substream_target
As above, but to handle transitions (e.g., wait for keyframe, or get this if available) ...
Definition: rtp.h:269
struct janus_rtp_switching_context janus_rtp_switching_context
RTP context, in order to make sure SSRC changes result in coherent seq/ts increases.
uint32_t target_ts
Definition: rtp.h:224
int janus_audiocodec_pt(janus_audiocodec acodec)
Definition: rtp.c:772
rtp_header janus_rtp_header
Definition: rtp.h:55
char * data
Definition: rtp.h:59
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...
Definition: rtp.c:80
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...
Definition: rtp.c:52
Helper struct for processing and tracking simulcast streams.
Definition: rtp.h:261
gint32 prev_delay
Definition: rtp.h:228
void janus_rtp_switching_context_reset(janus_rtp_switching_context *context)
Set (or reset) the context fields to their default values.
Definition: rtp.c:356
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) ...
Definition: rtp.c:177
gint length
Definition: rtp.h:60
uint16_t last_seq
Definition: rtp.h:225
uint16_t base_seq
Definition: rtp.h:225
gboolean janus_rtp_simulcasting_context_process_rtp(janus_rtp_simulcasting_context *context, char *buf, int len, uint32_t *ssrcs, char **rids, janus_videocodec vcodec, janus_rtp_switching_context *sc)
Process an RTP packet, and decide whether this should be relayed or not, updating the context accordi...
Definition: rtp.c:881
const char * janus_audiocodec_name(janus_audiocodec acodec)
Definition: rtp.c:733
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-dela...
Definition: rtp.c:212
gint64 last_time
Definition: rtp.h:229
uint32_t last_ssrc
Definition: rtp.h:224
void janus_rtp_simulcasting_context_reset(janus_rtp_simulcasting_context *context)
Set (or reset) the context fields to their default values.
Definition: rtp.c:837
int janus_rtp_header_extension_parse_framemarking(char *buf, int len, int id, janus_videocodec codec, uint8_t *tid)
Helper to parse a frame-marking RTP extension (http://tools.ietf.org/html/draft-ietf-avtext-framemark...
Definition: rtp.c:271