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

Side by Side Diff: webrtc/modules/audio_processing/echo_cancellation_impl.h

Issue 2427553003: Moved the AEC render sample queue into the audio processing module (Closed)
Patch Set: Rebase Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/constructormagic.h" 17 #include "webrtc/base/constructormagic.h"
18 #include "webrtc/base/criticalsection.h" 18 #include "webrtc/base/criticalsection.h"
19 #include "webrtc/base/swap_queue.h"
20 #include "webrtc/modules/audio_processing/include/audio_processing.h" 19 #include "webrtc/modules/audio_processing/include/audio_processing.h"
21 #include "webrtc/modules/audio_processing/render_queue_item_verifier.h"
22 20
23 namespace webrtc { 21 namespace webrtc {
24 22
25 class AudioBuffer; 23 class AudioBuffer;
26 24
27 class EchoCancellationImpl : public EchoCancellation { 25 class EchoCancellationImpl : public EchoCancellation {
28 public: 26 public:
29 EchoCancellationImpl(rtc::CriticalSection* crit_render, 27 EchoCancellationImpl(rtc::CriticalSection* crit_render,
30 rtc::CriticalSection* crit_capture); 28 rtc::CriticalSection* crit_capture);
31 ~EchoCancellationImpl() override; 29 ~EchoCancellationImpl() override;
32 30
33 int ProcessRenderAudio(const AudioBuffer* audio); 31 void ProcessRenderAudio(rtc::ArrayView<const float> packed_render_audio);
34 int ProcessCaptureAudio(AudioBuffer* audio, int stream_delay_ms); 32 int ProcessCaptureAudio(AudioBuffer* audio, int stream_delay_ms);
35 33
36 // EchoCancellation implementation. 34 // EchoCancellation implementation.
37 bool is_enabled() const override; 35 bool is_enabled() const override;
38 int stream_drift_samples() const override; 36 int stream_drift_samples() const override;
39 SuppressionLevel suppression_level() const override; 37 SuppressionLevel suppression_level() const override;
40 bool is_drift_compensation_enabled() const override; 38 bool is_drift_compensation_enabled() const override;
41 39
42 void Initialize(int sample_rate_hz, 40 void Initialize(int sample_rate_hz,
43 size_t num_reverse_channels_, 41 size_t num_reverse_channels_,
44 size_t num_output_channels_, 42 size_t num_output_channels_,
45 size_t num_proc_channels_); 43 size_t num_proc_channels_);
46 void SetExtraOptions(const webrtc::Config& config); 44 void SetExtraOptions(const webrtc::Config& config);
47 bool is_delay_agnostic_enabled() const; 45 bool is_delay_agnostic_enabled() const;
48 bool is_extended_filter_enabled() const; 46 bool is_extended_filter_enabled() const;
49 bool is_aec3_enabled() const; 47 bool is_aec3_enabled() const;
50 std::string GetExperimentsDescription(); 48 std::string GetExperimentsDescription();
51 bool is_refined_adaptive_filter_enabled() const; 49 bool is_refined_adaptive_filter_enabled() const;
52 50
53 // Reads render side data that has been queued on the render call.
54 // Called holding the capture lock.
55 void ReadQueuedRenderData();
56
57 // Returns the system delay of the first AEC component. 51 // Returns the system delay of the first AEC component.
58 int GetSystemDelayInSamples() const; 52 int GetSystemDelayInSamples() const;
59 53
54 static void PackRenderAudioBuffer(const AudioBuffer* audio,
55 size_t num_output_channels,
56 size_t num_channels,
57 std::vector<float>* packed_buffer);
58 static size_t NumCancellersRequired(size_t num_output_channels,
59 size_t num_reverse_channels);
60
60 private: 61 private:
61 class Canceller; 62 class Canceller;
62 struct StreamProperties; 63 struct StreamProperties;
63 64
64 // EchoCancellation implementation. 65 // EchoCancellation implementation.
65 int Enable(bool enable) override; 66 int Enable(bool enable) override;
66 int enable_drift_compensation(bool enable) override; 67 int enable_drift_compensation(bool enable) override;
67 void set_stream_drift_samples(int drift) override; 68 void set_stream_drift_samples(int drift) override;
68 int set_suppression_level(SuppressionLevel level) override; 69 int set_suppression_level(SuppressionLevel level) override;
69 int enable_metrics(bool enable) override; 70 int enable_metrics(bool enable) override;
70 bool are_metrics_enabled() const override; 71 bool are_metrics_enabled() const override;
71 bool stream_has_echo() const override; 72 bool stream_has_echo() const override;
72 int GetMetrics(Metrics* metrics) override; 73 int GetMetrics(Metrics* metrics) override;
73 int enable_delay_logging(bool enable) override; 74 int enable_delay_logging(bool enable) override;
74 bool is_delay_logging_enabled() const override; 75 bool is_delay_logging_enabled() const override;
75 int GetDelayMetrics(int* median, int* std) override; 76 int GetDelayMetrics(int* median, int* std) override;
76 int GetDelayMetrics(int* median, 77 int GetDelayMetrics(int* median,
77 int* std, 78 int* std,
78 float* fraction_poor_delays) override; 79 float* fraction_poor_delays) override;
79 80
80 struct AecCore* aec_core() const override; 81 struct AecCore* aec_core() const override;
81 82
82 size_t NumCancellersRequired() const;
83
84 void AllocateRenderQueue(); 83 void AllocateRenderQueue();
85 int Configure(); 84 int Configure();
86 85
87 rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_); 86 rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_);
88 rtc::CriticalSection* const crit_capture_; 87 rtc::CriticalSection* const crit_capture_;
89 88
90 bool enabled_ = false; 89 bool enabled_ = false;
91 bool drift_compensation_enabled_ GUARDED_BY(crit_capture_); 90 bool drift_compensation_enabled_ GUARDED_BY(crit_capture_);
92 bool metrics_enabled_ GUARDED_BY(crit_capture_); 91 bool metrics_enabled_ GUARDED_BY(crit_capture_);
93 SuppressionLevel suppression_level_ GUARDED_BY(crit_capture_); 92 SuppressionLevel suppression_level_ GUARDED_BY(crit_capture_);
94 int stream_drift_samples_ GUARDED_BY(crit_capture_); 93 int stream_drift_samples_ GUARDED_BY(crit_capture_);
95 bool was_stream_drift_set_ GUARDED_BY(crit_capture_); 94 bool was_stream_drift_set_ GUARDED_BY(crit_capture_);
96 bool stream_has_echo_ GUARDED_BY(crit_capture_); 95 bool stream_has_echo_ GUARDED_BY(crit_capture_);
97 bool delay_logging_enabled_ GUARDED_BY(crit_capture_); 96 bool delay_logging_enabled_ GUARDED_BY(crit_capture_);
98 bool extended_filter_enabled_ GUARDED_BY(crit_capture_); 97 bool extended_filter_enabled_ GUARDED_BY(crit_capture_);
99 bool delay_agnostic_enabled_ GUARDED_BY(crit_capture_); 98 bool delay_agnostic_enabled_ GUARDED_BY(crit_capture_);
100 bool aec3_enabled_ GUARDED_BY(crit_capture_); 99 bool aec3_enabled_ GUARDED_BY(crit_capture_);
101 bool refined_adaptive_filter_enabled_ GUARDED_BY(crit_capture_) = false; 100 bool refined_adaptive_filter_enabled_ GUARDED_BY(crit_capture_) = false;
102 101
103 size_t render_queue_element_max_size_ GUARDED_BY(crit_render_)
104 GUARDED_BY(crit_capture_);
105 std::vector<float> render_queue_buffer_ GUARDED_BY(crit_render_);
106 std::vector<float> capture_queue_buffer_ GUARDED_BY(crit_capture_);
107
108 // Lock protection not needed.
109 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>>
110 render_signal_queue_;
111
112 std::vector<std::unique_ptr<Canceller>> cancellers_; 102 std::vector<std::unique_ptr<Canceller>> cancellers_;
113 std::unique_ptr<StreamProperties> stream_properties_; 103 std::unique_ptr<StreamProperties> stream_properties_;
114 104
115 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCancellationImpl); 105 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCancellationImpl);
116 }; 106 };
117 107
118 } // namespace webrtc 108 } // namespace webrtc
119 109
120 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ 110 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698