annotate include/endp.h @ 30:9fd693f234f8

definitions for RTCP SDES
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 08 Jul 2024 03:28:38 +0000
parents 3e01a71b7c7c
children aa97e77e7de6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * twrtp_endp is the big abstraction provided by libtwrtp: a complete
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * RTP endpoint with RTP & RTCP sockets, sending and receiving both types
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * of packets, and incorporating twjit.
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #pragma once
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdint.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdbool.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <osmocom/core/osmo_io.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <osmocom/core/socket.h>
29
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
14 #include <osmocom/core/timer.h>
19
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include <themwi/rtp/twjit.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 struct twrtp_endp_tx {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 uint32_t ssrc;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 uint32_t ts;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 uint16_t seq;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 bool started;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 bool restart;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 };
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
29
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
26 struct twrtp_endp_rtcp_rx {
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
27 uint32_t sr_ssrc;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
28 uint16_t sr_ntp_sec;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
29 uint16_t sr_ntp_fract;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
30 struct timespec sr_rx_time;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
31 uint32_t rr_lost_word;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
32 uint32_t rr_jitter;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
33 bool got_sr;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
34 bool got_rr;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
35 };
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
36
19
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 struct twrtp_endp_stats {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 uint32_t rx_rtp_pkt;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 uint32_t rx_rtp_badsrc;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 uint32_t rx_rtcp_pkt;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 uint32_t rx_rtcp_badsrc;
29
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
42 uint32_t rx_rtcp_invalid;
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
43 uint32_t rx_rtcp_wrong_ssrc;
19
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 uint32_t tx_rtp_pkt;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 uint32_t tx_rtp_bytes;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 uint32_t tx_rtcp_pkt;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 };
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 struct twrtp_endp {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 /* the root of the matter: the two sockets */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 int rtp_fd;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 int rtcp_fd;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 struct osmo_io_fd *iofd_rtp;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 struct osmo_io_fd *iofd_rtcp;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 struct osmo_sockaddr rtp_remote;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 struct osmo_sockaddr rtcp_remote;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 /* Rx and Tx state */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 struct twrtp_jibuf_inst *twjit;
29
3e01a71b7c7c implement RTCP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
59 struct twrtp_endp_rtcp_rx rtcp_rx;
19
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 struct twrtp_endp_tx tx;
30
9fd693f234f8 definitions for RTCP SDES
Mychaela Falconia <falcon@freecalypso.org>
parents: 29
diff changeset
61 uint8_t *sdes_buf;
9fd693f234f8 definitions for RTCP SDES
Mychaela Falconia <falcon@freecalypso.org>
parents: 29
diff changeset
62 uint16_t sdes_len;
9fd693f234f8 definitions for RTCP SDES
Mychaela Falconia <falcon@freecalypso.org>
parents: 29
diff changeset
63 uint16_t auto_rtcp_interval;
19
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 /* always have to have stats */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 struct twrtp_endp_stats stats;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 /* bool flags at the end for structure packing optimization */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 bool register_done;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 bool remote_set;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 bool rx_enable;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 };
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 /* public API functions */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 struct twrtp_endp *twrtp_endp_create(void *ctx,
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 struct twrtp_jibuf_config *config);
20
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
76 void twrtp_endp_destroy(struct twrtp_endp *endp);
19
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
20
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
78 int twrtp_endp_register_fds(struct twrtp_endp *endp);
21
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents: 20
diff changeset
79 int twrtp_endp_bind_ip_port(struct twrtp_endp *endp, const char *ip,
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents: 20
diff changeset
80 uint16_t port);
22
587437b62ed5 implement twrtp_endp_set_remote_ipv4()
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
81
587437b62ed5 implement twrtp_endp_set_remote_ipv4()
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
82 void twrtp_endp_set_remote_ipv4(struct twrtp_endp *endp,
587437b62ed5 implement twrtp_endp_set_remote_ipv4()
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
83 const struct in_addr *ip, uint16_t port);
24
84d427017d2f endp: implement RTP Tx
Mychaela Falconia <falcon@freecalypso.org>
parents: 22
diff changeset
84
84d427017d2f endp: implement RTP Tx
Mychaela Falconia <falcon@freecalypso.org>
parents: 22
diff changeset
85 int twrtp_endp_tx_quantum(struct twrtp_endp *endp, const uint8_t *payload,
84d427017d2f endp: implement RTP Tx
Mychaela Falconia <falcon@freecalypso.org>
parents: 22
diff changeset
86 unsigned payload_len, uint8_t payload_type,
26
f71efdd08c33 RTP Tx: add auto_marker mode of operation
Mychaela Falconia <falcon@freecalypso.org>
parents: 24
diff changeset
87 bool marker, bool auto_marker, bool send_rtcp);
27
a0b89c028053 RTP Tx: implement skip operation
Mychaela Falconia <falcon@freecalypso.org>
parents: 26
diff changeset
88 void twrtp_endp_tx_skip(struct twrtp_endp *endp);
30
9fd693f234f8 definitions for RTCP SDES
Mychaela Falconia <falcon@freecalypso.org>
parents: 29
diff changeset
89
9fd693f234f8 definitions for RTCP SDES
Mychaela Falconia <falcon@freecalypso.org>
parents: 29
diff changeset
90 int twrtp_endp_set_sdes(struct twrtp_endp *endp, const char *cname,
9fd693f234f8 definitions for RTCP SDES
Mychaela Falconia <falcon@freecalypso.org>
parents: 29
diff changeset
91 const char *name, const char *email, const char *phone,
9fd693f234f8 definitions for RTCP SDES
Mychaela Falconia <falcon@freecalypso.org>
parents: 29
diff changeset
92 const char *loc, const char *tool, const char *note);