OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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_AEC3_ECHO_CANCELLER3_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_ |
13 | 13 |
14 #include <string> | |
15 | |
16 #include "webrtc/base/constructormagic.h" | 14 #include "webrtc/base/constructormagic.h" |
15 #include "webrtc/modules/audio_processing/aec3/block_framer.h" | |
16 #include "webrtc/modules/audio_processing/aec3/block_processor.h" | |
17 #include "webrtc/modules/audio_processing/aec3/cascaded_biquad_filter.h" | |
18 #include "webrtc/modules/audio_processing/aec3/frame_blocker.h" | |
19 #include "webrtc/modules/audio_processing/aec3/render_transfer_buffer.h" | |
17 #include "webrtc/modules/audio_processing/audio_buffer.h" | 20 #include "webrtc/modules/audio_processing/audio_buffer.h" |
21 #include "webrtc/modules/audio_processing/include/audio_processing.h" | |
22 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" | |
18 | 23 |
19 namespace webrtc { | 24 namespace webrtc { |
20 | 25 |
26 // Main class for the echo canceller3. It does 4 things: | |
27 // -Receives 10 ms frames of band-split audio. | |
28 // -Optionally applies an anti-hum (high-pass) filter on the | |
29 // received signals. | |
30 // -Provides the lower level echo canceller functionality with | |
31 // blocks of 64 samples of audio data. | |
32 // -Partially handles the jitter in the render and capture API | |
33 // call sequence. | |
34 // The class is supposed to be used in a single-threaded manner | |
hlundin-webrtc
2016/12/16 10:04:47
What does single-threaded mean here? Should all me
peah-webrtc
2016/12/20 10:10:25
Good point. I changed the comment to be more clear
hlundin-webrtc
2016/12/20 15:10:34
I propose you use a RaceChecker, similarly to how
peah-webrtc
2016/12/21 23:13:48
I agree!
Done.
| |
35 // apart from the AnalyzeRender call which can be performed | |
36 // from another thread. | |
21 class EchoCanceller3 { | 37 class EchoCanceller3 { |
22 public: | 38 public: |
23 EchoCanceller3(int sample_rate_hz, bool use_anti_hum_filter); | 39 EchoCanceller3(int sample_rate_hz, bool use_highpass_filter); |
24 ~EchoCanceller3(); | 40 ~EchoCanceller3(); |
25 // Analyzes and stores an internal copy of the split-band domain render | 41 // Analyzes and stores an internal copy of the split-band domain render |
26 // signal. | 42 // signal. |
27 bool AnalyzeRender(AudioBuffer* farend); | 43 bool AnalyzeRender(AudioBuffer* farend); |
28 // Analyzes the full-band domain capture signal to detect signal saturation. | 44 // Analyzes the full-band domain capture signal to detect signal saturation. |
29 void AnalyzeCapture(AudioBuffer* capture); | 45 void AnalyzeCapture(AudioBuffer* capture); |
30 // Processes the split-band domain capture signal in order to remove any echo | 46 // Processes the split-band domain capture signal in order to remove any echo |
31 // present in the signal. | 47 // present in the signal. |
32 void ProcessCapture(AudioBuffer* capture, bool known_echo_path_change); | 48 void ProcessCapture(AudioBuffer* capture, bool known_echo_path_change); |
33 | 49 |
50 // Signals whether an external detector has detected echo leakage from the | |
51 // echo canceller. | |
52 // Note that in the case echo leakage has been flagged, it should be unflagged | |
53 // once it is no longer occurring. | |
54 void ReportEchoLeakage(bool leakage_detected) { | |
55 block_processor_.ReportEchoLeakage(leakage_detected); | |
56 } | |
57 | |
34 // Validates a config. | 58 // Validates a config. |
35 static bool Validate(const AudioProcessing::Config::EchoCanceller3& config); | 59 static bool Validate(const AudioProcessing::Config::EchoCanceller3& config); |
36 // Dumps a config to a string. | 60 // Dumps a config to a string. |
37 static std::string ToString( | 61 static std::string ToString( |
38 const AudioProcessing::Config::EchoCanceller3& config); | 62 const AudioProcessing::Config::EchoCanceller3& config); |
39 | 63 |
40 private: | 64 private: |
65 class RenderWriterState { | |
hlundin-webrtc
2016/12/16 10:04:47
"State" suggests that this is a simple data contai
ivoc
2016/12/19 11:30:22
Since this class is private and EchoCanceller3 onl
peah-webrtc
2016/12/20 10:10:25
Good point!
Done.
peah-webrtc
2016/12/20 10:10:25
Done.
| |
66 public: | |
67 RenderWriterState( | |
68 ApmDataDumper* data_dumper, | |
69 RenderTransferBufferWriter* transfer_buffer_writer, | |
70 std::unique_ptr<CascadedBiQuadFilter> render_highpass_filter, | |
71 int sample_rate_hz, | |
72 int frame_length, | |
73 int num_bands); | |
74 ~RenderWriterState(); | |
75 bool Insert(AudioBuffer* render); | |
76 | |
77 private: | |
78 ApmDataDumper* data_dumper_; | |
79 const int sample_rate_hz_; | |
80 const size_t frame_length_; | |
81 const int num_bands_; | |
82 RenderTransferBufferWriter* transfer_buffer_writer_; | |
83 std::unique_ptr<CascadedBiQuadFilter> render_highpass_filter_; | |
84 std::vector<float> render_queue_input_frame_; | |
85 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RenderWriterState); | |
86 }; | |
87 // State that may be accessed by the render thread. | |
88 std::unique_ptr<RenderWriterState> render_writer_; | |
89 | |
90 // State that may be accessed by the capture thread. | |
41 static int instance_count_; | 91 static int instance_count_; |
42 size_t frame_length_; | 92 std::unique_ptr<ApmDataDumper> data_dumper_; |
93 const int sample_rate_hz_; | |
94 const int num_bands_; | |
95 const size_t frame_length_; | |
96 BlockFramer output_framer_; | |
97 FrameBlocker capture_blocker_; | |
98 FrameBlocker render_blocker_; | |
99 RenderTransferBuffer render_transfer_buffer_; | |
100 BlockProcessor block_processor_; | |
101 std::vector<float> render_queue_output_frame_; | |
102 std::unique_ptr<CascadedBiQuadFilter> capture_highpass_filter_; | |
103 bool saturated_microphone_signal_ = false; | |
104 bool EmptyRenderQueue(); | |
hlundin-webrtc
2016/12/16 10:04:47
Declare methods before data members.
https://googl
peah-webrtc
2016/12/20 10:10:25
Done.
| |
43 | 105 |
44 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCanceller3); | 106 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCanceller3); |
45 }; | 107 }; |
46 } // namespace webrtc | 108 } // namespace webrtc |
47 | 109 |
48 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_ | 110 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_ |
OLD | NEW |