OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/modules/rtp_rtcp/source/report_block_information.h" | |
12 | |
13 #include "webrtc/base/checks.h" | |
14 #include "webrtc/base/trace_event.h" | |
15 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" | |
16 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | |
17 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | |
18 | |
19 namespace webrtc { | |
20 namespace rtcp { | |
21 | |
22 ReportBlockInformation::ReportBlockInformation() | |
23 : number_rtt_(0), last_rtt_(0), min_rtt_(0), max_rtt_(0), sum_rtt_(0) { | |
24 memset(&last_received_block_, 0, sizeof(last_received_block_)); | |
25 } | |
26 | |
27 uint32_t ReportBlockInformation::LastRttMs() const { | |
28 return CompactNtpIntervalToMs(last_rtt_); | |
29 } | |
30 uint32_t ReportBlockInformation::MinRttMs() const { | |
31 return CompactNtpIntervalToMs(min_rtt_); | |
32 } | |
33 uint32_t ReportBlockInformation::MaxRttMs() const { | |
34 return CompactNtpIntervalToMs(max_rtt_); | |
35 } | |
36 uint32_t ReportBlockInformation::AvgRttMs() const { | |
37 RTC_CHECK_GT(number_rtt_, 0u); | |
philipel
2016/02/29 13:21:47
Expected value first:
RTC_CHECK_GT(0u, number_rtt_
danilchap
2016/02/29 14:41:27
Disagree,
Code search shows that expected value la
philipel
2016/03/03 14:00:58
I think you are right. Shouldn't it be DCHECK inst
danilchap
2016/03/03 14:44:48
Done.
| |
38 return CompactNtpIntervalToMs(sum_rtt_ / number_rtt_); | |
39 } | |
40 | |
41 void ReportBlockInformation::AddBlock(const rtcp::ReportBlock& block, | |
42 uint32_t remote_ssrc, | |
43 NtpTime now) { | |
44 last_received_block_.remoteSSRC = remote_ssrc; | |
45 last_received_block_.sourceSSRC = block.source_ssrc(); | |
46 last_received_block_.fractionLost = block.fraction_lost(); | |
47 last_received_block_.cumulativeLost = block.cumulative_lost(); | |
48 last_received_block_.extendedHighSeqNum = block.extended_high_seq_num(); | |
49 last_received_block_.jitter = block.jitter(); | |
50 last_received_block_.lastSR = block.last_sr(); | |
51 last_received_block_.delaySinceLastSR = block.delay_since_last_sr(); | |
52 | |
53 AddRtt(CompactNtp(now)); | |
54 } | |
55 | |
56 void ReportBlockInformation::AddBlock( | |
57 const RTCPUtility::RTCPPacketReportBlockItem& block, | |
58 uint32_t remote_ssrc, | |
59 NtpTime now) { | |
60 last_received_block_.remoteSSRC = remote_ssrc; | |
61 last_received_block_.sourceSSRC = block.SSRC; | |
62 last_received_block_.fractionLost = block.FractionLost; | |
63 last_received_block_.cumulativeLost = block.CumulativeNumOfPacketsLost; | |
64 last_received_block_.extendedHighSeqNum = block.ExtendedHighestSequenceNumber; | |
65 last_received_block_.jitter = block.Jitter; | |
66 last_received_block_.lastSR = block.LastSR; | |
67 last_received_block_.delaySinceLastSR = block.DelayLastSR; | |
68 | |
69 AddRtt(CompactNtp(now)); | |
70 } | |
71 | |
72 void ReportBlockInformation::AddRtt(uint32_t receive_time) { | |
73 uint32_t send_time = last_received_block_.lastSR; | |
74 uint32_t rtt_ms = 0; | |
75 if (send_time > 0) { | |
76 uint32_t delay = last_received_block_.delaySinceLastSR; | |
77 | |
78 // RTT in 1/(2^16) seconds. | |
79 uint32_t rtt_ntp = receive_time - delay - send_time; | |
80 | |
81 last_rtt_ = rtt_ntp; | |
82 if (number_rtt_ == 0) { | |
83 min_rtt_ = rtt_ntp; | |
84 max_rtt_ = rtt_ntp; | |
85 } else { | |
86 if (min_rtt_ > rtt_ntp) | |
87 min_rtt_ = rtt_ntp; | |
88 if (max_rtt_ < rtt_ntp) | |
89 max_rtt_ = rtt_ntp; | |
90 } | |
91 sum_rtt_ += rtt_ntp; | |
92 ++number_rtt_; | |
93 rtt_ms = CompactNtpIntervalToMs(last_rtt_); | |
94 } | |
95 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT", | |
96 last_received_block_.sourceSSRC, rtt_ms); | |
97 } | |
98 } // namespace rtcp | |
99 } // namespace webrtc | |
OLD | NEW |