FreeCalypso > hg > themwi-rtp-lib
comparison src/endp_create.c @ 38:781f491f20dd
set sensible osmo_io msgb alloc sizes for RTP & RTCP Rx
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 19 Dec 2024 01:10:08 +0000 (2 months ago) |
parents | 84d427017d2f |
children | 8cdfef36d9db |
comparison
equal
deleted
inserted
replaced
37:8f1700a42ca5 | 38:781f491f20dd |
---|---|
10 #include <osmocom/core/osmo_io.h> | 10 #include <osmocom/core/osmo_io.h> |
11 #include <osmocom/core/utils.h> | 11 #include <osmocom/core/utils.h> |
12 | 12 |
13 #include <themwi/rtp/endp.h> | 13 #include <themwi/rtp/endp.h> |
14 #include <themwi/rtp/twjit.h> | 14 #include <themwi/rtp/twjit.h> |
15 #include <themwi/rtp/rtp_basic_hdr.h> | |
16 #include <themwi/rtp/rtcp_defs.h> | |
15 #include "endp_internal.h" | 17 #include "endp_internal.h" |
18 | |
19 /* We need to know maximum expected sizes of RTP and RTCP Rx packets | |
20 * for osmo_io msgb allocation. For RTP, the largest packet size in | |
21 * 3GPP and IP-PSTN applications is 176 bytes: 12 bytes of RTP header | |
22 * plus 160 bytes of payload for 20 ms of uncompressed G.711 audio | |
23 * or CSData. Of course there may be other applications that use | |
24 * larger RTP packets, in which case we may have to add an API function | |
25 * that overrides our default msgb alloc size setting - but let's | |
26 * cross that bridge if and when we actually have such users. | |
27 * | |
28 * In case of RTCP, we fully process all received packets inside | |
29 * the present library, hence we can set osmo_io msgb alloc size | |
30 * based on what our RTCP Rx code can parse and make use of. Any | |
31 * additional RTCP Rx data, such as very long SDES strings, will | |
32 * simply be truncated at osmo_io level - but the subsequent parsing | |
33 * code will never get to those bits anyway. | |
34 */ | |
35 | |
36 #define MAX_RTP_RX_PACKET (sizeof(struct rtp_basic_hdr) + 160) | |
37 #define MAX_RTCP_RX_PACKET (sizeof(struct rtcp_sr_rr_hdr) + \ | |
38 sizeof(struct rtcp_sr_block) + \ | |
39 sizeof(struct rtcp_rr_block) * 31) | |
16 | 40 |
17 struct twrtp_endp *twrtp_endp_create(void *ctx, | 41 struct twrtp_endp *twrtp_endp_create(void *ctx, |
18 struct twrtp_jibuf_config *config) | 42 struct twrtp_jibuf_config *config) |
19 { | 43 { |
20 struct twrtp_endp *endp; | 44 struct twrtp_endp *endp; |
28 &_twrtp_endp_iops_rtp, endp); | 52 &_twrtp_endp_iops_rtp, endp); |
29 if (!endp->iofd_rtp) { | 53 if (!endp->iofd_rtp) { |
30 talloc_free(endp); | 54 talloc_free(endp); |
31 return NULL; | 55 return NULL; |
32 } | 56 } |
57 osmo_iofd_set_alloc_info(endp->iofd_rtp, MAX_RTP_RX_PACKET, 0); | |
33 | 58 |
34 endp->iofd_rtcp = osmo_iofd_setup(endp, -1, NULL, | 59 endp->iofd_rtcp = osmo_iofd_setup(endp, -1, NULL, |
35 OSMO_IO_FD_MODE_RECVFROM_SENDTO, | 60 OSMO_IO_FD_MODE_RECVFROM_SENDTO, |
36 &_twrtp_endp_iops_rtcp, endp); | 61 &_twrtp_endp_iops_rtcp, endp); |
37 if (!endp->iofd_rtcp) { | 62 if (!endp->iofd_rtcp) { |
38 osmo_iofd_free(endp->iofd_rtp); | 63 osmo_iofd_free(endp->iofd_rtp); |
39 talloc_free(endp); | 64 talloc_free(endp); |
40 return NULL; | 65 return NULL; |
41 } | 66 } |
67 osmo_iofd_set_alloc_info(endp->iofd_rtcp, MAX_RTCP_RX_PACKET, 0); | |
42 | 68 |
43 endp->twjit = twrtp_jibuf_create(endp, config); | 69 endp->twjit = twrtp_jibuf_create(endp, config); |
44 if (!endp->twjit) { | 70 if (!endp->twjit) { |
45 osmo_iofd_free(endp->iofd_rtp); | 71 osmo_iofd_free(endp->iofd_rtp); |
46 osmo_iofd_free(endp->iofd_rtcp); | 72 osmo_iofd_free(endp->iofd_rtcp); |