blob: debbc61bc95c4b724b2e73c37c95b3e6799c34c3 [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_NOISE_SUPPRESSION_IMPL_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
solenberg5e465c32015-12-08 13:22:33 -080014#include "webrtc/base/constructormagic.h"
peahdf3efa82015-11-28 12:35:15 -080015#include "webrtc/base/criticalsection.h"
solenberg5e465c32015-12-08 13:22:33 -080016#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.org7fad4b82013-05-28 08:11:59 +000017#include "webrtc/modules/audio_processing/include/audio_processing.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000018
19namespace webrtc {
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000020
niklase@google.com470e71d2011-07-07 08:21:25 +000021class AudioBuffer;
22
solenberg5e465c32015-12-08 13:22:33 -080023class NoiseSuppressionImpl : public NoiseSuppression {
niklase@google.com470e71d2011-07-07 08:21:25 +000024 public:
solenberg5e465c32015-12-08 13:22:33 -080025 explicit NoiseSuppressionImpl(rtc::CriticalSection* crit);
26 ~NoiseSuppressionImpl() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000027
solenberg5e465c32015-12-08 13:22:33 -080028 // TODO(peah): Fold into ctor, once public API is removed.
Peter Kasting69558702016-01-12 16:26:35 -080029 void Initialize(size_t channels, int sample_rate_hz);
solenberg29e2f932015-12-16 01:18:15 -080030 void AnalyzeCaptureAudio(AudioBuffer* audio);
31 void ProcessCaptureAudio(AudioBuffer* audio);
niklase@google.com470e71d2011-07-07 08:21:25 +000032
33 // NoiseSuppression implementation.
solenberg5e465c32015-12-08 13:22:33 -080034 int Enable(bool enable) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000035 bool is_enabled() const override;
solenberg5e465c32015-12-08 13:22:33 -080036 int set_level(Level level) override;
Minyue13b96ba2015-10-03 00:39:14 +020037 Level level() const override;
solenberg5e465c32015-12-08 13:22:33 -080038 float speech_probability() const override;
niklase@google.com470e71d2011-07-07 08:21:25 +000039
niklase@google.com470e71d2011-07-07 08:21:25 +000040 private:
solenberg5e465c32015-12-08 13:22:33 -080041 class Suppressor;
peahdf3efa82015-11-28 12:35:15 -080042 rtc::CriticalSection* const crit_;
solenberg5e465c32015-12-08 13:22:33 -080043 bool enabled_ GUARDED_BY(crit_) = false;
44 Level level_ GUARDED_BY(crit_) = kModerate;
Peter Kasting69558702016-01-12 16:26:35 -080045 size_t channels_ GUARDED_BY(crit_) = 0;
solenberg29e2f932015-12-16 01:18:15 -080046 int sample_rate_hz_ GUARDED_BY(crit_) = 0;
solenberg5e465c32015-12-08 13:22:33 -080047 std::vector<rtc::scoped_ptr<Suppressor>> suppressors_ GUARDED_BY(crit_);
48 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(NoiseSuppressionImpl);
niklase@google.com470e71d2011-07-07 08:21:25 +000049};
50} // namespace webrtc
51
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000052#endif // WEBRTC_MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_