| 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 3329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3459 channel_->SetRecvParameters(parameters); | 3459 channel_->SetRecvParameters(parameters); |
| 3460 | 3460 |
| 3461 EXPECT_TRUE(GetRecvStream(kSsrc1).started()); | 3461 EXPECT_TRUE(GetRecvStream(kSsrc1).started()); |
| 3462 } | 3462 } |
| 3463 | 3463 |
| 3464 // Tests that the library initializes and shuts down properly. | 3464 // Tests that the library initializes and shuts down properly. |
| 3465 TEST(WebRtcVoiceEngineTest, StartupShutdown) { | 3465 TEST(WebRtcVoiceEngineTest, StartupShutdown) { |
| 3466 // If the VoiceEngine wants to gather available codecs early, that's fine but | 3466 // If the VoiceEngine wants to gather available codecs early, that's fine but |
| 3467 // we never want it to create a decoder at this stage. | 3467 // we never want it to create a decoder at this stage. |
| 3468 cricket::WebRtcVoiceEngine engine( | 3468 cricket::WebRtcVoiceEngine engine( |
| 3469 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); | 3469 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3470 webrtc::RtcEventLogNullImpl event_log; | 3470 webrtc::RtcEventLogNullImpl event_log; |
| 3471 std::unique_ptr<webrtc::Call> call( | 3471 std::unique_ptr<webrtc::Call> call( |
| 3472 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3472 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3473 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3473 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3474 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3474 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3475 EXPECT_TRUE(channel != nullptr); | 3475 EXPECT_TRUE(channel != nullptr); |
| 3476 delete channel; | 3476 delete channel; |
| 3477 } | 3477 } |
| 3478 | 3478 |
| 3479 // Tests that reference counting on the external ADM is correct. | 3479 // Tests that reference counting on the external ADM is correct. |
| 3480 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { | 3480 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { |
| 3481 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm; | 3481 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm; |
| 3482 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0)); | 3482 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0)); |
| 3483 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0)); | 3483 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0)); |
| 3484 { | 3484 { |
| 3485 cricket::WebRtcVoiceEngine engine( | 3485 cricket::WebRtcVoiceEngine engine( |
| 3486 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); | 3486 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3487 webrtc::RtcEventLogNullImpl event_log; | 3487 webrtc::RtcEventLogNullImpl event_log; |
| 3488 std::unique_ptr<webrtc::Call> call( | 3488 std::unique_ptr<webrtc::Call> call( |
| 3489 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3489 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3490 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3490 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3491 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3491 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3492 EXPECT_TRUE(channel != nullptr); | 3492 EXPECT_TRUE(channel != nullptr); |
| 3493 delete channel; | 3493 delete channel; |
| 3494 } | 3494 } |
| 3495 } | 3495 } |
| 3496 | 3496 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3544 cricket::AudioCodec(0, "", 0, 0, 2), nullptr)); | 3544 cricket::AudioCodec(0, "", 0, 0, 2), nullptr)); |
| 3545 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3545 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3546 cricket::AudioCodec(0, "", 5000, 0, 1), nullptr)); | 3546 cricket::AudioCodec(0, "", 5000, 0, 1), nullptr)); |
| 3547 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3547 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3548 cricket::AudioCodec(0, "", 0, 5000, 1), nullptr)); | 3548 cricket::AudioCodec(0, "", 0, 5000, 1), nullptr)); |
| 3549 | 3549 |
| 3550 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. | 3550 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. |
| 3551 // TODO(ossu): Why are the payload types of codecs with non-static payload | 3551 // TODO(ossu): Why are the payload types of codecs with non-static payload |
| 3552 // type assignments checked here? It shouldn't really matter. | 3552 // type assignments checked here? It shouldn't really matter. |
| 3553 cricket::WebRtcVoiceEngine engine( | 3553 cricket::WebRtcVoiceEngine engine( |
| 3554 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); | 3554 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3555 for (const cricket::AudioCodec& codec : engine.send_codecs()) { | 3555 for (const cricket::AudioCodec& codec : engine.send_codecs()) { |
| 3556 if (codec.name == "CN" && codec.clockrate == 16000) { | 3556 if (codec.name == "CN" && codec.clockrate == 16000) { |
| 3557 EXPECT_EQ(105, codec.id); | 3557 EXPECT_EQ(105, codec.id); |
| 3558 } else if (codec.name == "CN" && codec.clockrate == 32000) { | 3558 } else if (codec.name == "CN" && codec.clockrate == 32000) { |
| 3559 EXPECT_EQ(106, codec.id); | 3559 EXPECT_EQ(106, codec.id); |
| 3560 } else if (codec.name == "ISAC" && codec.clockrate == 16000) { | 3560 } else if (codec.name == "ISAC" && codec.clockrate == 16000) { |
| 3561 EXPECT_EQ(103, codec.id); | 3561 EXPECT_EQ(103, codec.id); |
| 3562 } else if (codec.name == "ISAC" && codec.clockrate == 32000) { | 3562 } else if (codec.name == "ISAC" && codec.clockrate == 32000) { |
| 3563 EXPECT_EQ(104, codec.id); | 3563 EXPECT_EQ(104, codec.id); |
| 3564 } else if (codec.name == "G722" && codec.clockrate == 8000) { | 3564 } else if (codec.name == "G722" && codec.clockrate == 8000) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3580 EXPECT_EQ("10", codec.params.find("minptime")->second); | 3580 EXPECT_EQ("10", codec.params.find("minptime")->second); |
| 3581 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end()); | 3581 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end()); |
| 3582 EXPECT_EQ("1", codec.params.find("useinbandfec")->second); | 3582 EXPECT_EQ("1", codec.params.find("useinbandfec")->second); |
| 3583 } | 3583 } |
| 3584 } | 3584 } |
| 3585 } | 3585 } |
| 3586 | 3586 |
| 3587 // Tests that VoE supports at least 32 channels | 3587 // Tests that VoE supports at least 32 channels |
| 3588 TEST(WebRtcVoiceEngineTest, Has32Channels) { | 3588 TEST(WebRtcVoiceEngineTest, Has32Channels) { |
| 3589 cricket::WebRtcVoiceEngine engine( | 3589 cricket::WebRtcVoiceEngine engine( |
| 3590 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); | 3590 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
| 3591 webrtc::RtcEventLogNullImpl event_log; | 3591 webrtc::RtcEventLogNullImpl event_log; |
| 3592 std::unique_ptr<webrtc::Call> call( | 3592 std::unique_ptr<webrtc::Call> call( |
| 3593 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3593 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3594 | 3594 |
| 3595 cricket::VoiceMediaChannel* channels[32]; | 3595 cricket::VoiceMediaChannel* channels[32]; |
| 3596 int num_channels = 0; | 3596 int num_channels = 0; |
| 3597 while (num_channels < arraysize(channels)) { | 3597 while (num_channels < arraysize(channels)) { |
| 3598 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3598 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
| 3599 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3599 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
| 3600 if (!channel) | 3600 if (!channel) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3613 // Test that we set our preferred codecs properly. | 3613 // Test that we set our preferred codecs properly. |
| 3614 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3614 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
| 3615 // TODO(ossu): I'm not sure of the intent of this test. It's either: | 3615 // TODO(ossu): I'm not sure of the intent of this test. It's either: |
| 3616 // - Check that our builtin codecs are usable by Channel. | 3616 // - Check that our builtin codecs are usable by Channel. |
| 3617 // - The codecs provided by the engine is usable by Channel. | 3617 // - The codecs provided by the engine is usable by Channel. |
| 3618 // It does not check that the codecs in the RecvParameters are actually | 3618 // It does not check that the codecs in the RecvParameters are actually |
| 3619 // what we sent in - though it's probably reasonable to expect so, if | 3619 // what we sent in - though it's probably reasonable to expect so, if |
| 3620 // SetRecvParameters returns true. | 3620 // SetRecvParameters returns true. |
| 3621 // I think it will become clear once audio decoder injection is completed. | 3621 // I think it will become clear once audio decoder injection is completed. |
| 3622 cricket::WebRtcVoiceEngine engine( | 3622 cricket::WebRtcVoiceEngine engine( |
| 3623 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3623 nullptr, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); |
| 3624 webrtc::RtcEventLogNullImpl event_log; | 3624 webrtc::RtcEventLogNullImpl event_log; |
| 3625 std::unique_ptr<webrtc::Call> call( | 3625 std::unique_ptr<webrtc::Call> call( |
| 3626 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3626 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3627 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3627 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
| 3628 cricket::AudioOptions(), call.get()); | 3628 cricket::AudioOptions(), call.get()); |
| 3629 cricket::AudioRecvParameters parameters; | 3629 cricket::AudioRecvParameters parameters; |
| 3630 parameters.codecs = engine.recv_codecs(); | 3630 parameters.codecs = engine.recv_codecs(); |
| 3631 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3631 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3632 } | 3632 } |
| OLD | NEW |