blob: cde077df4a3a1a6a85a77f715b3c96d202e26314 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
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
11#ifndef WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H
12#define WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H
13
tommi31fc21f2016-01-21 10:37:37 -080014#include "webrtc/base/criticalsection.h"
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000015#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000016
17namespace webrtc {
18
19class AudioFrame;
20namespace voe {
21
22class AudioLevel
23{
24public:
25 AudioLevel();
26 virtual ~AudioLevel();
27
henrika@webrtc.orgd108a462013-04-03 11:25:31 +000028 // Called on "API thread(s)" from APIs like VoEBase::CreateChannel(),
29 // VoEBase::StopSend(), VoEVolumeControl::GetSpeechOutputLevel().
pbos@webrtc.org6141e132013-04-09 10:09:10 +000030 int8_t Level() const;
31 int16_t LevelFullRange() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000032 void Clear();
33
henrika@webrtc.orgd108a462013-04-03 11:25:31 +000034 // Called on a native capture audio thread (platform dependent) from the
35 // AudioTransport::RecordedDataIsAvailable() callback.
36 // In Chrome, this method is called on the AudioInputDevice thread.
37 void ComputeLevel(const AudioFrame& audioFrame);
38
niklase@google.com470e71d2011-07-07 08:21:25 +000039private:
40 enum { kUpdateFrequency = 10};
41
pbosd8de1152016-02-01 09:00:51 -080042 rtc::CriticalSection _critSect;
henrika@webrtc.orgd108a462013-04-03 11:25:31 +000043
pbos@webrtc.org6141e132013-04-09 10:09:10 +000044 int16_t _absMax;
45 int16_t _count;
46 int8_t _currentLevel;
47 int16_t _currentLevelFullRange;
niklase@google.com470e71d2011-07-07 08:21:25 +000048};
49
50} // namespace voe
51
52} // namespace webrtc
53
54#endif // WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H