OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 21 matching lines...) Expand all Loading... |
32 // Wallclock time is represented using the timestamp format of | 32 // Wallclock time is represented using the timestamp format of |
33 // the Network Time Protocol (NTP). | 33 // the Network Time Protocol (NTP). |
34 // ... | 34 // ... |
35 // In some fields where a more compact representation is | 35 // In some fields where a more compact representation is |
36 // appropriate, only the middle 32 bits are used; that is, the low 16 | 36 // appropriate, only the middle 32 bits are used; that is, the low 16 |
37 // bits of the integer part and the high 16 bits of the fractional part. | 37 // bits of the integer part and the high 16 bits of the fractional part. |
38 inline uint32_t CompactNtp(NtpTime ntp) { | 38 inline uint32_t CompactNtp(NtpTime ntp) { |
39 return (ntp.seconds() << 16) | (ntp.fractions() >> 16); | 39 return (ntp.seconds() << 16) | (ntp.fractions() >> 16); |
40 } | 40 } |
41 // Converts interval between compact ntp timestamps to milliseconds. | 41 // Converts interval between compact ntp timestamps to milliseconds. |
42 // This interval can be upto ~18.2 hours (2^16 seconds). | 42 // This interval can be up to ~9.1 hours (2^15 seconds). |
43 inline uint32_t CompactNtpIntervalToMs(uint32_t compact_ntp_interval) { | 43 // Values close to 2^16 seconds consider negative and result in minimum rtt = 1. |
44 uint64_t value = static_cast<uint64_t>(compact_ntp_interval); | 44 int64_t CompactNtpRttToMs(uint32_t compact_ntp_interval); |
45 return (value * 1000 + (1 << 15)) >> 16; | |
46 } | |
47 | 45 |
48 } // namespace webrtc | 46 } // namespace webrtc |
49 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ | 47 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ |
OLD | NEW |