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

Side by Side Diff: webrtc/voice_engine/channel.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 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.
700 // 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 I wasn't sure if this method was intended to proce
hlundin-webrtc 2017/07/07 06:48:44 Acknowledged.
699 _outputAudioLevel.ComputeLevel(*audioFrame); 701 _outputAudioLevel.ComputeLevel(*audioFrame);
702 // See the description for "totalAudioEnergy" in the WebRTC stats spec for an
703 // explanation of these formulas. In short, we need a value that can be used
704 // to compute RMS audio levels over different time intervals, by taking the
705 // difference between the results from two getStats calls. To do this, the
706 // value needs to be of units "squared sample value * time".
707 double additional_energy =
708 static_cast<double>(_outputAudioLevel.LevelFullRange()) / INT16_MAX;
709 additional_energy *= additional_energy;
710 _totalOutputEnergy += additional_energy * 0.01;
711 _totalOutputDuration += 0.01;
700 712
701 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { 713 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) {
702 // The first frame with a valid rtp timestamp. 714 // The first frame with a valid rtp timestamp.
703 capture_start_rtp_time_stamp_ = audioFrame->timestamp_; 715 capture_start_rtp_time_stamp_ = audioFrame->timestamp_;
704 } 716 }
705 717
706 if (capture_start_rtp_time_stamp_ >= 0) { 718 if (capture_start_rtp_time_stamp_ >= 0) {
707 // audioFrame.timestamp_ should be valid from now on. 719 // audioFrame.timestamp_ should be valid from now on.
708 720
709 // Compute elapsed time. 721 // Compute elapsed time.
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 } 2375 }
2364 2376
2365 int Channel::GetSpeechOutputLevel() const { 2377 int Channel::GetSpeechOutputLevel() const {
2366 return _outputAudioLevel.Level(); 2378 return _outputAudioLevel.Level();
2367 } 2379 }
2368 2380
2369 int Channel::GetSpeechOutputLevelFullRange() const { 2381 int Channel::GetSpeechOutputLevelFullRange() const {
2370 return _outputAudioLevel.LevelFullRange(); 2382 return _outputAudioLevel.LevelFullRange();
2371 } 2383 }
2372 2384
2385 double Channel::GetTotalOutputEnergy() const {
2386 return _totalOutputEnergy;
2387 }
2388
2389 double Channel::GetTotalOutputDuration() const {
2390 return _totalOutputDuration;
2391 }
2392
2373 void Channel::SetInputMute(bool enable) { 2393 void Channel::SetInputMute(bool enable) {
2374 rtc::CritScope cs(&volume_settings_critsect_); 2394 rtc::CritScope cs(&volume_settings_critsect_);
2375 input_mute_ = enable; 2395 input_mute_ = enable;
2376 } 2396 }
2377 2397
2378 bool Channel::InputMute() const { 2398 bool Channel::InputMute() const {
2379 rtc::CritScope cs(&volume_settings_critsect_); 2399 rtc::CritScope cs(&volume_settings_critsect_);
2380 return input_mute_; 2400 return input_mute_;
2381 } 2401 }
2382 2402
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 int64_t min_rtt = 0; 3160 int64_t min_rtt = 0;
3141 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3161 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3142 0) { 3162 0) {
3143 return 0; 3163 return 0;
3144 } 3164 }
3145 return rtt; 3165 return rtt;
3146 } 3166 }
3147 3167
3148 } // namespace voe 3168 } // namespace voe
3149 } // namespace webrtc 3169 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698