blob: 070dcabc5d6df0447dcaaa65dfe5c205031993ac [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.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000033 bool is_enabled() const override;
34 int stream_drift_samples() const override;
Minyue13b96ba2015-10-03 00:39:14 +020035 SuppressionLevel suppression_level() const override;
36 bool is_drift_compensation_enabled() const override;
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38 // ProcessingComponent implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000039 int Initialize() override;
40 void SetExtraOptions(const Config& config) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000041
Minyue13b96ba2015-10-03 00:39:14 +020042 bool is_delay_agnostic_enabled() const;
43 bool is_extended_filter_enabled() const;
44
niklase@google.com470e71d2011-07-07 08:21:25 +000045 private:
46 // EchoCancellation implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000047 int Enable(bool enable) override;
48 int enable_drift_compensation(bool enable) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000049 void set_stream_drift_samples(int drift) override;
50 int set_suppression_level(SuppressionLevel level) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000051 int enable_metrics(bool enable) override;
52 bool are_metrics_enabled() const override;
53 bool stream_has_echo() const override;
54 int GetMetrics(Metrics* metrics) override;
55 int enable_delay_logging(bool enable) override;
56 bool is_delay_logging_enabled() const override;
57 int GetDelayMetrics(int* median, int* std) override;
58 int GetDelayMetrics(int* median,
59 int* std,
60 float* fraction_poor_delays) override;
61 struct AecCore* aec_core() const override;
niklase@google.com470e71d2011-07-07 08:21:25 +000062
63 // ProcessingComponent implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000064 void* CreateHandle() const override;
65 int InitializeHandle(void* handle) const override;
66 int ConfigureHandle(void* handle) const override;
67 void DestroyHandle(void* handle) const override;
68 int num_handles_required() const override;
69 int GetHandleError(void* handle) const override;
niklase@google.com470e71d2011-07-07 08:21:25 +000070
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000071 const AudioProcessing* apm_;
72 CriticalSectionWrapper* crit_;
niklase@google.com470e71d2011-07-07 08:21:25 +000073 bool drift_compensation_enabled_;
74 bool metrics_enabled_;
75 SuppressionLevel suppression_level_;
niklase@google.com470e71d2011-07-07 08:21:25 +000076 int stream_drift_samples_;
77 bool was_stream_drift_set_;
78 bool stream_has_echo_;
bjornv@google.com1ba3dbe2011-10-03 08:18:10 +000079 bool delay_logging_enabled_;
Henrik Lundin441f6342015-06-09 16:03:13 +020080 bool extended_filter_enabled_;
henrik.lundin0f133b92015-07-02 00:17:55 -070081 bool delay_agnostic_enabled_;
niklase@google.com470e71d2011-07-07 08:21:25 +000082};
andrew@webrtc.org61e596f2013-07-25 18:28:29 +000083
niklase@google.com470e71d2011-07-07 08:21:25 +000084} // namespace webrtc
85
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000086#endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_