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/g711/audio_decoder_g711.h" | 13 #include "webrtc/api/audio_codecs/g711/audio_decoder_g711.h" |
13 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h" | 14 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h" |
14 #include "webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h" | 15 #include "webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h" |
15 #include "webrtc/api/audio_codecs/opus/audio_decoder_opus.h" | 16 #include "webrtc/api/audio_codecs/opus/audio_decoder_opus.h" |
16 #include "webrtc/rtc_base/ptr_util.h" | 17 #include "webrtc/rtc_base/ptr_util.h" |
17 #include "webrtc/test/gmock.h" | 18 #include "webrtc/test/gmock.h" |
18 #include "webrtc/test/gtest.h" | 19 #include "webrtc/test/gtest.h" |
19 #include "webrtc/test/mock_audio_decoder.h" | 20 #include "webrtc/test/mock_audio_decoder.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 testing::ElementsAre( | 159 testing::ElementsAre( |
159 AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13300}})); | 160 AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13300}})); |
160 EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); | 161 EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); |
161 EXPECT_TRUE(factory->IsSupportedDecoder({"ilbc", 8000, 1})); | 162 EXPECT_TRUE(factory->IsSupportedDecoder({"ilbc", 8000, 1})); |
162 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 8000, 1})); | 163 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 8000, 1})); |
163 auto dec = factory->MakeAudioDecoder({"ilbc", 8000, 1}); | 164 auto dec = factory->MakeAudioDecoder({"ilbc", 8000, 1}); |
164 ASSERT_NE(nullptr, dec); | 165 ASSERT_NE(nullptr, dec); |
165 EXPECT_EQ(8000, dec->SampleRateHz()); | 166 EXPECT_EQ(8000, dec->SampleRateHz()); |
166 } | 167 } |
167 | 168 |
| 169 TEST(AudioDecoderFactoryTemplateTest, L16) { |
| 170 auto factory = CreateAudioDecoderFactory<AudioDecoderL16>(); |
| 171 EXPECT_THAT( |
| 172 factory->GetSupportedDecoders(), |
| 173 testing::ElementsAre( |
| 174 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}}, |
| 175 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}}, |
| 176 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}}, |
| 177 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, |
| 178 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, |
| 179 AudioCodecSpec{{"L16", 32000, 2}, {32000, 2, 32000 * 16 * 2}})); |
| 180 EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); |
| 181 EXPECT_TRUE(factory->IsSupportedDecoder({"L16", 48000, 1})); |
| 182 EXPECT_FALSE(factory->IsSupportedDecoder({"L16", 96000, 1})); |
| 183 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"L16", 8000, 0})); |
| 184 auto dec = factory->MakeAudioDecoder({"L16", 48000, 2}); |
| 185 ASSERT_NE(nullptr, dec); |
| 186 EXPECT_EQ(48000, dec->SampleRateHz()); |
| 187 } |
| 188 |
168 TEST(AudioDecoderFactoryTemplateTest, Opus) { | 189 TEST(AudioDecoderFactoryTemplateTest, Opus) { |
169 auto factory = CreateAudioDecoderFactory<AudioDecoderOpus>(); | 190 auto factory = CreateAudioDecoderFactory<AudioDecoderOpus>(); |
170 AudioCodecInfo opus_info{48000, 1, 64000, 6000, 510000}; | 191 AudioCodecInfo opus_info{48000, 1, 64000, 6000, 510000}; |
171 opus_info.allow_comfort_noise = false; | 192 opus_info.allow_comfort_noise = false; |
172 opus_info.supports_network_adaption = true; | 193 opus_info.supports_network_adaption = true; |
173 const SdpAudioFormat opus_format( | 194 const SdpAudioFormat opus_format( |
174 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}); | 195 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}); |
175 EXPECT_THAT(factory->GetSupportedDecoders(), | 196 EXPECT_THAT(factory->GetSupportedDecoders(), |
176 testing::ElementsAre(AudioCodecSpec{opus_format, opus_info})); | 197 testing::ElementsAre(AudioCodecSpec{opus_format, opus_info})); |
177 EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1})); | 198 EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1})); |
178 EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2})); | 199 EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2})); |
179 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); | 200 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); |
180 auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}); | 201 auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}); |
181 ASSERT_NE(nullptr, dec); | 202 ASSERT_NE(nullptr, dec); |
182 EXPECT_EQ(48000, dec->SampleRateHz()); | 203 EXPECT_EQ(48000, dec->SampleRateHz()); |
183 } | 204 } |
184 | 205 |
185 } // namespace webrtc | 206 } // namespace webrtc |
OLD | NEW |