blob: c9b0b142e64482f39cbcee9ae5d31963dbaa671a [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +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
pbos@webrtc.org471ae722013-05-21 13:52:32 +000014#include "webrtc/typedefs.h"
15#include "webrtc/voice_engine/voice_engine_defines.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000016
17namespace webrtc {
18
19class AudioFrame;
henrika@webrtc.orgc4efe712013-04-03 11:25:31 +000020class CriticalSectionWrapper;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000021namespace voe {
22
23class AudioLevel
24{
25public:
26 AudioLevel();
27 virtual ~AudioLevel();
28
henrika@webrtc.orgc4efe712013-04-03 11:25:31 +000029 // Called on "API thread(s)" from APIs like VoEBase::CreateChannel(),
30 // VoEBase::StopSend(), VoEVolumeControl::GetSpeechOutputLevel().
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000031 int8_t Level() const;
32 int16_t LevelFullRange() const;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000033 void Clear();
34
henrika@webrtc.orgc4efe712013-04-03 11:25:31 +000035 // Called on a native capture audio thread (platform dependent) from the
36 // AudioTransport::RecordedDataIsAvailable() callback.
37 // In Chrome, this method is called on the AudioInputDevice thread.
38 void ComputeLevel(const AudioFrame& audioFrame);
39
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000040private:
41 enum { kUpdateFrequency = 10};
42
henrika@webrtc.orgc4efe712013-04-03 11:25:31 +000043 CriticalSectionWrapper& _critSect;
44
pbos@webrtc.org54f03bc2013-04-09 10:09:10 +000045 int16_t _absMax;
46 int16_t _count;
47 int8_t _currentLevel;
48 int16_t _currentLevelFullRange;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000049};
50
51} // namespace voe
52
53} // namespace webrtc
54
55#endif // WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H