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

Unified Diff: webrtc/voice_engine/transmit_mixer.cc

Issue 2964593002: Adding stats that can be used to compute output audio levels. (Closed)
Patch Set: Record new stats in statscollector so they show up when getStats is called from Java and fix RTCSta… 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
Index: webrtc/voice_engine/transmit_mixer.cc
diff --git a/webrtc/voice_engine/transmit_mixer.cc b/webrtc/voice_engine/transmit_mixer.cc
index 6796f8457c5e5b3060920c6be9995b8f739612b2..84390d3f5fc84172e1eab7f634555e2b8cc1df4d 100644
--- a/webrtc/voice_engine/transmit_mixer.cc
+++ b/webrtc/voice_engine/transmit_mixer.cc
@@ -308,6 +308,19 @@ TransmitMixer::PrepareDemux(const void* audioSamples,
// --- Measure audio level of speech after all processing.
_audioLevel.ComputeLevel(_audioFrame);
+
+ // TODO(zstein): Extract helper to share with voice_engine/channel.cc
+ // See the description for "totalAudioEnergy" in the WebRTC stats spec 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".
hbos 2017/07/10 09:58:24 Ditto link, ditto constant.
Zach Stein 2017/07/10 18:35:20 Link added. I think the sample duration should act
+ double additional_energy =
+ static_cast<double>(_audioLevel.LevelFullRange()) / INT16_MAX;
+ additional_energy *= additional_energy;
+ _totalInputEnergy += additional_energy * 0.01;
+ _totalInputDuration += 0.01;
+
return 0;
}
@@ -851,6 +864,14 @@ int16_t TransmitMixer::AudioLevelFullRange() const
return _audioLevel.LevelFullRange();
}
+double TransmitMixer::GetTotalInputEnergy() const {
+ return _totalInputEnergy;
+}
+
+double TransmitMixer::GetTotalInputDuration() const {
+ return _totalInputDuration;
+}
+
bool TransmitMixer::IsRecordingCall()
{
return _fileCallRecording;
« webrtc/voice_engine/transmit_mixer.h ('K') | « webrtc/voice_engine/transmit_mixer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698