19
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * twrtp_endp is the big abstraction provided by libtwrtp: a complete
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * RTP endpoint with RTP & RTCP sockets, sending and receiving both types
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * of packets, and incorporating twjit.
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #pragma once
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdint.h>
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdbool.h>
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <osmocom/core/osmo_io.h>
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <osmocom/core/socket.h>
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <themwi/rtp/twjit.h>
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 struct twrtp_endp_tx {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 uint32_t ssrc;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 uint32_t ts;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 uint16_t seq;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 bool started;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 bool restart;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 };
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct twrtp_endp_stats {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 uint32_t rx_rtp_pkt;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 uint32_t rx_rtp_badsrc;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 uint32_t rx_rtcp_pkt;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 uint32_t rx_rtcp_badsrc;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 uint32_t tx_rtp_pkt;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 uint32_t tx_rtp_bytes;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 uint32_t tx_rtcp_pkt;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 };
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 struct twrtp_endp {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 /* the root of the matter: the two sockets */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 int rtp_fd;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 int rtcp_fd;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 struct osmo_io_fd *iofd_rtp;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 struct osmo_io_fd *iofd_rtcp;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 struct osmo_sockaddr rtp_remote;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 struct osmo_sockaddr rtcp_remote;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* Rx and Tx state */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 struct twrtp_jibuf_inst *twjit;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* RTCP Rx structure to be inserted here */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 struct twrtp_endp_tx tx;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /* always have to have stats */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 struct twrtp_endp_stats stats;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 /* bool flags at the end for structure packing optimization */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 bool register_done;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 bool remote_set;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 bool rx_enable;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 };
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 /* public API functions */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 struct twrtp_endp *twrtp_endp_create(void *ctx,
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 struct twrtp_jibuf_config *config);
|
20
|
59 void twrtp_endp_destroy(struct twrtp_endp *endp);
|
19
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60
|
20
|
61 int twrtp_endp_register_fds(struct twrtp_endp *endp);
|