FreeCalypso > hg > themwi-rtp-lib
view src/twjit.c @ 12:323957bebd53
twjit: smarter counting of underruns
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 Jul 2024 02:47:21 +0000 |
parents | 95f6c8ce33b0 |
children | 355de6301404 |
line wrap: on
line source
/* * Themyscira Wireless jitter buffer implementation: main body. */ #include <stdint.h> #include <stdbool.h> #include <string.h> #include <osmocom/core/linuxlist.h> #include <osmocom/core/msgb.h> #include <osmocom/core/talloc.h> #include <osmocom/core/utils.h> #include <themwi/rtp/twjit.h> void twrtp_jibuf_init_defaults(struct twrtp_jibuf_config *config) { memset(config, 0, sizeof(struct twrtp_jibuf_config)); config->bd_start = 2; /* smallest allowed */ config->bd_hiwat = 3; /* Nstart+1 is practically-useful minimum */ config->thinning_int = 17; /* prime number, usually 340 ms */ config->max_future_sec = 10; /* 10 s is a long time for voice */ } /* create and destroy functions */ struct twrtp_jibuf_inst * twrtp_jibuf_create(void *ctx, uint16_t quantum_ms, uint16_t clock_khz, struct twrtp_jibuf_config *config) { struct twrtp_jibuf_inst *twjit; twjit = talloc_zero(ctx, struct twrtp_jibuf_inst); if (!twjit) return NULL; twjit->ext_config = config; twjit->ts_quantum = (uint32_t)quantum_ms * clock_khz; twjit->quanta_per_sec = 1000 / quantum_ms; twjit->ts_units_per_ms = clock_khz; twjit->ts_units_per_sec = (uint32_t) clock_khz * 1000; twjit->ns_to_ts_units = 1000000 / clock_khz; twjit->state = TWJIT_STATE_EMPTY; INIT_LLIST_HEAD(&twjit->sb[0].queue); INIT_LLIST_HEAD(&twjit->sb[1].queue); return twjit; } void twrtp_jibuf_destroy(struct twrtp_jibuf_inst *twjit) { msgb_queue_free(&twjit->sb[0].queue); msgb_queue_free(&twjit->sb[1].queue); talloc_free(twjit); }