| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/api/audio_codecs/audio_decoder_factory_template.h" | 11 #include "webrtc/api/audio_codecs/audio_decoder_factory_template.h" |
| 12 #include "webrtc/api/audio_codecs/L16/audio_decoder_L16.h" | 12 #include "webrtc/api/audio_codecs/L16/audio_decoder_L16.h" |
| 13 #include "webrtc/api/audio_codecs/g711/audio_decoder_g711.h" | 13 #include "webrtc/api/audio_codecs/g711/audio_decoder_g711.h" |
| 14 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h" | 14 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h" |
| 15 #include "webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h" | 15 #include "webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h" |
| 16 #include "webrtc/api/audio_codecs/isac/audio_decoder_isac_fix.h" | 16 #include "webrtc/api/audio_codecs/isac/audio_decoder_isac_fix.h" |
| 17 #include "webrtc/api/audio_codecs/isac/audio_decoder_isac_float.h" |
| 17 #include "webrtc/api/audio_codecs/opus/audio_decoder_opus.h" | 18 #include "webrtc/api/audio_codecs/opus/audio_decoder_opus.h" |
| 18 #include "webrtc/rtc_base/ptr_util.h" | 19 #include "webrtc/rtc_base/ptr_util.h" |
| 19 #include "webrtc/test/gmock.h" | 20 #include "webrtc/test/gmock.h" |
| 20 #include "webrtc/test/gtest.h" | 21 #include "webrtc/test/gtest.h" |
| 21 #include "webrtc/test/mock_audio_decoder.h" | 22 #include "webrtc/test/mock_audio_decoder.h" |
| 22 | 23 |
| 23 namespace webrtc { | 24 namespace webrtc { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 EXPECT_EQ(8000, dec->SampleRateHz()); | 168 EXPECT_EQ(8000, dec->SampleRateHz()); |
| 168 } | 169 } |
| 169 | 170 |
| 170 TEST(AudioDecoderFactoryTemplateTest, IsacFix) { | 171 TEST(AudioDecoderFactoryTemplateTest, IsacFix) { |
| 171 auto factory = CreateAudioDecoderFactory<AudioDecoderIsacFix>(); | 172 auto factory = CreateAudioDecoderFactory<AudioDecoderIsacFix>(); |
| 172 EXPECT_THAT(factory->GetSupportedDecoders(), | 173 EXPECT_THAT(factory->GetSupportedDecoders(), |
| 173 testing::ElementsAre(AudioCodecSpec{ | 174 testing::ElementsAre(AudioCodecSpec{ |
| 174 {"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}})); | 175 {"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}})); |
| 175 EXPECT_FALSE(factory->IsSupportedDecoder({"isac", 16000, 2})); | 176 EXPECT_FALSE(factory->IsSupportedDecoder({"isac", 16000, 2})); |
| 176 EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 16000, 1})); | 177 EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 16000, 1})); |
| 178 EXPECT_FALSE(factory->IsSupportedDecoder({"isac", 32000, 1})); |
| 177 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"isac", 8000, 1})); | 179 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"isac", 8000, 1})); |
| 178 auto dec = factory->MakeAudioDecoder({"isac", 16000, 1}); | 180 auto dec = factory->MakeAudioDecoder({"isac", 16000, 1}); |
| 179 ASSERT_NE(nullptr, dec); | 181 ASSERT_NE(nullptr, dec); |
| 180 EXPECT_EQ(16000, dec->SampleRateHz()); | 182 EXPECT_EQ(16000, dec->SampleRateHz()); |
| 181 } | 183 } |
| 182 | 184 |
| 185 TEST(AudioDecoderFactoryTemplateTest, IsacFloat) { |
| 186 auto factory = CreateAudioDecoderFactory<AudioDecoderIsacFloat>(); |
| 187 EXPECT_THAT( |
| 188 factory->GetSupportedDecoders(), |
| 189 testing::ElementsAre( |
| 190 AudioCodecSpec{{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}}, |
| 191 AudioCodecSpec{{"ISAC", 32000, 1}, {32000, 1, 56000, 10000, 56000}})); |
| 192 EXPECT_FALSE(factory->IsSupportedDecoder({"isac", 16000, 2})); |
| 193 EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 16000, 1})); |
| 194 EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 32000, 1})); |
| 195 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"isac", 8000, 1})); |
| 196 auto dec1 = factory->MakeAudioDecoder({"isac", 16000, 1}); |
| 197 ASSERT_NE(nullptr, dec1); |
| 198 EXPECT_EQ(16000, dec1->SampleRateHz()); |
| 199 auto dec2 = factory->MakeAudioDecoder({"isac", 32000, 1}); |
| 200 ASSERT_NE(nullptr, dec2); |
| 201 EXPECT_EQ(32000, dec2->SampleRateHz()); |
| 202 } |
| 203 |
| 183 TEST(AudioDecoderFactoryTemplateTest, L16) { | 204 TEST(AudioDecoderFactoryTemplateTest, L16) { |
| 184 auto factory = CreateAudioDecoderFactory<AudioDecoderL16>(); | 205 auto factory = CreateAudioDecoderFactory<AudioDecoderL16>(); |
| 185 EXPECT_THAT( | 206 EXPECT_THAT( |
| 186 factory->GetSupportedDecoders(), | 207 factory->GetSupportedDecoders(), |
| 187 testing::ElementsAre( | 208 testing::ElementsAre( |
| 188 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}}, | 209 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}}, |
| 189 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}}, | 210 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}}, |
| 190 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}}, | 211 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}}, |
| 191 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, | 212 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, |
| 192 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, | 213 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 211 testing::ElementsAre(AudioCodecSpec{opus_format, opus_info})); | 232 testing::ElementsAre(AudioCodecSpec{opus_format, opus_info})); |
| 212 EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1})); | 233 EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1})); |
| 213 EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2})); | 234 EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2})); |
| 214 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); | 235 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); |
| 215 auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}); | 236 auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}); |
| 216 ASSERT_NE(nullptr, dec); | 237 ASSERT_NE(nullptr, dec); |
| 217 EXPECT_EQ(48000, dec->SampleRateHz()); | 238 EXPECT_EQ(48000, dec->SampleRateHz()); |
| 218 } | 239 } |
| 219 | 240 |
| 220 } // namespace webrtc | 241 } // namespace webrtc |
| OLD | NEW |