diff --git a/lib/codeclib.c b/lib/codeclib.c index 2b78a0463..06ecdae1c 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -2010,6 +2010,7 @@ void encoder_close(encoder_t *enc) { void encoder_free(encoder_t *enc) { encoder_close(enc); av_packet_free(&enc->avpkt); + resample_shutdown(&enc->resampler); g_slice_free1(sizeof(*enc), enc); } @@ -2150,8 +2151,14 @@ static int encoder_fifo_flush(encoder_t *enc, int encoder_input_fifo(encoder_t *enc, AVFrame *frame, int (*callback)(encoder_t *, void *u1, void *u2), void *u1, void *u2) { - if (av_audio_fifo_write(enc->fifo, (void **) frame->extended_data, frame->nb_samples) < 0) + AVFrame *rsmp_frame = resample_frame(&enc->resampler, frame, &enc->actual_format); + if (!rsmp_frame) { + ilog(LOG_ERR | LOG_FLAG_LIMIT, "Resampling failed"); return -1; + } + if (av_audio_fifo_write(enc->fifo, (void **) rsmp_frame->extended_data, rsmp_frame->nb_samples) < 0) + return -1; + av_frame_free(&rsmp_frame); return encoder_fifo_flush(enc, callback, u1, u2); } diff --git a/lib/codeclib.h b/lib/codeclib.h index 57d5c68d9..ef44fdb39 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -327,6 +327,8 @@ struct encoder_s { encoder_callback_t callback; union codec_format_options format_options; + resample_t resampler; + union { struct { const AVCodec *codec; diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index 17fb9cd07..434af6135 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -83,6 +83,164 @@ sub stun_succ { +($sock_a, $sock_b) = new_call([qw(198.51.100.65 3000)], [qw(198.51.100.65 3002)]); + +($port_a) = offer('opus<>opus+DTMF', { }, <opus+DTMF', { flags => [qw,allow-asymmetric-codecs,] }, <opus+DTMF', { codec => { accept => ['all'], transcode => [qw,G722 PCMA,] } }, <opus+DTMF', { }, <