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

Unified Diff: webrtc/voice_engine/channel.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/transmit_mixer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/channel.cc
diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc
index 02001bac6b0805d1de0a0f3d38415f0fb2cd9326..5c2525cf2b803b4b1ec5a31cff1e57afe7d8e8fd 100644
--- a/webrtc/voice_engine/channel.cc
+++ b/webrtc/voice_engine/channel.cc
@@ -697,20 +697,9 @@ MixerParticipant::AudioFrameInfo Channel::GetAudioFrameWithMuted(
// Measure audio level (0-9)
// TODO(henrik.lundin) Use the |muted| information here too.
- // TODO(deadbeef): Use RmsLevel for |_outputAudioLevel| as well (see
+ // TODO(deadbeef): Use RmsLevel for |_outputAudioLevel| (see
// https://crbug.com/webrtc/7517).
- _outputAudioLevel.ComputeLevel(*audioFrame);
- // See the description for "totalAudioEnergy" in the WebRTC stats spec
- // (https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy)
- // for an explanation of these formulas. In short, we need a value that can
- // be used to compute RMS audio levels over different time intervals, by
- // taking the difference between the results from two getStats calls. To do
- // this, the value needs to be of units "squared sample value * time".
- double additional_energy =
- static_cast<double>(_outputAudioLevel.LevelFullRange()) / INT16_MAX;
- additional_energy *= additional_energy;
- totalOutputEnergy_ += additional_energy * kAudioSampleDurationSeconds;
- totalOutputDuration_ += kAudioSampleDurationSeconds;
+ _outputAudioLevel.ComputeLevel(*audioFrame, kAudioSampleDurationSeconds);
if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) {
// The first frame with a valid rtp timestamp.
@@ -2385,11 +2374,11 @@ int Channel::GetSpeechOutputLevelFullRange() const {
}
double Channel::GetTotalOutputEnergy() const {
- return totalOutputEnergy_;
+ return _outputAudioLevel.TotalEnergy();
}
double Channel::GetTotalOutputDuration() const {
- return totalOutputDuration_;
+ return _outputAudioLevel.TotalDuration();
}
void Channel::SetInputMute(bool enable) {
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/transmit_mixer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698