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/g722/audio_decoder_g722.h" | 12 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h" |
| 13 #include "webrtc/api/audio_codecs/opus/audio_decoder_opus.h" |
13 #include "webrtc/base/ptr_util.h" | 14 #include "webrtc/base/ptr_util.h" |
14 #include "webrtc/test/gmock.h" | 15 #include "webrtc/test/gmock.h" |
15 #include "webrtc/test/gtest.h" | 16 #include "webrtc/test/gtest.h" |
16 #include "webrtc/test/mock_audio_decoder.h" | 17 #include "webrtc/test/mock_audio_decoder.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 struct BogusParams { | 23 struct BogusParams { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 testing::ElementsAre( | 118 testing::ElementsAre( |
118 AudioCodecSpec{{"g722", 8000, 1}, {16000, 1, 64000}})); | 119 AudioCodecSpec{{"g722", 8000, 1}, {16000, 1, 64000}})); |
119 EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); | 120 EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); |
120 EXPECT_TRUE(factory->IsSupportedDecoder({"g722", 8000, 1})); | 121 EXPECT_TRUE(factory->IsSupportedDecoder({"g722", 8000, 1})); |
121 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); | 122 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); |
122 auto dec = factory->MakeAudioDecoder({"g722", 8000, 1}); | 123 auto dec = factory->MakeAudioDecoder({"g722", 8000, 1}); |
123 ASSERT_NE(nullptr, dec); | 124 ASSERT_NE(nullptr, dec); |
124 EXPECT_EQ(16000, dec->SampleRateHz()); | 125 EXPECT_EQ(16000, dec->SampleRateHz()); |
125 } | 126 } |
126 | 127 |
| 128 TEST(AudioDecoderFactoryTemplateTest, Opus) { |
| 129 auto factory = CreateAudioDecoderFactory<AudioDecoderOpus>(); |
| 130 AudioCodecInfo opus_info{48000, 1, 64000, 6000, 510000}; |
| 131 opus_info.allow_comfort_noise = false; |
| 132 opus_info.supports_network_adaption = true; |
| 133 const SdpAudioFormat opus_format( |
| 134 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}); |
| 135 EXPECT_THAT(factory->GetSupportedDecoders(), |
| 136 testing::ElementsAre(AudioCodecSpec{opus_format, opus_info})); |
| 137 EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1})); |
| 138 EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2})); |
| 139 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); |
| 140 auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}); |
| 141 ASSERT_NE(nullptr, dec); |
| 142 EXPECT_EQ(48000, dec->SampleRateHz()); |
| 143 } |
| 144 |
127 } // namespace webrtc | 145 } // namespace webrtc |
OLD | NEW |