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

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: Also report send stats. 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
Zach Stein 2017/07/06 17:41:37 I think we could add this computation to AudioLeve
313 // TODO(zstein): Use sample_rate_hz_?
hlundin-webrtc 2017/07/03 13:23:03 What would you do with sample_rate_hz_?
Zach Stein 2017/07/06 17:41:37 Done.
314 // See the description for "totalAudioEnergy" in the WebRTC stats spec for
315 // an explanation of these formulas. In short, we need a value that can be
316 // used to compute RMS audio levels over different time intervals, by taking
317 // thedifference between the results from two getStats calls. To do this,
318 // the value needs to be of units "squared sample value * time".
319 double additional_energy =
320 static_cast<double>(_audioLevel.LevelFullRange()) / INT16_MAX;
321 additional_energy *= additional_energy;
322 _totalInputEnergy += additional_energy * 0.01;
323 _totalInputDuration += 0.01;
324
311 return 0; 325 return 0;
312 } 326 }
313 327
314 void TransmitMixer::ProcessAndEncodeAudio() { 328 void TransmitMixer::ProcessAndEncodeAudio() {
315 RTC_DCHECK_GT(_audioFrame.samples_per_channel_, 0); 329 RTC_DCHECK_GT(_audioFrame.samples_per_channel_, 0);
316 for (ChannelManager::Iterator it(_channelManagerPtr); it.IsValid(); 330 for (ChannelManager::Iterator it(_channelManagerPtr); it.IsValid();
317 it.Increment()) { 331 it.Increment()) {
318 Channel* const channel = it.GetChannel(); 332 Channel* const channel = it.GetChannel();
319 if (channel->Sending()) { 333 if (channel->Sending()) {
320 channel->ProcessAndEncodeAudio(_audioFrame); 334 channel->ProcessAndEncodeAudio(_audioFrame);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 // Speech + file level [0,9] 858 // Speech + file level [0,9]
845 return _audioLevel.Level(); 859 return _audioLevel.Level();
846 } 860 }
847 861
848 int16_t TransmitMixer::AudioLevelFullRange() const 862 int16_t TransmitMixer::AudioLevelFullRange() const
849 { 863 {
850 // Speech + file level [0,32767] 864 // Speech + file level [0,32767]
851 return _audioLevel.LevelFullRange(); 865 return _audioLevel.LevelFullRange();
852 } 866 }
853 867
868 double TransmitMixer::GetTotalInputEnergy() const {
869 return _totalInputEnergy;
870 }
871
872 double TransmitMixer::GetTotalInputDuration() const {
873 return _totalInputDuration;
874 }
875
854 bool TransmitMixer::IsRecordingCall() 876 bool TransmitMixer::IsRecordingCall()
855 { 877 {
856 return _fileCallRecording; 878 return _fileCallRecording;
857 } 879 }
858 880
859 bool TransmitMixer::IsRecordingMic() 881 bool TransmitMixer::IsRecordingMic()
860 { 882 {
861 rtc::CritScope cs(&_critSect); 883 rtc::CritScope cs(&_critSect);
862 return _fileRecording; 884 return _fileRecording;
863 } 885 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 void TransmitMixer::EnableStereoChannelSwapping(bool enable) { 1038 void TransmitMixer::EnableStereoChannelSwapping(bool enable) {
1017 swap_stereo_channels_ = enable; 1039 swap_stereo_channels_ = enable;
1018 } 1040 }
1019 1041
1020 bool TransmitMixer::IsStereoChannelSwappingEnabled() { 1042 bool TransmitMixer::IsStereoChannelSwappingEnabled() {
1021 return swap_stereo_channels_; 1043 return swap_stereo_channels_;
1022 } 1044 }
1023 1045
1024 } // namespace voe 1046 } // namespace voe
1025 } // namespace webrtc 1047 } // namespace webrtc
OLDNEW
« 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