Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/time_util.h

Issue 2393723004: replace NtpTime->Clock with Clock->NtpTime dependency (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.cc ('k') | webrtc/system_wrappers/include/clock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h>
15 15
16 #include "webrtc/system_wrappers/include/ntp_time.h" 16 #include "webrtc/system_wrappers/include/ntp_time.h"
17 17
18 namespace webrtc { 18 namespace webrtc {
19 19
20 // Converts NTP timestamp to RTP timestamp. 20 // Converts NTP timestamp to RTP timestamp.
21 inline uint32_t NtpToRtp(NtpTime ntp, uint32_t freq) { 21 inline uint32_t NtpToRtp(NtpTime ntp, uint32_t freq) {
22 uint32_t tmp = (static_cast<uint64_t>(ntp.fractions()) * freq) >> 32; 22 uint32_t tmp = (static_cast<uint64_t>(ntp.fractions()) * freq) >> 32;
23 return ntp.seconds() * freq + tmp; 23 return ntp.seconds() * freq + tmp;
24 } 24 }
25 // Return the current RTP timestamp from the NTP timestamp
26 // returned by the specified clock.
27 inline uint32_t CurrentRtp(const Clock& clock, uint32_t freq) {
28 return NtpToRtp(NtpTime(clock), freq);
29 }
30 25
31 // Helper function for compact ntp representation: 26 // Helper function for compact ntp representation:
32 // RFC 3550, Section 4. Time Format. 27 // RFC 3550, Section 4. Time Format.
33 // Wallclock time is represented using the timestamp format of 28 // Wallclock time is represented using the timestamp format of
34 // the Network Time Protocol (NTP). 29 // the Network Time Protocol (NTP).
35 // ... 30 // ...
36 // In some fields where a more compact representation is 31 // In some fields where a more compact representation is
37 // appropriate, only the middle 32 bits are used; that is, the low 16 32 // appropriate, only the middle 32 bits are used; that is, the low 16
38 // bits of the integer part and the high 16 bits of the fractional part. 33 // bits of the integer part and the high 16 bits of the fractional part.
39 inline uint32_t CompactNtp(NtpTime ntp) { 34 inline uint32_t CompactNtp(NtpTime ntp) {
40 return (ntp.seconds() << 16) | (ntp.fractions() >> 16); 35 return (ntp.seconds() << 16) | (ntp.fractions() >> 16);
41 } 36 }
42 // Converts interval between compact ntp timestamps to milliseconds. 37 // Converts interval between compact ntp timestamps to milliseconds.
43 // This interval can be up to ~9.1 hours (2^15 seconds). 38 // 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. 39 // Values close to 2^16 seconds consider negative and result in minimum rtt = 1.
45 int64_t CompactNtpRttToMs(uint32_t compact_ntp_interval); 40 int64_t CompactNtpRttToMs(uint32_t compact_ntp_interval);
46 41
47 } // namespace webrtc 42 } // namespace webrtc
48 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_ 43 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_TIME_UTIL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.cc ('k') | webrtc/system_wrappers/include/clock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698