FreeCalypso > hg > themwi-rtp-lib
view src/twjit.c @ 8:95f6c8ce33b0
twjit: prep for rework of time delta handling
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 05 Jul 2024 21:57:51 +0000 |
parents | 668b84c52094 |
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); }