FreeCalypso > hg > themwi-rtp-lib
annotate src/rtp_rx.c @ 37:8f1700a42ca5 default tip
set_remote: add functions for IPv6 and for sockaddr_{in,in6}
A convenient way to pass in remote end address as struct sockaddr_in
is needed for tw-border-mgw; IPv6 support will be needed in order to
bring twrtp_endp into Osmocom mainline.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 23 Nov 2024 19:08:28 +0000 |
parents | 9e477a4b485a |
children |
rev | line source |
---|---|
23
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Here we implement RTP Rx path via osmo_io callback. |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdint.h> |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdbool.h> |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <osmocom/core/msgb.h> |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <osmocom/core/osmo_io.h> |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <osmocom/core/socket.h> |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <osmocom/core/utils.h> |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <themwi/rtp/endp.h> |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <themwi/rtp/twjit.h> |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "endp_internal.h" |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 static void rtp_rx_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg, |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 const struct osmo_sockaddr *saddr) |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 { |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 struct twrtp_endp *endp = osmo_iofd_get_data(iofd); |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (!msg) |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return; |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (!endp->remote_set) { |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 msgb_free(msg); |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 return; |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 if (osmo_sockaddr_cmp(saddr, &endp->rtp_remote)) { |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 endp->stats.rx_rtp_badsrc++; |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 msgb_free(msg); |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 return; |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 endp->stats.rx_rtp_pkt++; |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (endp->rx_enable) |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 twrtp_jibuf_input(endp->twjit, msg); |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 else |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 msgb_free(msg); |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 const struct osmo_io_ops _twrtp_endp_iops_rtp = { |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 .recvfrom_cb = rtp_rx_cb, |
9e477a4b485a
endp: implement RTP Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 }; |