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 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ |
13 | 13 |
14 #include <stdint.h> | 14 #include "webrtc/base/basictypes.h" |
15 | |
16 #include "webrtc/system_wrappers/include/ntp_time.h" | 15 #include "webrtc/system_wrappers/include/ntp_time.h" |
17 | 16 |
18 namespace webrtc { | 17 namespace webrtc { |
19 | 18 |
20 // Converts NTP timestamp to RTP timestamp. | 19 // Converts NTP timestamp to RTP timestamp. |
21 inline uint32_t NtpToRtp(NtpTime ntp, uint32_t freq) { | 20 inline uint32_t NtpToRtp(NtpTime ntp, uint32_t freq) { |
22 uint32_t tmp = (static_cast<uint64_t>(ntp.fractions()) * freq) >> 32; | 21 uint32_t tmp = (static_cast<uint64_t>(ntp.fractions()) * freq) >> 32; |
23 return ntp.seconds() * freq + tmp; | 22 return ntp.seconds() * freq + tmp; |
24 } | 23 } |
25 // Return the current RTP timestamp from the NTP timestamp | 24 // Return the current RTP timestamp from the NTP timestamp |
(...skipping 13 matching lines...) Expand all Loading... |
39 inline uint32_t CompactNtp(NtpTime ntp) { | 38 inline uint32_t CompactNtp(NtpTime ntp) { |
40 return (ntp.seconds() << 16) | (ntp.fractions() >> 16); | 39 return (ntp.seconds() << 16) | (ntp.fractions() >> 16); |
41 } | 40 } |
42 // Converts interval between compact ntp timestamps to milliseconds. | 41 // Converts interval between compact ntp timestamps to milliseconds. |
43 // This interval can be up to ~9.1 hours (2^15 seconds). | 42 // This interval can be up to ~9.1 hours (2^15 seconds). |
44 // Values close to 2^16 seconds consider negative and result in minimum rtt = 1. | 43 // Values close to 2^16 seconds consider negative and result in minimum rtt = 1. |
45 int64_t CompactNtpRttToMs(uint32_t compact_ntp_interval); | 44 int64_t CompactNtpRttToMs(uint32_t compact_ntp_interval); |
46 | 45 |
47 } // namespace webrtc | 46 } // namespace webrtc |
48 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ | 47 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ |
OLD | NEW |