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