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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 { | 690 { |
691 rtc::CritScope cs(&_fileCritSect); | 691 rtc::CritScope cs(&_fileCritSect); |
692 | 692 |
693 if (_outputFileRecording && output_file_recorder_) { | 693 if (_outputFileRecording && output_file_recorder_) { |
694 output_file_recorder_->RecordAudioToFile(*audioFrame); | 694 output_file_recorder_->RecordAudioToFile(*audioFrame); |
695 } | 695 } |
696 } | 696 } |
697 | 697 |
698 // Measure audio level (0-9) | 698 // Measure audio level (0-9) |
699 // TODO(henrik.lundin) Use the |muted| information here too. | 699 // TODO(henrik.lundin) Use the |muted| information here too. |
700 // TODO(deadbeef): Use RmsLevel for |_outputAudioLevel| as well (see | 700 // TODO(deadbeef): Use RmsLevel for |_outputAudioLevel| (see |
701 // https://crbug.com/webrtc/7517). | 701 // https://crbug.com/webrtc/7517). |
702 _outputAudioLevel.ComputeLevel(*audioFrame); | 702 _outputAudioLevel.ComputeLevel(*audioFrame, kAudioSampleDurationSeconds); |
703 // See the description for "totalAudioEnergy" in the WebRTC stats spec | |
704 // (https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudi
oenergy) | |
705 // for an explanation of these formulas. In short, we need a value that can | |
706 // be used to compute RMS audio levels over different time intervals, by | |
707 // taking the difference between the results from two getStats calls. To do | |
708 // this, the value needs to be of units "squared sample value * time". | |
709 double additional_energy = | |
710 static_cast<double>(_outputAudioLevel.LevelFullRange()) / INT16_MAX; | |
711 additional_energy *= additional_energy; | |
712 totalOutputEnergy_ += additional_energy * kAudioSampleDurationSeconds; | |
713 totalOutputDuration_ += kAudioSampleDurationSeconds; | |
714 | 703 |
715 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { | 704 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { |
716 // The first frame with a valid rtp timestamp. | 705 // The first frame with a valid rtp timestamp. |
717 capture_start_rtp_time_stamp_ = audioFrame->timestamp_; | 706 capture_start_rtp_time_stamp_ = audioFrame->timestamp_; |
718 } | 707 } |
719 | 708 |
720 if (capture_start_rtp_time_stamp_ >= 0) { | 709 if (capture_start_rtp_time_stamp_ >= 0) { |
721 // audioFrame.timestamp_ should be valid from now on. | 710 // audioFrame.timestamp_ should be valid from now on. |
722 | 711 |
723 // Compute elapsed time. | 712 // Compute elapsed time. |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 | 2367 |
2379 int Channel::GetSpeechOutputLevel() const { | 2368 int Channel::GetSpeechOutputLevel() const { |
2380 return _outputAudioLevel.Level(); | 2369 return _outputAudioLevel.Level(); |
2381 } | 2370 } |
2382 | 2371 |
2383 int Channel::GetSpeechOutputLevelFullRange() const { | 2372 int Channel::GetSpeechOutputLevelFullRange() const { |
2384 return _outputAudioLevel.LevelFullRange(); | 2373 return _outputAudioLevel.LevelFullRange(); |
2385 } | 2374 } |
2386 | 2375 |
2387 double Channel::GetTotalOutputEnergy() const { | 2376 double Channel::GetTotalOutputEnergy() const { |
2388 return totalOutputEnergy_; | 2377 return _outputAudioLevel.TotalEnergy(); |
2389 } | 2378 } |
2390 | 2379 |
2391 double Channel::GetTotalOutputDuration() const { | 2380 double Channel::GetTotalOutputDuration() const { |
2392 return totalOutputDuration_; | 2381 return _outputAudioLevel.TotalDuration(); |
2393 } | 2382 } |
2394 | 2383 |
2395 void Channel::SetInputMute(bool enable) { | 2384 void Channel::SetInputMute(bool enable) { |
2396 rtc::CritScope cs(&volume_settings_critsect_); | 2385 rtc::CritScope cs(&volume_settings_critsect_); |
2397 input_mute_ = enable; | 2386 input_mute_ = enable; |
2398 } | 2387 } |
2399 | 2388 |
2400 bool Channel::InputMute() const { | 2389 bool Channel::InputMute() const { |
2401 rtc::CritScope cs(&volume_settings_critsect_); | 2390 rtc::CritScope cs(&volume_settings_critsect_); |
2402 return input_mute_; | 2391 return input_mute_; |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3170 int64_t min_rtt = 0; | 3159 int64_t min_rtt = 0; |
3171 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3160 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3172 0) { | 3161 0) { |
3173 return 0; | 3162 return 0; |
3174 } | 3163 } |
3175 return rtt; | 3164 return rtt; |
3176 } | 3165 } |
3177 | 3166 |
3178 } // namespace voe | 3167 } // namespace voe |
3179 } // namespace webrtc | 3168 } // namespace webrtc |
OLD | NEW |