ACM: Adding support for more than 2 channels in the send pipeline
This CL adds support in the audio coding module for sending more than 2 channels to the encoder. Bug: webrtc:11007 Change-Id: I0909b5c37a54c9d2e1353b864e55008cda50ffae Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/155583 Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Reviewed-by: Alex Loiko <aleloi@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29385}
This commit is contained in:
@ -1634,6 +1634,96 @@ TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_50kbps) {
|
||||
RunInner(40000, 60000);
|
||||
}
|
||||
|
||||
// Verify that it works when the data to send is mono and the encoder is set to
|
||||
// send surround audio.
|
||||
TEST_F(AudioCodingModuleTestOldApi, SendingMultiChannelForMonoInput) {
|
||||
constexpr int kSampleRateHz = 48000;
|
||||
constexpr int kSamplesPerChannel = (kSampleRateHz * 10) / 1000;
|
||||
|
||||
audio_format_ = SdpAudioFormat({"multiopus",
|
||||
kSampleRateHz,
|
||||
6,
|
||||
{{"minptime", "10"},
|
||||
{"useinbandfec", "1"},
|
||||
{"channel_mapping", "0,4,1,2,3,5"},
|
||||
{"num_streams", "4"},
|
||||
{"coupled_streams", "2"}}});
|
||||
|
||||
RegisterCodec();
|
||||
|
||||
input_frame_.sample_rate_hz_ = kSampleRateHz;
|
||||
input_frame_.num_channels_ = 1;
|
||||
input_frame_.samples_per_channel_ = kSamplesPerChannel;
|
||||
for (size_t k = 0; k < 10; ++k) {
|
||||
ASSERT_GE(acm_->Add10MsData(input_frame_), 0);
|
||||
input_frame_.timestamp_ += kSamplesPerChannel;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that it works when the data to send is stereo and the encoder is set
|
||||
// to send surround audio.
|
||||
TEST_F(AudioCodingModuleTestOldApi, SendingMultiChannelForStereoInput) {
|
||||
constexpr int kSampleRateHz = 48000;
|
||||
constexpr int kSamplesPerChannel = (kSampleRateHz * 10) / 1000;
|
||||
|
||||
audio_format_ = SdpAudioFormat({"multiopus",
|
||||
kSampleRateHz,
|
||||
6,
|
||||
{{"minptime", "10"},
|
||||
{"useinbandfec", "1"},
|
||||
{"channel_mapping", "0,4,1,2,3,5"},
|
||||
{"num_streams", "4"},
|
||||
{"coupled_streams", "2"}}});
|
||||
|
||||
RegisterCodec();
|
||||
|
||||
input_frame_.sample_rate_hz_ = kSampleRateHz;
|
||||
input_frame_.num_channels_ = 2;
|
||||
input_frame_.samples_per_channel_ = kSamplesPerChannel;
|
||||
for (size_t k = 0; k < 10; ++k) {
|
||||
ASSERT_GE(acm_->Add10MsData(input_frame_), 0);
|
||||
input_frame_.timestamp_ += kSamplesPerChannel;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that it works when the data to send is mono and the encoder is set to
|
||||
// send stereo audio.
|
||||
TEST_F(AudioCodingModuleTestOldApi, SendingStereoForMonoInput) {
|
||||
constexpr int kSampleRateHz = 48000;
|
||||
constexpr int kSamplesPerChannel = (kSampleRateHz * 10) / 1000;
|
||||
|
||||
audio_format_ = SdpAudioFormat("opus", kSampleRateHz, 2);
|
||||
|
||||
RegisterCodec();
|
||||
|
||||
input_frame_.sample_rate_hz_ = kSampleRateHz;
|
||||
input_frame_.num_channels_ = 1;
|
||||
input_frame_.samples_per_channel_ = kSamplesPerChannel;
|
||||
for (size_t k = 0; k < 10; ++k) {
|
||||
ASSERT_GE(acm_->Add10MsData(input_frame_), 0);
|
||||
input_frame_.timestamp_ += kSamplesPerChannel;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that it works when the data to send is stereo and the encoder is set
|
||||
// to send mono audio.
|
||||
TEST_F(AudioCodingModuleTestOldApi, SendingMonoForStereoInput) {
|
||||
constexpr int kSampleRateHz = 48000;
|
||||
constexpr int kSamplesPerChannel = (kSampleRateHz * 10) / 1000;
|
||||
|
||||
audio_format_ = SdpAudioFormat("L16", kSampleRateHz, 1);
|
||||
|
||||
RegisterCodec();
|
||||
|
||||
input_frame_.sample_rate_hz_ = kSampleRateHz;
|
||||
input_frame_.num_channels_ = 1;
|
||||
input_frame_.samples_per_channel_ = kSamplesPerChannel;
|
||||
for (size_t k = 0; k < 10; ++k) {
|
||||
ASSERT_GE(acm_->Add10MsData(input_frame_), 0);
|
||||
input_frame_.timestamp_ += kSamplesPerChannel;
|
||||
}
|
||||
}
|
||||
|
||||
// The result on the Android platforms is inconsistent for this test case.
|
||||
// On android_rel the result is different from android and android arm64 rel.
|
||||
#if defined(WEBRTC_ANDROID)
|
||||
|
||||
Reference in New Issue
Block a user