comparison src/rtp_rx.c @ 23:9e477a4b485a

endp: implement RTP Rx
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Jul 2024 06:27:56 +0000
parents
children
comparison
equal deleted inserted replaced
22:587437b62ed5 23:9e477a4b485a
1 /*
2 * Here we implement RTP Rx path via osmo_io callback.
3 */
4
5 #include <stdint.h>
6 #include <stdbool.h>
7
8 #include <osmocom/core/msgb.h>
9 #include <osmocom/core/osmo_io.h>
10 #include <osmocom/core/socket.h>
11 #include <osmocom/core/utils.h>
12
13 #include <themwi/rtp/endp.h>
14 #include <themwi/rtp/twjit.h>
15 #include "endp_internal.h"
16
17 static void rtp_rx_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg,
18 const struct osmo_sockaddr *saddr)
19 {
20 struct twrtp_endp *endp = osmo_iofd_get_data(iofd);
21
22 if (!msg)
23 return;
24 if (!endp->remote_set) {
25 msgb_free(msg);
26 return;
27 }
28 if (osmo_sockaddr_cmp(saddr, &endp->rtp_remote)) {
29 endp->stats.rx_rtp_badsrc++;
30 msgb_free(msg);
31 return;
32 }
33 endp->stats.rx_rtp_pkt++;
34 if (endp->rx_enable)
35 twrtp_jibuf_input(endp->twjit, msg);
36 else
37 msgb_free(msg);
38 }
39
40 const struct osmo_io_ops _twrtp_endp_iops_rtp = {
41 .recvfrom_cb = rtp_rx_cb,
42 };