OLD | NEW |
---|---|
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 | 15 |
16 #include "webrtc/base/constructormagic.h" | |
16 #include "webrtc/base/criticalsection.h" | 17 #include "webrtc/base/criticalsection.h" |
17 #include "webrtc/common_audio/swap_queue.h" | 18 #include "webrtc/common_audio/swap_queue.h" |
18 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 19 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
19 #include "webrtc/modules/audio_processing/processing_component.h" | 20 #include "webrtc/modules/audio_processing/processing_component.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 | 23 |
23 class AudioBuffer; | 24 class AudioBuffer; |
24 | 25 |
25 class EchoCancellationImpl : public EchoCancellation, | 26 class EchoCancellationImpl : public EchoCancellation { |
26 public ProcessingComponent { | |
27 public: | 27 public: |
28 EchoCancellationImpl(const AudioProcessing* apm, | 28 EchoCancellationImpl(const AudioProcessing* apm, |
29 rtc::CriticalSection* crit_render, | 29 rtc::CriticalSection* crit_render, |
30 rtc::CriticalSection* crit_capture); | 30 rtc::CriticalSection* crit_capture); |
31 virtual ~EchoCancellationImpl(); | 31 virtual ~EchoCancellationImpl(); |
32 | 32 |
33 int ProcessRenderAudio(const AudioBuffer* audio); | 33 int ProcessRenderAudio(const AudioBuffer* audio); |
34 int ProcessCaptureAudio(AudioBuffer* audio); | 34 int ProcessCaptureAudio(AudioBuffer* audio); |
35 | 35 |
36 // EchoCancellation implementation. | 36 // EchoCancellation implementation. |
37 bool is_enabled() const override; | 37 bool is_enabled() const override; |
38 int stream_drift_samples() const override; | 38 int stream_drift_samples() const override; |
39 SuppressionLevel suppression_level() const override; | 39 SuppressionLevel suppression_level() const override; |
40 bool is_drift_compensation_enabled() const override; | 40 bool is_drift_compensation_enabled() const override; |
41 | 41 |
42 // ProcessingComponent implementation. | 42 void Initialize(); |
43 int Initialize() override; | 43 void SetExtraOptions(const Config& config); |
44 void SetExtraOptions(const Config& config) override; | |
45 bool is_delay_agnostic_enabled() const; | 44 bool is_delay_agnostic_enabled() const; |
46 bool is_extended_filter_enabled() const; | 45 bool is_extended_filter_enabled() const; |
47 bool is_next_generation_aec_enabled() const; | 46 bool is_next_generation_aec_enabled() const; |
48 | 47 |
49 // Reads render side data that has been queued on the render call. | 48 // Reads render side data that has been queued on the render call. |
50 // Called holding the capture lock. | 49 // Called holding the capture lock. |
51 void ReadQueuedRenderData(); | 50 void ReadQueuedRenderData(); |
52 | 51 |
53 private: | 52 private: |
53 class Canceller; | |
54 | |
54 // EchoCancellation implementation. | 55 // EchoCancellation implementation. |
55 int Enable(bool enable) override; | 56 int Enable(bool enable) override; |
56 int enable_drift_compensation(bool enable) override; | 57 int enable_drift_compensation(bool enable) override; |
57 void set_stream_drift_samples(int drift) override; | 58 void set_stream_drift_samples(int drift) override; |
58 int set_suppression_level(SuppressionLevel level) override; | 59 int set_suppression_level(SuppressionLevel level) override; |
59 int enable_metrics(bool enable) override; | 60 int enable_metrics(bool enable) override; |
60 bool are_metrics_enabled() const override; | 61 bool are_metrics_enabled() const override; |
61 bool stream_has_echo() const override; | 62 bool stream_has_echo() const override; |
62 int GetMetrics(Metrics* metrics) override; | 63 int GetMetrics(Metrics* metrics) override; |
63 int enable_delay_logging(bool enable) override; | 64 int enable_delay_logging(bool enable) override; |
64 bool is_delay_logging_enabled() const override; | 65 bool is_delay_logging_enabled() const override; |
65 int GetDelayMetrics(int* median, int* std) override; | 66 int GetDelayMetrics(int* median, int* std) override; |
66 int GetDelayMetrics(int* median, | 67 int GetDelayMetrics(int* median, |
67 int* std, | 68 int* std, |
68 float* fraction_poor_delays) override; | 69 float* fraction_poor_delays) override; |
69 | 70 |
70 struct AecCore* aec_core() const override; | 71 struct AecCore* aec_core() const override; |
71 | 72 |
72 // ProcessingComponent implementation. | 73 size_t num_handles_required() const; |
73 void* CreateHandle() const override; | |
74 int InitializeHandle(void* handle) const override; | |
75 int ConfigureHandle(void* handle) const override; | |
76 void DestroyHandle(void* handle) const override; | |
77 size_t num_handles_required() const override; | |
78 int GetHandleError(void* handle) const override; | |
79 | 74 |
80 void AllocateRenderQueue(); | 75 void AllocateRenderQueue(); |
76 int Configure(); | |
81 | 77 |
82 // Not guarded as its public API is thread safe. | 78 // Not guarded as its public API is thread safe. |
83 const AudioProcessing* apm_; | 79 const AudioProcessing* apm_; |
the sun
2016/03/03 10:00:53
Ah, this is why there aren't more changes to the i
peah-webrtc
2016/03/03 12:06:34
Yes, that should definitely be broken. But in can
the sun
2016/03/03 13:13:05
Good idea to do things piecewise! When I did the H
| |
84 | 80 |
85 rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_); | 81 rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_); |
86 rtc::CriticalSection* const crit_capture_; | 82 rtc::CriticalSection* const crit_capture_; |
87 | 83 |
84 bool enabled_ = false; | |
the sun
2016/03/03 10:00:53
No crit sect guard?
peah-webrtc
2016/03/03 12:06:34
This is not possible, as this variable is used in
the sun
2016/03/03 13:13:05
Acknowledged.
| |
88 bool drift_compensation_enabled_ GUARDED_BY(crit_capture_); | 85 bool drift_compensation_enabled_ GUARDED_BY(crit_capture_); |
89 bool metrics_enabled_ GUARDED_BY(crit_capture_); | 86 bool metrics_enabled_ GUARDED_BY(crit_capture_); |
90 SuppressionLevel suppression_level_ GUARDED_BY(crit_capture_); | 87 SuppressionLevel suppression_level_ GUARDED_BY(crit_capture_); |
91 int stream_drift_samples_ GUARDED_BY(crit_capture_); | 88 int stream_drift_samples_ GUARDED_BY(crit_capture_); |
92 bool was_stream_drift_set_ GUARDED_BY(crit_capture_); | 89 bool was_stream_drift_set_ GUARDED_BY(crit_capture_); |
93 bool stream_has_echo_ GUARDED_BY(crit_capture_); | 90 bool stream_has_echo_ GUARDED_BY(crit_capture_); |
94 bool delay_logging_enabled_ GUARDED_BY(crit_capture_); | 91 bool delay_logging_enabled_ GUARDED_BY(crit_capture_); |
95 bool extended_filter_enabled_ GUARDED_BY(crit_capture_); | 92 bool extended_filter_enabled_ GUARDED_BY(crit_capture_); |
96 bool delay_agnostic_enabled_ GUARDED_BY(crit_capture_); | 93 bool delay_agnostic_enabled_ GUARDED_BY(crit_capture_); |
97 bool next_generation_aec_enabled_ GUARDED_BY(crit_capture_); | 94 bool next_generation_aec_enabled_ GUARDED_BY(crit_capture_); |
98 | 95 |
99 size_t render_queue_element_max_size_ GUARDED_BY(crit_render_) | 96 size_t render_queue_element_max_size_ GUARDED_BY(crit_render_) |
100 GUARDED_BY(crit_capture_); | 97 GUARDED_BY(crit_capture_); |
101 std::vector<float> render_queue_buffer_ GUARDED_BY(crit_render_); | 98 std::vector<float> render_queue_buffer_ GUARDED_BY(crit_render_); |
102 std::vector<float> capture_queue_buffer_ GUARDED_BY(crit_capture_); | 99 std::vector<float> capture_queue_buffer_ GUARDED_BY(crit_capture_); |
103 | 100 |
104 // Lock protection not needed. | 101 // Lock protection not needed. |
105 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> | 102 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> |
106 render_signal_queue_; | 103 render_signal_queue_; |
104 | |
105 std::vector<std::unique_ptr<Canceller>> cancellers_; | |
106 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCancellationImpl); | |
107 }; | 107 }; |
108 | 108 |
109 } // namespace webrtc | 109 } // namespace webrtc |
110 | 110 |
111 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ | 111 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ |
OLD | NEW |