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

Side by Side Diff: webrtc/voice_engine/transmit_mixer.cc

Issue 2964593002: Adding stats that can be used to compute output audio levels. (Closed)
Patch Set: Remove unnecessary TODOs and address style feedback. 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 rtc::CritScope cs(&_critSect); 301 rtc::CritScope cs(&_critSect);
302 file_recording = _fileRecording; 302 file_recording = _fileRecording;
303 } 303 }
304 if (file_recording) 304 if (file_recording)
305 { 305 {
306 RecordAudioToFile(_audioFrame.sample_rate_hz_); 306 RecordAudioToFile(_audioFrame.sample_rate_hz_);
307 } 307 }
308 308
309 // --- Measure audio level of speech after all processing. 309 // --- Measure audio level of speech after all processing.
310 _audioLevel.ComputeLevel(_audioFrame); 310 _audioLevel.ComputeLevel(_audioFrame);
311
312 // TODO(zstein): Extract helper to share with voice_engine/channel.cc
313 // See the description for "totalAudioEnergy" in the WebRTC stats spec for
314 // an explanation of these formulas. In short, we need a value that can be
315 // used to compute RMS audio levels over different time intervals, by taking
316 // thedifference between the results from two getStats calls. To do this,
Taylor Brandstetter 2017/07/06 17:57:56 nit: space between "the" and "difference"
Zach Stein 2017/07/06 18:07:35 Done.
317 // the value needs to be of units "squared sample value * time".
318 double additional_energy =
319 static_cast<double>(_audioLevel.LevelFullRange()) / INT16_MAX;
320 additional_energy *= additional_energy;
321 _totalInputEnergy += additional_energy * 0.01;
322 _totalInputDuration += 0.01;
323
311 return 0; 324 return 0;
312 } 325 }
313 326
314 void TransmitMixer::ProcessAndEncodeAudio() { 327 void TransmitMixer::ProcessAndEncodeAudio() {
315 RTC_DCHECK_GT(_audioFrame.samples_per_channel_, 0); 328 RTC_DCHECK_GT(_audioFrame.samples_per_channel_, 0);
316 for (ChannelManager::Iterator it(_channelManagerPtr); it.IsValid(); 329 for (ChannelManager::Iterator it(_channelManagerPtr); it.IsValid();
317 it.Increment()) { 330 it.Increment()) {
318 Channel* const channel = it.GetChannel(); 331 Channel* const channel = it.GetChannel();
319 if (channel->Sending()) { 332 if (channel->Sending()) {
320 channel->ProcessAndEncodeAudio(_audioFrame); 333 channel->ProcessAndEncodeAudio(_audioFrame);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 // Speech + file level [0,9] 857 // Speech + file level [0,9]
845 return _audioLevel.Level(); 858 return _audioLevel.Level();
846 } 859 }
847 860
848 int16_t TransmitMixer::AudioLevelFullRange() const 861 int16_t TransmitMixer::AudioLevelFullRange() const
849 { 862 {
850 // Speech + file level [0,32767] 863 // Speech + file level [0,32767]
851 return _audioLevel.LevelFullRange(); 864 return _audioLevel.LevelFullRange();
852 } 865 }
853 866
867 double TransmitMixer::GetTotalInputEnergy() const {
868 return _totalInputEnergy;
869 }
870
871 double TransmitMixer::GetTotalInputDuration() const {
872 return _totalInputDuration;
873 }
874
854 bool TransmitMixer::IsRecordingCall() 875 bool TransmitMixer::IsRecordingCall()
855 { 876 {
856 return _fileCallRecording; 877 return _fileCallRecording;
857 } 878 }
858 879
859 bool TransmitMixer::IsRecordingMic() 880 bool TransmitMixer::IsRecordingMic()
860 { 881 {
861 rtc::CritScope cs(&_critSect); 882 rtc::CritScope cs(&_critSect);
862 return _fileRecording; 883 return _fileRecording;
863 } 884 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 void TransmitMixer::EnableStereoChannelSwapping(bool enable) { 1037 void TransmitMixer::EnableStereoChannelSwapping(bool enable) {
1017 swap_stereo_channels_ = enable; 1038 swap_stereo_channels_ = enable;
1018 } 1039 }
1019 1040
1020 bool TransmitMixer::IsStereoChannelSwappingEnabled() { 1041 bool TransmitMixer::IsStereoChannelSwappingEnabled() {
1021 return swap_stereo_channels_; 1042 return swap_stereo_channels_;
1022 } 1043 }
1023 1044
1024 } // namespace voe 1045 } // namespace voe
1025 } // namespace webrtc 1046 } // namespace webrtc
OLDNEW
« webrtc/pc/rtcstats_integrationtest.cc ('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