FreeCalypso > hg > themwi-rtp-lib
changeset 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 |
parents | 8f1700a42ca5 |
children | 1485211d4492 |
files | src/endp_create.c |
diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <themwi/rtp/endp.h> #include <themwi/rtp/twjit.h> +#include <themwi/rtp/rtp_basic_hdr.h> +#include <themwi/rtp/rtcp_defs.h> #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) {