Set the maximum number of audio channels to 24

The number of audio channels can be configured in SDP, and can thus be
set to arbitrary values. However, the audio code has limitations that
prevent a high number of channels from working well in practice.

Bug: chromium:1265806
Change-Id: I6f6c3f68a3791bb189a614eece6bd0ed7874f252
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237807
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35359}
This commit is contained in:
Ivo Creusen
2021-11-16 15:11:28 +00:00
committed by WebRTC LUCI CQ
parent 584e3f9f8e
commit d823259c7f
12 changed files with 84 additions and 8 deletions

View File

@ -104,9 +104,9 @@ TEST(AudioDecoderFactoryTest, CreateL16) {
rtc::scoped_refptr<AudioDecoderFactory> adf =
CreateBuiltinAudioDecoderFactory();
ASSERT_TRUE(adf);
// L16 supports any clock rate, any number of channels.
// L16 supports any clock rate and any number of channels up to 24.
const int clockrates[] = {8000, 16000, 32000, 48000};
const int num_channels[] = {1, 2, 3, 4711};
const int num_channels[] = {1, 2, 3, 24};
for (int clockrate : clockrates) {
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, 0),
absl::nullopt));
@ -117,6 +117,34 @@ TEST(AudioDecoderFactoryTest, CreateL16) {
}
}
// Tests that using more channels than the maximum does not work
TEST(AudioDecoderFactoryTest, MaxNrOfChannels) {
rtc::scoped_refptr<AudioDecoderFactory> adf =
CreateBuiltinAudioDecoderFactory();
std::vector<std::string> codecs = {
#ifdef WEBRTC_CODEC_OPUS
"opus",
#endif
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
"isac",
#endif
#ifdef WEBRTC_CODEC_ILBC
"ilbc",
#endif
"pcmu",
"pcma",
"l16",
"G722",
"G711",
};
for (auto codec : codecs) {
EXPECT_FALSE(adf->MakeAudioDecoder(
SdpAudioFormat(codec, 32000, AudioDecoder::kMaxNumberOfChannels + 1),
absl::nullopt));
}
}
TEST(AudioDecoderFactoryTest, CreateG722) {
rtc::scoped_refptr<AudioDecoderFactory> adf =
CreateBuiltinAudioDecoderFactory();

View File

@ -144,4 +144,35 @@ TEST(BuiltinAudioEncoderFactoryTest, SupportsTheExpectedFormats) {
ASSERT_THAT(supported_formats, ElementsAreArray(expected_formats));
}
// Tests that using more channels than the maximum does not work.
TEST(BuiltinAudioEncoderFactoryTest, MaxNrOfChannels) {
rtc::scoped_refptr<AudioEncoderFactory> aef =
CreateBuiltinAudioEncoderFactory();
std::vector<std::string> codecs = {
#ifdef WEBRTC_CODEC_OPUS
"opus",
#endif
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
"isac",
#endif
#ifdef WEBRTC_CODEC_ILBC
"ilbc",
#endif
"pcmu",
"pcma",
"l16",
"G722",
"G711",
};
for (auto codec : codecs) {
EXPECT_FALSE(aef->MakeAudioEncoder(
/*payload_type=*/111,
/*format=*/
SdpAudioFormat(codec, 32000, AudioEncoder::kMaxNumberOfChannels + 1),
/*codec_pair_id=*/absl::nullopt));
}
}
} // namespace webrtc