Audio rework, new jitter buffer
Jitter buffer is now based on packets, not on samples. The frames are dejittered in received form. After reading from jitter buffer, they are decoded in correct order. If a frame is missing, it is concealed by repeating audio.
This commit is contained in:
@@ -297,7 +297,11 @@ again:
|
||||
case DSP_MODE_AUDIO:
|
||||
memset(power, 1, length);
|
||||
input_num = samplerate_upsample_input_num(&sender->srstate, length);
|
||||
jitter_load(&sender->dejitter, samples, input_num);
|
||||
{
|
||||
int16_t spl[input_num];
|
||||
jitter_load_samples(&sender->dejitter, (uint8_t *)spl, input_num, sizeof(*spl), jitter_conceal_s16, NULL);
|
||||
int16_to_samples_speech(samples, spl, input_num);
|
||||
}
|
||||
samplerate_upsample(&sender->srstate, samples, input_num, samples, length);
|
||||
if (imts->pre_emphasis)
|
||||
pre_emphasis(&imts->estate, samples, length);
|
||||
@@ -549,6 +553,8 @@ void imts_set_dsp_mode(imts_t *imts, enum dsp_mode mode, int tone, double durati
|
||||
imts->demod_duration = 0.0;
|
||||
}
|
||||
|
||||
if (mode == DSP_MODE_AUDIO && imts->dsp_mode != mode)
|
||||
jitter_reset(&imts->sender.dejitter);
|
||||
if (imts->dsp_mode != mode) {
|
||||
LOGP_CHAN(DDSP, LOGL_DEBUG, "DSP mode %s -> %s\n", imts_dsp_mode_name(imts->dsp_mode), imts_dsp_mode_name(mode));
|
||||
imts->dsp_mode = mode;
|
||||
@@ -564,3 +570,27 @@ void imts_set_dsp_mode(imts_t *imts, enum dsp_mode mode, int tone, double durati
|
||||
}
|
||||
}
|
||||
|
||||
/* Receive audio from call instance. */
|
||||
void call_down_audio(void *decoder, void *decoder_priv, int callref, uint16_t sequence, uint8_t marker, uint32_t timestamp, uint32_t ssrc, uint8_t *payload, int payload_len)
|
||||
{
|
||||
sender_t *sender;
|
||||
imts_t *imts;
|
||||
|
||||
for (sender = sender_head; sender; sender = sender->next) {
|
||||
imts = (imts_t *) sender;
|
||||
if (imts->callref == callref)
|
||||
break;
|
||||
}
|
||||
if (!sender)
|
||||
return;
|
||||
|
||||
if (imts->dsp_mode == DSP_MODE_AUDIO) {
|
||||
jitter_frame_t *jf;
|
||||
jf = jitter_frame_alloc(decoder, decoder_priv, payload, payload_len, marker, sequence, timestamp, ssrc);
|
||||
if (jf)
|
||||
jitter_save(&imts->sender.dejitter, jf);
|
||||
}
|
||||
}
|
||||
|
||||
void call_down_clock(void) {}
|
||||
|
||||
|
@@ -1290,26 +1290,5 @@ void call_down_release(int callref, __attribute__((unused)) int cause)
|
||||
}
|
||||
}
|
||||
|
||||
/* Receive audio from call instance. */
|
||||
void call_down_audio(int callref, uint16_t sequence, uint32_t timestamp, uint32_t ssrc, sample_t *samples, int count)
|
||||
{
|
||||
sender_t *sender;
|
||||
imts_t *imts;
|
||||
|
||||
for (sender = sender_head; sender; sender = sender->next) {
|
||||
imts = (imts_t *) sender;
|
||||
if (imts->callref == callref)
|
||||
break;
|
||||
}
|
||||
if (!sender)
|
||||
return;
|
||||
|
||||
if (imts->dsp_mode == DSP_MODE_AUDIO) {
|
||||
jitter_save(&imts->sender.dejitter, samples, count, 1, sequence, timestamp, ssrc);
|
||||
}
|
||||
}
|
||||
|
||||
void call_down_clock(void) {}
|
||||
|
||||
void dump_info(void) {}
|
||||
|
||||
|
Reference in New Issue
Block a user