| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H | 11 #ifndef WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H |
| 12 #define WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H | 12 #define WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H |
| 13 | 13 |
| 14 #include "webrtc/base/criticalsection.h" |
| 14 #include "webrtc/typedefs.h" | 15 #include "webrtc/typedefs.h" |
| 15 #include "webrtc/voice_engine/voice_engine_defines.h" | 16 #include "webrtc/voice_engine/voice_engine_defines.h" |
| 16 | 17 |
| 17 namespace webrtc { | 18 namespace webrtc { |
| 18 | 19 |
| 19 class AudioFrame; | 20 class AudioFrame; |
| 20 class CriticalSectionWrapper; | |
| 21 namespace voe { | 21 namespace voe { |
| 22 | 22 |
| 23 class AudioLevel | 23 class AudioLevel |
| 24 { | 24 { |
| 25 public: | 25 public: |
| 26 AudioLevel(); | 26 AudioLevel(); |
| 27 virtual ~AudioLevel(); | 27 virtual ~AudioLevel(); |
| 28 | 28 |
| 29 // Called on "API thread(s)" from APIs like VoEBase::CreateChannel(), | 29 // Called on "API thread(s)" from APIs like VoEBase::CreateChannel(), |
| 30 // VoEBase::StopSend(), VoEVolumeControl::GetSpeechOutputLevel(). | 30 // VoEBase::StopSend(), VoEVolumeControl::GetSpeechOutputLevel(). |
| 31 int8_t Level() const; | 31 int8_t Level() const; |
| 32 int16_t LevelFullRange() const; | 32 int16_t LevelFullRange() const; |
| 33 void Clear(); | 33 void Clear(); |
| 34 | 34 |
| 35 // Called on a native capture audio thread (platform dependent) from the | 35 // Called on a native capture audio thread (platform dependent) from the |
| 36 // AudioTransport::RecordedDataIsAvailable() callback. | 36 // AudioTransport::RecordedDataIsAvailable() callback. |
| 37 // In Chrome, this method is called on the AudioInputDevice thread. | 37 // In Chrome, this method is called on the AudioInputDevice thread. |
| 38 void ComputeLevel(const AudioFrame& audioFrame); | 38 void ComputeLevel(const AudioFrame& audioFrame); |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 enum { kUpdateFrequency = 10}; | 41 enum { kUpdateFrequency = 10}; |
| 42 | 42 |
| 43 CriticalSectionWrapper& _critSect; | 43 mutable rtc::CriticalSection _critSect; |
| 44 | 44 |
| 45 int16_t _absMax; | 45 int16_t _absMax; |
| 46 int16_t _count; | 46 int16_t _count; |
| 47 int8_t _currentLevel; | 47 int8_t _currentLevel; |
| 48 int16_t _currentLevelFullRange; | 48 int16_t _currentLevelFullRange; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 } // namespace voe | 51 } // namespace voe |
| 52 | 52 |
| 53 } // namespace webrtc | 53 } // namespace webrtc |
| 54 | 54 |
| 55 #endif // WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H | 55 #endif // WEBRTC_VOICE_ENGINE_LEVEL_INDICATOR_H |
| OLD | NEW |