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_CONTROL_MOBILE_IMPL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_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 AecmRenderQueueItemVerifier { | |
25 public: | |
26 explicit AecmRenderQueueItemVerifier(size_t minimum_capacity) | |
27 : minimum_capacity_(minimum_capacity) {} | |
28 | |
29 bool operator()(const std::vector<int16_t>& 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 EchoControlMobileImpl : public EchoControlMobile, | 42 class EchoControlMobileImpl : public EchoControlMobile, |
23 public ProcessingComponent { | 43 public ProcessingComponent { |
24 public: | 44 public: |
25 EchoControlMobileImpl(const AudioProcessing* apm, | 45 EchoControlMobileImpl(const AudioProcessing* apm, |
26 CriticalSectionWrapper* crit); | 46 CriticalSectionWrapper* crit); |
27 virtual ~EchoControlMobileImpl(); | 47 virtual ~EchoControlMobileImpl(); |
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 // EchoControlMobile implementation. | 52 // EchoControlMobile implementation. |
33 bool is_enabled() const override; | 53 bool is_enabled() const override; |
34 RoutingMode routing_mode() const override; | 54 RoutingMode routing_mode() const override; |
35 bool is_comfort_noise_enabled() const override; | 55 bool is_comfort_noise_enabled() const override; |
36 | 56 |
37 // ProcessingComponent implementation. | 57 // ProcessingComponent implementation. |
38 int Initialize() override; | 58 int Initialize() override; |
39 | 59 |
60 // Reads render side data that has been queued on the render call. | |
61 void ReadQueuedRenderData(); | |
62 | |
40 private: | 63 private: |
64 static const size_t kAllowedValuesOfSamplesPerFrame1 = 80; | |
65 static const size_t kAllowedValuesOfSamplesPerFrame2 = 160; | |
66 // TODO(peah): Decrease this once we properly handle hugely unbalanced | |
67 // reverse and forward call numbers. | |
68 static const size_t kMaxNumFramesToBuffer = 100; | |
69 | |
41 // EchoControlMobile implementation. | 70 // EchoControlMobile implementation. |
42 int Enable(bool enable) override; | 71 int Enable(bool enable) override; |
43 int set_routing_mode(RoutingMode mode) override; | 72 int set_routing_mode(RoutingMode mode) override; |
44 int enable_comfort_noise(bool enable) override; | 73 int enable_comfort_noise(bool enable) override; |
45 int SetEchoPath(const void* echo_path, size_t size_bytes) override; | 74 int SetEchoPath(const void* echo_path, size_t size_bytes) override; |
46 int GetEchoPath(void* echo_path, size_t size_bytes) const override; | 75 int GetEchoPath(void* echo_path, size_t size_bytes) const override; |
47 | 76 |
48 // ProcessingComponent implementation. | 77 // ProcessingComponent implementation. |
49 void* CreateHandle() const override; | 78 void* CreateHandle() const override; |
50 int InitializeHandle(void* handle) const override; | 79 int InitializeHandle(void* handle) const override; |
51 int ConfigureHandle(void* handle) const override; | 80 int ConfigureHandle(void* handle) const override; |
52 void DestroyHandle(void* handle) const override; | 81 void DestroyHandle(void* handle) const override; |
53 int num_handles_required() const override; | 82 int num_handles_required() const override; |
54 int GetHandleError(void* handle) const override; | 83 int GetHandleError(void* handle) const override; |
55 | 84 |
85 void AllocateRenderQueue(); | |
86 | |
56 const AudioProcessing* apm_; | 87 const AudioProcessing* apm_; |
57 CriticalSectionWrapper* crit_; | 88 CriticalSectionWrapper* crit_; |
58 RoutingMode routing_mode_; | 89 RoutingMode routing_mode_; |
59 bool comfort_noise_enabled_; | 90 bool comfort_noise_enabled_; |
60 unsigned char* external_echo_path_; | 91 unsigned char* external_echo_path_; |
92 | |
93 size_t render_queue_element_max_size_; | |
94 std::vector<int16_t> render_queue_buffer_; | |
95 std::vector<int16_t> capture_queue_buffer_; | |
96 rtc::scoped_ptr<SwapQueue<std::vector<int16_t>, AecmRenderQueueItemVerifier>> | |
97 render_signal_queue_; | |
61 }; | 98 }; |
62 } // namespace webrtc | 99 } // namespace webrtc |
63 | 100 |
64 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ | 101 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ |
OLD | NEW |