blob: da217bba0280088ebdfdcbecf6ac52271913a067 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_
12#define MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
kwiberg88788ad2016-02-19 07:04:49 -080014#include <memory>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/audio_processing/include/audio_processing.h"
Steve Anton10542f22019-01-11 09:11:00 -080017#include "rtc_base/constructor_magic.h"
18#include "rtc_base/critical_section.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
20namespace webrtc {
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000021
niklase@google.com470e71d2011-07-07 08:21:25 +000022class AudioBuffer;
henrik.lundin50499422016-11-29 04:26:24 -080023class RmsLevel;
niklase@google.com470e71d2011-07-07 08:21:25 +000024
solenberg949028f2015-12-15 11:39:38 -080025class LevelEstimatorImpl : public LevelEstimator {
niklase@google.com470e71d2011-07-07 08:21:25 +000026 public:
solenberg949028f2015-12-15 11:39:38 -080027 explicit LevelEstimatorImpl(rtc::CriticalSection* crit);
28 ~LevelEstimatorImpl() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000029
solenberg949028f2015-12-15 11:39:38 -080030 // TODO(peah): Fold into ctor, once public API is removed.
31 void Initialize();
32 void ProcessStream(AudioBuffer* audio);
niklase@google.com470e71d2011-07-07 08:21:25 +000033
34 // LevelEstimator implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000035 int Enable(bool enable) override;
solenberg949028f2015-12-15 11:39:38 -080036 bool is_enabled() const override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000037 int RMS() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000038
solenberg949028f2015-12-15 11:39:38 -080039 private:
40 rtc::CriticalSection* const crit_ = nullptr;
danilchap56359be2017-09-07 07:53:45 -070041 bool enabled_ RTC_GUARDED_BY(crit_) = false;
42 std::unique_ptr<RmsLevel> rms_ RTC_GUARDED_BY(crit_);
solenberg949028f2015-12-15 11:39:38 -080043 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(LevelEstimatorImpl);
niklase@google.com470e71d2011-07-07 08:21:25 +000044};
45} // namespace webrtc
46
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020047#endif // MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_