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

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

Issue 2935693005: Adding stats that can be used to compute output audio levels.
Patch Set: Created 3 years, 6 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
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/channel_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 { 689 {
690 rtc::CritScope cs(&_fileCritSect); 690 rtc::CritScope cs(&_fileCritSect);
691 691
692 if (_outputFileRecording && output_file_recorder_) { 692 if (_outputFileRecording && output_file_recorder_) {
693 output_file_recorder_->RecordAudioToFile(*audioFrame); 693 output_file_recorder_->RecordAudioToFile(*audioFrame);
694 } 694 }
695 } 695 }
696 696
697 // Measure audio level (0-9) 697 // Measure audio level (0-9)
698 // TODO(henrik.lundin) Use the |muted| information here too. 698 // TODO(henrik.lundin) Use the |muted| information here too.
699 // TODO(deadbeef): Use RmsLevel for |_outputAudioLevel| as well.
699 _outputAudioLevel.ComputeLevel(*audioFrame); 700 _outputAudioLevel.ComputeLevel(*audioFrame);
701 // See the description for "totalAudioEnergy" in the WebRTC stats spec for an
702 // explanation of these formulas. In short, we need a value that can be used
703 // to compute RMS audio levels over different time intervals, by taking the
704 // difference between the results from two getStats calls. To do this, the
705 // value needs to be of units "squared sample value * time".
706 double additional_energy = _outputAudioLevel.LevelFullRange() / SHRT_MAX;
707 additional_energy *= additional_energy;
708 _totalOutputEnergy += additional_energy * 0.01;
709 _totalOutputDuration += 0.01;
700 710
701 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { 711 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) {
702 // The first frame with a valid rtp timestamp. 712 // The first frame with a valid rtp timestamp.
703 capture_start_rtp_time_stamp_ = audioFrame->timestamp_; 713 capture_start_rtp_time_stamp_ = audioFrame->timestamp_;
704 } 714 }
705 715
706 if (capture_start_rtp_time_stamp_ >= 0) { 716 if (capture_start_rtp_time_stamp_ >= 0) {
707 // audioFrame.timestamp_ should be valid from now on. 717 // audioFrame.timestamp_ should be valid from now on.
708 718
709 // Compute elapsed time. 719 // Compute elapsed time.
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 } 2373 }
2364 2374
2365 int Channel::GetSpeechOutputLevel() const { 2375 int Channel::GetSpeechOutputLevel() const {
2366 return _outputAudioLevel.Level(); 2376 return _outputAudioLevel.Level();
2367 } 2377 }
2368 2378
2369 int Channel::GetSpeechOutputLevelFullRange() const { 2379 int Channel::GetSpeechOutputLevelFullRange() const {
2370 return _outputAudioLevel.LevelFullRange(); 2380 return _outputAudioLevel.LevelFullRange();
2371 } 2381 }
2372 2382
2383 double Channel::GetTotalOutputEnergy() const {
2384 return _totalOutputEnergy;
2385 }
2386
2387 double Channel::GetTotalOutputDuration() const {
2388 return _totalOutputDuration;
2389 }
2390
2373 void Channel::SetInputMute(bool enable) { 2391 void Channel::SetInputMute(bool enable) {
2374 rtc::CritScope cs(&volume_settings_critsect_); 2392 rtc::CritScope cs(&volume_settings_critsect_);
2375 input_mute_ = enable; 2393 input_mute_ = enable;
2376 } 2394 }
2377 2395
2378 bool Channel::InputMute() const { 2396 bool Channel::InputMute() const {
2379 rtc::CritScope cs(&volume_settings_critsect_); 2397 rtc::CritScope cs(&volume_settings_critsect_);
2380 return input_mute_; 2398 return input_mute_;
2381 } 2399 }
2382 2400
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 int64_t min_rtt = 0; 3158 int64_t min_rtt = 0;
3141 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3159 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3142 0) { 3160 0) {
3143 return 0; 3161 return 0;
3144 } 3162 }
3145 return rtt; 3163 return rtt;
3146 } 3164 }
3147 3165
3148 } // namespace voe 3166 } // namespace voe
3149 } // namespace webrtc 3167 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698