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