| 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 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 EXPECT_CALL(adm, BuiltInAGCIsAvailable()).WillOnce(Return(false)); | 77 EXPECT_CALL(adm, BuiltInAGCIsAvailable()).WillOnce(Return(false)); |
| 78 EXPECT_CALL(adm, BuiltInNSIsAvailable()).WillOnce(Return(false)); | 78 EXPECT_CALL(adm, BuiltInNSIsAvailable()).WillOnce(Return(false)); |
| 79 StrictMock<webrtc::test::MockAudioProcessing> apm; | 79 StrictMock<webrtc::test::MockAudioProcessing> apm; |
| 80 EXPECT_CALL(apm, ApplyConfig(testing::_)); | 80 EXPECT_CALL(apm, ApplyConfig(testing::_)); |
| 81 EXPECT_CALL(apm, SetExtraOptions(testing::_)); | 81 EXPECT_CALL(apm, SetExtraOptions(testing::_)); |
| 82 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); | 82 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); |
| 83 cricket::FakeWebRtcVoiceEngine voe(&apm); | 83 cricket::FakeWebRtcVoiceEngine voe(&apm); |
| 84 EXPECT_FALSE(voe.IsInited()); | 84 EXPECT_FALSE(voe.IsInited()); |
| 85 { | 85 { |
| 86 cricket::WebRtcVoiceEngine engine( | 86 cricket::WebRtcVoiceEngine engine( |
| 87 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), | 87 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, |
| 88 new FakeVoEWrapper(&voe)); | 88 new FakeVoEWrapper(&voe)); |
| 89 EXPECT_TRUE(voe.IsInited()); | 89 EXPECT_TRUE(voe.IsInited()); |
| 90 } | 90 } |
| 91 EXPECT_FALSE(voe.IsInited()); | 91 EXPECT_FALSE(voe.IsInited()); |
| 92 } | 92 } |
| 93 | 93 |
| 94 class FakeAudioSink : public webrtc::AudioSinkInterface { | 94 class FakeAudioSink : public webrtc::AudioSinkInterface { |
| 95 public: | 95 public: |
| 96 void OnData(const Data& audio) override {} | 96 void OnData(const Data& audio) override {} |
| 97 }; | 97 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 109 override_field_trials_(field_trials) { | 109 override_field_trials_(field_trials) { |
| 110 auto factory = webrtc::MockAudioDecoderFactory::CreateUnusedFactory(); | 110 auto factory = webrtc::MockAudioDecoderFactory::CreateUnusedFactory(); |
| 111 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); | 111 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); |
| 112 EXPECT_CALL(adm_, Release()).WillOnce(Return(0)); | 112 EXPECT_CALL(adm_, Release()).WillOnce(Return(0)); |
| 113 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false)); | 113 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false)); |
| 114 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false)); | 114 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false)); |
| 115 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false)); | 115 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false)); |
| 116 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 116 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
| 117 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 117 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
| 118 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); | 118 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); |
| 119 engine_.reset(new cricket::WebRtcVoiceEngine(&adm_, factory, | 119 engine_.reset(new cricket::WebRtcVoiceEngine(&adm_, factory, nullptr, |
| 120 new FakeVoEWrapper(&voe_))); | 120 new FakeVoEWrapper(&voe_))); |
| 121 send_parameters_.codecs.push_back(kPcmuCodec); | 121 send_parameters_.codecs.push_back(kPcmuCodec); |
| 122 recv_parameters_.codecs.push_back(kPcmuCodec); | 122 recv_parameters_.codecs.push_back(kPcmuCodec); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool SetupChannel() { | 125 bool SetupChannel() { |
| 126 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 126 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
| 127 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 127 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
| 128 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), | 128 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), |
| 129 cricket::AudioOptions()); | 129 cricket::AudioOptions()); |
| (...skipping 3258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3388 channel_->SetRecvParameters(parameters); | 3388 channel_->SetRecvParameters(parameters); |
| 3389 | 3389 |
| 3390 EXPECT_TRUE(GetRecvStream(kSsrc1).started()); | 3390 EXPECT_TRUE(GetRecvStream(kSsrc1).started()); |
| 3391 } | 3391 } |
| 3392 | 3392 |
| 3393 // Tests that the library initializes and shuts down properly. | 3393 // Tests that the library initializes and shuts down properly. |
| 3394 TEST(WebRtcVoiceEngineTest, StartupShutdown) { | 3394 TEST(WebRtcVoiceEngineTest, StartupShutdown) { |
| 3395 // If the VoiceEngine wants to gather available codecs early, that's fine but | 3395 // If the VoiceEngine wants to gather available codecs early, that's fine but |
| 3396 // we never want it to create a decoder at this stage. | 3396 // we never want it to create a decoder at this stage. |
| 3397 cricket::WebRtcVoiceEngine engine( | 3397 cricket::WebRtcVoiceEngine engine( |
| 3398 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); | 3398 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3399 webrtc::RtcEventLogNullImpl event_log; | 3399 webrtc::RtcEventLogNullImpl event_log; |
| 3400 std::unique_ptr<webrtc::Call> call( | 3400 std::unique_ptr<webrtc::Call> call( |
| 3401 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3401 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3402 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3402 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3403 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3403 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3404 EXPECT_TRUE(channel != nullptr); | 3404 EXPECT_TRUE(channel != nullptr); |
| 3405 delete channel; | 3405 delete channel; |
| 3406 } | 3406 } |
| 3407 | 3407 |
| 3408 // Tests that reference counting on the external ADM is correct. | 3408 // Tests that reference counting on the external ADM is correct. |
| 3409 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { | 3409 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { |
| 3410 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm; | 3410 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm; |
| 3411 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0)); | 3411 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0)); |
| 3412 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0)); | 3412 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0)); |
| 3413 { | 3413 { |
| 3414 cricket::WebRtcVoiceEngine engine( | 3414 cricket::WebRtcVoiceEngine engine( |
| 3415 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); | 3415 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3416 webrtc::RtcEventLogNullImpl event_log; | 3416 webrtc::RtcEventLogNullImpl event_log; |
| 3417 std::unique_ptr<webrtc::Call> call( | 3417 std::unique_ptr<webrtc::Call> call( |
| 3418 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3418 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3419 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3419 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3420 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3420 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3421 EXPECT_TRUE(channel != nullptr); | 3421 EXPECT_TRUE(channel != nullptr); |
| 3422 delete channel; | 3422 delete channel; |
| 3423 } | 3423 } |
| 3424 } | 3424 } |
| 3425 | 3425 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3473 cricket::AudioCodec(0, "", 0, 0, 2), nullptr)); | 3473 cricket::AudioCodec(0, "", 0, 0, 2), nullptr)); |
| 3474 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3474 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3475 cricket::AudioCodec(0, "", 5000, 0, 1), nullptr)); | 3475 cricket::AudioCodec(0, "", 5000, 0, 1), nullptr)); |
| 3476 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3476 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3477 cricket::AudioCodec(0, "", 0, 5000, 1), nullptr)); | 3477 cricket::AudioCodec(0, "", 0, 5000, 1), nullptr)); |
| 3478 | 3478 |
| 3479 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. | 3479 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. |
| 3480 // TODO(ossu): Why are the payload types of codecs with non-static payload | 3480 // TODO(ossu): Why are the payload types of codecs with non-static payload |
| 3481 // type assignments checked here? It shouldn't really matter. | 3481 // type assignments checked here? It shouldn't really matter. |
| 3482 cricket::WebRtcVoiceEngine engine( | 3482 cricket::WebRtcVoiceEngine engine( |
| 3483 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); | 3483 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3484 for (const cricket::AudioCodec& codec : engine.send_codecs()) { | 3484 for (const cricket::AudioCodec& codec : engine.send_codecs()) { |
| 3485 if (codec.name == "CN" && codec.clockrate == 16000) { | 3485 if (codec.name == "CN" && codec.clockrate == 16000) { |
| 3486 EXPECT_EQ(105, codec.id); | 3486 EXPECT_EQ(105, codec.id); |
| 3487 } else if (codec.name == "CN" && codec.clockrate == 32000) { | 3487 } else if (codec.name == "CN" && codec.clockrate == 32000) { |
| 3488 EXPECT_EQ(106, codec.id); | 3488 EXPECT_EQ(106, codec.id); |
| 3489 } else if (codec.name == "ISAC" && codec.clockrate == 16000) { | 3489 } else if (codec.name == "ISAC" && codec.clockrate == 16000) { |
| 3490 EXPECT_EQ(103, codec.id); | 3490 EXPECT_EQ(103, codec.id); |
| 3491 } else if (codec.name == "ISAC" && codec.clockrate == 32000) { | 3491 } else if (codec.name == "ISAC" && codec.clockrate == 32000) { |
| 3492 EXPECT_EQ(104, codec.id); | 3492 EXPECT_EQ(104, codec.id); |
| 3493 } else if (codec.name == "G722" && codec.clockrate == 8000) { | 3493 } else if (codec.name == "G722" && codec.clockrate == 8000) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3509 EXPECT_EQ("10", codec.params.find("minptime")->second); | 3509 EXPECT_EQ("10", codec.params.find("minptime")->second); |
| 3510 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end()); | 3510 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end()); |
| 3511 EXPECT_EQ("1", codec.params.find("useinbandfec")->second); | 3511 EXPECT_EQ("1", codec.params.find("useinbandfec")->second); |
| 3512 } | 3512 } |
| 3513 } | 3513 } |
| 3514 } | 3514 } |
| 3515 | 3515 |
| 3516 // Tests that VoE supports at least 32 channels | 3516 // Tests that VoE supports at least 32 channels |
| 3517 TEST(WebRtcVoiceEngineTest, Has32Channels) { | 3517 TEST(WebRtcVoiceEngineTest, Has32Channels) { |
| 3518 cricket::WebRtcVoiceEngine engine( | 3518 cricket::WebRtcVoiceEngine engine( |
| 3519 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); | 3519 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3520 webrtc::RtcEventLogNullImpl event_log; | 3520 webrtc::RtcEventLogNullImpl event_log; |
| 3521 std::unique_ptr<webrtc::Call> call( | 3521 std::unique_ptr<webrtc::Call> call( |
| 3522 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3522 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3523 | 3523 |
| 3524 cricket::VoiceMediaChannel* channels[32]; | 3524 cricket::VoiceMediaChannel* channels[32]; |
| 3525 int num_channels = 0; | 3525 int num_channels = 0; |
| 3526 while (num_channels < arraysize(channels)) { | 3526 while (num_channels < arraysize(channels)) { |
| 3527 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3527 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3528 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3528 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3529 if (!channel) | 3529 if (!channel) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3542 // Test that we set our preferred codecs properly. | 3542 // Test that we set our preferred codecs properly. |
| 3543 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3543 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
| 3544 // TODO(ossu): I'm not sure of the intent of this test. It's either: | 3544 // TODO(ossu): I'm not sure of the intent of this test. It's either: |
| 3545 // - Check that our builtin codecs are usable by Channel. | 3545 // - Check that our builtin codecs are usable by Channel. |
| 3546 // - The codecs provided by the engine is usable by Channel. | 3546 // - The codecs provided by the engine is usable by Channel. |
| 3547 // It does not check that the codecs in the RecvParameters are actually | 3547 // It does not check that the codecs in the RecvParameters are actually |
| 3548 // what we sent in - though it's probably reasonable to expect so, if | 3548 // what we sent in - though it's probably reasonable to expect so, if |
| 3549 // SetRecvParameters returns true. | 3549 // SetRecvParameters returns true. |
| 3550 // I think it will become clear once audio decoder injection is completed. | 3550 // I think it will become clear once audio decoder injection is completed. |
| 3551 cricket::WebRtcVoiceEngine engine( | 3551 cricket::WebRtcVoiceEngine engine( |
| 3552 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3552 nullptr, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); |
| 3553 webrtc::RtcEventLogNullImpl event_log; | 3553 webrtc::RtcEventLogNullImpl event_log; |
| 3554 std::unique_ptr<webrtc::Call> call( | 3554 std::unique_ptr<webrtc::Call> call( |
| 3555 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3555 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3556 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3556 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
| 3557 cricket::AudioOptions(), call.get()); | 3557 cricket::AudioOptions(), call.get()); |
| 3558 cricket::AudioRecvParameters parameters; | 3558 cricket::AudioRecvParameters parameters; |
| 3559 parameters.codecs = engine.recv_codecs(); | 3559 parameters.codecs = engine.recv_codecs(); |
| 3560 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3560 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3561 } | 3561 } |
| OLD | NEW |