| 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 23 matching lines...) Expand all Loading... |
| 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 upto ~18.2 hours (2^16 seconds). |
| 43 inline uint32_t CompactNtpIntervalToMs(uint32_t compact_ntp_interval) { | 43 inline uint32_t CompactNtpIntervalToMs(uint32_t compact_ntp_interval) { |
| 44 return static_cast<uint64_t>(compact_ntp_interval) * 1000 / (1 << 16); | 44 uint64_t value = static_cast<uint64_t>(compact_ntp_interval); |
| 45 return (value * 1000 + (1 << 15)) >> 16; |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // namespace webrtc | 48 } // namespace webrtc |
| 48 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ | 49 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ |
| OLD | NEW |