annotate include/endp.h @ 19:b8cb5146e5b4

endp: beginning
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Jul 2024 02:14:01 +0000
parents
children 695fdb670d30
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>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <themwi/rtp/twjit.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 struct twrtp_endp_tx {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 uint32_t ssrc;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 uint32_t ts;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 uint16_t seq;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 bool started;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 bool restart;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 };
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 struct twrtp_endp_stats {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 uint32_t rx_rtp_pkt;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 uint32_t rx_rtp_badsrc;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 uint32_t rx_rtcp_pkt;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 uint32_t rx_rtcp_badsrc;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 uint32_t tx_rtp_pkt;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 uint32_t tx_rtp_bytes;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 uint32_t tx_rtcp_pkt;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 };
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 struct twrtp_endp {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 /* the root of the matter: the two sockets */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 int rtp_fd;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 int rtcp_fd;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 struct osmo_io_fd *iofd_rtp;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 struct osmo_io_fd *iofd_rtcp;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 struct osmo_sockaddr rtp_remote;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 struct osmo_sockaddr rtcp_remote;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 /* Rx and Tx state */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 struct twrtp_jibuf_inst *twjit;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /* RTCP Rx structure to be inserted here */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 struct twrtp_endp_tx tx;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 /* always have to have stats */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 struct twrtp_endp_stats stats;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 /* bool flags at the end for structure packing optimization */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 bool register_done;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 bool remote_set;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 bool rx_enable;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 };
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* public API functions */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 struct twrtp_endp *twrtp_endp_create(void *ctx,
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 struct twrtp_jibuf_config *config);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 void twrtp_endp_destroy(struct twrtp_endp *endp);