OLD | NEW |
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 Loading... |
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 = |
| 707 static_cast<double>(_outputAudioLevel.LevelFullRange()) / INT16_MAX; |
| 708 additional_energy *= additional_energy; |
| 709 _totalOutputEnergy += additional_energy * 0.01; |
| 710 _totalOutputDuration += 0.01; |
700 | 711 |
701 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { | 712 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { |
702 // The first frame with a valid rtp timestamp. | 713 // The first frame with a valid rtp timestamp. |
703 capture_start_rtp_time_stamp_ = audioFrame->timestamp_; | 714 capture_start_rtp_time_stamp_ = audioFrame->timestamp_; |
704 } | 715 } |
705 | 716 |
706 if (capture_start_rtp_time_stamp_ >= 0) { | 717 if (capture_start_rtp_time_stamp_ >= 0) { |
707 // audioFrame.timestamp_ should be valid from now on. | 718 // audioFrame.timestamp_ should be valid from now on. |
708 | 719 |
709 // Compute elapsed time. | 720 // Compute elapsed time. |
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 } | 2374 } |
2364 | 2375 |
2365 int Channel::GetSpeechOutputLevel() const { | 2376 int Channel::GetSpeechOutputLevel() const { |
2366 return _outputAudioLevel.Level(); | 2377 return _outputAudioLevel.Level(); |
2367 } | 2378 } |
2368 | 2379 |
2369 int Channel::GetSpeechOutputLevelFullRange() const { | 2380 int Channel::GetSpeechOutputLevelFullRange() const { |
2370 return _outputAudioLevel.LevelFullRange(); | 2381 return _outputAudioLevel.LevelFullRange(); |
2371 } | 2382 } |
2372 | 2383 |
| 2384 double Channel::GetTotalOutputEnergy() const { |
| 2385 return _totalOutputEnergy; |
| 2386 } |
| 2387 |
| 2388 double Channel::GetTotalOutputDuration() const { |
| 2389 return _totalOutputDuration; |
| 2390 } |
| 2391 |
2373 void Channel::SetInputMute(bool enable) { | 2392 void Channel::SetInputMute(bool enable) { |
2374 rtc::CritScope cs(&volume_settings_critsect_); | 2393 rtc::CritScope cs(&volume_settings_critsect_); |
2375 input_mute_ = enable; | 2394 input_mute_ = enable; |
2376 } | 2395 } |
2377 | 2396 |
2378 bool Channel::InputMute() const { | 2397 bool Channel::InputMute() const { |
2379 rtc::CritScope cs(&volume_settings_critsect_); | 2398 rtc::CritScope cs(&volume_settings_critsect_); |
2380 return input_mute_; | 2399 return input_mute_; |
2381 } | 2400 } |
2382 | 2401 |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3140 int64_t min_rtt = 0; | 3159 int64_t min_rtt = 0; |
3141 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3160 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3142 0) { | 3161 0) { |
3143 return 0; | 3162 return 0; |
3144 } | 3163 } |
3145 return rtt; | 3164 return rtt; |
3146 } | 3165 } |
3147 | 3166 |
3148 } // namespace voe | 3167 } // namespace voe |
3149 } // namespace webrtc | 3168 } // namespace webrtc |
OLD | NEW |