blob: 45459389576b95b40dacfc8bce335d6adf3a060b [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;
pbos@webrtc.org91620802013-08-02 11:44:11 +000034 virtual int stream_drift_samples() const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000035
36 // ProcessingComponent implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000037 virtual int Initialize() OVERRIDE;
andrew@webrtc.org1760a172013-09-25 23:17:38 +000038 virtual void SetExtraOptions(const Config& config) OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000039
40 private:
41 // EchoCancellation implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000042 virtual int Enable(bool enable) OVERRIDE;
43 virtual int enable_drift_compensation(bool enable) OVERRIDE;
44 virtual bool is_drift_compensation_enabled() const OVERRIDE;
pbos@webrtc.org91620802013-08-02 11:44:11 +000045 virtual void set_stream_drift_samples(int drift) OVERRIDE;
46 virtual int set_suppression_level(SuppressionLevel level) OVERRIDE;
47 virtual SuppressionLevel suppression_level() const OVERRIDE;
48 virtual int enable_metrics(bool enable) OVERRIDE;
49 virtual bool are_metrics_enabled() const OVERRIDE;
50 virtual bool stream_has_echo() const OVERRIDE;
51 virtual int GetMetrics(Metrics* metrics) OVERRIDE;
52 virtual int enable_delay_logging(bool enable) OVERRIDE;
53 virtual bool is_delay_logging_enabled() const OVERRIDE;
54 virtual int GetDelayMetrics(int* median, int* std) OVERRIDE;
bjornv@webrtc.orgb1786db2015-02-03 06:06:26 +000055 virtual int GetDelayMetrics(int* median, int* std,
56 float* fraction_poor_delays) OVERRIDE;
pbos@webrtc.org91620802013-08-02 11:44:11 +000057 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_;
niklase@google.com470e71d2011-07-07 08:21:25 +000072 int stream_drift_samples_;
73 bool was_stream_drift_set_;
74 bool stream_has_echo_;
bjornv@google.com1ba3dbe2011-10-03 08:18:10 +000075 bool delay_logging_enabled_;
andrew@webrtc.org1760a172013-09-25 23:17:38 +000076 bool delay_correction_enabled_;
bjornv@webrtc.orge9d37602014-04-23 13:20:07 +000077 bool reported_delay_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_