OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2008 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 <memory> | 11 #include <memory> |
12 | 12 |
13 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | 13 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
| 14 #include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" |
14 #include "webrtc/base/arraysize.h" | 15 #include "webrtc/base/arraysize.h" |
15 #include "webrtc/base/byteorder.h" | 16 #include "webrtc/base/byteorder.h" |
16 #include "webrtc/base/safe_conversions.h" | 17 #include "webrtc/base/safe_conversions.h" |
17 #include "webrtc/call/call.h" | 18 #include "webrtc/call/call.h" |
18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 19 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
19 #include "webrtc/media/base/fakemediaengine.h" | 20 #include "webrtc/media/base/fakemediaengine.h" |
20 #include "webrtc/media/base/fakenetworkinterface.h" | 21 #include "webrtc/media/base/fakenetworkinterface.h" |
21 #include "webrtc/media/base/fakertp.h" | 22 #include "webrtc/media/base/fakertp.h" |
22 #include "webrtc/media/base/mediaconstants.h" | 23 #include "webrtc/media/base/mediaconstants.h" |
23 #include "webrtc/media/engine/fakewebrtccall.h" | 24 #include "webrtc/media/engine/fakewebrtccall.h" |
24 #include "webrtc/media/engine/fakewebrtcvoiceengine.h" | 25 #include "webrtc/media/engine/fakewebrtcvoiceengine.h" |
25 #include "webrtc/media/engine/webrtcvoiceengine.h" | 26 #include "webrtc/media/engine/webrtcvoiceengine.h" |
26 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h" | 27 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h" |
| 28 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder_factory.h" |
27 #include "webrtc/modules/audio_device/include/mock_audio_device.h" | 29 #include "webrtc/modules/audio_device/include/mock_audio_device.h" |
28 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" | 30 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" |
29 #include "webrtc/pc/channel.h" | 31 #include "webrtc/pc/channel.h" |
30 #include "webrtc/test/field_trial.h" | 32 #include "webrtc/test/field_trial.h" |
31 #include "webrtc/test/gtest.h" | 33 #include "webrtc/test/gtest.h" |
32 #include "webrtc/voice_engine/transmit_mixer.h" | 34 #include "webrtc/voice_engine/transmit_mixer.h" |
33 | 35 |
34 using testing::ContainerEq; | 36 using testing::ContainerEq; |
35 using testing::Return; | 37 using testing::Return; |
36 using testing::StrictMock; | 38 using testing::StrictMock; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 StrictMock<webrtc::test::MockAudioProcessing> apm; | 124 StrictMock<webrtc::test::MockAudioProcessing> apm; |
123 EXPECT_CALL(apm, ApplyConfig(testing::_)); | 125 EXPECT_CALL(apm, ApplyConfig(testing::_)); |
124 EXPECT_CALL(apm, SetExtraOptions(testing::_)); | 126 EXPECT_CALL(apm, SetExtraOptions(testing::_)); |
125 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); | 127 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); |
126 StrictMock<MockTransmitMixer> transmit_mixer; | 128 StrictMock<MockTransmitMixer> transmit_mixer; |
127 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false)); | 129 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false)); |
128 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer); | 130 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer); |
129 EXPECT_FALSE(voe.IsInited()); | 131 EXPECT_FALSE(voe.IsInited()); |
130 { | 132 { |
131 cricket::WebRtcVoiceEngine engine( | 133 cricket::WebRtcVoiceEngine engine( |
132 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, | 134 &adm, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 135 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, |
133 new FakeVoEWrapper(&voe)); | 136 new FakeVoEWrapper(&voe)); |
134 EXPECT_TRUE(voe.IsInited()); | 137 EXPECT_TRUE(voe.IsInited()); |
135 } | 138 } |
136 EXPECT_FALSE(voe.IsInited()); | 139 EXPECT_FALSE(voe.IsInited()); |
137 } | 140 } |
138 | 141 |
139 class FakeAudioSink : public webrtc::AudioSinkInterface { | 142 class FakeAudioSink : public webrtc::AudioSinkInterface { |
140 public: | 143 public: |
141 void OnData(const Data& audio) override {} | 144 void OnData(const Data& audio) override {} |
142 }; | 145 }; |
(...skipping 24 matching lines...) Expand all Loading... |
167 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); | 170 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); |
168 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0)); | 171 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0)); |
169 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(false)); | 172 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(false)); |
170 // Init does not overwrite default AGC config. | 173 // Init does not overwrite default AGC config. |
171 EXPECT_CALL(apm_gc_, target_level_dbfs()).WillOnce(Return(1)); | 174 EXPECT_CALL(apm_gc_, target_level_dbfs()).WillOnce(Return(1)); |
172 EXPECT_CALL(apm_gc_, compression_gain_db()).WillRepeatedly(Return(5)); | 175 EXPECT_CALL(apm_gc_, compression_gain_db()).WillRepeatedly(Return(5)); |
173 EXPECT_CALL(apm_gc_, is_limiter_enabled()).WillRepeatedly(Return(true)); | 176 EXPECT_CALL(apm_gc_, is_limiter_enabled()).WillRepeatedly(Return(true)); |
174 EXPECT_CALL(apm_gc_, set_target_level_dbfs(1)).WillOnce(Return(0)); | 177 EXPECT_CALL(apm_gc_, set_target_level_dbfs(1)).WillOnce(Return(0)); |
175 EXPECT_CALL(apm_gc_, set_compression_gain_db(5)).WillRepeatedly(Return(0)); | 178 EXPECT_CALL(apm_gc_, set_compression_gain_db(5)).WillRepeatedly(Return(0)); |
176 EXPECT_CALL(apm_gc_, enable_limiter(true)).WillRepeatedly(Return(0)); | 179 EXPECT_CALL(apm_gc_, enable_limiter(true)).WillRepeatedly(Return(0)); |
177 // TODO(kwiberg): We should use a mock AudioDecoderFactory, but a bunch of | 180 // TODO(kwiberg): We should use mock factories here, but a bunch of |
178 // the tests here probe the specific set of codecs provided by the builtin | 181 // the tests here probe the specific set of codecs provided by the builtin |
179 // factory. Those tests should probably be moved elsewhere. | 182 // factories. Those tests should probably be moved elsewhere. |
180 engine_.reset(new cricket::WebRtcVoiceEngine( | 183 auto encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); |
181 &adm_, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, | 184 auto decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); |
182 new FakeVoEWrapper(&voe_))); | 185 engine_.reset(new cricket::WebRtcVoiceEngine(&adm_, encoder_factory, |
| 186 decoder_factory, nullptr, |
| 187 new FakeVoEWrapper(&voe_))); |
183 send_parameters_.codecs.push_back(kPcmuCodec); | 188 send_parameters_.codecs.push_back(kPcmuCodec); |
184 recv_parameters_.codecs.push_back(kPcmuCodec); | 189 recv_parameters_.codecs.push_back(kPcmuCodec); |
185 // Default Options. | 190 // Default Options. |
186 EXPECT_TRUE(IsHighPassFilterEnabled()); | 191 EXPECT_TRUE(IsHighPassFilterEnabled()); |
187 } | 192 } |
188 | 193 |
189 bool SetupChannel() { | 194 bool SetupChannel() { |
190 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 195 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
191 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 196 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
192 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), | 197 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), |
(...skipping 3039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3232 channel_->SetRecvParameters(parameters); | 3237 channel_->SetRecvParameters(parameters); |
3233 | 3238 |
3234 EXPECT_TRUE(GetRecvStream(kSsrcX).started()); | 3239 EXPECT_TRUE(GetRecvStream(kSsrcX).started()); |
3235 } | 3240 } |
3236 | 3241 |
3237 // Tests that the library initializes and shuts down properly. | 3242 // Tests that the library initializes and shuts down properly. |
3238 TEST(WebRtcVoiceEngineTest, StartupShutdown) { | 3243 TEST(WebRtcVoiceEngineTest, StartupShutdown) { |
3239 // If the VoiceEngine wants to gather available codecs early, that's fine but | 3244 // If the VoiceEngine wants to gather available codecs early, that's fine but |
3240 // we never want it to create a decoder at this stage. | 3245 // we never want it to create a decoder at this stage. |
3241 cricket::WebRtcVoiceEngine engine( | 3246 cricket::WebRtcVoiceEngine engine( |
3242 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); | 3247 nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3248 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
3243 webrtc::RtcEventLogNullImpl event_log; | 3249 webrtc::RtcEventLogNullImpl event_log; |
3244 std::unique_ptr<webrtc::Call> call( | 3250 std::unique_ptr<webrtc::Call> call( |
3245 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3251 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3246 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3252 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
3247 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3253 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
3248 EXPECT_TRUE(channel != nullptr); | 3254 EXPECT_TRUE(channel != nullptr); |
3249 delete channel; | 3255 delete channel; |
3250 } | 3256 } |
3251 | 3257 |
3252 // Tests that reference counting on the external ADM is correct. | 3258 // Tests that reference counting on the external ADM is correct. |
3253 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { | 3259 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { |
3254 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm; | 3260 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm; |
3255 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0)); | 3261 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0)); |
3256 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0)); | 3262 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0)); |
3257 // Return 100ms just in case this function gets called. If we don't, | 3263 // Return 100ms just in case this function gets called. If we don't, |
3258 // we could enter a tight loop since the mock would return 0. | 3264 // we could enter a tight loop since the mock would return 0. |
3259 EXPECT_CALL(adm, TimeUntilNextProcess()).WillRepeatedly(Return(100)); | 3265 EXPECT_CALL(adm, TimeUntilNextProcess()).WillRepeatedly(Return(100)); |
3260 { | 3266 { |
3261 cricket::WebRtcVoiceEngine engine( | 3267 cricket::WebRtcVoiceEngine engine( |
3262 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); | 3268 &adm, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3269 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
3263 webrtc::RtcEventLogNullImpl event_log; | 3270 webrtc::RtcEventLogNullImpl event_log; |
3264 std::unique_ptr<webrtc::Call> call( | 3271 std::unique_ptr<webrtc::Call> call( |
3265 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3272 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3266 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3273 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
3267 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3274 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
3268 EXPECT_TRUE(channel != nullptr); | 3275 EXPECT_TRUE(channel != nullptr); |
3269 delete channel; | 3276 delete channel; |
3270 } | 3277 } |
3271 } | 3278 } |
3272 | 3279 |
3273 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. | 3280 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. |
3274 TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { | 3281 TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { |
3275 // TODO(ossu): Why are the payload types of codecs with non-static payload | 3282 // TODO(ossu): Why are the payload types of codecs with non-static payload |
3276 // type assignments checked here? It shouldn't really matter. | 3283 // type assignments checked here? It shouldn't really matter. |
3277 cricket::WebRtcVoiceEngine engine( | 3284 cricket::WebRtcVoiceEngine engine( |
3278 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); | 3285 nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3286 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
3279 for (const cricket::AudioCodec& codec : engine.send_codecs()) { | 3287 for (const cricket::AudioCodec& codec : engine.send_codecs()) { |
3280 auto is_codec = [&codec](const char* name, int clockrate = 0) { | 3288 auto is_codec = [&codec](const char* name, int clockrate = 0) { |
3281 return STR_CASE_CMP(codec.name.c_str(), name) == 0 && | 3289 return STR_CASE_CMP(codec.name.c_str(), name) == 0 && |
3282 (clockrate == 0 || codec.clockrate == clockrate); | 3290 (clockrate == 0 || codec.clockrate == clockrate); |
3283 }; | 3291 }; |
3284 if (is_codec("CN", 16000)) { | 3292 if (is_codec("CN", 16000)) { |
3285 EXPECT_EQ(105, codec.id); | 3293 EXPECT_EQ(105, codec.id); |
3286 } else if (is_codec("CN", 32000)) { | 3294 } else if (is_codec("CN", 32000)) { |
3287 EXPECT_EQ(106, codec.id); | 3295 EXPECT_EQ(106, codec.id); |
3288 } else if (is_codec("ISAC", 16000)) { | 3296 } else if (is_codec("ISAC", 16000)) { |
(...skipping 19 matching lines...) Expand all Loading... |
3308 EXPECT_EQ("10", codec.params.find("minptime")->second); | 3316 EXPECT_EQ("10", codec.params.find("minptime")->second); |
3309 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end()); | 3317 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end()); |
3310 EXPECT_EQ("1", codec.params.find("useinbandfec")->second); | 3318 EXPECT_EQ("1", codec.params.find("useinbandfec")->second); |
3311 } | 3319 } |
3312 } | 3320 } |
3313 } | 3321 } |
3314 | 3322 |
3315 // Tests that VoE supports at least 32 channels | 3323 // Tests that VoE supports at least 32 channels |
3316 TEST(WebRtcVoiceEngineTest, Has32Channels) { | 3324 TEST(WebRtcVoiceEngineTest, Has32Channels) { |
3317 cricket::WebRtcVoiceEngine engine( | 3325 cricket::WebRtcVoiceEngine engine( |
3318 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); | 3326 nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3327 webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
3319 webrtc::RtcEventLogNullImpl event_log; | 3328 webrtc::RtcEventLogNullImpl event_log; |
3320 std::unique_ptr<webrtc::Call> call( | 3329 std::unique_ptr<webrtc::Call> call( |
3321 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3330 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3322 | 3331 |
3323 cricket::VoiceMediaChannel* channels[32]; | 3332 cricket::VoiceMediaChannel* channels[32]; |
3324 int num_channels = 0; | 3333 int num_channels = 0; |
3325 while (num_channels < arraysize(channels)) { | 3334 while (num_channels < arraysize(channels)) { |
3326 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3335 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
3327 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3336 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
3328 if (!channel) | 3337 if (!channel) |
(...skipping 12 matching lines...) Expand all Loading... |
3341 // Test that we set our preferred codecs properly. | 3350 // Test that we set our preferred codecs properly. |
3342 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3351 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
3343 // TODO(ossu): I'm not sure of the intent of this test. It's either: | 3352 // TODO(ossu): I'm not sure of the intent of this test. It's either: |
3344 // - Check that our builtin codecs are usable by Channel. | 3353 // - Check that our builtin codecs are usable by Channel. |
3345 // - The codecs provided by the engine is usable by Channel. | 3354 // - The codecs provided by the engine is usable by Channel. |
3346 // It does not check that the codecs in the RecvParameters are actually | 3355 // It does not check that the codecs in the RecvParameters are actually |
3347 // what we sent in - though it's probably reasonable to expect so, if | 3356 // what we sent in - though it's probably reasonable to expect so, if |
3348 // SetRecvParameters returns true. | 3357 // SetRecvParameters returns true. |
3349 // I think it will become clear once audio decoder injection is completed. | 3358 // I think it will become clear once audio decoder injection is completed. |
3350 cricket::WebRtcVoiceEngine engine( | 3359 cricket::WebRtcVoiceEngine engine( |
3351 nullptr, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); | 3360 nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), |
| 3361 webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); |
3352 webrtc::RtcEventLogNullImpl event_log; | 3362 webrtc::RtcEventLogNullImpl event_log; |
3353 std::unique_ptr<webrtc::Call> call( | 3363 std::unique_ptr<webrtc::Call> call( |
3354 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3364 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3355 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3365 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3356 cricket::AudioOptions(), call.get()); | 3366 cricket::AudioOptions(), call.get()); |
3357 cricket::AudioRecvParameters parameters; | 3367 cricket::AudioRecvParameters parameters; |
3358 parameters.codecs = engine.recv_codecs(); | 3368 parameters.codecs = engine.recv_codecs(); |
3359 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3369 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3360 } | 3370 } |
3361 | 3371 |
3362 TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { | 3372 TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { |
3363 std::vector<webrtc::AudioCodecSpec> specs; | 3373 std::vector<webrtc::AudioCodecSpec> specs; |
3364 webrtc::AudioCodecSpec spec1{{"codec1", 48000, 2, {{"param1", "value1"}}}, | 3374 webrtc::AudioCodecSpec spec1{{"codec1", 48000, 2, {{"param1", "value1"}}}, |
3365 {48000, 2, 16000, 10000, 20000}}; | 3375 {48000, 2, 16000, 10000, 20000}}; |
3366 spec1.info.allow_comfort_noise = false; | 3376 spec1.info.allow_comfort_noise = false; |
3367 spec1.info.supports_network_adaption = true; | 3377 spec1.info.supports_network_adaption = true; |
3368 specs.push_back(spec1); | 3378 specs.push_back(spec1); |
3369 webrtc::AudioCodecSpec spec2{{"codec2", 32000, 1}, {32000, 1, 32000}}; | 3379 webrtc::AudioCodecSpec spec2{{"codec2", 32000, 1}, {32000, 1, 32000}}; |
3370 spec2.info.allow_comfort_noise = false; | 3380 spec2.info.allow_comfort_noise = false; |
3371 specs.push_back(spec2); | 3381 specs.push_back(spec2); |
3372 specs.push_back(webrtc::AudioCodecSpec{ | 3382 specs.push_back(webrtc::AudioCodecSpec{ |
3373 {"codec3", 16000, 1, {{"param1", "value1b"}, {"param2", "value2"}}}, | 3383 {"codec3", 16000, 1, {{"param1", "value1b"}, {"param2", "value2"}}}, |
3374 {16000, 1, 13300}}); | 3384 {16000, 1, 13300}}); |
3375 specs.push_back( | 3385 specs.push_back( |
3376 webrtc::AudioCodecSpec{{"codec4", 8000, 1}, {8000, 1, 64000}}); | 3386 webrtc::AudioCodecSpec{{"codec4", 8000, 1}, {8000, 1, 64000}}); |
3377 specs.push_back( | 3387 specs.push_back( |
3378 webrtc::AudioCodecSpec{{"codec5", 8000, 2}, {8000, 1, 64000}}); | 3388 webrtc::AudioCodecSpec{{"codec5", 8000, 2}, {8000, 1, 64000}}); |
3379 | 3389 |
3380 rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> mock_factory = | 3390 rtc::scoped_refptr<webrtc::MockAudioEncoderFactory> unused_encoder_factory = |
| 3391 webrtc::MockAudioEncoderFactory::CreateUnusedFactory(); |
| 3392 rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> mock_decoder_factory = |
3381 new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>; | 3393 new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>; |
3382 EXPECT_CALL(*mock_factory.get(), GetSupportedDecoders()) | 3394 EXPECT_CALL(*mock_decoder_factory.get(), GetSupportedDecoders()) |
3383 .WillOnce(Return(specs)); | 3395 .WillOnce(Return(specs)); |
3384 | 3396 |
3385 cricket::WebRtcVoiceEngine engine(nullptr, mock_factory, nullptr); | 3397 cricket::WebRtcVoiceEngine engine(nullptr, unused_encoder_factory, |
| 3398 mock_decoder_factory, nullptr); |
3386 auto codecs = engine.recv_codecs(); | 3399 auto codecs = engine.recv_codecs(); |
3387 EXPECT_EQ(11, codecs.size()); | 3400 EXPECT_EQ(11, codecs.size()); |
3388 | 3401 |
3389 // Rather than just ASSERTing that there are enough codecs, ensure that we can | 3402 // Rather than just ASSERTing that there are enough codecs, ensure that we can |
3390 // check the actual values safely, to provide better test results. | 3403 // check the actual values safely, to provide better test results. |
3391 auto get_codec = | 3404 auto get_codec = |
3392 [&codecs](size_t index) -> const cricket::AudioCodec& { | 3405 [&codecs](size_t index) -> const cricket::AudioCodec& { |
3393 static const cricket::AudioCodec missing_codec(0, "<missing>", 0, 0, 0); | 3406 static const cricket::AudioCodec missing_codec(0, "<missing>", 0, 0, 0); |
3394 if (codecs.size() > index) | 3407 if (codecs.size() > index) |
3395 return codecs[index]; | 3408 return codecs[index]; |
(...skipping 28 matching lines...) Expand all Loading... |
3424 // Without this cast, the comparison turned unsigned and, thus, failed for -1. | 3437 // Without this cast, the comparison turned unsigned and, thus, failed for -1. |
3425 const int num_specs = static_cast<int>(specs.size()); | 3438 const int num_specs = static_cast<int>(specs.size()); |
3426 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); | 3439 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); |
3427 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); | 3440 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); |
3428 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); | 3441 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); |
3429 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); | 3442 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); |
3430 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); | 3443 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); |
3431 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); | 3444 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); |
3432 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); | 3445 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); |
3433 } | 3446 } |
OLD | NEW |