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_encoder_factory_template.h" | 11 #include "webrtc/api/audio_codecs/audio_encoder_factory_template.h" |
12 #include "webrtc/api/audio_codecs/g722/audio_encoder_g722.h" | 12 #include "webrtc/api/audio_codecs/g722/audio_encoder_g722.h" |
13 #include "webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h" | 13 #include "webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h" |
| 14 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.h" |
14 #include "webrtc/base/ptr_util.h" | 15 #include "webrtc/base/ptr_util.h" |
15 #include "webrtc/test/gmock.h" | 16 #include "webrtc/test/gmock.h" |
16 #include "webrtc/test/gtest.h" | 17 #include "webrtc/test/gtest.h" |
17 #include "webrtc/test/mock_audio_encoder.h" | 18 #include "webrtc/test/mock_audio_encoder.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 struct BogusParams { | 24 struct BogusParams { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), | 143 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
143 factory->QueryAudioEncoder({"foo", 8000, 1})); | 144 factory->QueryAudioEncoder({"foo", 8000, 1})); |
144 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({8000, 1, 13333}), | 145 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({8000, 1, 13333}), |
145 factory->QueryAudioEncoder({"ilbc", 8000, 1})); | 146 factory->QueryAudioEncoder({"ilbc", 8000, 1})); |
146 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 8000, 1})); | 147 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 8000, 1})); |
147 auto enc = factory->MakeAudioEncoder(17, {"ilbc", 8000, 1}); | 148 auto enc = factory->MakeAudioEncoder(17, {"ilbc", 8000, 1}); |
148 ASSERT_NE(nullptr, enc); | 149 ASSERT_NE(nullptr, enc); |
149 EXPECT_EQ(8000, enc->SampleRateHz()); | 150 EXPECT_EQ(8000, enc->SampleRateHz()); |
150 } | 151 } |
151 | 152 |
| 153 TEST(AudioEncoderFactoryTemplateTest, Opus) { |
| 154 auto factory = CreateAudioEncoderFactory<AudioEncoderOpus>(); |
| 155 AudioCodecInfo info = {48000, 1, 32000, 6000, 510000}; |
| 156 info.allow_comfort_noise = false; |
| 157 info.supports_network_adaption = true; |
| 158 EXPECT_THAT( |
| 159 factory->GetSupportedEncoders(), |
| 160 testing::ElementsAre(AudioCodecSpec{ |
| 161 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}, |
| 162 info})); |
| 163 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
| 164 factory->QueryAudioEncoder({"foo", 8000, 1})); |
| 165 EXPECT_EQ( |
| 166 rtc::Optional<AudioCodecInfo>(info), |
| 167 factory->QueryAudioEncoder( |
| 168 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); |
| 169 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); |
| 170 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); |
| 171 ASSERT_NE(nullptr, enc); |
| 172 EXPECT_EQ(48000, enc->SampleRateHz()); |
| 173 } |
| 174 |
152 } // namespace webrtc | 175 } // namespace webrtc |
OLD | NEW |