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

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

Issue 2934833002: G722 implementation of the AudioEncoderFactoryTemplate API (Closed)
Patch Set: remove, rename, nit Created 3 years, 6 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
« no previous file with comments | « webrtc/api/audio_codecs/test/BUILD.gn ('k') | webrtc/modules/audio_coding/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/g722/audio_encoder_g722.h"
12 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.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
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 auto enc1 = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}); 113 auto enc1 = factory->MakeAudioEncoder(17, {"bogus", 8000, 1});
113 ASSERT_NE(nullptr, enc1); 114 ASSERT_NE(nullptr, enc1);
114 EXPECT_EQ(8000, enc1->SampleRateHz()); 115 EXPECT_EQ(8000, enc1->SampleRateHz());
115 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"sham", 16000, 2})); 116 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"sham", 16000, 2}));
116 auto enc2 = 117 auto enc2 =
117 factory->MakeAudioEncoder(17, {"sham", 16000, 2, {{"param", "value"}}}); 118 factory->MakeAudioEncoder(17, {"sham", 16000, 2, {{"param", "value"}}});
118 ASSERT_NE(nullptr, enc2); 119 ASSERT_NE(nullptr, enc2);
119 EXPECT_EQ(16000, enc2->SampleRateHz()); 120 EXPECT_EQ(16000, enc2->SampleRateHz());
120 } 121 }
121 122
123 TEST(AudioEncoderFactoryTemplateTest, G722) {
the sun 2017/06/13 14:49:30 I guess the idea is to eventually move this test c
kwiberg-webrtc 2017/06/13 19:12:10 I hadn't in fact thought that far ahead, but yes,
124 auto factory = CreateAudioEncoderFactory<AudioEncoderG722>();
125 EXPECT_THAT(factory->GetSupportedEncoders(),
126 testing::ElementsAre(
127 AudioCodecSpec{{"g722", 8000, 1}, {16000, 1, 64000}}));
128 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(),
129 factory->QueryAudioEncoder({"foo", 8000, 1}));
130 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 64000}),
131 factory->QueryAudioEncoder({"g722", 8000, 1}));
132 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1}));
133 auto enc = factory->MakeAudioEncoder(17, {"g722", 8000, 1});
134 ASSERT_NE(nullptr, enc);
135 EXPECT_EQ(16000, enc->SampleRateHz());
136 }
137
122 TEST(AudioEncoderFactoryTemplateTest, Opus) { 138 TEST(AudioEncoderFactoryTemplateTest, Opus) {
123 auto factory = CreateAudioEncoderFactory<AudioEncoderOpus>(); 139 auto factory = CreateAudioEncoderFactory<AudioEncoderOpus>();
124 AudioCodecInfo info = {48000, 1, 32000, 6000, 510000}; 140 AudioCodecInfo info = {48000, 1, 32000, 6000, 510000};
125 info.allow_comfort_noise = false; 141 info.allow_comfort_noise = false;
126 info.supports_network_adaption = true; 142 info.supports_network_adaption = true;
127 EXPECT_THAT( 143 EXPECT_THAT(
128 factory->GetSupportedEncoders(), 144 factory->GetSupportedEncoders(),
129 testing::ElementsAre(AudioCodecSpec{ 145 testing::ElementsAre(AudioCodecSpec{
130 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}, 146 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}},
131 info})); 147 info}));
132 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), 148 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(),
133 factory->QueryAudioEncoder({"foo", 8000, 1})); 149 factory->QueryAudioEncoder({"foo", 8000, 1}));
134 EXPECT_EQ( 150 EXPECT_EQ(
135 rtc::Optional<AudioCodecInfo>(info), 151 rtc::Optional<AudioCodecInfo>(info),
136 factory->QueryAudioEncoder( 152 factory->QueryAudioEncoder(
137 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); 153 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}));
138 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); 154 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1}));
139 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); 155 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2});
140 ASSERT_NE(nullptr, enc); 156 ASSERT_NE(nullptr, enc);
141 EXPECT_EQ(48000, enc->SampleRateHz()); 157 EXPECT_EQ(48000, enc->SampleRateHz());
142 } 158 }
143 159
144 } // namespace webrtc 160 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/audio_codecs/test/BUILD.gn ('k') | webrtc/modules/audio_coding/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698