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" | |
15 #include "webrtc/common_audio/swap_queue.h" | |
14 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 16 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
15 #include "webrtc/modules/audio_processing/processing_component.h" | 17 #include "webrtc/modules/audio_processing/processing_component.h" |
16 | 18 |
17 namespace webrtc { | 19 namespace webrtc { |
18 | 20 |
21 namespace { | |
hlundin-webrtc
2015/11/05 12:57:02
"Do not use unnamed namespaces in .h files."
https
peah-webrtc
2015/11/06 06:55:04
Done.
| |
22 // Functor to use when supplying a verifier function for the queue item | |
23 // verifcation. | |
24 class AecRenderQueueItemVerifier { | |
25 public: | |
26 explicit AecRenderQueueItemVerifier(size_t minimum_capacity) | |
27 : minimum_capacity_(minimum_capacity) {} | |
28 | |
29 bool operator()(const std::vector<float>& v) const { | |
30 return v.capacity() >= minimum_capacity_; | |
31 } | |
32 | |
33 private: | |
34 size_t minimum_capacity_; | |
35 }; | |
36 | |
37 } // namespace anonymous | |
38 | |
19 class AudioBuffer; | 39 class AudioBuffer; |
20 class CriticalSectionWrapper; | 40 class CriticalSectionWrapper; |
21 | 41 |
22 class EchoCancellationImpl : public EchoCancellation, | 42 class EchoCancellationImpl : public EchoCancellation, |
23 public ProcessingComponent { | 43 public ProcessingComponent { |
24 public: | 44 public: |
25 EchoCancellationImpl(const AudioProcessing* apm, | 45 EchoCancellationImpl(const AudioProcessing* apm, |
26 CriticalSectionWrapper* crit); | 46 CriticalSectionWrapper* crit); |
27 virtual ~EchoCancellationImpl(); | 47 virtual ~EchoCancellationImpl(); |
28 | 48 |
29 int ProcessRenderAudio(const AudioBuffer* audio); | 49 int ProcessRenderAudio(const AudioBuffer* audio); |
30 int ProcessCaptureAudio(AudioBuffer* audio); | 50 int ProcessCaptureAudio(AudioBuffer* audio); |
31 | 51 |
32 // EchoCancellation implementation. | 52 // EchoCancellation implementation. |
33 bool is_enabled() const override; | 53 bool is_enabled() const override; |
34 int stream_drift_samples() const override; | 54 int stream_drift_samples() const override; |
35 SuppressionLevel suppression_level() const override; | 55 SuppressionLevel suppression_level() const override; |
36 bool is_drift_compensation_enabled() const override; | 56 bool is_drift_compensation_enabled() const override; |
37 | 57 |
38 // ProcessingComponent implementation. | 58 // ProcessingComponent implementation. |
39 int Initialize() override; | 59 int Initialize() override; |
40 void SetExtraOptions(const Config& config) override; | 60 void SetExtraOptions(const Config& config) override; |
41 | 61 |
42 bool is_delay_agnostic_enabled() const; | 62 bool is_delay_agnostic_enabled() const; |
43 bool is_extended_filter_enabled() const; | 63 bool is_extended_filter_enabled() const; |
44 | 64 |
65 // Reads render side data that has been queued on the render call. | |
66 void ReadQueuedRenderData(); | |
67 | |
45 private: | 68 private: |
69 static const size_t kAllowedValuesOfSamplesPerFrame1 = 80; | |
70 static const size_t kAllowedValuesOfSamplesPerFrame2 = 160; | |
71 // TODO(peah): Decrease this once we properly handle hugely unbalanced | |
72 // reverse and forward call numbers. | |
73 static const size_t kMaxNumFramesToBuffer = 100; | |
74 | |
46 // EchoCancellation implementation. | 75 // EchoCancellation implementation. |
47 int Enable(bool enable) override; | 76 int Enable(bool enable) override; |
48 int enable_drift_compensation(bool enable) override; | 77 int enable_drift_compensation(bool enable) override; |
49 void set_stream_drift_samples(int drift) override; | 78 void set_stream_drift_samples(int drift) override; |
50 int set_suppression_level(SuppressionLevel level) override; | 79 int set_suppression_level(SuppressionLevel level) override; |
51 int enable_metrics(bool enable) override; | 80 int enable_metrics(bool enable) override; |
52 bool are_metrics_enabled() const override; | 81 bool are_metrics_enabled() const override; |
53 bool stream_has_echo() const override; | 82 bool stream_has_echo() const override; |
54 int GetMetrics(Metrics* metrics) override; | 83 int GetMetrics(Metrics* metrics) override; |
55 int enable_delay_logging(bool enable) override; | 84 int enable_delay_logging(bool enable) override; |
56 bool is_delay_logging_enabled() const override; | 85 bool is_delay_logging_enabled() const override; |
57 int GetDelayMetrics(int* median, int* std) override; | 86 int GetDelayMetrics(int* median, int* std) override; |
58 int GetDelayMetrics(int* median, | 87 int GetDelayMetrics(int* median, |
59 int* std, | 88 int* std, |
60 float* fraction_poor_delays) override; | 89 float* fraction_poor_delays) override; |
61 struct AecCore* aec_core() const override; | 90 struct AecCore* aec_core() const override; |
62 | 91 |
63 // ProcessingComponent implementation. | 92 // ProcessingComponent implementation. |
64 void* CreateHandle() const override; | 93 void* CreateHandle() const override; |
65 int InitializeHandle(void* handle) const override; | 94 int InitializeHandle(void* handle) const override; |
66 int ConfigureHandle(void* handle) const override; | 95 int ConfigureHandle(void* handle) const override; |
67 void DestroyHandle(void* handle) const override; | 96 void DestroyHandle(void* handle) const override; |
68 int num_handles_required() const override; | 97 int num_handles_required() const override; |
69 int GetHandleError(void* handle) const override; | 98 int GetHandleError(void* handle) const override; |
70 | 99 |
100 void AllocateRenderQueue(); | |
101 | |
71 const AudioProcessing* apm_; | 102 const AudioProcessing* apm_; |
72 CriticalSectionWrapper* crit_; | 103 CriticalSectionWrapper* crit_; |
73 bool drift_compensation_enabled_; | 104 bool drift_compensation_enabled_; |
74 bool metrics_enabled_; | 105 bool metrics_enabled_; |
75 SuppressionLevel suppression_level_; | 106 SuppressionLevel suppression_level_; |
76 int stream_drift_samples_; | 107 int stream_drift_samples_; |
77 bool was_stream_drift_set_; | 108 bool was_stream_drift_set_; |
78 bool stream_has_echo_; | 109 bool stream_has_echo_; |
79 bool delay_logging_enabled_; | 110 bool delay_logging_enabled_; |
80 bool extended_filter_enabled_; | 111 bool extended_filter_enabled_; |
81 bool delay_agnostic_enabled_; | 112 bool delay_agnostic_enabled_; |
113 | |
114 size_t render_queue_element_max_size_; | |
115 std::vector<float> render_queue_buffer_; | |
116 std::vector<float> capture_queue_buffer_; | |
117 rtc::scoped_ptr<SwapQueue<std::vector<float>, AecRenderQueueItemVerifier>> | |
118 render_signal_queue_; | |
82 }; | 119 }; |
83 | 120 |
84 } // namespace webrtc | 121 } // namespace webrtc |
85 | 122 |
86 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ | 123 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ |
OLD | NEW |