FreeCalypso > hg > themwi-rtp-lib
changeset 15:355de6301404
twjit: simplify create API, factor out clock & quantum config
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 Jul 2024 21:31:16 +0000 |
parents | 073b8c7b361f |
children | 58e9719d1a84 |
files | include/twjit.h src/twjit.c |
diffstat | 2 files changed, 27 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/include/twjit.h Sat Jul 06 17:32:26 2024 +0000 +++ b/include/twjit.h Sat Jul 06 21:31:16 2024 +0000 @@ -129,9 +129,18 @@ /* twjit module API 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 * +twrtp_jibuf_create(void *ctx, struct twrtp_jibuf_config *config); + +/* + * The default timescale is 8 kHz (8000 samples per second), + * and the default quantum duration (packetization interval) is 20 ms. + * The following function can be used to change these fundamental + * parameters; it may be called only right after twrtp_jibuf_create(), + * before any packets are fed to twrtp_jibuf_input(). + */ +void twrtp_jibuf_set_ts_quant(struct twrtp_jibuf_inst *twjit, + uint16_t clock_khz, uint16_t quantum_ms); void twrtp_jibuf_destroy(struct twrtp_jibuf_inst *twjit);
--- a/src/twjit.c Sat Jul 06 17:32:26 2024 +0000 +++ b/src/twjit.c Sat Jul 06 21:31:16 2024 +0000 @@ -25,8 +25,7 @@ /* 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) +twrtp_jibuf_create(void *ctx, struct twrtp_jibuf_config *config) { struct twrtp_jibuf_inst *twjit; @@ -35,14 +34,11 @@ 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); + /* default of 8 kHz clock, 20 ms quantum */ + twrtp_jibuf_set_ts_quant(twjit, 8, 20); return twjit; } @@ -53,3 +49,15 @@ msgb_queue_free(&twjit->sb[1].queue); talloc_free(twjit); } + +/* basic housekeeping */ + +void twrtp_jibuf_set_ts_quant(struct twrtp_jibuf_inst *twjit, + uint16_t clock_khz, uint16_t quantum_ms) +{ + 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; +}