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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 if (!IsNewerTimestamp(timestamp, last_timestamp_) || | 91 if (!IsNewerTimestamp(timestamp, last_timestamp_) || |
92 !IsNewerSequenceNumber(sequence_number, last_seq_no_)) { | 92 !IsNewerSequenceNumber(sequence_number, last_seq_no_)) { |
93 // Wrong timestamp or sequence order; use stored value. | 93 // Wrong timestamp or sequence order; use stored value. |
94 packet_len_ms = packet_len_ms_; | 94 packet_len_ms = packet_len_ms_; |
95 } else { | 95 } else { |
96 // Calculate timestamps per packet and derive packet length in ms. | 96 // Calculate timestamps per packet and derive packet length in ms. |
97 int64_t packet_len_samp = | 97 int64_t packet_len_samp = |
98 static_cast<uint32_t>(timestamp - last_timestamp_) / | 98 static_cast<uint32_t>(timestamp - last_timestamp_) / |
99 static_cast<uint16_t>(sequence_number - last_seq_no_); | 99 static_cast<uint16_t>(sequence_number - last_seq_no_); |
100 packet_len_ms = | 100 packet_len_ms = |
101 rtc::checked_cast<int>(1000 * packet_len_samp / sample_rate_hz); | 101 rtc::saturated_cast<int>(1000 * packet_len_samp / sample_rate_hz); |
102 } | 102 } |
103 | 103 |
104 if (packet_len_ms > 0) { | 104 if (packet_len_ms > 0) { |
105 // Cannot update statistics unless |packet_len_ms| is valid. | 105 // Cannot update statistics unless |packet_len_ms| is valid. |
106 // Calculate inter-arrival time (IAT) in integer "packet times" | 106 // Calculate inter-arrival time (IAT) in integer "packet times" |
107 // (rounding down). This is the value used as index to the histogram | 107 // (rounding down). This is the value used as index to the histogram |
108 // vector |iat_vector_|. | 108 // vector |iat_vector_|. |
109 int iat_packets = packet_iat_stopwatch_->ElapsedMs() / packet_len_ms; | 109 int iat_packets = packet_iat_stopwatch_->ElapsedMs() / packet_len_ms; |
110 | 110 |
111 if (streaming_mode_) { | 111 if (streaming_mode_) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 int DelayManager::base_target_level() const { return base_target_level_; } | 417 int DelayManager::base_target_level() const { return base_target_level_; } |
418 void DelayManager::set_streaming_mode(bool value) { streaming_mode_ = value; } | 418 void DelayManager::set_streaming_mode(bool value) { streaming_mode_ = value; } |
419 int DelayManager::last_pack_cng_or_dtmf() const { | 419 int DelayManager::last_pack_cng_or_dtmf() const { |
420 return last_pack_cng_or_dtmf_; | 420 return last_pack_cng_or_dtmf_; |
421 } | 421 } |
422 | 422 |
423 void DelayManager::set_last_pack_cng_or_dtmf(int value) { | 423 void DelayManager::set_last_pack_cng_or_dtmf(int value) { |
424 last_pack_cng_or_dtmf_ = value; | 424 last_pack_cng_or_dtmf_ = value; |
425 } | 425 } |
426 } // namespace webrtc | 426 } // namespace webrtc |
OLD | NEW |