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/isac/audio_encoder_isac_fix.h" |
| 17 #include "webrtc/api/audio_codecs/isac/audio_encoder_isac_float.h" |
17 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.h" | 18 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.h" |
18 #include "webrtc/rtc_base/ptr_util.h" | 19 #include "webrtc/rtc_base/ptr_util.h" |
19 #include "webrtc/test/gmock.h" | 20 #include "webrtc/test/gmock.h" |
20 #include "webrtc/test/gtest.h" | 21 #include "webrtc/test/gtest.h" |
21 #include "webrtc/test/mock_audio_encoder.h" | 22 #include "webrtc/test/mock_audio_encoder.h" |
22 | 23 |
23 namespace webrtc { | 24 namespace webrtc { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 175 |
175 TEST(AudioEncoderFactoryTemplateTest, IsacFix) { | 176 TEST(AudioEncoderFactoryTemplateTest, IsacFix) { |
176 auto factory = CreateAudioEncoderFactory<AudioEncoderIsacFix>(); | 177 auto factory = CreateAudioEncoderFactory<AudioEncoderIsacFix>(); |
177 EXPECT_THAT(factory->GetSupportedEncoders(), | 178 EXPECT_THAT(factory->GetSupportedEncoders(), |
178 testing::ElementsAre(AudioCodecSpec{ | 179 testing::ElementsAre(AudioCodecSpec{ |
179 {"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}})); | 180 {"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}})); |
180 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), | 181 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
181 factory->QueryAudioEncoder({"isac", 16000, 2})); | 182 factory->QueryAudioEncoder({"isac", 16000, 2})); |
182 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 32000, 10000, 32000}), | 183 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 32000, 10000, 32000}), |
183 factory->QueryAudioEncoder({"isac", 16000, 1})); | 184 factory->QueryAudioEncoder({"isac", 16000, 1})); |
| 185 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
| 186 factory->QueryAudioEncoder({"isac", 32000, 1})); |
184 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"isac", 8000, 1})); | 187 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"isac", 8000, 1})); |
185 auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}); | 188 auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}); |
186 ASSERT_NE(nullptr, enc1); | 189 ASSERT_NE(nullptr, enc1); |
187 EXPECT_EQ(16000, enc1->SampleRateHz()); | 190 EXPECT_EQ(16000, enc1->SampleRateHz()); |
188 EXPECT_EQ(3u, enc1->Num10MsFramesInNextPacket()); | 191 EXPECT_EQ(3u, enc1->Num10MsFramesInNextPacket()); |
189 auto enc2 = | 192 auto enc2 = |
190 factory->MakeAudioEncoder(17, {"isac", 16000, 1, {{"ptime", "60"}}}); | 193 factory->MakeAudioEncoder(17, {"isac", 16000, 1, {{"ptime", "60"}}}); |
191 ASSERT_NE(nullptr, enc2); | 194 ASSERT_NE(nullptr, enc2); |
192 EXPECT_EQ(6u, enc2->Num10MsFramesInNextPacket()); | 195 EXPECT_EQ(6u, enc2->Num10MsFramesInNextPacket()); |
193 } | 196 } |
194 | 197 |
| 198 TEST(AudioEncoderFactoryTemplateTest, IsacFloat) { |
| 199 auto factory = CreateAudioEncoderFactory<AudioEncoderIsacFloat>(); |
| 200 EXPECT_THAT( |
| 201 factory->GetSupportedEncoders(), |
| 202 testing::ElementsAre( |
| 203 AudioCodecSpec{{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}}, |
| 204 AudioCodecSpec{{"ISAC", 32000, 1}, {32000, 1, 56000, 10000, 56000}})); |
| 205 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
| 206 factory->QueryAudioEncoder({"isac", 16000, 2})); |
| 207 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 32000, 10000, 32000}), |
| 208 factory->QueryAudioEncoder({"isac", 16000, 1})); |
| 209 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({32000, 1, 56000, 10000, 56000}), |
| 210 factory->QueryAudioEncoder({"isac", 32000, 1})); |
| 211 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"isac", 8000, 1})); |
| 212 auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}); |
| 213 ASSERT_NE(nullptr, enc1); |
| 214 EXPECT_EQ(16000, enc1->SampleRateHz()); |
| 215 auto enc2 = factory->MakeAudioEncoder(17, {"isac", 32000, 1}); |
| 216 ASSERT_NE(nullptr, enc2); |
| 217 EXPECT_EQ(32000, enc2->SampleRateHz()); |
| 218 } |
| 219 |
195 TEST(AudioEncoderFactoryTemplateTest, L16) { | 220 TEST(AudioEncoderFactoryTemplateTest, L16) { |
196 auto factory = CreateAudioEncoderFactory<AudioEncoderL16>(); | 221 auto factory = CreateAudioEncoderFactory<AudioEncoderL16>(); |
197 EXPECT_THAT( | 222 EXPECT_THAT( |
198 factory->GetSupportedEncoders(), | 223 factory->GetSupportedEncoders(), |
199 testing::ElementsAre( | 224 testing::ElementsAre( |
200 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}}, | 225 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}}, |
201 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}}, | 226 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}}, |
202 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}}, | 227 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}}, |
203 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, | 228 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, |
204 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, | 229 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, |
(...skipping 24 matching lines...) Expand all Loading... |
229 rtc::Optional<AudioCodecInfo>(info), | 254 rtc::Optional<AudioCodecInfo>(info), |
230 factory->QueryAudioEncoder( | 255 factory->QueryAudioEncoder( |
231 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); | 256 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); |
232 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); | 257 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); |
233 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); | 258 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); |
234 ASSERT_NE(nullptr, enc); | 259 ASSERT_NE(nullptr, enc); |
235 EXPECT_EQ(48000, enc->SampleRateHz()); | 260 EXPECT_EQ(48000, enc->SampleRateHz()); |
236 } | 261 } |
237 | 262 |
238 } // namespace webrtc | 263 } // namespace webrtc |
OLD | NEW |