reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
re_rtp.h
Go to the documentation of this file.
1
7#include <stdint.h>
8
10enum {
13 RTP_HEADER_SIZE = 12
14};
15
16
34
37 RTCP_FIR = 192,
38 RTCP_NACK = 193,
39 RTCP_SR = 200,
40 RTCP_RR = 201,
41 RTCP_SDES = 202,
42 RTCP_BYE = 203,
43 RTCP_APP = 204,
44 RTCP_RTPFB = 205,
45 RTCP_PSFB = 206,
46 RTCP_XR = 207,
47 RTCP_AVB = 208,
48};
49
62
67
74
76struct rtcp_rr {
78 //unsigned int fraction:8; /**< Fraction lost since last SR/RR */
79 //int lost:24; /**< Cumul. no. pkts lost (signed!) */
85};
86
93
95struct rtcp_msg {
97 struct rtcp_hdr {
98 unsigned int version:2;
99 unsigned int p:1;
100 unsigned int count:5;
101 unsigned int pt:8;
104 union {
106 struct {
113 struct rtcp_rr rrv[1];
114 } sr;
115
117 struct {
118 uint32_t ssrc;
119 struct rtcp_rr rrv[1];
120 } rr;
121 } r;
122};
123
126 struct {
128 int lost;
130 } tx;
131 struct {
132 uint32_t sent;
133 int lost;
134 uint32_t jit;
135 } rx;
137};
138
139struct sa;
140struct re_printf;
141struct rtp_sock;
142
143typedef void (rtp_recv_h)(const struct sa *src, const struct rtp_header *hdr,
144 struct mbuf *mb, void *arg);
145typedef void (rtcp_recv_h)(const struct sa *src, struct rtcp_msg *msg,
146 void *arg);
147
148/* RTP api */
149int rtp_alloc(struct rtp_sock **rsp);
150int rtp_listen(struct rtp_sock **rsp, int proto, const struct sa *ip,
152 rtp_recv_h *recvh, rtcp_recv_h *rtcph, void *arg);
153int rtp_hdr_encode(struct mbuf *mb, const struct rtp_header *hdr);
154int rtp_hdr_decode(struct rtp_header *hdr, struct mbuf *mb);
155int rtp_encode(struct rtp_sock *rs, bool marker, uint8_t pt,
156 uint32_t ts, struct mbuf *mb);
157int rtp_decode(struct rtp_sock *rs, struct mbuf *mb, struct rtp_header *hdr);
158int rtp_send(struct rtp_sock *rs, const struct sa *dst,
159 bool marker, uint8_t pt, uint32_t ts, struct mbuf *mb);
160int rtp_debug(struct re_printf *pf, const struct rtp_sock *rs);
161void *rtp_sock(const struct rtp_sock *rs);
163const struct sa *rtp_local(const struct rtp_sock *rs);
164
165/* RTCP session api */
166void rtcp_start(struct rtp_sock *rs, const char *cname,
167 const struct sa *peer);
168void rtcp_enable_mux(struct rtp_sock *rs, bool enabled);
172int rtcp_send_app(struct rtp_sock *rs, const char name[4],
173 const uint8_t *data, size_t len);
174int rtcp_send_fir(struct rtp_sock *rs, uint32_t ssrc);
177int rtcp_debug(struct re_printf *pf, const struct rtp_sock *rs);
178void *rtcp_sock(const struct rtp_sock *rs);
179int rtcp_stats(struct rtp_sock *rs, uint32_t ssrc, struct rtcp_stats *stats);
180
181/* RTCP utils */
182int rtcp_encode(struct mbuf *mb, enum rtcp_type type, uint32_t count, ...);
183int rtcp_decode(struct rtcp_msg **msgp, struct mbuf *mb);
184int rtcp_msg_print(struct re_printf *pf, const struct rtcp_msg *msg);
186const char *rtcp_type_name(enum rtcp_type type);
187const char *rtcp_sdes_name(enum rtcp_sdes_type sdes);
int rtcp_send_app(struct rtp_sock *rs, const char name[4], const uint8_t *data, size_t len)
Send an RTCP Application-Defined (APP) packet.
Definition rtcp.c:55
rtcp_rtpfb
Transport Layer Feedback Messages.
Definition re_rtp.h:64
@ RTCP_RTPFB_GNACK
Generic NACK.
Definition re_rtp.h:65
rtcp_sdes_type
SDES Types.
Definition re_rtp.h:51
@ RTCP_SDES_NOTE
Notice about the source
Definition re_rtp.h:59
@ RTCP_SDES_CNAME
Canonical name
Definition re_rtp.h:53
@ RTCP_SDES_PHONE
User's phone number
Definition re_rtp.h:56
@ RTCP_SDES_TOOL
Name of application or tool
Definition re_rtp.h:58
@ RTCP_SDES_LOC
Geographic user location
Definition re_rtp.h:57
@ RTCP_SDES_EMAIL
User's electronic mail address.
Definition re_rtp.h:55
@ RTCP_SDES_END
End of SDES list
Definition re_rtp.h:52
@ RTCP_SDES_NAME
User name
Definition re_rtp.h:54
@ RTCP_SDES_PRIV
Private extension
Definition re_rtp.h:60
void rtcp_set_srate_rx(struct rtp_sock *rs, uint32_t srate_rx)
void() rtp_recv_h(const struct sa *src, const struct rtp_header *hdr, struct mbuf *mb, void *arg)
Definition re_rtp.h:143
int rtp_encode(struct rtp_sock *rs, bool marker, uint8_t pt, uint32_t ts, struct mbuf *mb)
int rtcp_encode(struct mbuf *mb, enum rtcp_type type, uint32_t count,...)
rtcp_type
RTCP Packet Types.
Definition re_rtp.h:36
@ RTCP_APP
Application-defined
Definition re_rtp.h:43
@ RTCP_RTPFB
Transport layer FB message (RFC 4585)
Definition re_rtp.h:44
@ RTCP_RR
Receiver Report
Definition re_rtp.h:40
@ RTCP_SR
Sender Report
Definition re_rtp.h:39
@ RTCP_XR
Extended Report (RFC 3611)
Definition re_rtp.h:46
@ RTCP_PSFB
Payload-specific FB message (RFC 4585)
Definition re_rtp.h:45
@ RTCP_SDES
Source Description
Definition re_rtp.h:41
@ RTCP_FIR
Full INTRA-frame Request (RFC 2032)
Definition re_rtp.h:37
@ RTCP_NACK
Negative Acknowledgement (RFC 2032)
Definition re_rtp.h:38
@ RTCP_AVB
AVB RTCP Packet (IEEE1733)
Definition re_rtp.h:47
@ RTCP_BYE
Goodbye
Definition re_rtp.h:42
int rtcp_send_pli(struct rtp_sock *rs, uint32_t fb_ssrc)
Send an RTCP Picture Loss Indication (PLI) packet.
Definition rtcp.c:100
void * rtcp_sock(const struct rtp_sock *rs)
int rtp_send(struct rtp_sock *rs, const struct sa *dst, bool marker, uint8_t pt, uint32_t ts, struct mbuf *mb)
int rtcp_debug(struct re_printf *pf, const struct rtp_sock *rs)
void rtcp_set_srate(struct rtp_sock *rs, uint32_t sr_tx, uint32_t sr_rx)
void() rtcp_recv_h(const struct sa *src, struct rtcp_msg *msg, void *arg)
Definition re_rtp.h:145
void * rtp_sock(const struct rtp_sock *rs)
int rtcp_msg_print(struct re_printf *pf, const struct rtcp_msg *msg)
Print an RTCP Message.
Definition rtcp.c:153
int rtp_debug(struct re_printf *pf, const struct rtp_sock *rs)
rtcp_psfb
Payload-Specific Feedback Messages.
Definition re_rtp.h:69
@ RTCP_PSFB_AFB
Application layer Feedback Messages.
Definition re_rtp.h:72
@ RTCP_PSFB_PLI
Picture Loss Indication (PLI)
Definition re_rtp.h:70
@ RTCP_PSFB_SLI
Slice Loss Indication (SLI)
Definition re_rtp.h:71
void rtcp_start(struct rtp_sock *rs, const char *cname, const struct sa *peer)
int rtcp_send_nack(struct rtp_sock *rs, uint16_t fsn, uint16_t blp)
Send an RTCP NACK packet.
Definition rtcp.c:86
void rtcp_enable_mux(struct rtp_sock *rs, bool enabled)
void rtcp_set_srate_tx(struct rtp_sock *rs, uint32_t srate_tx)
uint32_t rtp_sess_ssrc(const struct rtp_sock *rs)
int rtp_decode(struct rtp_sock *rs, struct mbuf *mb, struct rtp_header *hdr)
@ RTP_VERSION
Defines the RTP version we support.
Definition re_rtp.h:11
@ RTP_HEADER_SIZE
Number of bytes in RTP Header
Definition re_rtp.h:13
@ RTCP_VERSION
Supported RTCP Version
Definition re_rtp.h:12
int rtp_listen(struct rtp_sock **rsp, int proto, const struct sa *ip, uint16_t min_port, uint16_t max_port, bool enable_rtcp, rtp_recv_h *recvh, rtcp_recv_h *rtcph, void *arg)
const char * rtcp_type_name(enum rtcp_type type)
Definition rtcp.c:107
int rtp_alloc(struct rtp_sock **rsp)
int rtp_hdr_encode(struct mbuf *mb, const struct rtp_header *hdr)
int rtcp_send_fir(struct rtp_sock *rs, uint32_t ssrc)
Send a Full INTRA-frame Request (FIR) packet.
Definition rtcp.c:71
int rtcp_sdes_encode(struct mbuf *mb, uint32_t src, uint32_t itemc,...)
const char * rtcp_sdes_name(enum rtcp_sdes_type sdes)
Definition rtcp.c:127
int rtcp_decode(struct rtcp_msg **msgp, struct mbuf *mb)
const struct sa * rtp_local(const struct rtp_sock *rs)
int rtp_hdr_decode(struct rtp_header *hdr, struct mbuf *mb)
unsigned short uint16_t
Definition stdint.h:84
unsigned int uint32_t
Definition stdint.h:85
unsigned char uint8_t
Definition stdint.h:83
RTCP Header.
Definition re_rtp.h:97
unsigned int p
Padding flag
Definition re_rtp.h:99
unsigned int pt
RTCP packet type
Definition re_rtp.h:101
unsigned int count
Varies by packet type
Definition re_rtp.h:100
unsigned int version
Protocol version
Definition re_rtp.h:98
uint16_t length
Packet length in words.
Definition re_rtp.h:102
One RTCP Message.
Definition re_rtp.h:95
union rtcp_msg::@11 r
uint32_t ntp_sec
NTP timestamp - seconds
Definition re_rtp.h:108
uint32_t osent
RTP octets sent
Definition re_rtp.h:112
struct rtcp_msg::rtcp_hdr hdr
struct rtcp_msg::@11::@12 sr
Sender report (SR)
uint32_t ssrc
Sender generating report
Definition re_rtp.h:107
struct rtcp_msg::@11::@13 rr
Reception report (RR)
uint32_t ntp_frac
NTP timestamp - fractions.
Definition re_rtp.h:109
struct rtcp_rr rrv[1]
Reception report blocks
Definition re_rtp.h:113
uint32_t psent
RTP packets sent
Definition re_rtp.h:111
uint32_t rtp_ts
RTP timestamp
Definition re_rtp.h:110
Reception report block.
Definition re_rtp.h:76
uint32_t lsr
Last SR packet from this source.
Definition re_rtp.h:83
uint32_t dlsr
Delay since last SR packet
Definition re_rtp.h:84
uint32_t jitter
Interarrival jitter
Definition re_rtp.h:82
uint32_t fraction_lost_32
Combine the previous two fields.
Definition re_rtp.h:80
uint32_t ssrc
Data source being reported
Definition re_rtp.h:77
uint32_t last_seq
Extended last seq.
Definition re_rtp.h:81
SDES item.
Definition re_rtp.h:88
char * data
Text, not null-terminated
Definition re_rtp.h:91
uint8_t length
Length of item (in octets)
Definition re_rtp.h:90
enum rtcp_sdes_type type
Type of item (enum rtcp_sdes_type)
Definition re_rtp.h:89
RTCP Statistics.
Definition re_rtp.h:125
struct rtcp_stats::@14 tx
uint32_t sent
Tx RTP Packets
Definition re_rtp.h:127
uint32_t jit
Tx Inter-arrival Jitter in [us].
Definition re_rtp.h:129
uint32_t rtt
Current Round-Trip Time in [us].
Definition re_rtp.h:136
int lost
Tx RTP Packets Lost
Definition re_rtp.h:128
struct rtcp_stats::@15 rx
Defines the RTP header.
Definition re_rtp.h:18
bool ext
Extension bit
Definition re_rtp.h:21
uint16_t seq
Sequence number
Definition re_rtp.h:25
uint8_t cc
CSRC count
Definition re_rtp.h:22
bool m
Marker bit
Definition re_rtp.h:23
bool pad
Padding bit
Definition re_rtp.h:20
uint32_t ts
Timestamp
Definition re_rtp.h:26
uint32_t csrc[16]
Contributing sources
Definition re_rtp.h:28
uint8_t pt
Payload type
Definition re_rtp.h:24
uint16_t type
Defined by profile
Definition re_rtp.h:30
uint32_t ssrc
Synchronization source.
Definition re_rtp.h:27
uint16_t len
Number of 32-bit words.
Definition re_rtp.h:31
struct rtp_header::@10 x
uint8_t ver
RTP version number
Definition re_rtp.h:19
void list()
Definition userAdmin.cxx:66