OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 #include "webrtc/modules/audio_processing/aec3/render_delay_controller.h" | 10 #include "webrtc/modules/audio_processing/aec3/render_delay_controller.h" |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <memory> | 13 #include <memory> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" | 17 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" |
18 #include "webrtc/modules/audio_processing/aec3/echo_path_delay_estimator.h" | 18 #include "webrtc/modules/audio_processing/aec3/echo_path_delay_estimator.h" |
19 #include "webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.h
" | 19 #include "webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.h
" |
| 20 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
20 #include "webrtc/rtc_base/atomicops.h" | 21 #include "webrtc/rtc_base/atomicops.h" |
21 #include "webrtc/rtc_base/constructormagic.h" | 22 #include "webrtc/rtc_base/constructormagic.h" |
22 | 23 |
23 namespace webrtc { | 24 namespace webrtc { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 class RenderDelayControllerImpl final : public RenderDelayController { | 28 class RenderDelayControllerImpl final : public RenderDelayController { |
28 public: | 29 public: |
29 RenderDelayControllerImpl(int sample_rate_hz); | 30 RenderDelayControllerImpl( |
| 31 const AudioProcessing::Config::EchoCanceller3& config, |
| 32 int sample_rate_hz); |
30 ~RenderDelayControllerImpl() override; | 33 ~RenderDelayControllerImpl() override; |
31 void Reset() override; | 34 void Reset() override; |
32 void SetDelay(size_t render_delay) override; | 35 void SetDelay(size_t render_delay) override; |
33 size_t GetDelay(const DownsampledRenderBuffer& render_buffer, | 36 size_t GetDelay(const DownsampledRenderBuffer& render_buffer, |
34 rtc::ArrayView<const float> capture) override; | 37 rtc::ArrayView<const float> capture) override; |
35 rtc::Optional<size_t> AlignmentHeadroomSamples() const override { | 38 rtc::Optional<size_t> AlignmentHeadroomSamples() const override { |
36 return headroom_samples_; | 39 return headroom_samples_; |
37 } | 40 } |
38 | 41 |
39 private: | 42 private: |
(...skipping 21 matching lines...) Expand all Loading... |
61 // Add hysteresis. | 64 // Add hysteresis. |
62 if (new_delay == current_delay + 1) { | 65 if (new_delay == current_delay + 1) { |
63 new_delay = current_delay; | 66 new_delay = current_delay; |
64 } | 67 } |
65 | 68 |
66 return new_delay; | 69 return new_delay; |
67 } | 70 } |
68 | 71 |
69 int RenderDelayControllerImpl::instance_count_ = 0; | 72 int RenderDelayControllerImpl::instance_count_ = 0; |
70 | 73 |
71 RenderDelayControllerImpl::RenderDelayControllerImpl(int sample_rate_hz) | 74 RenderDelayControllerImpl::RenderDelayControllerImpl( |
| 75 const AudioProcessing::Config::EchoCanceller3& config, |
| 76 int sample_rate_hz) |
72 : data_dumper_( | 77 : data_dumper_( |
73 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))), | 78 new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))), |
74 delay_estimator_(data_dumper_.get()) { | 79 delay_estimator_(data_dumper_.get(), config) { |
75 RTC_DCHECK(ValidFullBandRate(sample_rate_hz)); | 80 RTC_DCHECK(ValidFullBandRate(sample_rate_hz)); |
76 } | 81 } |
77 | 82 |
78 RenderDelayControllerImpl::~RenderDelayControllerImpl() = default; | 83 RenderDelayControllerImpl::~RenderDelayControllerImpl() = default; |
79 | 84 |
80 void RenderDelayControllerImpl::Reset() { | 85 void RenderDelayControllerImpl::Reset() { |
81 delay_ = kMinEchoPathDelayBlocks; | 86 delay_ = kMinEchoPathDelayBlocks; |
82 blocks_since_last_delay_estimate_ = 300000; | 87 blocks_since_last_delay_estimate_ = 300000; |
83 echo_path_delay_samples_ = 0; | 88 echo_path_delay_samples_ = 0; |
84 align_call_counter_ = 0; | 89 align_call_counter_ = 0; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 132 |
128 data_dumper_->DumpRaw("aec3_render_delay_controller_delay", 1, | 133 data_dumper_->DumpRaw("aec3_render_delay_controller_delay", 1, |
129 &echo_path_delay_samples_); | 134 &echo_path_delay_samples_); |
130 data_dumper_->DumpRaw("aec3_render_delay_controller_buffer_delay", delay_); | 135 data_dumper_->DumpRaw("aec3_render_delay_controller_buffer_delay", delay_); |
131 | 136 |
132 return delay_; | 137 return delay_; |
133 } | 138 } |
134 | 139 |
135 } // namespace | 140 } // namespace |
136 | 141 |
137 RenderDelayController* RenderDelayController::Create(int sample_rate_hz) { | 142 RenderDelayController* RenderDelayController::Create( |
138 return new RenderDelayControllerImpl(sample_rate_hz); | 143 const AudioProcessing::Config::EchoCanceller3& config, |
| 144 int sample_rate_hz) { |
| 145 return new RenderDelayControllerImpl(config, sample_rate_hz); |
139 } | 146 } |
140 | 147 |
141 } // namespace webrtc | 148 } // namespace webrtc |
OLD | NEW |