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