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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698