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/base/arraysize.h" | 14 #include "webrtc/base/arraysize.h" |
15 #include "webrtc/base/byteorder.h" | 15 #include "webrtc/base/byteorder.h" |
16 #include "webrtc/base/gunit.h" | |
17 #include "webrtc/call/call.h" | 16 #include "webrtc/call/call.h" |
18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 17 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
19 #include "webrtc/media/base/fakemediaengine.h" | 18 #include "webrtc/media/base/fakemediaengine.h" |
20 #include "webrtc/media/base/fakenetworkinterface.h" | 19 #include "webrtc/media/base/fakenetworkinterface.h" |
21 #include "webrtc/media/base/fakertp.h" | 20 #include "webrtc/media/base/fakertp.h" |
22 #include "webrtc/media/base/mediaconstants.h" | 21 #include "webrtc/media/base/mediaconstants.h" |
23 #include "webrtc/media/engine/fakewebrtccall.h" | 22 #include "webrtc/media/engine/fakewebrtccall.h" |
24 #include "webrtc/media/engine/fakewebrtcvoiceengine.h" | 23 #include "webrtc/media/engine/fakewebrtcvoiceengine.h" |
25 #include "webrtc/media/engine/webrtcvoiceengine.h" | 24 #include "webrtc/media/engine/webrtcvoiceengine.h" |
26 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h" | 25 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h" |
27 #include "webrtc/modules/audio_device/include/mock_audio_device.h" | 26 #include "webrtc/modules/audio_device/include/mock_audio_device.h" |
28 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" | 27 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" |
29 #include "webrtc/pc/channel.h" | 28 #include "webrtc/pc/channel.h" |
30 #include "webrtc/test/field_trial.h" | 29 #include "webrtc/test/field_trial.h" |
30 #include "webrtc/test/gtest.h" | |
31 #include "webrtc/voice_engine/transmit_mixer.h" | |
31 | 32 |
32 using testing::Return; | 33 using testing::Return; |
33 using testing::StrictMock; | 34 using testing::StrictMock; |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1); | 38 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1); |
38 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1); | 39 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1); |
39 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2); | 40 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2); |
40 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1); | 41 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1); |
41 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1); | 42 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1); |
42 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1); | 43 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1); |
43 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1); | 44 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1); |
44 const cricket::AudioCodec | 45 const cricket::AudioCodec |
45 kTelephoneEventCodec1(106, "telephone-event", 8000, 0, 1); | 46 kTelephoneEventCodec1(106, "telephone-event", 8000, 0, 1); |
46 const cricket::AudioCodec | 47 const cricket::AudioCodec |
47 kTelephoneEventCodec2(107, "telephone-event", 32000, 0, 1); | 48 kTelephoneEventCodec2(107, "telephone-event", 32000, 0, 1); |
48 | 49 |
49 const uint32_t kSsrc1 = 0x99; | 50 const uint32_t kSsrc1 = 0x99; |
50 const uint32_t kSsrc2 = 2; | 51 const uint32_t kSsrc2 = 2; |
51 const uint32_t kSsrc3 = 3; | 52 const uint32_t kSsrc3 = 3; |
52 const uint32_t kSsrc4 = 0x42; | 53 const uint32_t kSsrc4 = 0x42; |
53 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; | 54 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; |
54 | 55 |
55 constexpr int kRtpHistoryMs = 5000; | 56 constexpr int kRtpHistoryMs = 5000; |
56 | 57 |
57 class FakeVoEWrapper : public cricket::VoEWrapper { | 58 class FakeVoEWrapper : public cricket::VoEWrapper { |
58 public: | 59 public: |
59 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) | 60 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) |
60 : cricket::VoEWrapper(engine, // processing | 61 : cricket::VoEWrapper(engine, // base |
61 engine, // base | |
62 engine, // codec | 62 engine, // codec |
63 engine, // hw | 63 engine, // hw |
64 engine) { // volume | 64 engine) { // volume |
65 } | 65 } |
66 }; | 66 }; |
67 | 67 |
68 class MockTransmitMixer : public webrtc::voe::TransmitMixer { | |
69 public: | |
70 MockTransmitMixer() = default; | |
71 virtual ~MockTransmitMixer() = default; | |
72 | |
73 MOCK_METHOD1(EnableStereoChannelSwapping, void(bool enable)); | |
74 }; | |
68 } // namespace | 75 } // namespace |
69 | 76 |
70 // Tests that our stub library "works". | 77 // Tests that our stub library "works". |
71 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { | 78 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { |
72 StrictMock<webrtc::test::MockAudioDeviceModule> adm; | 79 StrictMock<webrtc::test::MockAudioDeviceModule> adm; |
73 EXPECT_CALL(adm, AddRef()).WillOnce(Return(0)); | 80 EXPECT_CALL(adm, AddRef()).WillOnce(Return(0)); |
74 EXPECT_CALL(adm, Release()).WillOnce(Return(0)); | 81 EXPECT_CALL(adm, Release()).WillOnce(Return(0)); |
75 EXPECT_CALL(adm, BuiltInAECIsAvailable()).WillOnce(Return(false)); | 82 EXPECT_CALL(adm, BuiltInAECIsAvailable()).WillOnce(Return(false)); |
76 EXPECT_CALL(adm, BuiltInAGCIsAvailable()).WillOnce(Return(false)); | 83 EXPECT_CALL(adm, BuiltInAGCIsAvailable()).WillOnce(Return(false)); |
77 EXPECT_CALL(adm, BuiltInNSIsAvailable()).WillOnce(Return(false)); | 84 EXPECT_CALL(adm, BuiltInNSIsAvailable()).WillOnce(Return(false)); |
85 EXPECT_CALL(adm, SetAGC(true)).WillOnce(Return(0)); | |
78 StrictMock<webrtc::test::MockAudioProcessing> apm; | 86 StrictMock<webrtc::test::MockAudioProcessing> apm; |
79 EXPECT_CALL(apm, ApplyConfig(testing::_)); | 87 EXPECT_CALL(apm, ApplyConfig(testing::_)); |
80 EXPECT_CALL(apm, SetExtraOptions(testing::_)); | 88 EXPECT_CALL(apm, SetExtraOptions(testing::_)); |
81 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); | 89 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); |
82 cricket::FakeWebRtcVoiceEngine voe(&apm); | 90 StrictMock<MockTransmitMixer> transmit_mixer; |
91 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false)); | |
92 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer); | |
83 EXPECT_FALSE(voe.IsInited()); | 93 EXPECT_FALSE(voe.IsInited()); |
84 { | 94 { |
85 cricket::WebRtcVoiceEngine engine( | 95 cricket::WebRtcVoiceEngine engine( |
86 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, | 96 &adm, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, |
87 new FakeVoEWrapper(&voe)); | 97 new FakeVoEWrapper(&voe)); |
88 EXPECT_TRUE(voe.IsInited()); | 98 EXPECT_TRUE(voe.IsInited()); |
89 } | 99 } |
90 EXPECT_FALSE(voe.IsInited()); | 100 EXPECT_FALSE(voe.IsInited()); |
91 } | 101 } |
92 | 102 |
93 class FakeAudioSink : public webrtc::AudioSinkInterface { | 103 class FakeAudioSink : public webrtc::AudioSinkInterface { |
94 public: | 104 public: |
95 void OnData(const Data& audio) override {} | 105 void OnData(const Data& audio) override {} |
96 }; | 106 }; |
97 | 107 |
98 class FakeAudioSource : public cricket::AudioSource { | 108 class FakeAudioSource : public cricket::AudioSource { |
99 void SetSink(Sink* sink) override {} | 109 void SetSink(Sink* sink) override {} |
100 }; | 110 }; |
101 | 111 |
102 class WebRtcVoiceEngineTestFake : public testing::Test { | 112 class WebRtcVoiceEngineTestFake : public testing::Test { |
103 public: | 113 public: |
104 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} | 114 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} |
105 | 115 |
106 explicit WebRtcVoiceEngineTestFake(const char* field_trials) | 116 explicit WebRtcVoiceEngineTestFake(const char* field_trials) |
107 : call_(webrtc::Call::Config(&event_log_)), voe_(&apm_), | 117 : apm_gc_(*apm_.gain_control()), apm_ec_(*apm_.echo_cancellation()), |
118 apm_ns_(*apm_.noise_suppression()), apm_vd_(*apm_.voice_detection()), | |
119 call_(webrtc::Call::Config(&event_log_)), voe_(&apm_, &transmit_mixer_), | |
108 override_field_trials_(field_trials) { | 120 override_field_trials_(field_trials) { |
121 // AudioDeviceModule. | |
109 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); | 122 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); |
110 EXPECT_CALL(adm_, Release()).WillOnce(Return(0)); | 123 EXPECT_CALL(adm_, Release()).WillOnce(Return(0)); |
111 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false)); | 124 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false)); |
112 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false)); | 125 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false)); |
113 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false)); | 126 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false)); |
127 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0)); | |
128 // AudioProcessing. | |
114 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 129 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
115 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 130 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
116 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); | 131 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); |
132 // Default Options. | |
133 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
134 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
135 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); | |
136 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); | |
137 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0)); | |
138 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(false)); | |
139 // Init does not overwrite default AGC config. | |
140 EXPECT_CALL(apm_gc_, target_level_dbfs()).WillOnce(Return(1)); | |
141 EXPECT_CALL(apm_gc_, compression_gain_db()).WillRepeatedly(Return(5)); | |
142 EXPECT_CALL(apm_gc_, is_limiter_enabled()).WillRepeatedly(Return(true)); | |
143 EXPECT_CALL(apm_gc_, set_target_level_dbfs(1)).WillOnce(Return(0)); | |
144 EXPECT_CALL(apm_gc_, set_compression_gain_db(5)).WillRepeatedly(Return(0)); | |
145 EXPECT_CALL(apm_gc_, enable_limiter(true)).WillRepeatedly(Return(0)); | |
117 // TODO(kwiberg): We should use a mock AudioDecoderFactory, but a bunch of | 146 // TODO(kwiberg): We should use a mock AudioDecoderFactory, but a bunch of |
118 // the tests here probe the specific set of codecs provided by the builtin | 147 // the tests here probe the specific set of codecs provided by the builtin |
119 // factory. Those tests should probably be moved elsewhere. | 148 // factory. Those tests should probably be moved elsewhere. |
120 engine_.reset(new cricket::WebRtcVoiceEngine( | 149 engine_.reset(new cricket::WebRtcVoiceEngine( |
121 &adm_, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, | 150 &adm_, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, |
122 new FakeVoEWrapper(&voe_))); | 151 new FakeVoEWrapper(&voe_))); |
123 send_parameters_.codecs.push_back(kPcmuCodec); | 152 send_parameters_.codecs.push_back(kPcmuCodec); |
124 recv_parameters_.codecs.push_back(kPcmuCodec); | 153 recv_parameters_.codecs.push_back(kPcmuCodec); |
154 // Default Options. | |
155 EXPECT_TRUE(IsHighPassFilterEnabled()); | |
125 } | 156 } |
126 | 157 |
127 bool SetupChannel() { | 158 bool SetupChannel() { |
128 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 159 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
129 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 160 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
130 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), | 161 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), |
131 cricket::AudioOptions()); | 162 cricket::AudioOptions()); |
132 return (channel_ != nullptr); | 163 return (channel_ != nullptr); |
133 } | 164 } |
134 | 165 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 } | 630 } |
600 } | 631 } |
601 | 632 |
602 bool IsHighPassFilterEnabled() { | 633 bool IsHighPassFilterEnabled() { |
603 return engine_->GetApmConfigForTest().high_pass_filter.enabled; | 634 return engine_->GetApmConfigForTest().high_pass_filter.enabled; |
604 } | 635 } |
605 | 636 |
606 protected: | 637 protected: |
607 StrictMock<webrtc::test::MockAudioDeviceModule> adm_; | 638 StrictMock<webrtc::test::MockAudioDeviceModule> adm_; |
608 StrictMock<webrtc::test::MockAudioProcessing> apm_; | 639 StrictMock<webrtc::test::MockAudioProcessing> apm_; |
640 webrtc::test::MockGainControl& apm_gc_; | |
641 webrtc::test::MockEchoCancellation& apm_ec_; | |
642 webrtc::test::MockNoiseSuppression& apm_ns_; | |
643 webrtc::test::MockVoiceDetection& apm_vd_; | |
644 StrictMock<MockTransmitMixer> transmit_mixer_; | |
609 webrtc::RtcEventLogNullImpl event_log_; | 645 webrtc::RtcEventLogNullImpl event_log_; |
610 cricket::FakeCall call_; | 646 cricket::FakeCall call_; |
611 cricket::FakeWebRtcVoiceEngine voe_; | 647 cricket::FakeWebRtcVoiceEngine voe_; |
612 std::unique_ptr<cricket::WebRtcVoiceEngine> engine_; | 648 std::unique_ptr<cricket::WebRtcVoiceEngine> engine_; |
613 cricket::VoiceMediaChannel* channel_ = nullptr; | 649 cricket::VoiceMediaChannel* channel_ = nullptr; |
614 cricket::AudioSendParameters send_parameters_; | 650 cricket::AudioSendParameters send_parameters_; |
615 cricket::AudioRecvParameters recv_parameters_; | 651 cricket::AudioRecvParameters recv_parameters_; |
616 FakeAudioSource fake_source_; | 652 FakeAudioSource fake_source_; |
617 private: | 653 private: |
618 webrtc::test::ScopedFieldTrials override_field_trials_; | 654 webrtc::test::ScopedFieldTrials override_field_trials_; |
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2442 | 2478 |
2443 // Now remove the recv streams. | 2479 // Now remove the recv streams. |
2444 EXPECT_TRUE(channel_->RemoveRecvStream(3)); | 2480 EXPECT_TRUE(channel_->RemoveRecvStream(3)); |
2445 EXPECT_TRUE(channel_->RemoveRecvStream(2)); | 2481 EXPECT_TRUE(channel_->RemoveRecvStream(2)); |
2446 } | 2482 } |
2447 | 2483 |
2448 // Test that we can create a channel configured for Codian bridges, | 2484 // Test that we can create a channel configured for Codian bridges, |
2449 // and start sending on it. | 2485 // and start sending on it. |
2450 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { | 2486 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { |
2451 EXPECT_TRUE(SetupSendStream()); | 2487 EXPECT_TRUE(SetupSendStream()); |
2452 cricket::AudioOptions options_adjust_agc; | 2488 send_parameters_.options.adjust_agc_delta = rtc::Optional<int>(-10); |
2453 options_adjust_agc.adjust_agc_delta = rtc::Optional<int>(-10); | 2489 EXPECT_CALL(apm_gc_, |
2454 webrtc::AgcConfig agc_config; | 2490 set_target_level_dbfs(11)).Times(2).WillRepeatedly(Return(0)); |
2455 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | |
2456 EXPECT_EQ(0, agc_config.targetLeveldBOv); | |
2457 send_parameters_.options = options_adjust_agc; | |
2458 SetSendParameters(send_parameters_); | 2491 SetSendParameters(send_parameters_); |
2459 SetSend(true); | 2492 SetSend(true); |
2460 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending()); | 2493 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending()); |
2461 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | |
2462 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated | |
2463 SetSend(false); | 2494 SetSend(false); |
2464 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); | 2495 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); |
2465 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | |
2466 } | 2496 } |
2467 | 2497 |
2468 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { | 2498 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { |
2469 EXPECT_TRUE(SetupSendStream()); | 2499 EXPECT_TRUE(SetupSendStream()); |
2470 EXPECT_CALL(adm_, | 2500 EXPECT_CALL(adm_, |
2471 BuiltInAGCIsAvailable()).Times(2).WillRepeatedly(Return(false)); | 2501 BuiltInAGCIsAvailable()).Times(2).WillRepeatedly(Return(false)); |
2472 webrtc::AgcConfig agc_config; | 2502 EXPECT_CALL(adm_, SetAGC(true)).Times(2).WillRepeatedly(Return(0)); |
2473 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2503 EXPECT_CALL(apm_gc_, Enable(true)).Times(2).WillOnce(Return(0)); |
2474 EXPECT_EQ(0, agc_config.targetLeveldBOv); | |
2475 send_parameters_.options.tx_agc_target_dbov = rtc::Optional<uint16_t>(3); | 2504 send_parameters_.options.tx_agc_target_dbov = rtc::Optional<uint16_t>(3); |
2476 send_parameters_.options.tx_agc_digital_compression_gain = | 2505 send_parameters_.options.tx_agc_digital_compression_gain = |
2477 rtc::Optional<uint16_t>(9); | 2506 rtc::Optional<uint16_t>(9); |
2478 send_parameters_.options.tx_agc_limiter = rtc::Optional<bool>(true); | 2507 send_parameters_.options.tx_agc_limiter = rtc::Optional<bool>(true); |
2479 send_parameters_.options.auto_gain_control = rtc::Optional<bool>(true); | 2508 send_parameters_.options.auto_gain_control = rtc::Optional<bool>(true); |
2509 EXPECT_CALL(apm_gc_, set_target_level_dbfs(3)).WillOnce(Return(0)); | |
2510 EXPECT_CALL(apm_gc_, set_compression_gain_db(9)).WillRepeatedly(Return(0)); | |
2511 EXPECT_CALL(apm_gc_, enable_limiter(true)).WillRepeatedly(Return(0)); | |
2480 SetSendParameters(send_parameters_); | 2512 SetSendParameters(send_parameters_); |
2481 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | |
2482 EXPECT_EQ(3, agc_config.targetLeveldBOv); | |
2483 EXPECT_EQ(9, agc_config.digitalCompressionGaindB); | |
2484 EXPECT_TRUE(agc_config.limiterEnable); | |
2485 | 2513 |
2486 // Check interaction with adjust_agc_delta. Both should be respected, for | 2514 // Check interaction with adjust_agc_delta. Both should be respected, for |
2487 // backwards compatibility. | 2515 // backwards compatibility. |
2488 send_parameters_.options.adjust_agc_delta = rtc::Optional<int>(-10); | 2516 send_parameters_.options.adjust_agc_delta = rtc::Optional<int>(-10); |
2517 EXPECT_CALL(apm_gc_, set_target_level_dbfs(13)).WillOnce(Return(0)); | |
2489 SetSendParameters(send_parameters_); | 2518 SetSendParameters(send_parameters_); |
2490 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | |
2491 EXPECT_EQ(13, agc_config.targetLeveldBOv); | |
2492 } | 2519 } |
2493 | 2520 |
2494 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { | 2521 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { |
2495 EXPECT_TRUE(SetupSendStream()); | 2522 EXPECT_TRUE(SetupSendStream()); |
2496 EXPECT_CALL(adm_, SetRecordingSampleRate(48000)).WillOnce(Return(0)); | 2523 EXPECT_CALL(adm_, SetRecordingSampleRate(48000)).WillOnce(Return(0)); |
2497 EXPECT_CALL(adm_, SetPlayoutSampleRate(44100)).WillOnce(Return(0)); | 2524 EXPECT_CALL(adm_, SetPlayoutSampleRate(44100)).WillOnce(Return(0)); |
2498 send_parameters_.options.recording_sample_rate = | 2525 send_parameters_.options.recording_sample_rate = |
2499 rtc::Optional<uint32_t>(48000); | 2526 rtc::Optional<uint32_t>(48000); |
2500 send_parameters_.options.playout_sample_rate = rtc::Optional<uint32_t>(44100); | 2527 send_parameters_.options.playout_sample_rate = rtc::Optional<uint32_t>(44100); |
2501 SetSendParameters(send_parameters_); | 2528 SetSendParameters(send_parameters_); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2902 } | 2929 } |
2903 | 2930 |
2904 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { | 2931 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
2905 EXPECT_TRUE(SetupSendStream()); | 2932 EXPECT_TRUE(SetupSendStream()); |
2906 EXPECT_CALL(adm_, | 2933 EXPECT_CALL(adm_, |
2907 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); | 2934 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); |
2908 EXPECT_CALL(adm_, | 2935 EXPECT_CALL(adm_, |
2909 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); | 2936 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); |
2910 EXPECT_CALL(adm_, | 2937 EXPECT_CALL(adm_, |
2911 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); | 2938 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); |
2912 bool ec_enabled; | 2939 |
2913 webrtc::EcModes ec_mode; | |
2914 webrtc::AecmModes aecm_mode; | |
2915 bool cng_enabled; | |
2916 bool agc_enabled; | |
2917 webrtc::AgcModes agc_mode; | |
2918 webrtc::AgcConfig agc_config; | |
2919 bool ns_enabled; | |
2920 webrtc::NsModes ns_mode; | |
2921 bool stereo_swapping_enabled; | |
2922 bool typing_detection_enabled; | |
2923 voe_.GetEcStatus(ec_enabled, ec_mode); | |
2924 voe_.GetAecmMode(aecm_mode, cng_enabled); | |
2925 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
2926 voe_.GetAgcConfig(agc_config); | |
2927 voe_.GetNsStatus(ns_enabled, ns_mode); | |
2928 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | |
2929 voe_.GetTypingDetectionStatus(typing_detection_enabled); | |
2930 EXPECT_TRUE(ec_enabled); | |
2931 EXPECT_TRUE(voe_.ec_metrics_enabled()); | |
2932 EXPECT_FALSE(cng_enabled); | |
2933 EXPECT_TRUE(agc_enabled); | |
2934 EXPECT_EQ(0, agc_config.targetLeveldBOv); | |
2935 EXPECT_TRUE(ns_enabled); | |
2936 EXPECT_TRUE(IsHighPassFilterEnabled()); | |
2937 EXPECT_FALSE(stereo_swapping_enabled); | |
2938 EXPECT_TRUE(typing_detection_enabled); | |
2939 EXPECT_EQ(ec_mode, webrtc::kEcConference); | |
2940 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); | |
2941 EXPECT_EQ(50, voe_.GetNetEqCapacity()); | 2940 EXPECT_EQ(50, voe_.GetNetEqCapacity()); |
2942 EXPECT_FALSE(voe_.GetNetEqFastAccelerate()); | 2941 EXPECT_FALSE(voe_.GetNetEqFastAccelerate()); |
2943 | 2942 |
2944 // Nothing set in AudioOptions, so everything should be as default. | 2943 // Nothing set in AudioOptions, so everything should be as default. |
2945 send_parameters_.options = cricket::AudioOptions(); | 2944 send_parameters_.options = cricket::AudioOptions(); |
2946 SetSendParameters(send_parameters_); | 2945 SetSendParameters(send_parameters_); |
2947 voe_.GetEcStatus(ec_enabled, ec_mode); | |
2948 voe_.GetAecmMode(aecm_mode, cng_enabled); | |
2949 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
2950 voe_.GetAgcConfig(agc_config); | |
2951 voe_.GetNsStatus(ns_enabled, ns_mode); | |
2952 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | |
2953 voe_.GetTypingDetectionStatus(typing_detection_enabled); | |
2954 EXPECT_TRUE(ec_enabled); | |
2955 EXPECT_TRUE(voe_.ec_metrics_enabled()); | |
2956 EXPECT_FALSE(cng_enabled); | |
2957 EXPECT_TRUE(agc_enabled); | |
2958 EXPECT_EQ(0, agc_config.targetLeveldBOv); | |
2959 EXPECT_TRUE(ns_enabled); | |
2960 EXPECT_TRUE(IsHighPassFilterEnabled()); | 2946 EXPECT_TRUE(IsHighPassFilterEnabled()); |
2961 EXPECT_FALSE(stereo_swapping_enabled); | |
2962 EXPECT_TRUE(typing_detection_enabled); | |
2963 EXPECT_EQ(ec_mode, webrtc::kEcConference); | |
2964 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); | |
2965 EXPECT_EQ(50, voe_.GetNetEqCapacity()); | 2947 EXPECT_EQ(50, voe_.GetNetEqCapacity()); |
2966 EXPECT_FALSE(voe_.GetNetEqFastAccelerate()); | 2948 EXPECT_FALSE(voe_.GetNetEqFastAccelerate()); |
2967 | 2949 |
2968 // Turn echo cancellation off | 2950 // Turn echo cancellation off |
2951 EXPECT_CALL(apm_ec_, Enable(false)).WillOnce(Return(0)); | |
2952 EXPECT_CALL(apm_ec_, enable_metrics(false)).WillOnce(Return(0)); | |
2969 send_parameters_.options.echo_cancellation = rtc::Optional<bool>(false); | 2953 send_parameters_.options.echo_cancellation = rtc::Optional<bool>(false); |
2970 SetSendParameters(send_parameters_); | 2954 SetSendParameters(send_parameters_); |
2971 voe_.GetEcStatus(ec_enabled, ec_mode); | |
2972 EXPECT_FALSE(ec_enabled); | |
2973 | 2955 |
2974 // Turn echo cancellation back on, with settings, and make sure | 2956 // Turn echo cancellation back on, with settings, and make sure |
2975 // nothing else changed. | 2957 // nothing else changed. |
2958 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
2959 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
2976 send_parameters_.options.echo_cancellation = rtc::Optional<bool>(true); | 2960 send_parameters_.options.echo_cancellation = rtc::Optional<bool>(true); |
2977 SetSendParameters(send_parameters_); | 2961 SetSendParameters(send_parameters_); |
2978 voe_.GetEcStatus(ec_enabled, ec_mode); | |
2979 voe_.GetAecmMode(aecm_mode, cng_enabled); | |
2980 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
2981 voe_.GetAgcConfig(agc_config); | |
2982 voe_.GetNsStatus(ns_enabled, ns_mode); | |
2983 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | |
2984 voe_.GetTypingDetectionStatus(typing_detection_enabled); | |
2985 EXPECT_TRUE(ec_enabled); | |
2986 EXPECT_TRUE(voe_.ec_metrics_enabled()); | |
2987 EXPECT_TRUE(agc_enabled); | |
2988 EXPECT_EQ(0, agc_config.targetLeveldBOv); | |
2989 EXPECT_TRUE(ns_enabled); | |
2990 EXPECT_TRUE(IsHighPassFilterEnabled()); | |
2991 EXPECT_FALSE(stereo_swapping_enabled); | |
2992 EXPECT_TRUE(typing_detection_enabled); | |
2993 EXPECT_EQ(ec_mode, webrtc::kEcConference); | |
2994 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); | |
2995 | 2962 |
2996 // Turn on delay agnostic aec and make sure nothing change w.r.t. echo | 2963 // Turn on delay agnostic aec and make sure nothing change w.r.t. echo |
2997 // control. | 2964 // control. |
2965 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
2966 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
2998 send_parameters_.options.delay_agnostic_aec = rtc::Optional<bool>(true); | 2967 send_parameters_.options.delay_agnostic_aec = rtc::Optional<bool>(true); |
2999 SetSendParameters(send_parameters_); | 2968 SetSendParameters(send_parameters_); |
3000 voe_.GetEcStatus(ec_enabled, ec_mode); | |
3001 voe_.GetAecmMode(aecm_mode, cng_enabled); | |
3002 EXPECT_TRUE(ec_enabled); | |
3003 EXPECT_TRUE(voe_.ec_metrics_enabled()); | |
3004 EXPECT_EQ(ec_mode, webrtc::kEcConference); | |
3005 | 2969 |
3006 // Turn off echo cancellation and delay agnostic aec. | 2970 // Turn off echo cancellation and delay agnostic aec. |
2971 EXPECT_CALL(apm_ec_, Enable(false)).WillOnce(Return(0)); | |
2972 EXPECT_CALL(apm_ec_, enable_metrics(false)).WillOnce(Return(0)); | |
3007 send_parameters_.options.delay_agnostic_aec = rtc::Optional<bool>(false); | 2973 send_parameters_.options.delay_agnostic_aec = rtc::Optional<bool>(false); |
3008 send_parameters_.options.extended_filter_aec = rtc::Optional<bool>(false); | 2974 send_parameters_.options.extended_filter_aec = rtc::Optional<bool>(false); |
3009 send_parameters_.options.echo_cancellation = rtc::Optional<bool>(false); | 2975 send_parameters_.options.echo_cancellation = rtc::Optional<bool>(false); |
3010 SetSendParameters(send_parameters_); | 2976 SetSendParameters(send_parameters_); |
3011 voe_.GetEcStatus(ec_enabled, ec_mode); | 2977 |
3012 EXPECT_FALSE(ec_enabled); | |
3013 // Turning delay agnostic aec back on should also turn on echo cancellation. | 2978 // Turning delay agnostic aec back on should also turn on echo cancellation. |
2979 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
2980 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3014 send_parameters_.options.delay_agnostic_aec = rtc::Optional<bool>(true); | 2981 send_parameters_.options.delay_agnostic_aec = rtc::Optional<bool>(true); |
3015 SetSendParameters(send_parameters_); | 2982 SetSendParameters(send_parameters_); |
3016 voe_.GetEcStatus(ec_enabled, ec_mode); | |
3017 EXPECT_TRUE(ec_enabled); | |
3018 EXPECT_TRUE(voe_.ec_metrics_enabled()); | |
3019 EXPECT_EQ(ec_mode, webrtc::kEcConference); | |
3020 | 2983 |
3021 // Turn off AGC | 2984 // Turn off AGC |
2985 EXPECT_CALL(adm_, SetAGC(false)).WillOnce(Return(0)); | |
2986 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
2987 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
2988 EXPECT_CALL(apm_gc_, Enable(false)).WillOnce(Return(0)); | |
3022 send_parameters_.options.auto_gain_control = rtc::Optional<bool>(false); | 2989 send_parameters_.options.auto_gain_control = rtc::Optional<bool>(false); |
3023 SetSendParameters(send_parameters_); | 2990 SetSendParameters(send_parameters_); |
3024 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
3025 EXPECT_FALSE(agc_enabled); | |
3026 | 2991 |
3027 // Turn AGC back on | 2992 // Turn AGC back on |
2993 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0)); | |
2994 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
2995 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
2996 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); | |
3028 send_parameters_.options.auto_gain_control = rtc::Optional<bool>(true); | 2997 send_parameters_.options.auto_gain_control = rtc::Optional<bool>(true); |
3029 send_parameters_.options.adjust_agc_delta = rtc::Optional<int>(); | 2998 send_parameters_.options.adjust_agc_delta = rtc::Optional<int>(); |
3030 SetSendParameters(send_parameters_); | 2999 SetSendParameters(send_parameters_); |
3031 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
3032 EXPECT_TRUE(agc_enabled); | |
3033 voe_.GetAgcConfig(agc_config); | |
3034 EXPECT_EQ(0, agc_config.targetLeveldBOv); | |
3035 | 3000 |
3036 // Turn off other options (and stereo swapping on). | 3001 // Turn off other options (and stereo swapping on). |
3002 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0)); | |
3003 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
3004 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3005 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); | |
3006 EXPECT_CALL(apm_ns_, Enable(false)).WillOnce(Return(0)); | |
3007 EXPECT_CALL(apm_vd_, Enable(false)).WillOnce(Return(0)); | |
3008 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(true)); | |
3037 send_parameters_.options.noise_suppression = rtc::Optional<bool>(false); | 3009 send_parameters_.options.noise_suppression = rtc::Optional<bool>(false); |
3038 send_parameters_.options.highpass_filter = rtc::Optional<bool>(false); | 3010 send_parameters_.options.highpass_filter = rtc::Optional<bool>(false); |
3039 send_parameters_.options.typing_detection = rtc::Optional<bool>(false); | 3011 send_parameters_.options.typing_detection = rtc::Optional<bool>(false); |
3040 send_parameters_.options.stereo_swapping = rtc::Optional<bool>(true); | 3012 send_parameters_.options.stereo_swapping = rtc::Optional<bool>(true); |
3041 SetSendParameters(send_parameters_); | 3013 SetSendParameters(send_parameters_); |
3042 voe_.GetNsStatus(ns_enabled, ns_mode); | |
3043 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | |
3044 voe_.GetTypingDetectionStatus(typing_detection_enabled); | |
3045 EXPECT_FALSE(ns_enabled); | |
3046 EXPECT_FALSE(IsHighPassFilterEnabled()); | 3014 EXPECT_FALSE(IsHighPassFilterEnabled()); |
3047 EXPECT_FALSE(typing_detection_enabled); | |
3048 EXPECT_TRUE(stereo_swapping_enabled); | |
3049 | 3015 |
3050 // Set options again to ensure it has no impact. | 3016 // Set options again to ensure it has no impact. |
3017 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0)); | |
3018 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
3019 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3020 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); | |
3021 EXPECT_CALL(apm_ns_, Enable(false)).WillOnce(Return(0)); | |
3022 EXPECT_CALL(apm_vd_, Enable(false)).WillOnce(Return(0)); | |
3023 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(true)); | |
3051 SetSendParameters(send_parameters_); | 3024 SetSendParameters(send_parameters_); |
3052 voe_.GetEcStatus(ec_enabled, ec_mode); | |
3053 voe_.GetNsStatus(ns_enabled, ns_mode); | |
3054 EXPECT_TRUE(ec_enabled); | |
3055 EXPECT_EQ(webrtc::kEcConference, ec_mode); | |
3056 EXPECT_FALSE(ns_enabled); | |
3057 EXPECT_EQ(webrtc::kNsHighSuppression, ns_mode); | |
3058 } | |
3059 | |
3060 TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) { | |
3061 EXPECT_TRUE(SetupSendStream()); | |
3062 | |
3063 bool ec_enabled; | |
3064 webrtc::EcModes ec_mode; | |
3065 bool agc_enabled; | |
3066 webrtc::AgcModes agc_mode; | |
3067 bool ns_enabled; | |
3068 webrtc::NsModes ns_mode; | |
3069 bool stereo_swapping_enabled; | |
3070 bool typing_detection_enabled; | |
3071 | |
3072 voe_.GetEcStatus(ec_enabled, ec_mode); | |
3073 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
3074 voe_.GetNsStatus(ns_enabled, ns_mode); | |
3075 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | |
3076 voe_.GetTypingDetectionStatus(typing_detection_enabled); | |
3077 EXPECT_TRUE(ec_enabled); | |
3078 EXPECT_TRUE(agc_enabled); | |
3079 EXPECT_TRUE(ns_enabled); | |
3080 EXPECT_TRUE(IsHighPassFilterEnabled()); | |
3081 EXPECT_TRUE(typing_detection_enabled); | |
3082 EXPECT_FALSE(stereo_swapping_enabled); | |
3083 } | |
3084 | |
3085 TEST_F(WebRtcVoiceEngineTestFake, InitDoesNotOverwriteDefaultAgcConfig) { | |
3086 webrtc::AgcConfig set_config = {0}; | |
3087 set_config.targetLeveldBOv = 3; | |
3088 set_config.digitalCompressionGaindB = 9; | |
3089 set_config.limiterEnable = true; | |
3090 EXPECT_EQ(0, voe_.SetAgcConfig(set_config)); | |
3091 | |
3092 webrtc::AgcConfig config = {0}; | |
3093 EXPECT_EQ(0, voe_.GetAgcConfig(config)); | |
3094 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv); | |
3095 EXPECT_EQ(set_config.digitalCompressionGaindB, | |
3096 config.digitalCompressionGaindB); | |
3097 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable); | |
3098 } | 3025 } |
3099 | 3026 |
3100 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { | 3027 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { |
3101 EXPECT_TRUE(SetupSendStream()); | 3028 EXPECT_TRUE(SetupSendStream()); |
3102 EXPECT_CALL(adm_, | 3029 EXPECT_CALL(adm_, |
3103 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); | 3030 BuiltInAECIsAvailable()).Times(8).WillRepeatedly(Return(false)); |
3104 EXPECT_CALL(adm_, | 3031 EXPECT_CALL(adm_, |
3105 BuiltInAGCIsAvailable()).Times(9).WillRepeatedly(Return(false)); | 3032 BuiltInAGCIsAvailable()).Times(8).WillRepeatedly(Return(false)); |
3106 EXPECT_CALL(adm_, | 3033 EXPECT_CALL(adm_, |
3107 BuiltInNSIsAvailable()).Times(9).WillRepeatedly(Return(false)); | 3034 BuiltInNSIsAvailable()).Times(8).WillRepeatedly(Return(false)); |
3108 EXPECT_CALL(adm_, | 3035 EXPECT_CALL(adm_, |
3109 RecordingIsInitialized()).Times(2).WillRepeatedly(Return(false)); | 3036 RecordingIsInitialized()).Times(2).WillRepeatedly(Return(false)); |
3110 EXPECT_CALL(adm_, Recording()).Times(2).WillRepeatedly(Return(false)); | 3037 EXPECT_CALL(adm_, Recording()).Times(2).WillRepeatedly(Return(false)); |
3111 EXPECT_CALL(adm_, InitRecording()).Times(2).WillRepeatedly(Return(0)); | 3038 EXPECT_CALL(adm_, InitRecording()).Times(2).WillRepeatedly(Return(0)); |
3112 EXPECT_CALL(apm_, ApplyConfig(testing::_)).Times(10); | 3039 EXPECT_CALL(apm_, ApplyConfig(testing::_)).Times(10); |
3113 EXPECT_CALL(apm_, SetExtraOptions(testing::_)).Times(10); | 3040 EXPECT_CALL(apm_, SetExtraOptions(testing::_)).Times(10); |
3114 | 3041 |
3115 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel1( | 3042 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel1( |
3116 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel( | 3043 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel( |
3117 &call_, cricket::MediaConfig(), cricket::AudioOptions()))); | 3044 &call_, cricket::MediaConfig(), cricket::AudioOptions()))); |
3118 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel2( | 3045 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel2( |
3119 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel( | 3046 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel( |
3120 &call_, cricket::MediaConfig(), cricket::AudioOptions()))); | 3047 &call_, cricket::MediaConfig(), cricket::AudioOptions()))); |
3121 | 3048 |
3122 // Have to add a stream to make SetSend work. | 3049 // Have to add a stream to make SetSend work. |
3123 cricket::StreamParams stream1; | 3050 cricket::StreamParams stream1; |
3124 stream1.ssrcs.push_back(1); | 3051 stream1.ssrcs.push_back(1); |
3125 channel1->AddSendStream(stream1); | 3052 channel1->AddSendStream(stream1); |
3126 cricket::StreamParams stream2; | 3053 cricket::StreamParams stream2; |
3127 stream2.ssrcs.push_back(2); | 3054 stream2.ssrcs.push_back(2); |
3128 channel2->AddSendStream(stream2); | 3055 channel2->AddSendStream(stream2); |
3129 | 3056 |
3130 // AEC and AGC and NS | 3057 // AEC and AGC and NS |
3131 cricket::AudioSendParameters parameters_options_all = send_parameters_; | 3058 cricket::AudioSendParameters parameters_options_all = send_parameters_; |
3132 parameters_options_all.options.echo_cancellation = rtc::Optional<bool>(true); | 3059 parameters_options_all.options.echo_cancellation = rtc::Optional<bool>(true); |
3133 parameters_options_all.options.auto_gain_control = rtc::Optional<bool>(true); | 3060 parameters_options_all.options.auto_gain_control = rtc::Optional<bool>(true); |
3134 parameters_options_all.options.noise_suppression = rtc::Optional<bool>(true); | 3061 parameters_options_all.options.noise_suppression = rtc::Optional<bool>(true); |
3062 EXPECT_CALL(adm_, SetAGC(true)).Times(2).WillRepeatedly(Return(0)); | |
3063 EXPECT_CALL(apm_ec_, Enable(true)).Times(2).WillRepeatedly(Return(0)); | |
3064 EXPECT_CALL(apm_ec_, enable_metrics(true)).Times(2).WillRepeatedly(Return(0)); | |
3065 EXPECT_CALL(apm_gc_, Enable(true)).Times(2).WillRepeatedly(Return(0)); | |
3066 EXPECT_CALL(apm_ns_, Enable(true)).Times(2).WillRepeatedly(Return(0)); | |
3135 EXPECT_TRUE(channel1->SetSendParameters(parameters_options_all)); | 3067 EXPECT_TRUE(channel1->SetSendParameters(parameters_options_all)); |
3136 EXPECT_EQ(parameters_options_all.options, channel1->options()); | 3068 EXPECT_EQ(parameters_options_all.options, channel1->options()); |
3137 EXPECT_TRUE(channel2->SetSendParameters(parameters_options_all)); | 3069 EXPECT_TRUE(channel2->SetSendParameters(parameters_options_all)); |
3138 EXPECT_EQ(parameters_options_all.options, channel2->options()); | 3070 EXPECT_EQ(parameters_options_all.options, channel2->options()); |
3139 | 3071 |
3140 // unset NS | 3072 // unset NS |
3141 cricket::AudioSendParameters parameters_options_no_ns = send_parameters_; | 3073 cricket::AudioSendParameters parameters_options_no_ns = send_parameters_; |
3142 parameters_options_no_ns.options.noise_suppression = | 3074 parameters_options_no_ns.options.noise_suppression = |
3143 rtc::Optional<bool>(false); | 3075 rtc::Optional<bool>(false); |
3076 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0)); | |
3077 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
3078 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3079 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); | |
3080 EXPECT_CALL(apm_ns_, Enable(false)).WillOnce(Return(0)); | |
3144 EXPECT_TRUE(channel1->SetSendParameters(parameters_options_no_ns)); | 3081 EXPECT_TRUE(channel1->SetSendParameters(parameters_options_no_ns)); |
3145 cricket::AudioOptions expected_options = parameters_options_all.options; | 3082 cricket::AudioOptions expected_options = parameters_options_all.options; |
3146 expected_options.echo_cancellation = rtc::Optional<bool>(true); | 3083 expected_options.echo_cancellation = rtc::Optional<bool>(true); |
3147 expected_options.auto_gain_control = rtc::Optional<bool>(true); | 3084 expected_options.auto_gain_control = rtc::Optional<bool>(true); |
3148 expected_options.noise_suppression = rtc::Optional<bool>(false); | 3085 expected_options.noise_suppression = rtc::Optional<bool>(false); |
3149 EXPECT_EQ(expected_options, channel1->options()); | 3086 EXPECT_EQ(expected_options, channel1->options()); |
3150 | 3087 |
3151 // unset AGC | 3088 // unset AGC |
3152 cricket::AudioSendParameters parameters_options_no_agc = send_parameters_; | 3089 cricket::AudioSendParameters parameters_options_no_agc = send_parameters_; |
3153 parameters_options_no_agc.options.auto_gain_control = | 3090 parameters_options_no_agc.options.auto_gain_control = |
3154 rtc::Optional<bool>(false); | 3091 rtc::Optional<bool>(false); |
3092 EXPECT_CALL(adm_, SetAGC(false)).WillOnce(Return(0)); | |
3093 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
3094 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3095 EXPECT_CALL(apm_gc_, Enable(false)).WillOnce(Return(0)); | |
3096 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); | |
3155 EXPECT_TRUE(channel2->SetSendParameters(parameters_options_no_agc)); | 3097 EXPECT_TRUE(channel2->SetSendParameters(parameters_options_no_agc)); |
3156 expected_options.echo_cancellation = rtc::Optional<bool>(true); | 3098 expected_options.echo_cancellation = rtc::Optional<bool>(true); |
3157 expected_options.auto_gain_control = rtc::Optional<bool>(false); | 3099 expected_options.auto_gain_control = rtc::Optional<bool>(false); |
3158 expected_options.noise_suppression = rtc::Optional<bool>(true); | 3100 expected_options.noise_suppression = rtc::Optional<bool>(true); |
3159 EXPECT_EQ(expected_options, channel2->options()); | 3101 EXPECT_EQ(expected_options, channel2->options()); |
3160 | 3102 |
3103 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0)); | |
3104 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
3105 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3106 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); | |
3107 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); | |
3161 EXPECT_TRUE(channel_->SetSendParameters(parameters_options_all)); | 3108 EXPECT_TRUE(channel_->SetSendParameters(parameters_options_all)); |
3162 bool ec_enabled; | |
3163 webrtc::EcModes ec_mode; | |
3164 bool agc_enabled; | |
3165 webrtc::AgcModes agc_mode; | |
3166 bool ns_enabled; | |
3167 webrtc::NsModes ns_mode; | |
3168 voe_.GetEcStatus(ec_enabled, ec_mode); | |
3169 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
3170 voe_.GetNsStatus(ns_enabled, ns_mode); | |
3171 EXPECT_TRUE(ec_enabled); | |
3172 EXPECT_TRUE(agc_enabled); | |
3173 EXPECT_TRUE(ns_enabled); | |
3174 | 3109 |
3110 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0)); | |
3111 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
3112 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3113 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); | |
3114 EXPECT_CALL(apm_ns_, Enable(false)).WillOnce(Return(0)); | |
3175 channel1->SetSend(true); | 3115 channel1->SetSend(true); |
3176 voe_.GetEcStatus(ec_enabled, ec_mode); | |
3177 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
3178 voe_.GetNsStatus(ns_enabled, ns_mode); | |
3179 EXPECT_TRUE(ec_enabled); | |
3180 EXPECT_TRUE(agc_enabled); | |
3181 EXPECT_FALSE(ns_enabled); | |
3182 | 3116 |
3117 EXPECT_CALL(adm_, SetAGC(false)).WillOnce(Return(0)); | |
3118 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
3119 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3120 EXPECT_CALL(apm_gc_, Enable(false)).WillOnce(Return(0)); | |
3121 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); | |
3183 channel2->SetSend(true); | 3122 channel2->SetSend(true); |
3184 voe_.GetEcStatus(ec_enabled, ec_mode); | |
3185 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
3186 voe_.GetNsStatus(ns_enabled, ns_mode); | |
3187 EXPECT_TRUE(ec_enabled); | |
3188 EXPECT_FALSE(agc_enabled); | |
3189 EXPECT_TRUE(ns_enabled); | |
3190 | 3123 |
3191 // Make sure settings take effect while we are sending. | 3124 // Make sure settings take effect while we are sending. |
3192 EXPECT_TRUE(channel_->SetSendParameters(parameters_options_all)); | |
3193 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | |
3194 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | |
3195 cricket::AudioSendParameters parameters_options_no_agc_nor_ns = | 3125 cricket::AudioSendParameters parameters_options_no_agc_nor_ns = |
3196 send_parameters_; | 3126 send_parameters_; |
3197 parameters_options_no_agc_nor_ns.options.auto_gain_control = | 3127 parameters_options_no_agc_nor_ns.options.auto_gain_control = |
3198 rtc::Optional<bool>(false); | 3128 rtc::Optional<bool>(false); |
3199 parameters_options_no_agc_nor_ns.options.noise_suppression = | 3129 parameters_options_no_agc_nor_ns.options.noise_suppression = |
3200 rtc::Optional<bool>(false); | 3130 rtc::Optional<bool>(false); |
3201 channel2->SetSend(true); | 3131 EXPECT_CALL(adm_, SetAGC(false)).WillOnce(Return(0)); |
hlundin-webrtc
2017/02/13 21:03:57
I may be missing something, but the comment for th
the sun
2017/02/13 23:34:47
That channel is already sending. See line 3183/312
| |
3132 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); | |
3133 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); | |
3134 EXPECT_CALL(apm_gc_, Enable(false)).WillOnce(Return(0)); | |
3135 EXPECT_CALL(apm_ns_, Enable(false)).WillOnce(Return(0)); | |
3202 EXPECT_TRUE(channel2->SetSendParameters(parameters_options_no_agc_nor_ns)); | 3136 EXPECT_TRUE(channel2->SetSendParameters(parameters_options_no_agc_nor_ns)); |
3203 expected_options.echo_cancellation = rtc::Optional<bool>(true); | 3137 expected_options.echo_cancellation = rtc::Optional<bool>(true); |
3204 expected_options.auto_gain_control = rtc::Optional<bool>(false); | 3138 expected_options.auto_gain_control = rtc::Optional<bool>(false); |
3205 expected_options.noise_suppression = rtc::Optional<bool>(false); | 3139 expected_options.noise_suppression = rtc::Optional<bool>(false); |
3206 EXPECT_EQ(expected_options, channel2->options()); | 3140 EXPECT_EQ(expected_options, channel2->options()); |
3207 voe_.GetEcStatus(ec_enabled, ec_mode); | |
3208 voe_.GetAgcStatus(agc_enabled, agc_mode); | |
3209 voe_.GetNsStatus(ns_enabled, ns_mode); | |
3210 EXPECT_TRUE(ec_enabled); | |
3211 EXPECT_FALSE(agc_enabled); | |
3212 EXPECT_FALSE(ns_enabled); | |
3213 } | 3141 } |
3214 | 3142 |
3215 // This test verifies DSCP settings are properly applied on voice media channel. | 3143 // This test verifies DSCP settings are properly applied on voice media channel. |
3216 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { | 3144 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { |
3217 EXPECT_TRUE(SetupSendStream()); | 3145 EXPECT_TRUE(SetupSendStream()); |
3218 cricket::FakeNetworkInterface network_interface; | 3146 cricket::FakeNetworkInterface network_interface; |
3219 cricket::MediaConfig config; | 3147 cricket::MediaConfig config; |
3220 std::unique_ptr<cricket::VoiceMediaChannel> channel; | 3148 std::unique_ptr<cricket::VoiceMediaChannel> channel; |
3221 | 3149 |
3222 EXPECT_CALL(apm_, ApplyConfig(testing::_)).Times(3); | 3150 EXPECT_CALL(apm_, ApplyConfig(testing::_)).Times(3); |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3743 // Without this cast, the comparison turned unsigned and, thus, failed for -1. | 3671 // Without this cast, the comparison turned unsigned and, thus, failed for -1. |
3744 const int num_specs = static_cast<int>(specs.size()); | 3672 const int num_specs = static_cast<int>(specs.size()); |
3745 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); | 3673 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); |
3746 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); | 3674 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); |
3747 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); | 3675 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); |
3748 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); | 3676 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); |
3749 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); | 3677 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); |
3750 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); | 3678 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); |
3751 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); | 3679 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); |
3752 } | 3680 } |
OLD | NEW |