FreeCalypso > hg > themwi-rtp-lib
annotate include/endp.h @ 24:84d427017d2f
endp: implement RTP Tx
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Jul 2024 07:33:48 +0000 |
parents | 587437b62ed5 |
children | f71efdd08c33 |
rev | line source |
---|---|
19 | 1 /* |
2 * twrtp_endp is the big abstraction provided by libtwrtp: a complete | |
3 * RTP endpoint with RTP & RTCP sockets, sending and receiving both types | |
4 * of packets, and incorporating twjit. | |
5 */ | |
6 | |
7 #pragma once | |
8 | |
9 #include <stdint.h> | |
10 #include <stdbool.h> | |
11 | |
12 #include <osmocom/core/osmo_io.h> | |
13 #include <osmocom/core/socket.h> | |
14 | |
15 #include <themwi/rtp/twjit.h> | |
16 | |
17 struct twrtp_endp_tx { | |
18 uint32_t ssrc; | |
19 uint32_t ts; | |
20 uint16_t seq; | |
21 bool started; | |
22 bool restart; | |
23 }; | |
24 | |
25 struct twrtp_endp_stats { | |
26 uint32_t rx_rtp_pkt; | |
27 uint32_t rx_rtp_badsrc; | |
28 uint32_t rx_rtcp_pkt; | |
29 uint32_t rx_rtcp_badsrc; | |
30 uint32_t tx_rtp_pkt; | |
31 uint32_t tx_rtp_bytes; | |
32 uint32_t tx_rtcp_pkt; | |
33 }; | |
34 | |
35 struct twrtp_endp { | |
36 /* the root of the matter: the two sockets */ | |
37 int rtp_fd; | |
38 int rtcp_fd; | |
39 struct osmo_io_fd *iofd_rtp; | |
40 struct osmo_io_fd *iofd_rtcp; | |
41 struct osmo_sockaddr rtp_remote; | |
42 struct osmo_sockaddr rtcp_remote; | |
43 /* Rx and Tx state */ | |
44 struct twrtp_jibuf_inst *twjit; | |
45 /* RTCP Rx structure to be inserted here */ | |
46 struct twrtp_endp_tx tx; | |
47 /* always have to have stats */ | |
48 struct twrtp_endp_stats stats; | |
49 /* bool flags at the end for structure packing optimization */ | |
50 bool register_done; | |
51 bool remote_set; | |
52 bool rx_enable; | |
53 }; | |
54 | |
55 /* public API functions */ | |
56 | |
57 struct twrtp_endp *twrtp_endp_create(void *ctx, | |
58 struct twrtp_jibuf_config *config); | |
20
695fdb670d30
implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
59 void twrtp_endp_destroy(struct twrtp_endp *endp); |
19 | 60 |
20
695fdb670d30
implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
61 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
|
62 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
|
63 uint16_t port); |
22
587437b62ed5
implement twrtp_endp_set_remote_ipv4()
Mychaela Falconia <falcon@freecalypso.org>
parents:
21
diff
changeset
|
64 |
587437b62ed5
implement twrtp_endp_set_remote_ipv4()
Mychaela Falconia <falcon@freecalypso.org>
parents:
21
diff
changeset
|
65 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
|
66 const struct in_addr *ip, uint16_t port); |
24
84d427017d2f
endp: implement RTP Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
67 |
84d427017d2f
endp: implement RTP Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
68 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
|
69 unsigned payload_len, uint8_t payload_type, |
84d427017d2f
endp: implement RTP Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
70 bool marker, bool send_rtcp); |