# HG changeset patch # User Mychaela Falconia # Date 1734570608 0 # Node ID 781f491f20dda365f0c020970681c436fb2052a8 # Parent 8f1700a42ca519e25c4dfdfc65a687d5b8e75171 set sensible osmo_io msgb alloc sizes for RTP & RTCP Rx diff -r 8f1700a42ca5 -r 781f491f20dd src/endp_create.c --- a/src/endp_create.c Sat Nov 23 19:08:28 2024 +0000 +++ b/src/endp_create.c Thu Dec 19 01:10:08 2024 +0000 @@ -12,8 +12,32 @@ #include #include +#include +#include #include "endp_internal.h" +/* We need to know maximum expected sizes of RTP and RTCP Rx packets + * for osmo_io msgb allocation. For RTP, the largest packet size in + * 3GPP and IP-PSTN applications is 176 bytes: 12 bytes of RTP header + * plus 160 bytes of payload for 20 ms of uncompressed G.711 audio + * or CSData. Of course there may be other applications that use + * larger RTP packets, in which case we may have to add an API function + * that overrides our default msgb alloc size setting - but let's + * cross that bridge if and when we actually have such users. + * + * In case of RTCP, we fully process all received packets inside + * the present library, hence we can set osmo_io msgb alloc size + * based on what our RTCP Rx code can parse and make use of. Any + * additional RTCP Rx data, such as very long SDES strings, will + * simply be truncated at osmo_io level - but the subsequent parsing + * code will never get to those bits anyway. + */ + +#define MAX_RTP_RX_PACKET (sizeof(struct rtp_basic_hdr) + 160) +#define MAX_RTCP_RX_PACKET (sizeof(struct rtcp_sr_rr_hdr) + \ + sizeof(struct rtcp_sr_block) + \ + sizeof(struct rtcp_rr_block) * 31) + struct twrtp_endp *twrtp_endp_create(void *ctx, struct twrtp_jibuf_config *config) { @@ -30,6 +54,7 @@ talloc_free(endp); return NULL; } + osmo_iofd_set_alloc_info(endp->iofd_rtp, MAX_RTP_RX_PACKET, 0); endp->iofd_rtcp = osmo_iofd_setup(endp, -1, NULL, OSMO_IO_FD_MODE_RECVFROM_SENDTO, @@ -39,6 +64,7 @@ talloc_free(endp); return NULL; } + osmo_iofd_set_alloc_info(endp->iofd_rtcp, MAX_RTCP_RX_PACKET, 0); endp->twjit = twrtp_jibuf_create(endp, config); if (!endp->twjit) {