Move total audio energy and duration tracking to AudioLevel and protect with existing critial section.
BUG=webrtc:7982
Review-Url: https://codereview.webrtc.org/2984473002
Cr-Commit-Position: refs/heads/master@{#19105}
diff --git a/webrtc/voice_engine/audio_level.h b/webrtc/voice_engine/audio_level.h
index 3bcb0d9..caecf40 100644
--- a/webrtc/voice_engine/audio_level.h
+++ b/webrtc/voice_engine/audio_level.h
@@ -29,11 +29,15 @@
int8_t Level() const;
int16_t LevelFullRange() const;
void Clear();
+ // See the description for "totalAudioEnergy" in the WebRTC stats spec
+ // (https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy)
+ double TotalEnergy() const;
+ double TotalDuration() const;
// Called on a native capture audio thread (platform dependent) from the
// AudioTransport::RecordedDataIsAvailable() callback.
// In Chrome, this method is called on the AudioInputDevice thread.
- void ComputeLevel(const AudioFrame& audioFrame);
+ void ComputeLevel(const AudioFrame& audioFrame, double duration);
private:
enum { kUpdateFrequency = 10 };
@@ -44,6 +48,9 @@
int16_t count_;
int8_t current_level_;
int16_t current_level_full_range_;
+
+ double total_energy_ = 0.0;
+ double total_duration_ = 0.0;
};
} // namespace voe