Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: webrtc/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc

Issue 3001483002: iSAC floating-point implementation of the Audio{En,De}coderFactoryTemplate APIs (Closed)
Patch Set: rebase Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 enc = factory->MakeAudioEncoder(17, {"isac", 16000, 1}); 188 auto enc = factory->MakeAudioEncoder(17, {"isac", 16000, 1});
186 ASSERT_NE(nullptr, enc); 189 ASSERT_NE(nullptr, enc);
187 EXPECT_EQ(16000, enc->SampleRateHz()); 190 EXPECT_EQ(16000, enc->SampleRateHz());
188 } 191 }
189 192
193 TEST(AudioEncoderFactoryTemplateTest, IsacFloat) {
194 auto factory = CreateAudioEncoderFactory<AudioEncoderIsacFloat>();
195 EXPECT_THAT(
196 factory->GetSupportedEncoders(),
197 testing::ElementsAre(
198 AudioCodecSpec{{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}},
199 AudioCodecSpec{{"ISAC", 32000, 1}, {32000, 1, 56000, 10000, 56000}}));
200 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(),
201 factory->QueryAudioEncoder({"isac", 16000, 2}));
202 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 32000, 10000, 32000}),
203 factory->QueryAudioEncoder({"isac", 16000, 1}));
204 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({32000, 1, 56000, 10000, 56000}),
205 factory->QueryAudioEncoder({"isac", 32000, 1}));
206 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"isac", 8000, 1}));
207 auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1});
208 ASSERT_NE(nullptr, enc1);
209 EXPECT_EQ(16000, enc1->SampleRateHz());
210 auto enc2 = factory->MakeAudioEncoder(17, {"isac", 32000, 1});
211 ASSERT_NE(nullptr, enc2);
212 EXPECT_EQ(32000, enc2->SampleRateHz());
213 }
214
190 TEST(AudioEncoderFactoryTemplateTest, L16) { 215 TEST(AudioEncoderFactoryTemplateTest, L16) {
191 auto factory = CreateAudioEncoderFactory<AudioEncoderL16>(); 216 auto factory = CreateAudioEncoderFactory<AudioEncoderL16>();
192 EXPECT_THAT( 217 EXPECT_THAT(
193 factory->GetSupportedEncoders(), 218 factory->GetSupportedEncoders(),
194 testing::ElementsAre( 219 testing::ElementsAre(
195 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}}, 220 AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}},
196 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}}, 221 AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}},
197 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}}, 222 AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}},
198 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, 223 AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}},
199 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, 224 AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}},
(...skipping 24 matching lines...) Expand all
224 rtc::Optional<AudioCodecInfo>(info), 249 rtc::Optional<AudioCodecInfo>(info),
225 factory->QueryAudioEncoder( 250 factory->QueryAudioEncoder(
226 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); 251 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}));
227 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); 252 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1}));
228 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); 253 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2});
229 ASSERT_NE(nullptr, enc); 254 ASSERT_NE(nullptr, enc);
230 EXPECT_EQ(48000, enc->SampleRateHz()); 255 EXPECT_EQ(48000, enc->SampleRateHz());
231 } 256 }
232 257
233 } // namespace webrtc 258 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698