| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class AudioLevel { | 22 class AudioLevel { |
| 23 public: | 23 public: |
| 24 AudioLevel(); | 24 AudioLevel(); |
| 25 ~AudioLevel(); | 25 ~AudioLevel(); |
| 26 | 26 |
| 27 // Called on "API thread(s)" from APIs like VoEBase::CreateChannel(), | 27 // Called on "API thread(s)" from APIs like VoEBase::CreateChannel(), |
| 28 // VoEBase::StopSend(), VoEVolumeControl::GetSpeechOutputLevel(). | 28 // VoEBase::StopSend(), VoEVolumeControl::GetSpeechOutputLevel(). |
| 29 int8_t Level() const; | 29 int8_t Level() const; |
| 30 int16_t LevelFullRange() const; | 30 int16_t LevelFullRange() const; |
| 31 void Clear(); | 31 void Clear(); |
| 32 // See the description for "totalAudioEnergy" in the WebRTC stats spec |
| 33 // (https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudi
oenergy) |
| 34 double TotalEnergy() const; |
| 35 double TotalDuration() const; |
| 32 | 36 |
| 33 // Called on a native capture audio thread (platform dependent) from the | 37 // Called on a native capture audio thread (platform dependent) from the |
| 34 // AudioTransport::RecordedDataIsAvailable() callback. | 38 // AudioTransport::RecordedDataIsAvailable() callback. |
| 35 // In Chrome, this method is called on the AudioInputDevice thread. | 39 // In Chrome, this method is called on the AudioInputDevice thread. |
| 36 void ComputeLevel(const AudioFrame& audioFrame); | 40 void ComputeLevel(const AudioFrame& audioFrame, double duration); |
| 37 | 41 |
| 38 private: | 42 private: |
| 39 enum { kUpdateFrequency = 10 }; | 43 enum { kUpdateFrequency = 10 }; |
| 40 | 44 |
| 41 rtc::CriticalSection crit_sect_; | 45 rtc::CriticalSection crit_sect_; |
| 42 | 46 |
| 43 int16_t abs_max_; | 47 int16_t abs_max_; |
| 44 int16_t count_; | 48 int16_t count_; |
| 45 int8_t current_level_; | 49 int8_t current_level_; |
| 46 int16_t current_level_full_range_; | 50 int16_t current_level_full_range_; |
| 51 |
| 52 double total_energy_ = 0.0; |
| 53 double total_duration_ = 0.0; |
| 47 }; | 54 }; |
| 48 | 55 |
| 49 } // namespace voe | 56 } // namespace voe |
| 50 } // namespace webrtc | 57 } // namespace webrtc |
| 51 | 58 |
| 52 #endif // WEBRTC_VOICE_ENGINE_AUDIO_LEVEL_H_ | 59 #endif // WEBRTC_VOICE_ENGINE_AUDIO_LEVEL_H_ |
| OLD | NEW |