Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Side by Side Diff: webrtc/voice_engine/audio_level.h

Issue 2984473002: Move total audio energy and duration tracking to AudioLevel and protect with existing critial secti… (Closed)
Patch Set: rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/voice_engine/audio_level.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « no previous file | webrtc/voice_engine/audio_level.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698