| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
| 11 #include "webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h" | 11 #include "webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h" |
| 12 | 12 |
| 13 #include <math.h> | 13 #include <math.h> |
| 14 | 14 |
| 15 #include <cstdlib> |
| 16 |
| 15 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" | 17 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" |
| 16 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 18 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
| 17 | 19 |
| 18 namespace webrtc { | 20 namespace webrtc { |
| 19 | 21 |
| 20 const int64_t kStatisticsTimeoutMs = 8000; | 22 const int64_t kStatisticsTimeoutMs = 8000; |
| 21 const int64_t kStatisticsProcessIntervalMs = 1000; | 23 const int64_t kStatisticsProcessIntervalMs = 1000; |
| 22 | 24 |
| 23 StreamStatistician::~StreamStatistician() {} | 25 StreamStatistician::~StreamStatistician() {} |
| 24 | 26 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 108 |
| 107 void StreamStatisticianImpl::UpdateJitter(const RTPHeader& header, | 109 void StreamStatisticianImpl::UpdateJitter(const RTPHeader& header, |
| 108 NtpTime receive_time) { | 110 NtpTime receive_time) { |
| 109 uint32_t receive_time_rtp = | 111 uint32_t receive_time_rtp = |
| 110 NtpToRtp(receive_time, header.payload_type_frequency); | 112 NtpToRtp(receive_time, header.payload_type_frequency); |
| 111 uint32_t last_receive_time_rtp = | 113 uint32_t last_receive_time_rtp = |
| 112 NtpToRtp(last_receive_time_ntp_, header.payload_type_frequency); | 114 NtpToRtp(last_receive_time_ntp_, header.payload_type_frequency); |
| 113 int32_t time_diff_samples = (receive_time_rtp - last_receive_time_rtp) - | 115 int32_t time_diff_samples = (receive_time_rtp - last_receive_time_rtp) - |
| 114 (header.timestamp - last_received_timestamp_); | 116 (header.timestamp - last_received_timestamp_); |
| 115 | 117 |
| 116 time_diff_samples = abs(time_diff_samples); | 118 time_diff_samples = std::abs(time_diff_samples); |
| 117 | 119 |
| 118 // lib_jingle sometimes deliver crazy jumps in TS for the same stream. | 120 // lib_jingle sometimes deliver crazy jumps in TS for the same stream. |
| 119 // If this happens, don't update jitter value. Use 5 secs video frequency | 121 // If this happens, don't update jitter value. Use 5 secs video frequency |
| 120 // as the threshold. | 122 // as the threshold. |
| 121 if (time_diff_samples < 450000) { | 123 if (time_diff_samples < 450000) { |
| 122 // Note we calculate in Q4 to avoid using float. | 124 // Note we calculate in Q4 to avoid using float. |
| 123 int32_t jitter_diff_q4 = (time_diff_samples << 4) - jitter_q4_; | 125 int32_t jitter_diff_q4 = (time_diff_samples << 4) - jitter_q4_; |
| 124 jitter_q4_ += ((jitter_diff_q4 + 8) >> 4); | 126 jitter_q4_ += ((jitter_diff_q4 + 8) >> 4); |
| 125 } | 127 } |
| 126 | 128 |
| 127 // Extended jitter report, RFC 5450. | 129 // Extended jitter report, RFC 5450. |
| 128 // Actual network jitter, excluding the source-introduced jitter. | 130 // Actual network jitter, excluding the source-introduced jitter. |
| 129 int32_t time_diff_samples_ext = | 131 int32_t time_diff_samples_ext = |
| 130 (receive_time_rtp - last_receive_time_rtp) - | 132 (receive_time_rtp - last_receive_time_rtp) - |
| 131 ((header.timestamp + | 133 ((header.timestamp + |
| 132 header.extension.transmissionTimeOffset) - | 134 header.extension.transmissionTimeOffset) - |
| 133 (last_received_timestamp_ + | 135 (last_received_timestamp_ + |
| 134 last_received_transmission_time_offset_)); | 136 last_received_transmission_time_offset_)); |
| 135 | 137 |
| 136 time_diff_samples_ext = abs(time_diff_samples_ext); | 138 time_diff_samples_ext = std::abs(time_diff_samples_ext); |
| 137 | 139 |
| 138 if (time_diff_samples_ext < 450000) { | 140 if (time_diff_samples_ext < 450000) { |
| 139 int32_t jitter_diffQ4TransmissionTimeOffset = | 141 int32_t jitter_diffQ4TransmissionTimeOffset = |
| 140 (time_diff_samples_ext << 4) - jitter_q4_transmission_time_offset_; | 142 (time_diff_samples_ext << 4) - jitter_q4_transmission_time_offset_; |
| 141 jitter_q4_transmission_time_offset_ += | 143 jitter_q4_transmission_time_offset_ += |
| 142 ((jitter_diffQ4TransmissionTimeOffset + 8) >> 4); | 144 ((jitter_diffQ4TransmissionTimeOffset + 8) >> 4); |
| 143 } | 145 } |
| 144 } | 146 } |
| 145 | 147 |
| 146 void StreamStatisticianImpl::NotifyRtpCallback() { | 148 void StreamStatisticianImpl::NotifyRtpCallback() { |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 529 |
| 528 void NullReceiveStatistics::Process() {} | 530 void NullReceiveStatistics::Process() {} |
| 529 | 531 |
| 530 void NullReceiveStatistics::RegisterRtcpStatisticsCallback( | 532 void NullReceiveStatistics::RegisterRtcpStatisticsCallback( |
| 531 RtcpStatisticsCallback* callback) {} | 533 RtcpStatisticsCallback* callback) {} |
| 532 | 534 |
| 533 void NullReceiveStatistics::RegisterRtpStatisticsCallback( | 535 void NullReceiveStatistics::RegisterRtpStatisticsCallback( |
| 534 StreamDataCountersCallback* callback) {} | 536 StreamDataCountersCallback* callback) {} |
| 535 | 537 |
| 536 } // namespace webrtc | 538 } // namespace webrtc |
| OLD | NEW |