From 2b7efedc483362d3afc2ae71dfb716ac5427f600 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 31 Jul 2022 07:55:14 +0200 Subject: Refactoring jitter buffer Features are: * Packet based buffer * Random in, first out * Adaptive delay compensation (voice) * Fixed delay (data, optionally MODEM/FAX) * Interpolation of missing frames * Any sample size --- src/anetz/anetz.c | 9 +++------ src/anetz/dsp.c | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/anetz') diff --git a/src/anetz/anetz.c b/src/anetz/anetz.c index d5e1a76..3af185b 100644 --- a/src/anetz/anetz.c +++ b/src/anetz/anetz.c @@ -513,7 +513,7 @@ void call_down_release(int callref, __attribute__((unused)) int cause) } /* Receive audio from call instance. */ -void call_down_audio(int callref, sample_t *samples, int count) +void call_down_audio(int callref, uint16_t sequence, uint32_t timestamp, uint32_t ssrc, sample_t *samples, int count) { sender_t *sender; anetz_t *anetz; @@ -526,11 +526,8 @@ void call_down_audio(int callref, sample_t *samples, int count) if (!sender) return; - if (anetz->dsp_mode == DSP_MODE_AUDIO) { - sample_t up[(int)((double)count * anetz->sender.srstate.factor + 0.5) + 10]; - count = samplerate_upsample(&anetz->sender.srstate, samples, count, up); - jitter_save(&anetz->sender.dejitter, up, count); - } + if (anetz->dsp_mode == DSP_MODE_AUDIO) + jitter_save(&anetz->sender.dejitter, samples, count, 1, sequence, timestamp, ssrc); } void call_down_clock(void) {} diff --git a/src/anetz/dsp.c b/src/anetz/dsp.c index 1bc20a1..e9a4dbb 100644 --- a/src/anetz/dsp.c +++ b/src/anetz/dsp.c @@ -357,6 +357,7 @@ static void fsk_tone(anetz_t *anetz, sample_t *samples, int length) void sender_send(sender_t *sender, sample_t *samples, uint8_t *power, int length) { anetz_t *anetz = (anetz_t *) sender; + int input_num; memset(power, 1, length); @@ -365,7 +366,9 @@ void sender_send(sender_t *sender, sample_t *samples, uint8_t *power, int length memset(samples, 0, length * sizeof(*samples)); break; case DSP_MODE_AUDIO: - jitter_load(&anetz->sender.dejitter, samples, length); + input_num = samplerate_upsample_input_num(&sender->srstate, length); + jitter_load(&sender->dejitter, samples, input_num); + samplerate_upsample(&sender->srstate, samples, input_num, samples, length); break; case DSP_MODE_TONE: fsk_tone(anetz, samples, length); -- cgit v1.2.3