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

Side by Side Diff: webrtc/base/timeutils.h

Issue 1859413002: Delete unused code in rtc timeutils. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Deleted a TODO comment. Created 4 years, 8 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 | « no previous file | webrtc/base/timeutils.cc » ('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 2005 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2005 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 11 matching lines...) Expand all
22 static const int64_t kNumMicrosecsPerSec = INT64_C(1000000); 22 static const int64_t kNumMicrosecsPerSec = INT64_C(1000000);
23 static const int64_t kNumNanosecsPerSec = INT64_C(1000000000); 23 static const int64_t kNumNanosecsPerSec = INT64_C(1000000000);
24 24
25 static const int64_t kNumMicrosecsPerMillisec = 25 static const int64_t kNumMicrosecsPerMillisec =
26 kNumMicrosecsPerSec / kNumMillisecsPerSec; 26 kNumMicrosecsPerSec / kNumMillisecsPerSec;
27 static const int64_t kNumNanosecsPerMillisec = 27 static const int64_t kNumNanosecsPerMillisec =
28 kNumNanosecsPerSec / kNumMillisecsPerSec; 28 kNumNanosecsPerSec / kNumMillisecsPerSec;
29 static const int64_t kNumNanosecsPerMicrosec = 29 static const int64_t kNumNanosecsPerMicrosec =
30 kNumNanosecsPerSec / kNumMicrosecsPerSec; 30 kNumNanosecsPerSec / kNumMicrosecsPerSec;
31 31
32 // January 1970, in NTP milliseconds.
33 static const int64_t kJan1970AsNtpMillisecs = INT64_C(2208988800000);
34
35 typedef uint32_t TimeStamp; 32 typedef uint32_t TimeStamp;
36 33
37 // Returns the current time in milliseconds in 32 bits. 34 // Returns the current time in milliseconds in 32 bits.
38 uint32_t Time32(); 35 uint32_t Time32();
39 36
40 // Returns the current time in milliseconds in 64 bits. 37 // Returns the current time in milliseconds in 64 bits.
41 int64_t Time64(); 38 int64_t Time64();
42 39
43 // Returns the current time in milliseconds. 40 // Returns the current time in milliseconds.
44 // TODO(honghaiz): Returns Time64 once majority of the webrtc code migrates to 41 // TODO(honghaiz): Returns Time64 once majority of the webrtc code migrates to
45 // 64-bit timestamp. 42 // 64-bit timestamp.
46 inline uint32_t Time() { 43 inline uint32_t Time() {
47 return Time32(); 44 return Time32();
48 } 45 }
49 46
50 // Returns the current time in microseconds. 47 // Returns the current time in microseconds.
51 uint64_t TimeMicros(); 48 uint64_t TimeMicros();
52 // Returns the current time in nanoseconds. 49 // Returns the current time in nanoseconds.
53 uint64_t TimeNanos(); 50 uint64_t TimeNanos();
54 51
55 // Stores current time in *tm and microseconds in *microseconds.
56 void CurrentTmTime(struct tm *tm, int *microseconds);
57
58 // Returns a future timestamp, 'elapsed' milliseconds from now. 52 // Returns a future timestamp, 'elapsed' milliseconds from now.
59 uint32_t TimeAfter(int32_t elapsed); 53 uint32_t TimeAfter(int32_t elapsed);
60 54
61 // Comparisons between time values, which can wrap around.
62 bool TimeIsBetween(uint32_t earlier,
63 uint32_t middle,
64 uint32_t later); // Inclusive
65 bool TimeIsLaterOrEqual(uint32_t earlier, uint32_t later); // Inclusive 55 bool TimeIsLaterOrEqual(uint32_t earlier, uint32_t later); // Inclusive
66 bool TimeIsLater(uint32_t earlier, uint32_t later); // Exclusive 56 bool TimeIsLater(uint32_t earlier, uint32_t later); // Exclusive
67 57
68 // Returns the later of two timestamps. 58 // Returns the later of two timestamps.
69 inline uint32_t TimeMax(uint32_t ts1, uint32_t ts2) { 59 inline uint32_t TimeMax(uint32_t ts1, uint32_t ts2) {
70 return TimeIsLaterOrEqual(ts1, ts2) ? ts2 : ts1; 60 return TimeIsLaterOrEqual(ts1, ts2) ? ts2 : ts1;
71 } 61 }
72 62
73 // Returns the earlier of two timestamps. 63 // Returns the earlier of two timestamps.
74 inline uint32_t TimeMin(uint32_t ts1, uint32_t ts2) { 64 inline uint32_t TimeMin(uint32_t ts1, uint32_t ts2) {
(...skipping 11 matching lines...) Expand all
86 // The number of milliseconds that have elapsed since 'earlier'. 76 // The number of milliseconds that have elapsed since 'earlier'.
87 inline int32_t TimeSince(uint32_t earlier) { 77 inline int32_t TimeSince(uint32_t earlier) {
88 return TimeDiff(Time(), earlier); 78 return TimeDiff(Time(), earlier);
89 } 79 }
90 80
91 // The number of milliseconds that will elapse between now and 'later'. 81 // The number of milliseconds that will elapse between now and 'later'.
92 inline int32_t TimeUntil(uint32_t later) { 82 inline int32_t TimeUntil(uint32_t later) {
93 return TimeDiff(later, Time()); 83 return TimeDiff(later, Time());
94 } 84 }
95 85
96 // Converts a unix timestamp in nanoseconds to an NTP timestamp in ms.
97 inline int64_t UnixTimestampNanosecsToNtpMillisecs(int64_t unix_ts_ns) {
98 return unix_ts_ns / kNumNanosecsPerMillisec + kJan1970AsNtpMillisecs;
99 }
100
101 class TimestampWrapAroundHandler { 86 class TimestampWrapAroundHandler {
102 public: 87 public:
103 TimestampWrapAroundHandler(); 88 TimestampWrapAroundHandler();
104 89
105 int64_t Unwrap(uint32_t ts); 90 int64_t Unwrap(uint32_t ts);
106 91
107 private: 92 private:
108 uint32_t last_ts_; 93 uint32_t last_ts_;
109 int64_t num_wrap_; 94 int64_t num_wrap_;
110 }; 95 };
111 96
112 // Convert from std::tm, which is relative to 1900-01-01 00:00 to number of 97 // Convert from std::tm, which is relative to 1900-01-01 00:00 to number of
113 // seconds from 1970-01-01 00:00 ("epoch"). Don't return time_t since that 98 // seconds from 1970-01-01 00:00 ("epoch"). Don't return time_t since that
114 // is still 32 bits on many systems. 99 // is still 32 bits on many systems.
115 int64_t TmToSeconds(const std::tm& tm); 100 int64_t TmToSeconds(const std::tm& tm);
116 101
117 } // namespace rtc 102 } // namespace rtc
118 103
119 #endif // WEBRTC_BASE_TIMEUTILS_H_ 104 #endif // WEBRTC_BASE_TIMEUTILS_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/timeutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698