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_checker.h" |
15 #include "webrtc/common_audio/swap_queue.h" | 16 #include "webrtc/common_audio/swap_queue.h" |
16 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 17 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
17 #include "webrtc/modules/audio_processing/processing_component.h" | 18 #include "webrtc/modules/audio_processing/processing_component.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 class AudioBuffer; | 22 class AudioBuffer; |
22 class CriticalSectionWrapper; | 23 class CriticalSectionWrapper; |
23 | 24 |
24 // Functor to use when supplying a verifier function for the queue item | 25 // Functor to use when supplying a verifier function for the queue item |
25 // verifcation. | 26 // verifcation. |
26 class AecRenderQueueItemVerifier { | 27 class AecRenderQueueItemVerifier { |
27 public: | 28 public: |
28 explicit AecRenderQueueItemVerifier(size_t minimum_capacity) | 29 explicit AecRenderQueueItemVerifier(size_t minimum_capacity) |
29 : minimum_capacity_(minimum_capacity) {} | 30 : minimum_capacity_(minimum_capacity) {} |
30 | 31 |
31 bool operator()(const std::vector<float>& v) const { | 32 bool operator()(const std::vector<float>& v) const { |
32 return v.capacity() >= minimum_capacity_; | 33 return v.capacity() >= minimum_capacity_; |
33 } | 34 } |
34 | 35 |
35 private: | 36 private: |
36 size_t minimum_capacity_; | 37 size_t minimum_capacity_; |
37 }; | 38 }; |
38 | 39 |
39 class EchoCancellationImpl : public EchoCancellation, | 40 class EchoCancellationImpl : public EchoCancellation, |
40 public ProcessingComponent { | 41 public ProcessingComponent { |
41 public: | 42 public: |
42 EchoCancellationImpl(const AudioProcessing* apm, | 43 EchoCancellationImpl(const AudioProcessing* apm, |
43 CriticalSectionWrapper* crit); | 44 CriticalSectionWrapper* crit, |
| 45 const rtc::ThreadChecker* render_thread_checker); |
44 virtual ~EchoCancellationImpl(); | 46 virtual ~EchoCancellationImpl(); |
45 | 47 |
46 int ProcessRenderAudio(const AudioBuffer* audio); | 48 int ProcessRenderAudio(const AudioBuffer* audio); |
47 int ProcessCaptureAudio(AudioBuffer* audio); | 49 int ProcessCaptureAudio(AudioBuffer* audio); |
48 | 50 |
49 // EchoCancellation implementation. | 51 // EchoCancellation implementation. |
50 bool is_enabled() const override; | 52 bool is_enabled() const override; |
51 int stream_drift_samples() const override; | 53 int stream_drift_samples() const override; |
52 SuppressionLevel suppression_level() const override; | 54 SuppressionLevel suppression_level() const override; |
53 bool is_drift_compensation_enabled() const override; | 55 bool is_drift_compensation_enabled() const override; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 int InitializeHandle(void* handle) const override; | 93 int InitializeHandle(void* handle) const override; |
92 int ConfigureHandle(void* handle) const override; | 94 int ConfigureHandle(void* handle) const override; |
93 void DestroyHandle(void* handle) const override; | 95 void DestroyHandle(void* handle) const override; |
94 int num_handles_required() const override; | 96 int num_handles_required() const override; |
95 int GetHandleError(void* handle) const override; | 97 int GetHandleError(void* handle) const override; |
96 | 98 |
97 void AllocateRenderQueue(); | 99 void AllocateRenderQueue(); |
98 | 100 |
99 const AudioProcessing* apm_; | 101 const AudioProcessing* apm_; |
100 CriticalSectionWrapper* crit_; | 102 CriticalSectionWrapper* crit_; |
| 103 const rtc::ThreadChecker* const render_thread_checker_; |
| 104 |
101 bool drift_compensation_enabled_; | 105 bool drift_compensation_enabled_; |
102 bool metrics_enabled_; | 106 bool metrics_enabled_; |
103 SuppressionLevel suppression_level_; | 107 SuppressionLevel suppression_level_; |
104 int stream_drift_samples_; | 108 int stream_drift_samples_; |
105 bool was_stream_drift_set_; | 109 bool was_stream_drift_set_; |
106 bool stream_has_echo_; | 110 bool stream_has_echo_; |
107 bool delay_logging_enabled_; | 111 bool delay_logging_enabled_; |
108 bool extended_filter_enabled_; | 112 bool extended_filter_enabled_; |
109 bool delay_agnostic_enabled_; | 113 bool delay_agnostic_enabled_; |
110 | 114 |
111 size_t render_queue_element_max_size_; | 115 size_t render_queue_element_max_size_; |
112 std::vector<float> render_queue_buffer_; | 116 std::vector<float> render_queue_buffer_; |
113 std::vector<float> capture_queue_buffer_; | 117 std::vector<float> capture_queue_buffer_; |
114 rtc::scoped_ptr<SwapQueue<std::vector<float>, AecRenderQueueItemVerifier>> | 118 rtc::scoped_ptr<SwapQueue<std::vector<float>, AecRenderQueueItemVerifier>> |
115 render_signal_queue_; | 119 render_signal_queue_; |
116 }; | 120 }; |
117 | 121 |
118 } // namespace webrtc | 122 } // namespace webrtc |
119 | 123 |
120 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ | 124 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ |
OLD | NEW |