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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 43 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
44 #include "webrtc/voice_engine/output_mixer.h" | 44 #include "webrtc/voice_engine/output_mixer.h" |
45 #include "webrtc/voice_engine/statistics.h" | 45 #include "webrtc/voice_engine/statistics.h" |
46 #include "webrtc/voice_engine/utility.h" | 46 #include "webrtc/voice_engine/utility.h" |
47 | 47 |
48 namespace webrtc { | 48 namespace webrtc { |
49 namespace voe { | 49 namespace voe { |
50 | 50 |
51 namespace { | 51 namespace { |
52 | 52 |
| 53 constexpr double kAudioSampleDurationSeconds = 0.01; |
53 constexpr int64_t kMaxRetransmissionWindowMs = 1000; | 54 constexpr int64_t kMaxRetransmissionWindowMs = 1000; |
54 constexpr int64_t kMinRetransmissionWindowMs = 30; | 55 constexpr int64_t kMinRetransmissionWindowMs = 30; |
55 | 56 |
56 } // namespace | 57 } // namespace |
57 | 58 |
58 const int kTelephoneEventAttenuationdB = 10; | 59 const int kTelephoneEventAttenuationdB = 10; |
59 | 60 |
60 class RtcEventLogProxy final : public webrtc::RtcEventLog { | 61 class RtcEventLogProxy final : public webrtc::RtcEventLog { |
61 public: | 62 public: |
62 RtcEventLogProxy() : event_log_(nullptr) {} | 63 RtcEventLogProxy() : event_log_(nullptr) {} |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 { | 690 { |
690 rtc::CritScope cs(&_fileCritSect); | 691 rtc::CritScope cs(&_fileCritSect); |
691 | 692 |
692 if (_outputFileRecording && output_file_recorder_) { | 693 if (_outputFileRecording && output_file_recorder_) { |
693 output_file_recorder_->RecordAudioToFile(*audioFrame); | 694 output_file_recorder_->RecordAudioToFile(*audioFrame); |
694 } | 695 } |
695 } | 696 } |
696 | 697 |
697 // Measure audio level (0-9) | 698 // Measure audio level (0-9) |
698 // 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 |
| 701 // https://crbug.com/webrtc/7517). |
699 _outputAudioLevel.ComputeLevel(*audioFrame); | 702 _outputAudioLevel.ComputeLevel(*audioFrame); |
| 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; |
700 | 714 |
701 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { | 715 if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { |
702 // The first frame with a valid rtp timestamp. | 716 // The first frame with a valid rtp timestamp. |
703 capture_start_rtp_time_stamp_ = audioFrame->timestamp_; | 717 capture_start_rtp_time_stamp_ = audioFrame->timestamp_; |
704 } | 718 } |
705 | 719 |
706 if (capture_start_rtp_time_stamp_ >= 0) { | 720 if (capture_start_rtp_time_stamp_ >= 0) { |
707 // audioFrame.timestamp_ should be valid from now on. | 721 // audioFrame.timestamp_ should be valid from now on. |
708 | 722 |
709 // Compute elapsed time. | 723 // Compute elapsed time. |
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 } | 2377 } |
2364 | 2378 |
2365 int Channel::GetSpeechOutputLevel() const { | 2379 int Channel::GetSpeechOutputLevel() const { |
2366 return _outputAudioLevel.Level(); | 2380 return _outputAudioLevel.Level(); |
2367 } | 2381 } |
2368 | 2382 |
2369 int Channel::GetSpeechOutputLevelFullRange() const { | 2383 int Channel::GetSpeechOutputLevelFullRange() const { |
2370 return _outputAudioLevel.LevelFullRange(); | 2384 return _outputAudioLevel.LevelFullRange(); |
2371 } | 2385 } |
2372 | 2386 |
| 2387 double Channel::GetTotalOutputEnergy() const { |
| 2388 return totalOutputEnergy_; |
| 2389 } |
| 2390 |
| 2391 double Channel::GetTotalOutputDuration() const { |
| 2392 return totalOutputDuration_; |
| 2393 } |
| 2394 |
2373 void Channel::SetInputMute(bool enable) { | 2395 void Channel::SetInputMute(bool enable) { |
2374 rtc::CritScope cs(&volume_settings_critsect_); | 2396 rtc::CritScope cs(&volume_settings_critsect_); |
2375 input_mute_ = enable; | 2397 input_mute_ = enable; |
2376 } | 2398 } |
2377 | 2399 |
2378 bool Channel::InputMute() const { | 2400 bool Channel::InputMute() const { |
2379 rtc::CritScope cs(&volume_settings_critsect_); | 2401 rtc::CritScope cs(&volume_settings_critsect_); |
2380 return input_mute_; | 2402 return input_mute_; |
2381 } | 2403 } |
2382 | 2404 |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3140 int64_t min_rtt = 0; | 3162 int64_t min_rtt = 0; |
3141 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3163 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3142 0) { | 3164 0) { |
3143 return 0; | 3165 return 0; |
3144 } | 3166 } |
3145 return rtt; | 3167 return rtt; |
3146 } | 3168 } |
3147 | 3169 |
3148 } // namespace voe | 3170 } // namespace voe |
3149 } // namespace webrtc | 3171 } // namespace webrtc |
OLD | NEW |