blob: 1564fe586c5dc5e54431eff451d47b65a0706468 [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
peahdf3efa82015-11-28 12:35:15 -080014#include "webrtc/base/criticalsection.h"
pbos@webrtc.org7fad4b82013-05-28 08:11:59 +000015#include "webrtc/modules/audio_processing/include/audio_processing.h"
16#include "webrtc/modules/audio_processing/processing_component.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017
18namespace webrtc {
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000019
niklase@google.com470e71d2011-07-07 08:21:25 +000020class AudioBuffer;
21
22class NoiseSuppressionImpl : public NoiseSuppression,
23 public ProcessingComponent {
24 public:
peahdf3efa82015-11-28 12:35:15 -080025 NoiseSuppressionImpl(const AudioProcessing* apm, rtc::CriticalSection* crit);
niklase@google.com470e71d2011-07-07 08:21:25 +000026 virtual ~NoiseSuppressionImpl();
27
aluebs@webrtc.orgfda2c2e2014-09-18 09:54:06 +000028 int AnalyzeCaptureAudio(AudioBuffer* audio);
niklase@google.com470e71d2011-07-07 08:21:25 +000029 int ProcessCaptureAudio(AudioBuffer* audio);
30
31 // NoiseSuppression implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000032 bool is_enabled() const override;
33 float speech_probability() const override;
Minyue13b96ba2015-10-03 00:39:14 +020034 Level level() const override;
niklase@google.com470e71d2011-07-07 08:21:25 +000035
niklase@google.com470e71d2011-07-07 08:21:25 +000036 private:
37 // NoiseSuppression implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000038 int Enable(bool enable) override;
39 int set_level(Level level) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000040
41 // ProcessingComponent implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000042 void* CreateHandle() const override;
43 int InitializeHandle(void* handle) const override;
44 int ConfigureHandle(void* handle) const override;
45 void DestroyHandle(void* handle) const override;
46 int num_handles_required() const override;
47 int GetHandleError(void* handle) const override;
niklase@google.com470e71d2011-07-07 08:21:25 +000048
peahdf3efa82015-11-28 12:35:15 -080049 // Not guarded as its public API is thread safe.
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000050 const AudioProcessing* apm_;
peahdf3efa82015-11-28 12:35:15 -080051
52 rtc::CriticalSection* const crit_;
53
54 Level level_ GUARDED_BY(crit_);
niklase@google.com470e71d2011-07-07 08:21:25 +000055};
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000056
niklase@google.com470e71d2011-07-07 08:21:25 +000057} // namespace webrtc
58
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000059#endif // WEBRTC_MODULES_AUDIO_PROCESSING_NOISE_SUPPRESSION_IMPL_H_