andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/audio_processing/audio_processing_impl.h" |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 12 | |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 13 | #include <array> |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
Niels Möller | 105711e | 2022-06-14 15:48:26 +0200 | [diff] [blame] | 16 | #include "api/make_ref_counted.h" |
Mirko Bonadei | d970807 | 2019-01-25 20:26:48 +0100 | [diff] [blame] | 17 | #include "api/scoped_refptr.h" |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 18 | #include "modules/audio_processing/include/audio_processing.h" |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 19 | #include "modules/audio_processing/optionally_built_submodule_creators.h" |
Per Åhgren | cc73ed3 | 2020-04-26 23:56:17 +0200 | [diff] [blame] | 20 | #include "modules/audio_processing/test/audio_processing_builder_for_testing.h" |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 21 | #include "modules/audio_processing/test/echo_canceller_test_tools.h" |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 22 | #include "modules/audio_processing/test/echo_control_mock.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "modules/audio_processing/test/test_utils.h" |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 24 | #include "rtc_base/checks.h" |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 25 | #include "rtc_base/random.h" |
Hanna Silen | 0c1ad29 | 2022-06-16 16:35:45 +0200 | [diff] [blame] | 26 | #include "test/field_trial.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 27 | #include "test/gmock.h" |
| 28 | #include "test/gtest.h" |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 29 | |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 30 | namespace webrtc { |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 31 | namespace { |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 32 | |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 33 | using ::testing::Invoke; |
| 34 | using ::testing::NotNull; |
| 35 | |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 36 | class MockInitialize : public AudioProcessingImpl { |
| 37 | public: |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 38 | MockInitialize() : AudioProcessingImpl() {} |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 39 | |
Per Åhgren | 0ade983 | 2020-09-01 23:57:20 +0200 | [diff] [blame] | 40 | MOCK_METHOD(void, InitializeLocked, (), (override)); |
Niels Möller | 5b74723 | 2021-07-26 17:16:25 +0200 | [diff] [blame] | 41 | void RealInitializeLocked() { |
| 42 | AssertLockedForTest(); |
Per Åhgren | 0ade983 | 2020-09-01 23:57:20 +0200 | [diff] [blame] | 43 | AudioProcessingImpl::InitializeLocked(); |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 44 | } |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 45 | |
Danil Chapovalov | 704fb55 | 2020-05-18 15:10:15 +0200 | [diff] [blame] | 46 | MOCK_METHOD(void, AddRef, (), (const, override)); |
| 47 | MOCK_METHOD(rtc::RefCountReleaseStatus, Release, (), (const, override)); |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 50 | // Creates MockEchoControl instances and provides a raw pointer access to |
| 51 | // the next created one. The raw pointer is meant to be used with gmock. |
| 52 | // Returning a pointer of the next created MockEchoControl instance is necessary |
| 53 | // for the following reasons: (i) gmock expectations must be set before any call |
| 54 | // occurs, (ii) APM is initialized the first time that |
| 55 | // AudioProcessingImpl::ProcessStream() is called and the initialization leads |
| 56 | // to the creation of a new EchoControl object. |
| 57 | class MockEchoControlFactory : public EchoControlFactory { |
| 58 | public: |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 59 | MockEchoControlFactory() : next_mock_(std::make_unique<MockEchoControl>()) {} |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 60 | // Returns a pointer to the next MockEchoControl that this factory creates. |
| 61 | MockEchoControl* GetNext() const { return next_mock_.get(); } |
Per Åhgren | 4e5c709 | 2019-11-01 20:44:11 +0100 | [diff] [blame] | 62 | std::unique_ptr<EchoControl> Create(int sample_rate_hz, |
| 63 | int num_render_channels, |
| 64 | int num_capture_channels) override { |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 65 | std::unique_ptr<EchoControl> mock = std::move(next_mock_); |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 66 | next_mock_ = std::make_unique<MockEchoControl>(); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 67 | return mock; |
| 68 | } |
| 69 | |
| 70 | private: |
| 71 | std::unique_ptr<MockEchoControl> next_mock_; |
| 72 | }; |
| 73 | |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 74 | // Mocks EchoDetector and records the first samples of the last analyzed render |
| 75 | // stream frame. Used to check what data is read by an EchoDetector |
| 76 | // implementation injected into an APM. |
| 77 | class TestEchoDetector : public EchoDetector { |
| 78 | public: |
| 79 | TestEchoDetector() |
| 80 | : analyze_render_audio_called_(false), |
| 81 | last_render_audio_first_sample_(0.f) {} |
| 82 | ~TestEchoDetector() override = default; |
| 83 | void AnalyzeRenderAudio(rtc::ArrayView<const float> render_audio) override { |
| 84 | last_render_audio_first_sample_ = render_audio[0]; |
| 85 | analyze_render_audio_called_ = true; |
| 86 | } |
| 87 | void AnalyzeCaptureAudio(rtc::ArrayView<const float> capture_audio) override { |
| 88 | } |
| 89 | void Initialize(int capture_sample_rate_hz, |
| 90 | int num_capture_channels, |
| 91 | int render_sample_rate_hz, |
| 92 | int num_render_channels) override {} |
| 93 | EchoDetector::Metrics GetMetrics() const override { return {}; } |
| 94 | // Returns true if AnalyzeRenderAudio() has been called at least once. |
| 95 | bool analyze_render_audio_called() const { |
| 96 | return analyze_render_audio_called_; |
| 97 | } |
| 98 | // Returns the first sample of the last analyzed render frame. |
| 99 | float last_render_audio_first_sample() const { |
| 100 | return last_render_audio_first_sample_; |
| 101 | } |
| 102 | |
| 103 | private: |
| 104 | bool analyze_render_audio_called_; |
| 105 | float last_render_audio_first_sample_; |
| 106 | }; |
| 107 | |
| 108 | // Mocks CustomProcessing and applies ProcessSample() to all the samples. |
| 109 | // Meant to be injected into an APM to modify samples in a known and detectable |
| 110 | // way. |
| 111 | class TestRenderPreProcessor : public CustomProcessing { |
| 112 | public: |
| 113 | TestRenderPreProcessor() = default; |
| 114 | ~TestRenderPreProcessor() = default; |
| 115 | void Initialize(int sample_rate_hz, int num_channels) override {} |
| 116 | void Process(AudioBuffer* audio) override { |
| 117 | for (size_t k = 0; k < audio->num_channels(); ++k) { |
Per Åhgren | d47941e | 2019-08-22 11:51:13 +0200 | [diff] [blame] | 118 | rtc::ArrayView<float> channel_view(audio->channels()[k], |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 119 | audio->num_frames()); |
| 120 | std::transform(channel_view.begin(), channel_view.end(), |
| 121 | channel_view.begin(), ProcessSample); |
| 122 | } |
Mirko Bonadei | c4dd730 | 2019-02-25 09:12:02 +0100 | [diff] [blame] | 123 | } |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 124 | std::string ToString() const override { return "TestRenderPreProcessor"; } |
| 125 | void SetRuntimeSetting(AudioProcessing::RuntimeSetting setting) override {} |
| 126 | // Modifies a sample. This member is used in Process() to modify a frame and |
| 127 | // it is publicly visible to enable tests. |
| 128 | static constexpr float ProcessSample(float x) { return 2.f * x; } |
| 129 | }; |
| 130 | |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 131 | } // namespace |
| 132 | |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 133 | TEST(AudioProcessingImplTest, AudioParameterChangeTriggersInit) { |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 134 | MockInitialize mock; |
| 135 | ON_CALL(mock, InitializeLocked) |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 136 | .WillByDefault(Invoke(&mock, &MockInitialize::RealInitializeLocked)); |
| 137 | |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 138 | EXPECT_CALL(mock, InitializeLocked).Times(1); |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 139 | mock.Initialize(); |
| 140 | |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 141 | constexpr size_t kMaxSampleRateHz = 32000; |
| 142 | constexpr size_t kMaxNumChannels = 2; |
| 143 | std::array<int16_t, kMaxNumChannels * kMaxSampleRateHz / 100> frame; |
| 144 | frame.fill(0); |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 145 | StreamConfig config(16000, 1); |
peah | 2ace3f9 | 2016-09-10 04:42:27 -0700 | [diff] [blame] | 146 | // Call with the default parameters; there should be an init. |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 147 | EXPECT_CALL(mock, InitializeLocked).Times(0); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 148 | EXPECT_NOERR(mock.ProcessStream(frame.data(), config, config, frame.data())); |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 149 | EXPECT_NOERR( |
| 150 | mock.ProcessReverseStream(frame.data(), config, config, frame.data())); |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 151 | |
| 152 | // New sample rate. (Only impacts ProcessStream). |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 153 | config = StreamConfig(32000, 1); |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 154 | EXPECT_CALL(mock, InitializeLocked).Times(1); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 155 | EXPECT_NOERR(mock.ProcessStream(frame.data(), config, config, frame.data())); |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 156 | |
| 157 | // New number of channels. |
peah | 2ace3f9 | 2016-09-10 04:42:27 -0700 | [diff] [blame] | 158 | // TODO(peah): Investigate why this causes 2 inits. |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 159 | config = StreamConfig(32000, 2); |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 160 | EXPECT_CALL(mock, InitializeLocked).Times(2); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 161 | EXPECT_NOERR(mock.ProcessStream(frame.data(), config, config, frame.data())); |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 162 | // ProcessStream sets num_channels_ == num_output_channels. |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 163 | EXPECT_NOERR( |
| 164 | mock.ProcessReverseStream(frame.data(), config, config, frame.data())); |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 165 | |
aluebs | b031955 | 2016-03-17 20:39:53 -0700 | [diff] [blame] | 166 | // A new sample rate passed to ProcessReverseStream should cause an init. |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 167 | config = StreamConfig(16000, 2); |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 168 | EXPECT_CALL(mock, InitializeLocked).Times(1); |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 169 | EXPECT_NOERR( |
| 170 | mock.ProcessReverseStream(frame.data(), config, config, frame.data())); |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Alessio Bazzica | c054e78 | 2018-04-16 12:10:09 +0200 | [diff] [blame] | 173 | TEST(AudioProcessingImplTest, UpdateCapturePreGainRuntimeSetting) { |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 174 | rtc::scoped_refptr<AudioProcessing> apm = |
| 175 | AudioProcessingBuilderForTesting().Create(); |
Alex Loiko | b5c9a79 | 2018-04-16 16:31:22 +0200 | [diff] [blame] | 176 | webrtc::AudioProcessing::Config apm_config; |
| 177 | apm_config.pre_amplifier.enabled = true; |
| 178 | apm_config.pre_amplifier.fixed_gain_factor = 1.f; |
| 179 | apm->ApplyConfig(apm_config); |
| 180 | |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 181 | constexpr int kSampleRateHz = 48000; |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 182 | constexpr int16_t kAudioLevel = 10000; |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 183 | constexpr size_t kNumChannels = 2; |
Alex Loiko | b5c9a79 | 2018-04-16 16:31:22 +0200 | [diff] [blame] | 184 | |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 185 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 186 | StreamConfig config(kSampleRateHz, kNumChannels); |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 187 | frame.fill(kAudioLevel); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 188 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 189 | EXPECT_EQ(frame[100], kAudioLevel) |
Alex Loiko | b5c9a79 | 2018-04-16 16:31:22 +0200 | [diff] [blame] | 190 | << "With factor 1, frame shouldn't be modified."; |
| 191 | |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 192 | constexpr float kGainFactor = 2.f; |
Alex Loiko | b5c9a79 | 2018-04-16 16:31:22 +0200 | [diff] [blame] | 193 | apm->SetRuntimeSetting( |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 194 | AudioProcessing::RuntimeSetting::CreateCapturePreGain(kGainFactor)); |
Alex Loiko | b5c9a79 | 2018-04-16 16:31:22 +0200 | [diff] [blame] | 195 | |
| 196 | // Process for two frames to have time to ramp up gain. |
| 197 | for (int i = 0; i < 2; ++i) { |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 198 | frame.fill(kAudioLevel); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 199 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
Alex Loiko | b5c9a79 | 2018-04-16 16:31:22 +0200 | [diff] [blame] | 200 | } |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 201 | EXPECT_EQ(frame[100], kGainFactor * kAudioLevel) |
Alex Loiko | b5c9a79 | 2018-04-16 16:31:22 +0200 | [diff] [blame] | 202 | << "Frame should be amplified."; |
Alessio Bazzica | c054e78 | 2018-04-16 12:10:09 +0200 | [diff] [blame] | 203 | } |
| 204 | |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 205 | TEST(AudioProcessingImplTest, |
| 206 | LevelAdjustmentUpdateCapturePreGainRuntimeSetting) { |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 207 | rtc::scoped_refptr<AudioProcessing> apm = |
| 208 | AudioProcessingBuilderForTesting().Create(); |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 209 | webrtc::AudioProcessing::Config apm_config; |
| 210 | apm_config.capture_level_adjustment.enabled = true; |
| 211 | apm_config.capture_level_adjustment.pre_gain_factor = 1.f; |
| 212 | apm->ApplyConfig(apm_config); |
| 213 | |
| 214 | constexpr int kSampleRateHz = 48000; |
| 215 | constexpr int16_t kAudioLevel = 10000; |
| 216 | constexpr size_t kNumChannels = 2; |
| 217 | |
| 218 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 219 | StreamConfig config(kSampleRateHz, kNumChannels); |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 220 | frame.fill(kAudioLevel); |
| 221 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 222 | EXPECT_EQ(frame[100], kAudioLevel) |
| 223 | << "With factor 1, frame shouldn't be modified."; |
| 224 | |
| 225 | constexpr float kGainFactor = 2.f; |
| 226 | apm->SetRuntimeSetting( |
| 227 | AudioProcessing::RuntimeSetting::CreateCapturePreGain(kGainFactor)); |
| 228 | |
| 229 | // Process for two frames to have time to ramp up gain. |
| 230 | for (int i = 0; i < 2; ++i) { |
| 231 | frame.fill(kAudioLevel); |
| 232 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 233 | } |
| 234 | EXPECT_EQ(frame[100], kGainFactor * kAudioLevel) |
| 235 | << "Frame should be amplified."; |
| 236 | } |
| 237 | |
| 238 | TEST(AudioProcessingImplTest, |
| 239 | LevelAdjustmentUpdateCapturePostGainRuntimeSetting) { |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 240 | rtc::scoped_refptr<AudioProcessing> apm = |
| 241 | AudioProcessingBuilderForTesting().Create(); |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 242 | webrtc::AudioProcessing::Config apm_config; |
| 243 | apm_config.capture_level_adjustment.enabled = true; |
| 244 | apm_config.capture_level_adjustment.post_gain_factor = 1.f; |
| 245 | apm->ApplyConfig(apm_config); |
| 246 | |
| 247 | constexpr int kSampleRateHz = 48000; |
| 248 | constexpr int16_t kAudioLevel = 10000; |
| 249 | constexpr size_t kNumChannels = 2; |
| 250 | |
| 251 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 252 | StreamConfig config(kSampleRateHz, kNumChannels); |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 253 | frame.fill(kAudioLevel); |
| 254 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 255 | EXPECT_EQ(frame[100], kAudioLevel) |
| 256 | << "With factor 1, frame shouldn't be modified."; |
| 257 | |
| 258 | constexpr float kGainFactor = 2.f; |
| 259 | apm->SetRuntimeSetting( |
| 260 | AudioProcessing::RuntimeSetting::CreateCapturePostGain(kGainFactor)); |
| 261 | |
| 262 | // Process for two frames to have time to ramp up gain. |
| 263 | for (int i = 0; i < 2; ++i) { |
| 264 | frame.fill(kAudioLevel); |
| 265 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 266 | } |
| 267 | EXPECT_EQ(frame[100], kGainFactor * kAudioLevel) |
| 268 | << "Frame should be amplified."; |
| 269 | } |
| 270 | |
Per Åhgren | 652ada5 | 2021-03-03 10:52:44 +0000 | [diff] [blame] | 271 | TEST(AudioProcessingImplTest, EchoControllerObservesSetCaptureUsageChange) { |
| 272 | // Tests that the echo controller observes that the capture usage has been |
| 273 | // updated. |
| 274 | auto echo_control_factory = std::make_unique<MockEchoControlFactory>(); |
| 275 | const MockEchoControlFactory* echo_control_factory_ptr = |
| 276 | echo_control_factory.get(); |
| 277 | |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 278 | rtc::scoped_refptr<AudioProcessing> apm = |
Per Åhgren | 652ada5 | 2021-03-03 10:52:44 +0000 | [diff] [blame] | 279 | AudioProcessingBuilderForTesting() |
| 280 | .SetEchoControlFactory(std::move(echo_control_factory)) |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 281 | .Create(); |
Per Åhgren | 652ada5 | 2021-03-03 10:52:44 +0000 | [diff] [blame] | 282 | |
| 283 | constexpr int16_t kAudioLevel = 10000; |
| 284 | constexpr int kSampleRateHz = 48000; |
| 285 | constexpr int kNumChannels = 2; |
| 286 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 287 | StreamConfig config(kSampleRateHz, kNumChannels); |
Per Åhgren | 652ada5 | 2021-03-03 10:52:44 +0000 | [diff] [blame] | 288 | frame.fill(kAudioLevel); |
| 289 | |
| 290 | MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext(); |
| 291 | |
| 292 | // Ensure that SetCaptureOutputUsage is not called when no runtime settings |
| 293 | // are passed. |
| 294 | EXPECT_CALL(*echo_control_mock, SetCaptureOutputUsage(testing::_)).Times(0); |
| 295 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 296 | |
| 297 | // Ensure that SetCaptureOutputUsage is called with the right information when |
| 298 | // a runtime setting is passed. |
| 299 | EXPECT_CALL(*echo_control_mock, |
| 300 | SetCaptureOutputUsage(/*capture_output_used=*/false)) |
| 301 | .Times(1); |
| 302 | EXPECT_TRUE(apm->PostRuntimeSetting( |
| 303 | AudioProcessing::RuntimeSetting::CreateCaptureOutputUsedSetting( |
| 304 | /*capture_output_used=*/false))); |
| 305 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 306 | |
| 307 | EXPECT_CALL(*echo_control_mock, |
| 308 | SetCaptureOutputUsage(/*capture_output_used=*/true)) |
| 309 | .Times(1); |
| 310 | EXPECT_TRUE(apm->PostRuntimeSetting( |
| 311 | AudioProcessing::RuntimeSetting::CreateCaptureOutputUsedSetting( |
| 312 | /*capture_output_used=*/true))); |
| 313 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 314 | |
| 315 | // The number of positions to place items in the queue is equal to the queue |
| 316 | // size minus 1. |
| 317 | constexpr int kNumSlotsInQueue = RuntimeSettingQueueSize(); |
| 318 | |
| 319 | // Ensure that SetCaptureOutputUsage is called with the right information when |
| 320 | // many runtime settings are passed. |
| 321 | for (int k = 0; k < kNumSlotsInQueue - 1; ++k) { |
| 322 | EXPECT_TRUE(apm->PostRuntimeSetting( |
| 323 | AudioProcessing::RuntimeSetting::CreateCaptureOutputUsedSetting( |
| 324 | /*capture_output_used=*/false))); |
| 325 | } |
| 326 | EXPECT_CALL(*echo_control_mock, |
| 327 | SetCaptureOutputUsage(/*capture_output_used=*/false)) |
| 328 | .Times(kNumSlotsInQueue - 1); |
| 329 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 330 | |
| 331 | // Ensure that SetCaptureOutputUsage is properly called with the fallback |
| 332 | // value when the runtime settings queue becomes full. |
| 333 | for (int k = 0; k < kNumSlotsInQueue; ++k) { |
| 334 | EXPECT_TRUE(apm->PostRuntimeSetting( |
| 335 | AudioProcessing::RuntimeSetting::CreateCaptureOutputUsedSetting( |
| 336 | /*capture_output_used=*/false))); |
| 337 | } |
| 338 | EXPECT_FALSE(apm->PostRuntimeSetting( |
| 339 | AudioProcessing::RuntimeSetting::CreateCaptureOutputUsedSetting( |
| 340 | /*capture_output_used=*/false))); |
| 341 | EXPECT_FALSE(apm->PostRuntimeSetting( |
| 342 | AudioProcessing::RuntimeSetting::CreateCaptureOutputUsedSetting( |
| 343 | /*capture_output_used=*/false))); |
| 344 | EXPECT_CALL(*echo_control_mock, |
| 345 | SetCaptureOutputUsage(/*capture_output_used=*/false)) |
| 346 | .Times(kNumSlotsInQueue); |
| 347 | EXPECT_CALL(*echo_control_mock, |
| 348 | SetCaptureOutputUsage(/*capture_output_used=*/true)) |
| 349 | .Times(1); |
| 350 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 351 | } |
| 352 | |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 353 | TEST(AudioProcessingImplTest, |
| 354 | EchoControllerObservesPreAmplifierEchoPathGainChange) { |
| 355 | // Tests that the echo controller observes an echo path gain change when the |
| 356 | // pre-amplifier submodule changes the gain. |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 357 | auto echo_control_factory = std::make_unique<MockEchoControlFactory>(); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 358 | const auto* echo_control_factory_ptr = echo_control_factory.get(); |
| 359 | |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 360 | rtc::scoped_refptr<AudioProcessing> apm = |
Per Åhgren | cc73ed3 | 2020-04-26 23:56:17 +0200 | [diff] [blame] | 361 | AudioProcessingBuilderForTesting() |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 362 | .SetEchoControlFactory(std::move(echo_control_factory)) |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 363 | .Create(); |
Sam Zackrisson | 41478c7 | 2019-10-15 10:10:26 +0200 | [diff] [blame] | 364 | // Disable AGC. |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 365 | webrtc::AudioProcessing::Config apm_config; |
Sam Zackrisson | 41478c7 | 2019-10-15 10:10:26 +0200 | [diff] [blame] | 366 | apm_config.gain_controller1.enabled = false; |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 367 | apm_config.gain_controller2.enabled = false; |
| 368 | apm_config.pre_amplifier.enabled = true; |
| 369 | apm_config.pre_amplifier.fixed_gain_factor = 1.f; |
| 370 | apm->ApplyConfig(apm_config); |
| 371 | |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 372 | constexpr int16_t kAudioLevel = 10000; |
| 373 | constexpr size_t kSampleRateHz = 48000; |
| 374 | constexpr size_t kNumChannels = 2; |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 375 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 376 | StreamConfig config(kSampleRateHz, kNumChannels); |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 377 | frame.fill(kAudioLevel); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 378 | |
| 379 | MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext(); |
| 380 | |
Per Åhgren | 0aefbf0 | 2019-08-23 21:29:17 +0200 | [diff] [blame] | 381 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
Fredrik Hernqvist | bf47f34 | 2019-05-09 10:50:31 +0200 | [diff] [blame] | 382 | EXPECT_CALL(*echo_control_mock, |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 383 | ProcessCapture(NotNull(), testing::_, /*echo_path_change=*/false)) |
Fredrik Hernqvist | bf47f34 | 2019-05-09 10:50:31 +0200 | [diff] [blame] | 384 | .Times(1); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 385 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 386 | |
Per Åhgren | 0aefbf0 | 2019-08-23 21:29:17 +0200 | [diff] [blame] | 387 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
Fredrik Hernqvist | bf47f34 | 2019-05-09 10:50:31 +0200 | [diff] [blame] | 388 | EXPECT_CALL(*echo_control_mock, |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 389 | ProcessCapture(NotNull(), testing::_, /*echo_path_change=*/true)) |
Fredrik Hernqvist | bf47f34 | 2019-05-09 10:50:31 +0200 | [diff] [blame] | 390 | .Times(1); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 391 | apm->SetRuntimeSetting( |
| 392 | AudioProcessing::RuntimeSetting::CreateCapturePreGain(2.f)); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 393 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | TEST(AudioProcessingImplTest, |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 397 | EchoControllerObservesLevelAdjustmentPreGainEchoPathGainChange) { |
| 398 | // Tests that the echo controller observes an echo path gain change when the |
| 399 | // pre-amplifier submodule changes the gain. |
| 400 | auto echo_control_factory = std::make_unique<MockEchoControlFactory>(); |
| 401 | const auto* echo_control_factory_ptr = echo_control_factory.get(); |
| 402 | |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 403 | rtc::scoped_refptr<AudioProcessing> apm = |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 404 | AudioProcessingBuilderForTesting() |
| 405 | .SetEchoControlFactory(std::move(echo_control_factory)) |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 406 | .Create(); |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 407 | // Disable AGC. |
| 408 | webrtc::AudioProcessing::Config apm_config; |
| 409 | apm_config.gain_controller1.enabled = false; |
| 410 | apm_config.gain_controller2.enabled = false; |
| 411 | apm_config.capture_level_adjustment.enabled = true; |
| 412 | apm_config.capture_level_adjustment.pre_gain_factor = 1.f; |
| 413 | apm->ApplyConfig(apm_config); |
| 414 | |
| 415 | constexpr int16_t kAudioLevel = 10000; |
| 416 | constexpr size_t kSampleRateHz = 48000; |
| 417 | constexpr size_t kNumChannels = 2; |
| 418 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 419 | StreamConfig config(kSampleRateHz, kNumChannels); |
Per Åhgren | db5d728 | 2021-03-15 16:31:04 +0000 | [diff] [blame] | 420 | frame.fill(kAudioLevel); |
| 421 | |
| 422 | MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext(); |
| 423 | |
| 424 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
| 425 | EXPECT_CALL(*echo_control_mock, |
| 426 | ProcessCapture(NotNull(), testing::_, /*echo_path_change=*/false)) |
| 427 | .Times(1); |
| 428 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 429 | |
| 430 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
| 431 | EXPECT_CALL(*echo_control_mock, |
| 432 | ProcessCapture(NotNull(), testing::_, /*echo_path_change=*/true)) |
| 433 | .Times(1); |
| 434 | apm->SetRuntimeSetting( |
| 435 | AudioProcessing::RuntimeSetting::CreateCapturePreGain(2.f)); |
| 436 | apm->ProcessStream(frame.data(), config, config, frame.data()); |
| 437 | } |
| 438 | |
| 439 | TEST(AudioProcessingImplTest, |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 440 | EchoControllerObservesAnalogAgc1EchoPathGainChange) { |
| 441 | // Tests that the echo controller observes an echo path gain change when the |
| 442 | // AGC1 analog adaptive submodule changes the analog gain. |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 443 | auto echo_control_factory = std::make_unique<MockEchoControlFactory>(); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 444 | const auto* echo_control_factory_ptr = echo_control_factory.get(); |
| 445 | |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 446 | rtc::scoped_refptr<AudioProcessing> apm = |
Per Åhgren | cc73ed3 | 2020-04-26 23:56:17 +0200 | [diff] [blame] | 447 | AudioProcessingBuilderForTesting() |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 448 | .SetEchoControlFactory(std::move(echo_control_factory)) |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 449 | .Create(); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 450 | webrtc::AudioProcessing::Config apm_config; |
Sam Zackrisson | 41478c7 | 2019-10-15 10:10:26 +0200 | [diff] [blame] | 451 | // Enable AGC1. |
| 452 | apm_config.gain_controller1.enabled = true; |
| 453 | apm_config.gain_controller1.mode = |
| 454 | AudioProcessing::Config::GainController1::kAdaptiveAnalog; |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 455 | apm_config.gain_controller2.enabled = false; |
| 456 | apm_config.pre_amplifier.enabled = false; |
| 457 | apm->ApplyConfig(apm_config); |
| 458 | |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 459 | constexpr int16_t kAudioLevel = 1000; |
| 460 | constexpr size_t kSampleRateHz = 48000; |
| 461 | constexpr size_t kNumChannels = 2; |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 462 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 463 | StreamConfig stream_config(kSampleRateHz, kNumChannels); |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 464 | frame.fill(kAudioLevel); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 465 | |
| 466 | MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext(); |
| 467 | |
Sam Zackrisson | 41478c7 | 2019-10-15 10:10:26 +0200 | [diff] [blame] | 468 | const int initial_analog_gain = apm->recommended_stream_analog_level(); |
Per Åhgren | 0aefbf0 | 2019-08-23 21:29:17 +0200 | [diff] [blame] | 469 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 470 | EXPECT_CALL(*echo_control_mock, ProcessCapture(NotNull(), testing::_, false)) |
| 471 | .Times(1); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 472 | apm->ProcessStream(frame.data(), stream_config, stream_config, frame.data()); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 473 | |
| 474 | // Force an analog gain change if it did not happen. |
Sam Zackrisson | 41478c7 | 2019-10-15 10:10:26 +0200 | [diff] [blame] | 475 | if (initial_analog_gain == apm->recommended_stream_analog_level()) { |
| 476 | apm->set_stream_analog_level(initial_analog_gain + 1); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 477 | } |
| 478 | |
Per Åhgren | 0aefbf0 | 2019-08-23 21:29:17 +0200 | [diff] [blame] | 479 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 480 | EXPECT_CALL(*echo_control_mock, ProcessCapture(NotNull(), testing::_, true)) |
| 481 | .Times(1); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 482 | apm->ProcessStream(frame.data(), stream_config, stream_config, frame.data()); |
Alessio Bazzica | e449805 | 2018-12-17 09:44:06 +0100 | [diff] [blame] | 483 | } |
| 484 | |
Hanna Silen | 0c1ad29 | 2022-06-16 16:35:45 +0200 | [diff] [blame] | 485 | TEST(AudioProcessingImplTest, |
| 486 | EchoControllerObservesNoDigitalAgc2EchoPathGainChange) { |
| 487 | // Tests that the echo controller doesn't observe an echo path gain change |
| 488 | // when the AGC2 digital submodule changes the digital gain without analog |
| 489 | // gain changes. |
| 490 | auto echo_control_factory = std::make_unique<MockEchoControlFactory>(); |
| 491 | const auto* echo_control_factory_ptr = echo_control_factory.get(); |
| 492 | rtc::scoped_refptr<AudioProcessing> apm = |
| 493 | AudioProcessingBuilderForTesting() |
| 494 | .SetEchoControlFactory(std::move(echo_control_factory)) |
| 495 | .Create(); |
| 496 | webrtc::AudioProcessing::Config apm_config; |
| 497 | // Disable AGC1 analog. |
| 498 | apm_config.gain_controller1.enabled = false; |
| 499 | // Enable AGC2 digital. |
| 500 | apm_config.gain_controller2.enabled = true; |
| 501 | apm_config.gain_controller2.adaptive_digital.enabled = true; |
| 502 | apm->ApplyConfig(apm_config); |
| 503 | |
| 504 | constexpr int16_t kAudioLevel = 1000; |
| 505 | constexpr size_t kSampleRateHz = 48000; |
| 506 | constexpr size_t kNumChannels = 2; |
| 507 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
| 508 | StreamConfig stream_config(kSampleRateHz, kNumChannels); |
| 509 | frame.fill(kAudioLevel); |
| 510 | |
| 511 | MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext(); |
| 512 | |
| 513 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
| 514 | EXPECT_CALL(*echo_control_mock, ProcessCapture(NotNull(), testing::_, |
| 515 | /*echo_path_change=*/false)) |
| 516 | .Times(1); |
| 517 | apm->ProcessStream(frame.data(), stream_config, stream_config, frame.data()); |
| 518 | |
| 519 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
| 520 | EXPECT_CALL(*echo_control_mock, ProcessCapture(NotNull(), testing::_, |
| 521 | /*echo_path_change=*/false)) |
| 522 | .Times(1); |
| 523 | apm->ProcessStream(frame.data(), stream_config, stream_config, frame.data()); |
| 524 | } |
| 525 | |
| 526 | TEST(AudioProcessingImplTest, ProcessWithAgc2InjectedSpeechProbability) { |
| 527 | // Tests that a stream is successfully processed for the field trial |
| 528 | // `WebRTC-Audio-TransientSuppressorVadMode/Enabled-RnnVad/` using |
| 529 | // injected speech probability in AGC2 digital. |
| 530 | webrtc::test::ScopedFieldTrials field_trials( |
| 531 | "WebRTC-Audio-TransientSuppressorVadMode/Enabled-RnnVad/"); |
| 532 | rtc::scoped_refptr<AudioProcessing> apm = AudioProcessingBuilder().Create(); |
| 533 | ASSERT_EQ(apm->Initialize(), AudioProcessing::kNoError); |
| 534 | webrtc::AudioProcessing::Config apm_config; |
| 535 | // Disable AGC1 analog. |
| 536 | apm_config.gain_controller1.enabled = false; |
| 537 | // Enable AGC2 digital. |
| 538 | apm_config.gain_controller2.enabled = true; |
| 539 | apm_config.gain_controller2.adaptive_digital.enabled = true; |
| 540 | apm->ApplyConfig(apm_config); |
| 541 | constexpr int kSampleRateHz = 48000; |
| 542 | constexpr int kNumChannels = 1; |
| 543 | std::array<float, kSampleRateHz / 100> buffer; |
| 544 | float* channel_pointers[] = {buffer.data()}; |
| 545 | StreamConfig stream_config(/*sample_rate_hz=*/kSampleRateHz, |
| 546 | /*num_channels=*/kNumChannels); |
| 547 | Random random_generator(2341U); |
| 548 | constexpr int kFramesToProcess = 10; |
| 549 | for (int i = 0; i < kFramesToProcess; ++i) { |
| 550 | RandomizeSampleVector(&random_generator, buffer); |
| 551 | ASSERT_EQ(apm->ProcessStream(channel_pointers, stream_config, stream_config, |
| 552 | channel_pointers), |
| 553 | kNoErr); |
| 554 | } |
| 555 | } |
| 556 | |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 557 | TEST(AudioProcessingImplTest, EchoControllerObservesPlayoutVolumeChange) { |
| 558 | // Tests that the echo controller observes an echo path gain change when a |
| 559 | // playout volume change is reported. |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 560 | auto echo_control_factory = std::make_unique<MockEchoControlFactory>(); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 561 | const auto* echo_control_factory_ptr = echo_control_factory.get(); |
| 562 | |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 563 | rtc::scoped_refptr<AudioProcessing> apm = |
Per Åhgren | cc73ed3 | 2020-04-26 23:56:17 +0200 | [diff] [blame] | 564 | AudioProcessingBuilderForTesting() |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 565 | .SetEchoControlFactory(std::move(echo_control_factory)) |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 566 | .Create(); |
Sam Zackrisson | 41478c7 | 2019-10-15 10:10:26 +0200 | [diff] [blame] | 567 | // Disable AGC. |
| 568 | webrtc::AudioProcessing::Config apm_config; |
| 569 | apm_config.gain_controller1.enabled = false; |
| 570 | apm_config.gain_controller2.enabled = false; |
| 571 | apm->ApplyConfig(apm_config); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 572 | |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 573 | constexpr int16_t kAudioLevel = 10000; |
| 574 | constexpr size_t kSampleRateHz = 48000; |
| 575 | constexpr size_t kNumChannels = 2; |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 576 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 577 | StreamConfig stream_config(kSampleRateHz, kNumChannels); |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 578 | frame.fill(kAudioLevel); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 579 | |
| 580 | MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext(); |
| 581 | |
Per Åhgren | 0aefbf0 | 2019-08-23 21:29:17 +0200 | [diff] [blame] | 582 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 583 | EXPECT_CALL(*echo_control_mock, |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 584 | ProcessCapture(NotNull(), testing::_, /*echo_path_change=*/false)) |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 585 | .Times(1); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 586 | apm->ProcessStream(frame.data(), stream_config, stream_config, frame.data()); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 587 | |
Per Åhgren | 0aefbf0 | 2019-08-23 21:29:17 +0200 | [diff] [blame] | 588 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 589 | EXPECT_CALL(*echo_control_mock, |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 590 | ProcessCapture(NotNull(), testing::_, /*echo_path_change=*/false)) |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 591 | .Times(1); |
| 592 | apm->SetRuntimeSetting( |
| 593 | AudioProcessing::RuntimeSetting::CreatePlayoutVolumeChange(50)); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 594 | apm->ProcessStream(frame.data(), stream_config, stream_config, frame.data()); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 595 | |
Per Åhgren | 0aefbf0 | 2019-08-23 21:29:17 +0200 | [diff] [blame] | 596 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 597 | EXPECT_CALL(*echo_control_mock, |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 598 | ProcessCapture(NotNull(), testing::_, /*echo_path_change=*/false)) |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 599 | .Times(1); |
| 600 | apm->SetRuntimeSetting( |
| 601 | AudioProcessing::RuntimeSetting::CreatePlayoutVolumeChange(50)); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 602 | apm->ProcessStream(frame.data(), stream_config, stream_config, frame.data()); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 603 | |
Per Åhgren | 0aefbf0 | 2019-08-23 21:29:17 +0200 | [diff] [blame] | 604 | EXPECT_CALL(*echo_control_mock, AnalyzeCapture(testing::_)).Times(1); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 605 | EXPECT_CALL(*echo_control_mock, |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 606 | ProcessCapture(NotNull(), testing::_, /*echo_path_change=*/true)) |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 607 | .Times(1); |
| 608 | apm->SetRuntimeSetting( |
| 609 | AudioProcessing::RuntimeSetting::CreatePlayoutVolumeChange(100)); |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 610 | apm->ProcessStream(frame.data(), stream_config, stream_config, frame.data()); |
Fredrik Hernqvist | ca36285 | 2019-05-10 15:50:02 +0200 | [diff] [blame] | 611 | } |
| 612 | |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 613 | TEST(AudioProcessingImplTest, RenderPreProcessorBeforeEchoDetector) { |
| 614 | // Make sure that signal changes caused by a render pre-processing sub-module |
| 615 | // take place before any echo detector analysis. |
Tommi | 87f7090 | 2021-04-27 14:43:08 +0200 | [diff] [blame] | 616 | auto test_echo_detector = rtc::make_ref_counted<TestEchoDetector>(); |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 617 | std::unique_ptr<CustomProcessing> test_render_pre_processor( |
| 618 | new TestRenderPreProcessor()); |
| 619 | // Create APM injecting the test echo detector and render pre-processor. |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 620 | rtc::scoped_refptr<AudioProcessing> apm = |
Per Åhgren | cc73ed3 | 2020-04-26 23:56:17 +0200 | [diff] [blame] | 621 | AudioProcessingBuilderForTesting() |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 622 | .SetEchoDetector(test_echo_detector) |
| 623 | .SetRenderPreProcessing(std::move(test_render_pre_processor)) |
Niels Möller | 4f776ac | 2021-07-02 11:30:54 +0200 | [diff] [blame] | 624 | .Create(); |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 625 | webrtc::AudioProcessing::Config apm_config; |
| 626 | apm_config.pre_amplifier.enabled = true; |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 627 | apm->ApplyConfig(apm_config); |
| 628 | |
| 629 | constexpr int16_t kAudioLevel = 1000; |
| 630 | constexpr int kSampleRateHz = 16000; |
| 631 | constexpr size_t kNumChannels = 1; |
Sam Zackrisson | 12e319a | 2020-01-03 14:54:20 +0100 | [diff] [blame] | 632 | // Explicitly initialize APM to ensure no render frames are discarded. |
| 633 | const ProcessingConfig processing_config = {{ |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 634 | {kSampleRateHz, kNumChannels}, |
| 635 | {kSampleRateHz, kNumChannels}, |
| 636 | {kSampleRateHz, kNumChannels}, |
| 637 | {kSampleRateHz, kNumChannels}, |
Sam Zackrisson | 12e319a | 2020-01-03 14:54:20 +0100 | [diff] [blame] | 638 | }}; |
| 639 | apm->Initialize(processing_config); |
| 640 | |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 641 | std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame; |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 642 | StreamConfig stream_config(kSampleRateHz, kNumChannels); |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 643 | |
| 644 | constexpr float kAudioLevelFloat = static_cast<float>(kAudioLevel); |
| 645 | constexpr float kExpectedPreprocessedAudioLevel = |
| 646 | TestRenderPreProcessor::ProcessSample(kAudioLevelFloat); |
| 647 | ASSERT_NE(kAudioLevelFloat, kExpectedPreprocessedAudioLevel); |
| 648 | |
| 649 | // Analyze a render stream frame. |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 650 | frame.fill(kAudioLevel); |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 651 | ASSERT_EQ(AudioProcessing::Error::kNoError, |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 652 | apm->ProcessReverseStream(frame.data(), stream_config, |
| 653 | stream_config, frame.data())); |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 654 | // Trigger a call to in EchoDetector::AnalyzeRenderAudio() via |
| 655 | // ProcessStream(). |
Per Åhgren | 2507f8c | 2020-03-19 12:33:29 +0100 | [diff] [blame] | 656 | frame.fill(kAudioLevel); |
| 657 | ASSERT_EQ(AudioProcessing::Error::kNoError, |
| 658 | apm->ProcessStream(frame.data(), stream_config, stream_config, |
Per Åhgren | dc5522b | 2020-03-19 14:55:58 +0100 | [diff] [blame] | 659 | frame.data())); |
Alessio Bazzica | d2b9740 | 2018-08-09 14:23:11 +0200 | [diff] [blame] | 660 | // Regardless of how the call to in EchoDetector::AnalyzeRenderAudio() is |
| 661 | // triggered, the line below checks that the call has occurred. If not, the |
| 662 | // APM implementation may have changed and this test might need to be adapted. |
| 663 | ASSERT_TRUE(test_echo_detector->analyze_render_audio_called()); |
| 664 | // Check that the data read in EchoDetector::AnalyzeRenderAudio() is that |
| 665 | // produced by the render pre-processor. |
| 666 | EXPECT_EQ(kExpectedPreprocessedAudioLevel, |
| 667 | test_echo_detector->last_render_audio_first_sample()); |
| 668 | } |
| 669 | |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 670 | // Disabling build-optional submodules and trying to enable them via the APM |
| 671 | // config should be bit-exact with running APM with said submodules disabled. |
| 672 | // This mainly tests that SetCreateOptionalSubmodulesForTesting has an effect. |
| 673 | TEST(ApmWithSubmodulesExcludedTest, BitexactWithDisabledModules) { |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 674 | auto apm = rtc::make_ref_counted<AudioProcessingImpl>(); |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 675 | ASSERT_EQ(apm->Initialize(), AudioProcessing::kNoError); |
| 676 | |
| 677 | ApmSubmoduleCreationOverrides overrides; |
| 678 | overrides.transient_suppression = true; |
| 679 | apm->OverrideSubmoduleCreationForTesting(overrides); |
| 680 | |
| 681 | AudioProcessing::Config apm_config = apm->GetConfig(); |
| 682 | apm_config.transient_suppression.enabled = true; |
| 683 | apm->ApplyConfig(apm_config); |
| 684 | |
| 685 | rtc::scoped_refptr<AudioProcessing> apm_reference = |
| 686 | AudioProcessingBuilder().Create(); |
| 687 | apm_config = apm_reference->GetConfig(); |
| 688 | apm_config.transient_suppression.enabled = false; |
| 689 | apm_reference->ApplyConfig(apm_config); |
| 690 | |
| 691 | constexpr int kSampleRateHz = 16000; |
| 692 | constexpr int kNumChannels = 1; |
| 693 | std::array<float, kSampleRateHz / 100> buffer; |
| 694 | std::array<float, kSampleRateHz / 100> buffer_reference; |
| 695 | float* channel_pointers[] = {buffer.data()}; |
| 696 | float* channel_pointers_reference[] = {buffer_reference.data()}; |
| 697 | StreamConfig stream_config(/*sample_rate_hz=*/kSampleRateHz, |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 698 | /*num_channels=*/kNumChannels); |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 699 | Random random_generator(2341U); |
| 700 | constexpr int kFramesToProcessPerConfiguration = 10; |
| 701 | |
| 702 | for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) { |
| 703 | RandomizeSampleVector(&random_generator, buffer); |
| 704 | std::copy(buffer.begin(), buffer.end(), buffer_reference.begin()); |
| 705 | ASSERT_EQ(apm->ProcessStream(channel_pointers, stream_config, stream_config, |
| 706 | channel_pointers), |
| 707 | kNoErr); |
| 708 | ASSERT_EQ( |
| 709 | apm_reference->ProcessStream(channel_pointers_reference, stream_config, |
| 710 | stream_config, channel_pointers_reference), |
| 711 | kNoErr); |
| 712 | for (int j = 0; j < kSampleRateHz / 100; ++j) { |
| 713 | EXPECT_EQ(buffer[j], buffer_reference[j]); |
| 714 | } |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | // Disable transient suppressor creation and run APM in ways that should trigger |
| 719 | // calls to the transient suppressor API. |
| 720 | TEST(ApmWithSubmodulesExcludedTest, ReinitializeTransientSuppressor) { |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 721 | auto apm = rtc::make_ref_counted<AudioProcessingImpl>(); |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 722 | ASSERT_EQ(apm->Initialize(), kNoErr); |
| 723 | |
| 724 | ApmSubmoduleCreationOverrides overrides; |
| 725 | overrides.transient_suppression = true; |
| 726 | apm->OverrideSubmoduleCreationForTesting(overrides); |
| 727 | |
| 728 | AudioProcessing::Config config = apm->GetConfig(); |
| 729 | config.transient_suppression.enabled = true; |
| 730 | apm->ApplyConfig(config); |
| 731 | // 960 samples per frame: 10 ms of <= 48 kHz audio with <= 2 channels. |
| 732 | float buffer[960]; |
| 733 | float* channel_pointers[] = {&buffer[0], &buffer[480]}; |
| 734 | Random random_generator(2341U); |
| 735 | constexpr int kFramesToProcessPerConfiguration = 3; |
| 736 | |
| 737 | StreamConfig initial_stream_config(/*sample_rate_hz=*/16000, |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 738 | /*num_channels=*/1); |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 739 | for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) { |
| 740 | RandomizeSampleVector(&random_generator, buffer); |
| 741 | EXPECT_EQ(apm->ProcessStream(channel_pointers, initial_stream_config, |
| 742 | initial_stream_config, channel_pointers), |
| 743 | kNoErr); |
| 744 | } |
| 745 | |
| 746 | StreamConfig stereo_stream_config(/*sample_rate_hz=*/16000, |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 747 | /*num_channels=*/2); |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 748 | for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) { |
| 749 | RandomizeSampleVector(&random_generator, buffer); |
| 750 | EXPECT_EQ(apm->ProcessStream(channel_pointers, stereo_stream_config, |
| 751 | stereo_stream_config, channel_pointers), |
| 752 | kNoErr); |
| 753 | } |
| 754 | |
| 755 | StreamConfig high_sample_rate_stream_config(/*sample_rate_hz=*/48000, |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 756 | /*num_channels=*/2); |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 757 | for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) { |
| 758 | RandomizeSampleVector(&random_generator, buffer); |
| 759 | EXPECT_EQ( |
| 760 | apm->ProcessStream(channel_pointers, high_sample_rate_stream_config, |
| 761 | high_sample_rate_stream_config, channel_pointers), |
| 762 | kNoErr); |
| 763 | } |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | // Disable transient suppressor creation and run APM in ways that should trigger |
| 767 | // calls to the transient suppressor API. |
| 768 | TEST(ApmWithSubmodulesExcludedTest, ToggleTransientSuppressor) { |
Alessio Bazzica | be1b898 | 2021-09-17 08:26:10 +0200 | [diff] [blame] | 769 | auto apm = rtc::make_ref_counted<AudioProcessingImpl>(); |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 770 | ASSERT_EQ(apm->Initialize(), AudioProcessing::kNoError); |
| 771 | |
| 772 | ApmSubmoduleCreationOverrides overrides; |
| 773 | overrides.transient_suppression = true; |
| 774 | apm->OverrideSubmoduleCreationForTesting(overrides); |
| 775 | |
| 776 | // 960 samples per frame: 10 ms of <= 48 kHz audio with <= 2 channels. |
| 777 | float buffer[960]; |
| 778 | float* channel_pointers[] = {&buffer[0], &buffer[480]}; |
| 779 | Random random_generator(2341U); |
| 780 | constexpr int kFramesToProcessPerConfiguration = 3; |
| 781 | StreamConfig stream_config(/*sample_rate_hz=*/16000, |
Henrik Lundin | 64253a9 | 2022-02-04 09:02:48 +0000 | [diff] [blame] | 782 | /*num_channels=*/1); |
Sam Zackrisson | b37e59d | 2020-04-27 08:39:33 +0200 | [diff] [blame] | 783 | |
| 784 | AudioProcessing::Config config = apm->GetConfig(); |
| 785 | config.transient_suppression.enabled = true; |
| 786 | apm->ApplyConfig(config); |
| 787 | for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) { |
| 788 | RandomizeSampleVector(&random_generator, buffer); |
| 789 | EXPECT_EQ(apm->ProcessStream(channel_pointers, stream_config, stream_config, |
| 790 | channel_pointers), |
| 791 | kNoErr); |
| 792 | } |
| 793 | |
| 794 | config = apm->GetConfig(); |
| 795 | config.transient_suppression.enabled = false; |
| 796 | apm->ApplyConfig(config); |
| 797 | for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) { |
| 798 | RandomizeSampleVector(&random_generator, buffer); |
| 799 | EXPECT_EQ(apm->ProcessStream(channel_pointers, stream_config, stream_config, |
| 800 | channel_pointers), |
| 801 | kNoErr); |
| 802 | } |
| 803 | |
| 804 | config = apm->GetConfig(); |
| 805 | config.transient_suppression.enabled = true; |
| 806 | apm->ApplyConfig(config); |
| 807 | for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) { |
| 808 | RandomizeSampleVector(&random_generator, buffer); |
| 809 | EXPECT_EQ(apm->ProcessStream(channel_pointers, stream_config, stream_config, |
| 810 | channel_pointers), |
| 811 | kNoErr); |
| 812 | } |
| 813 | } |
andrew@webrtc.org | 60730cf | 2014-01-07 17:45:09 +0000 | [diff] [blame] | 814 | } // namespace webrtc |