Tests: Pass codec ID argument to audio codecs
Bug: webrtc:8941 Change-Id: Ia6d51dcbf7d69b38f3615e01d3f7031b8f5c31d0 Reviewed-on: https://webrtc-review.googlesource.com/58092 Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Oskar Sundbom <ossu@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22383}
This commit is contained in:
@ -19,7 +19,8 @@ TEST(AudioDecoderFactoryTest, CreateUnknownDecoder) {
|
||||
rtc::scoped_refptr<AudioDecoderFactory> adf =
|
||||
CreateBuiltinAudioDecoderFactory();
|
||||
ASSERT_TRUE(adf);
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("rey", 8000, 1)));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("rey", 8000, 1), rtc::nullopt));
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTest, CreatePcmu) {
|
||||
@ -27,11 +28,16 @@ TEST(AudioDecoderFactoryTest, CreatePcmu) {
|
||||
CreateBuiltinAudioDecoderFactory();
|
||||
ASSERT_TRUE(adf);
|
||||
// PCMu supports 8 kHz, and any number of channels.
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 0)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 1)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 2)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 3)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 16000, 1)));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 0), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 1), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 2), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 3), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 16000, 1), rtc::nullopt));
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTest, CreatePcma) {
|
||||
@ -39,11 +45,16 @@ TEST(AudioDecoderFactoryTest, CreatePcma) {
|
||||
CreateBuiltinAudioDecoderFactory();
|
||||
ASSERT_TRUE(adf);
|
||||
// PCMa supports 8 kHz, and any number of channels.
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 0)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 1)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 2)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 3)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 16000, 1)));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 0), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 1), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 2), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 3), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 16000, 1), rtc::nullopt));
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTest, CreateIlbc) {
|
||||
@ -51,12 +62,16 @@ TEST(AudioDecoderFactoryTest, CreateIlbc) {
|
||||
CreateBuiltinAudioDecoderFactory();
|
||||
ASSERT_TRUE(adf);
|
||||
// iLBC supports 8 kHz, 1 channel.
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 0)));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 0), rtc::nullopt));
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1)));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1), rtc::nullopt));
|
||||
#endif
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 2)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1)));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 2), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1), rtc::nullopt));
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTest, CreateIsac) {
|
||||
@ -65,15 +80,22 @@ TEST(AudioDecoderFactoryTest, CreateIsac) {
|
||||
ASSERT_TRUE(adf);
|
||||
// iSAC supports 16 kHz, 1 channel. The float implementation additionally
|
||||
// supports 32 kHz, 1 channel.
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 2)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 8000, 1)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 48000, 1)));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 2), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 8000, 1), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 48000, 1), rtc::nullopt));
|
||||
#ifdef WEBRTC_ARCH_ARM
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1)));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1), rtc::nullopt));
|
||||
#else
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1)));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1), rtc::nullopt));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -85,10 +107,11 @@ TEST(AudioDecoderFactoryTest, CreateL16) {
|
||||
const int clockrates[] = {8000, 16000, 32000, 48000};
|
||||
const int num_channels[] = {1, 2, 3, 4711};
|
||||
for (int clockrate : clockrates) {
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, 0)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, 0),
|
||||
rtc::nullopt));
|
||||
for (int channels : num_channels) {
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, channels)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(
|
||||
SdpAudioFormat("l16", clockrate, channels), rtc::nullopt));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,16 +121,22 @@ TEST(AudioDecoderFactoryTest, CreateG722) {
|
||||
CreateBuiltinAudioDecoderFactory();
|
||||
ASSERT_TRUE(adf);
|
||||
// g722 supports 8 kHz, 1-2 channels.
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 0)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1)));
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 2)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 3)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 16000, 1)));
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 32000, 1)));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 0), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1), rtc::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 2), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 3), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 16000, 1), rtc::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 32000, 1), rtc::nullopt));
|
||||
|
||||
// g722 actually uses a 16 kHz sample rate instead of the nominal 8 kHz.
|
||||
std::unique_ptr<AudioDecoder> dec =
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1), rtc::nullopt);
|
||||
EXPECT_EQ(16000, dec->SampleRateHz());
|
||||
}
|
||||
|
||||
@ -126,8 +155,10 @@ TEST(AudioDecoderFactoryTest, CreateOpus) {
|
||||
}
|
||||
const bool good = (hz == 48000 && channels == 2 &&
|
||||
(stereo == "XX" || stereo == "0" || stereo == "1"));
|
||||
EXPECT_EQ(good, static_cast<bool>(adf->MakeAudioDecoder(SdpAudioFormat(
|
||||
"opus", hz, channels, std::move(params)))));
|
||||
EXPECT_EQ(good,
|
||||
static_cast<bool>(adf->MakeAudioDecoder(
|
||||
SdpAudioFormat("opus", hz, channels, std::move(params)),
|
||||
rtc::nullopt)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ TEST_P(AudioEncoderFactoryTest, CanConstructAllSupportedEncoders) {
|
||||
auto supported_encoders = factory->GetSupportedEncoders();
|
||||
for (const auto& spec : supported_encoders) {
|
||||
auto info = factory->QueryAudioEncoder(spec.format);
|
||||
auto encoder = factory->MakeAudioEncoder(127, spec.format);
|
||||
auto encoder = factory->MakeAudioEncoder(127, spec.format, rtc::nullopt);
|
||||
EXPECT_TRUE(encoder);
|
||||
EXPECT_EQ(encoder->SampleRateHz(), info->sample_rate_hz);
|
||||
EXPECT_EQ(encoder->NumChannels(), info->num_channels);
|
||||
@ -56,7 +56,8 @@ TEST_P(AudioEncoderFactoryTest, CanRunAllSupportedEncoders) {
|
||||
auto factory = GetParam();
|
||||
auto supported_encoders = factory->GetSupportedEncoders();
|
||||
for (const auto& spec : supported_encoders) {
|
||||
auto encoder = factory->MakeAudioEncoder(kTestPayloadType, spec.format);
|
||||
auto encoder =
|
||||
factory->MakeAudioEncoder(kTestPayloadType, spec.format, rtc::nullopt);
|
||||
EXPECT_TRUE(encoder);
|
||||
encoder->Reset();
|
||||
const int num_samples = rtc::checked_cast<int>(
|
||||
|
Reference in New Issue
Block a user