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/opus/audio_encoder_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_encoder.h" | 17 #include "webrtc/test/mock_audio_encoder.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 struct BogusParams { | 23 struct BogusParams { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), | 127 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
127 factory->QueryAudioEncoder({"foo", 8000, 1})); | 128 factory->QueryAudioEncoder({"foo", 8000, 1})); |
128 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 64000}), | 129 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 64000}), |
129 factory->QueryAudioEncoder({"g722", 8000, 1})); | 130 factory->QueryAudioEncoder({"g722", 8000, 1})); |
130 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); | 131 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); |
131 auto enc = factory->MakeAudioEncoder(17, {"g722", 8000, 1}); | 132 auto enc = factory->MakeAudioEncoder(17, {"g722", 8000, 1}); |
132 ASSERT_NE(nullptr, enc); | 133 ASSERT_NE(nullptr, enc); |
133 EXPECT_EQ(16000, enc->SampleRateHz()); | 134 EXPECT_EQ(16000, enc->SampleRateHz()); |
134 } | 135 } |
135 | 136 |
| 137 TEST(AudioEncoderFactoryTemplateTest, Opus) { |
| 138 auto factory = CreateAudioEncoderFactory<AudioEncoderOpus>(); |
| 139 AudioCodecInfo info = {48000, 1, 32000, 6000, 510000}; |
| 140 info.allow_comfort_noise = false; |
| 141 info.supports_network_adaption = true; |
| 142 EXPECT_THAT( |
| 143 factory->GetSupportedEncoders(), |
| 144 testing::ElementsAre(AudioCodecSpec{ |
| 145 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}, |
| 146 info})); |
| 147 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
| 148 factory->QueryAudioEncoder({"foo", 8000, 1})); |
| 149 EXPECT_EQ( |
| 150 rtc::Optional<AudioCodecInfo>(info), |
| 151 factory->QueryAudioEncoder( |
| 152 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); |
| 153 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); |
| 154 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); |
| 155 ASSERT_NE(nullptr, enc); |
| 156 EXPECT_EQ(48000, enc->SampleRateHz()); |
| 157 } |
| 158 |
136 } // namespace webrtc | 159 } // namespace webrtc |
OLD | NEW |