niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
tommi | 31fc21f | 2016-01-21 10:37:37 -0800 | [diff] [blame] | 14 | #include "webrtc/base/criticalsection.h" |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 15 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | class AudioFrame; |
| 20 | namespace voe { |
| 21 | |
| 22 | class AudioLevel |
| 23 | { |
| 24 | public: |
| 25 | AudioLevel(); |
| 26 | virtual ~AudioLevel(); |
| 27 | |
henrika@webrtc.org | d108a46 | 2013-04-03 11:25:31 +0000 | [diff] [blame] | 28 | // Called on "API thread(s)" from APIs like VoEBase::CreateChannel(), |
| 29 | // VoEBase::StopSend(), VoEVolumeControl::GetSpeechOutputLevel(). |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 30 | int8_t Level() const; |
| 31 | int16_t LevelFullRange() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | void Clear(); |
| 33 | |
henrika@webrtc.org | d108a46 | 2013-04-03 11:25:31 +0000 | [diff] [blame] | 34 | // 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | private: |
| 40 | enum { kUpdateFrequency = 10}; |
| 41 | |
pbos | d8de115 | 2016-02-01 09:00:51 -0800 | [diff] [blame] | 42 | rtc::CriticalSection _critSect; |
henrika@webrtc.org | d108a46 | 2013-04-03 11:25:31 +0000 | [diff] [blame] | 43 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 44 | int16_t _absMax; |
| 45 | int16_t _count; |
| 46 | int8_t _currentLevel; |
| 47 | int16_t _currentLevelFullRange; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | } // namespace voe |
| 51 | |
| 52 | } // namespace webrtc |
| 53 | |
| 54 | #endif // WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H |