blob: ef73ef8feb323da21368be056e07f92117f4b5e3 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000011#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000014#include "webrtc/modules/audio_processing/include/audio_processing.h"
15#include "webrtc/modules/audio_processing/processing_component.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000016
17namespace webrtc {
andrew@webrtc.org61e596f2013-07-25 18:28:29 +000018
niklase@google.com470e71d2011-07-07 08:21:25 +000019class AudioBuffer;
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000020class CriticalSectionWrapper;
niklase@google.com470e71d2011-07-07 08:21:25 +000021
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000022class EchoCancellationImpl : public EchoCancellation,
23 public ProcessingComponent {
niklase@google.com470e71d2011-07-07 08:21:25 +000024 public:
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000025 EchoCancellationImpl(const AudioProcessing* apm,
26 CriticalSectionWrapper* crit);
niklase@google.com470e71d2011-07-07 08:21:25 +000027 virtual ~EchoCancellationImpl();
28
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000029 int ProcessRenderAudio(const AudioBuffer* audio);
30 int ProcessCaptureAudio(AudioBuffer* audio);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
32 // EchoCancellation implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000033 virtual bool is_enabled() const OVERRIDE;
34 virtual int device_sample_rate_hz() const OVERRIDE;
35 virtual int stream_drift_samples() const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000036
37 // ProcessingComponent implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000038 virtual int Initialize() OVERRIDE;
andrew@webrtc.org1760a172013-09-25 23:17:38 +000039 virtual void SetExtraOptions(const Config& config) OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000040
41 private:
42 // EchoCancellation implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000043 virtual int Enable(bool enable) OVERRIDE;
44 virtual int enable_drift_compensation(bool enable) OVERRIDE;
45 virtual bool is_drift_compensation_enabled() const OVERRIDE;
46 virtual int set_device_sample_rate_hz(int rate) OVERRIDE;
47 virtual void set_stream_drift_samples(int drift) OVERRIDE;
48 virtual int set_suppression_level(SuppressionLevel level) OVERRIDE;
49 virtual SuppressionLevel suppression_level() const OVERRIDE;
50 virtual int enable_metrics(bool enable) OVERRIDE;
51 virtual bool are_metrics_enabled() const OVERRIDE;
52 virtual bool stream_has_echo() const OVERRIDE;
53 virtual int GetMetrics(Metrics* metrics) OVERRIDE;
54 virtual int enable_delay_logging(bool enable) OVERRIDE;
55 virtual bool is_delay_logging_enabled() const OVERRIDE;
56 virtual int GetDelayMetrics(int* median, int* std) OVERRIDE;
57 virtual struct AecCore* aec_core() const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000058
59 // ProcessingComponent implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000060 virtual void* CreateHandle() const OVERRIDE;
61 virtual int InitializeHandle(void* handle) const OVERRIDE;
62 virtual int ConfigureHandle(void* handle) const OVERRIDE;
bjornv@webrtc.org5964fe02014-04-22 06:52:28 +000063 virtual void DestroyHandle(void* handle) const OVERRIDE;
pbos@webrtc.org91620802013-08-02 11:44:11 +000064 virtual int num_handles_required() const OVERRIDE;
65 virtual int GetHandleError(void* handle) const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000067 const AudioProcessing* apm_;
68 CriticalSectionWrapper* crit_;
niklase@google.com470e71d2011-07-07 08:21:25 +000069 bool drift_compensation_enabled_;
70 bool metrics_enabled_;
71 SuppressionLevel suppression_level_;
72 int device_sample_rate_hz_;
73 int stream_drift_samples_;
74 bool was_stream_drift_set_;
75 bool stream_has_echo_;
bjornv@google.com1ba3dbe2011-10-03 08:18:10 +000076 bool delay_logging_enabled_;
andrew@webrtc.org1760a172013-09-25 23:17:38 +000077 bool delay_correction_enabled_;
niklase@google.com470e71d2011-07-07 08:21:25 +000078};
andrew@webrtc.org61e596f2013-07-25 18:28:29 +000079
niklase@google.com470e71d2011-07-07 08:21:25 +000080} // namespace webrtc
81
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000082#endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_