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/L16/audio_encoder_L16.h" | 12 #include "webrtc/api/audio_codecs/L16/audio_encoder_L16.h" |
13 #include "webrtc/api/audio_codecs/g711/audio_encoder_g711.h" | 13 #include "webrtc/api/audio_codecs/g711/audio_encoder_g711.h" |
14 #include "webrtc/api/audio_codecs/g722/audio_encoder_g722.h" | 14 #include "webrtc/api/audio_codecs/g722/audio_encoder_g722.h" |
15 #include "webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h" | 15 #include "webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h" |
| 16 #include "webrtc/api/audio_codecs/isac/audio_encoder_isac_fix.h" |
16 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.h" | 17 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.h" |
17 #include "webrtc/rtc_base/ptr_util.h" | 18 #include "webrtc/rtc_base/ptr_util.h" |
18 #include "webrtc/test/gmock.h" | 19 #include "webrtc/test/gmock.h" |
19 #include "webrtc/test/gtest.h" | 20 #include "webrtc/test/gtest.h" |
20 #include "webrtc/test/mock_audio_encoder.h" | 21 #include "webrtc/test/mock_audio_encoder.h" |
21 | 22 |
22 namespace webrtc { | 23 namespace webrtc { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), | 165 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
165 factory->QueryAudioEncoder({"foo", 8000, 1})); | 166 factory->QueryAudioEncoder({"foo", 8000, 1})); |
166 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({8000, 1, 13333}), | 167 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({8000, 1, 13333}), |
167 factory->QueryAudioEncoder({"ilbc", 8000, 1})); | 168 factory->QueryAudioEncoder({"ilbc", 8000, 1})); |
168 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 8000, 1})); | 169 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 8000, 1})); |
169 auto enc = factory->MakeAudioEncoder(17, {"ilbc", 8000, 1}); | 170 auto enc = factory->MakeAudioEncoder(17, {"ilbc", 8000, 1}); |
170 ASSERT_NE(nullptr, enc); | 171 ASSERT_NE(nullptr, enc); |
171 EXPECT_EQ(8000, enc->SampleRateHz()); | 172 EXPECT_EQ(8000, enc->SampleRateHz()); |
172 } | 173 } |
173 | 174 |
| 175 TEST(AudioEncoderFactoryTemplateTest, IsacFix) { |
| 176 auto factory = CreateAudioEncoderFactory<AudioEncoderIsacFix>(); |
| 177 EXPECT_THAT(factory->GetSupportedEncoders(), |
| 178 testing::ElementsAre(AudioCodecSpec{ |
| 179 {"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}})); |
| 180 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
| 181 factory->QueryAudioEncoder({"isac", 16000, 2})); |
| 182 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 32000, 10000, 32000}), |
| 183 factory->QueryAudioEncoder({"isac", 16000, 1})); |
| 184 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"isac", 8000, 1})); |
| 185 auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}); |
| 186 ASSERT_NE(nullptr, enc1); |
| 187 EXPECT_EQ(16000, enc1->SampleRateHz()); |
| 188 EXPECT_EQ(3u, enc1->Num10MsFramesInNextPacket()); |
| 189 auto enc2 = |
| 190 factory->MakeAudioEncoder(17, {"isac", 16000, 1, {{"ptime", "60"}}}); |
| 191 ASSERT_NE(nullptr, enc2); |
| 192 EXPECT_EQ(6u, enc2->Num10MsFramesInNextPacket()); |
| 193 } |
| 194 |
174 TEST(AudioEncoderFactoryTemplateTest, L16) { | 195 TEST(AudioEncoderFactoryTemplateTest, L16) { |
175 auto factory = CreateAudioEncoderFactory<AudioEncoderL16>(); | 196 auto factory = CreateAudioEncoderFactory<AudioEncoderL16>(); |
176 EXPECT_THAT( | 197 EXPECT_THAT( |
177 factory->GetSupportedEncoders(), | 198 factory->GetSupportedEncoders(), |
178 testing::ElementsAre( | 199 testing::ElementsAre( |
179 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}}, | 200 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}}, |
180 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}}, | 201 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}}, |
181 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}}, | 202 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}}, |
182 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, | 203 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, |
183 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, | 204 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, |
(...skipping 24 matching lines...) Expand all Loading... |
208 rtc::Optional<AudioCodecInfo>(info), | 229 rtc::Optional<AudioCodecInfo>(info), |
209 factory->QueryAudioEncoder( | 230 factory->QueryAudioEncoder( |
210 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); | 231 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); |
211 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); | 232 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); |
212 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); | 233 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); |
213 ASSERT_NE(nullptr, enc); | 234 ASSERT_NE(nullptr, enc); |
214 EXPECT_EQ(48000, enc->SampleRateHz()); | 235 EXPECT_EQ(48000, enc->SampleRateHz()); |
215 } | 236 } |
216 | 237 |
217 } // namespace webrtc | 238 } // namespace webrtc |
OLD | NEW |