blob: 1d8a0712b58df5ff55da2ef0fa8fc232f53ba99c [file] [log] [blame]
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
#include "modules/audio_processing/audio_buffer.h"
#include "modules/audio_processing/rms_level.h"
namespace webrtc {
// An estimation component used to retrieve level metrics.
class LevelEstimator {
LevelEstimator(LevelEstimator&) = delete;
LevelEstimator& operator=(LevelEstimator&) = delete;
void ProcessStream(const AudioBuffer& audio);
// Returns the root mean square (RMS) level in dBFs (decibels from digital
// full-scale), or alternately dBov. It is computed over all primary stream
// frames since the last call to RMS(). The returned value is positive but
// should be interpreted as negative. It is constrained to [0, 127].
// The computation follows:
// with the intent that it can provide the RTP audio level indication.
// Frames passed to ProcessStream() with an |_energy| of zero are considered
// to have been muted. The RMS of the frame will be interpreted as -127.
int RMS() { return rms_.Average(); }
RmsLevel rms_;
} // namespace webrtc