WebRTC Opus C interface: Add support for non-48 kHz encode sample rate

Plus tests fo 16 kHz.

Bug: webrtc:10631
Change-Id: I162c40b6120d7e308e535faba7501e437b0b5dc4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137047
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28029}
This commit is contained in:
Karl Wiberg
2019-05-21 11:50:32 +02:00
committed by Commit Bot
parent 646fda0212
commit 7e7c5c3c25
9 changed files with 182 additions and 154 deletions

View File

@ -39,7 +39,8 @@ enum {
int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst,
size_t channels,
int32_t application) {
int32_t application,
int sample_rate_hz) {
int opus_app;
if (!inst)
return -1;
@ -59,7 +60,7 @@ int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst,
RTC_DCHECK(state);
int error;
state->encoder = opus_encoder_create(48000, (int)channels, opus_app,
state->encoder = opus_encoder_create(sample_rate_hz, (int)channels, opus_app,
&error);
if (error != OPUS_OK || (!state->encoder &&