niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
bjornv@webrtc.org | 0c6f931 | 2012-01-30 09:39:08 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 11 | #ifndef MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 14 | #include <memory> |
terelius | 85fa7d5 | 2016-03-24 01:51:52 -0700 | [diff] [blame] | 15 | #include <vector> |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 17 | #include "modules/audio_processing/include/audio_processing.h" |
| 18 | #include "modules/audio_processing/render_queue_item_verifier.h" |
| 19 | #include "rtc_base/constructormagic.h" |
| 20 | #include "rtc_base/criticalsection.h" |
| 21 | #include "rtc_base/swap_queue.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
andrew@webrtc.org | 56e4a05 | 2014-02-27 22:23:17 +0000 | [diff] [blame] | 24 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | class AudioBuffer; |
| 26 | |
peah | bb9edbd | 2016-03-10 12:54:25 -0800 | [diff] [blame] | 27 | class EchoControlMobileImpl : public EchoControlMobile { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | public: |
peah | 253534d | 2016-03-15 04:32:28 -0700 | [diff] [blame] | 29 | EchoControlMobileImpl(rtc::CriticalSection* crit_render, |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 30 | rtc::CriticalSection* crit_capture); |
| 31 | |
kwiberg | 83ffe45 | 2016-08-29 14:46:07 -0700 | [diff] [blame] | 32 | ~EchoControlMobileImpl() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
peah | a062460 | 2016-10-25 04:45:24 -0700 | [diff] [blame] | 34 | void ProcessRenderAudio(rtc::ArrayView<const int16_t> packed_render_audio); |
peah | 253534d | 2016-03-15 04:32:28 -0700 | [diff] [blame] | 35 | int ProcessCaptureAudio(AudioBuffer* audio, int stream_delay_ms); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
| 37 | // EchoControlMobile implementation. |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 38 | bool is_enabled() const override; |
Minyue | 13b96ba | 2015-10-03 00:39:14 +0200 | [diff] [blame] | 39 | RoutingMode routing_mode() const override; |
| 40 | bool is_comfort_noise_enabled() const override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
peah | 253534d | 2016-03-15 04:32:28 -0700 | [diff] [blame] | 42 | void Initialize(int sample_rate_hz, |
| 43 | size_t num_reverse_channels, |
| 44 | size_t num_output_channels); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
peah | a062460 | 2016-10-25 04:45:24 -0700 | [diff] [blame] | 46 | static void PackRenderAudioBuffer(const AudioBuffer* audio, |
| 47 | size_t num_output_channels, |
| 48 | size_t num_channels, |
| 49 | std::vector<int16_t>* packed_buffer); |
| 50 | |
| 51 | static size_t NumCancellersRequired(size_t num_output_channels, |
| 52 | size_t num_reverse_channels); |
peah | fa6228e | 2015-11-16 16:27:42 -0800 | [diff] [blame] | 53 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | private: |
peah | bb9edbd | 2016-03-10 12:54:25 -0800 | [diff] [blame] | 55 | class Canceller; |
peah | 253534d | 2016-03-15 04:32:28 -0700 | [diff] [blame] | 56 | struct StreamProperties; |
peah | bb9edbd | 2016-03-10 12:54:25 -0800 | [diff] [blame] | 57 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | // EchoControlMobile implementation. |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 59 | int Enable(bool enable) override; |
| 60 | int set_routing_mode(RoutingMode mode) override; |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 61 | int enable_comfort_noise(bool enable) override; |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 62 | int SetEchoPath(const void* echo_path, size_t size_bytes) override; |
| 63 | int GetEchoPath(void* echo_path, size_t size_bytes) const override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | |
peah | bb9edbd | 2016-03-10 12:54:25 -0800 | [diff] [blame] | 65 | int Configure(); |
peah | fa6228e | 2015-11-16 16:27:42 -0800 | [diff] [blame] | 66 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 67 | rtc::CriticalSection* const crit_render_ RTC_ACQUIRED_BEFORE(crit_capture_); |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 68 | rtc::CriticalSection* const crit_capture_; |
| 69 | |
peah | bb9edbd | 2016-03-10 12:54:25 -0800 | [diff] [blame] | 70 | bool enabled_ = false; |
| 71 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 72 | RoutingMode routing_mode_ RTC_GUARDED_BY(crit_capture_); |
| 73 | bool comfort_noise_enabled_ RTC_GUARDED_BY(crit_capture_); |
| 74 | unsigned char* external_echo_path_ RTC_GUARDED_BY(crit_render_) |
| 75 | RTC_GUARDED_BY(crit_capture_); |
peah | df3efa8 | 2015-11-28 12:35:15 -0800 | [diff] [blame] | 76 | |
peah | bb9edbd | 2016-03-10 12:54:25 -0800 | [diff] [blame] | 77 | std::vector<std::unique_ptr<Canceller>> cancellers_; |
peah | 253534d | 2016-03-15 04:32:28 -0700 | [diff] [blame] | 78 | std::unique_ptr<StreamProperties> stream_properties_; |
| 79 | |
peah | bb9edbd | 2016-03-10 12:54:25 -0800 | [diff] [blame] | 80 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoControlMobileImpl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | }; |
| 82 | } // namespace webrtc |
| 83 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 84 | #endif // MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ |