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 "webrtc/base/scoped_ptr.h" | 14 #include "webrtc/base/scoped_ptr.h" |
| 15 #include "webrtc/base/thread_annotations.h" |
15 #include "webrtc/base/thread_checker.h" | 16 #include "webrtc/base/thread_checker.h" |
16 #include "webrtc/common_audio/swap_queue.h" | 17 #include "webrtc/common_audio/swap_queue.h" |
17 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 18 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
18 #include "webrtc/modules/audio_processing/processing_component.h" | 19 #include "webrtc/modules/audio_processing/processing_component.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 namespace { | 23 namespace { |
23 // Functor to use when supplying a verifier function for the queue item | 24 // Functor to use when supplying a verifier function for the queue item |
24 // verifcation. | 25 // verifcation. |
25 class AecRenderQueueItemVerifier { | 26 class AecRenderQueueItemVerifier { |
26 public: | 27 public: |
27 explicit AecRenderQueueItemVerifier(size_t allowed_size_1, | 28 explicit AecRenderQueueItemVerifier(size_t allowed_size_1, |
28 size_t allowed_size_2) | 29 size_t allowed_size_2) |
29 : allowed_size_1_(allowed_size_1), allowed_size_2_(allowed_size_2) {} | 30 : allowed_size_1_(allowed_size_1), allowed_size_2_(allowed_size_2) {} |
30 | 31 |
31 bool operator()(const std::vector<float>& v) const { | 32 bool operator()(const std::vector<float>& v) const { |
32 return (((v.size() == allowed_size_1_) || (v.size() == allowed_size_2_)) && | 33 return (((v.size() == allowed_size_1_) || (v.size() == allowed_size_2_)) && |
33 (v.capacity() >= std::max(allowed_size_1_, allowed_size_2_))); | 34 (v.capacity() >= std::max(allowed_size_1_, allowed_size_2_))); |
34 } | 35 } |
35 | 36 |
36 private: | 37 private: |
37 size_t allowed_size_1_; | 38 size_t allowed_size_1_; |
38 size_t allowed_size_2_; | 39 size_t allowed_size_2_; |
39 }; | 40 }; |
40 | 41 |
41 } // namespace anonymous | 42 } // namespace anonymous |
42 | 43 |
43 class AudioBuffer; | 44 class AudioBuffer; |
44 class CriticalSectionWrapper; | |
45 | 45 |
46 class EchoCancellationImpl : public EchoCancellation, | 46 class EchoCancellationImpl : public EchoCancellation, |
47 public ProcessingComponent { | 47 public ProcessingComponent { |
48 public: | 48 public: |
49 EchoCancellationImpl(const AudioProcessing* apm, | 49 EchoCancellationImpl(const AudioProcessing* apm, |
50 CriticalSectionWrapper* crit, | 50 rtc::CriticalSection* crit_render, |
| 51 rtc::CriticalSection* crit_capture, |
51 rtc::ThreadChecker* render_thread, | 52 rtc::ThreadChecker* render_thread, |
52 rtc::ThreadChecker* capture_thread); | 53 rtc::ThreadChecker* capture_thread); |
53 virtual ~EchoCancellationImpl(); | 54 virtual ~EchoCancellationImpl(); |
54 | 55 |
55 int ProcessRenderAudio(const AudioBuffer* audio); | 56 int ProcessRenderAudio(const AudioBuffer* audio); |
56 int ProcessCaptureAudio(AudioBuffer* audio); | 57 int ProcessCaptureAudio(AudioBuffer* audio); |
57 | 58 |
58 // EchoCancellation implementation. | 59 // EchoCancellation implementation. |
59 bool is_enabled() const override; | 60 bool is_enabled() const override; |
60 int stream_drift_samples() const override; | 61 int stream_drift_samples() const override; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void* CreateHandle() const override; | 100 void* CreateHandle() const override; |
100 int InitializeHandle(void* handle) const override; | 101 int InitializeHandle(void* handle) const override; |
101 int ConfigureHandle(void* handle) const override; | 102 int ConfigureHandle(void* handle) const override; |
102 void DestroyHandle(void* handle) const override; | 103 void DestroyHandle(void* handle) const override; |
103 int num_handles_required() const override; | 104 int num_handles_required() const override; |
104 int GetHandleError(void* handle) const override; | 105 int GetHandleError(void* handle) const override; |
105 | 106 |
106 void AllocateRenderQueue(); | 107 void AllocateRenderQueue(); |
107 | 108 |
108 const AudioProcessing* apm_; | 109 const AudioProcessing* apm_; |
109 CriticalSectionWrapper* crit_; | 110 rtc::CriticalSection* const crit_render_; |
| 111 rtc::CriticalSection* const crit_capture_; |
110 const rtc::ThreadChecker* const render_thread_; | 112 const rtc::ThreadChecker* const render_thread_; |
111 const rtc::ThreadChecker* const capture_thread_; | 113 const rtc::ThreadChecker* const capture_thread_; |
112 | 114 |
113 bool drift_compensation_enabled_; | 115 bool drift_compensation_enabled_; |
114 bool metrics_enabled_; | 116 bool metrics_enabled_; |
115 SuppressionLevel suppression_level_; | 117 SuppressionLevel suppression_level_; |
116 int stream_drift_samples_; | 118 int stream_drift_samples_; |
117 bool was_stream_drift_set_; | 119 bool was_stream_drift_set_; |
118 bool stream_has_echo_; | 120 bool stream_has_echo_; |
119 bool delay_logging_enabled_; | 121 bool delay_logging_enabled_; |
120 bool extended_filter_enabled_; | 122 bool extended_filter_enabled_; |
121 bool delay_agnostic_enabled_; | 123 bool delay_agnostic_enabled_; |
122 | 124 |
123 size_t render_queue_element_max_size_; | 125 size_t render_queue_element_max_size_; |
124 std::vector<float> render_queue_buffer_; | 126 std::vector<float> render_queue_buffer_; |
125 std::vector<float> capture_queue_buffer_; | 127 std::vector<float> capture_queue_buffer_; |
126 rtc::scoped_ptr<SwapQueue<std::vector<float>, AecRenderQueueItemVerifier> > | 128 rtc::scoped_ptr<SwapQueue<std::vector<float>, AecRenderQueueItemVerifier> > |
127 render_signal_queue_; | 129 render_signal_queue_; |
128 }; | 130 }; |
129 | 131 |
130 } // namespace webrtc | 132 } // namespace webrtc |
131 | 133 |
132 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ | 134 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ |
OLD | NEW |