OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_NTP_TIME_H_ | |
11 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_NTP_TIME_H_ | |
12 | |
13 #include "webrtc/base/basictypes.h" | |
14 #include "webrtc/system_wrappers/include/clock.h" | |
15 | |
16 namespace webrtc { | |
17 namespace rtcp { | |
18 | |
19 class NtpTime { | |
20 public: | |
21 NtpTime() : seconds_(0), fractions_(0) {} | |
22 explicit NtpTime(const Clock& clock) { | |
23 clock.CurrentNtp(seconds_, fractions_); | |
24 } | |
25 NtpTime(uint32_t seconds, uint32_t fractions) | |
26 : seconds_(seconds), fractions_(fractions) {} | |
27 | |
28 NtpTime(const NtpTime&) = default; | |
29 NtpTime& operator=(const NtpTime&) = default; | |
30 | |
31 void SetCurrent(const Clock& clock) { | |
32 clock.CurrentNtp(seconds_, fractions_); | |
33 } | |
34 void Set(uint32_t seconds, uint32_t fractions) { | |
35 seconds_ = seconds; | |
36 fractions_ = fractions; | |
37 } | |
38 void clear() { seconds_ = fractions_ = 0; } | |
sprang_webrtc
2015/11/12 15:34:48
Assign separately
danilchap
2015/11/12 19:05:31
Done.
| |
39 | |
40 int64_t ToMs() const { return Clock::NtpToMs(seconds_, fractions_); } | |
41 uint32_t MidNtp() const { return (seconds_ << 16) | (fractions_ >> 16); } | |
sprang_webrtc
2015/11/12 15:34:48
I think this one deserves a comment :)
danilchap
2015/11/12 19:05:31
(bad excuse)RTCPUtility::MidNtp I took this from d
sprang_webrtc
2015/11/16 09:55:25
Ah, so great that we get one now!
| |
42 | |
43 // Conversion to bool to test if we have a valid value. | |
44 explicit operator bool() const { return seconds_ != 0 || fractions_ != 0; } | |
sprang_webrtc
2015/11/12 15:34:48
When would this be used? Are we implicitly saying
danilchap
2015/11/12 19:05:31
To make it more explicit conversion to bool replac
sprang_webrtc
2015/11/16 09:55:25
Gotcha. A comment to that affect would be great. :
danilchap
2015/11/16 11:01:33
Done.
| |
45 | |
46 uint32_t seconds() const { return seconds_; } | |
47 uint32_t fractions() const { return fractions_; } | |
48 | |
49 private: | |
50 uint32_t seconds_; | |
51 uint32_t fractions_; | |
52 }; | |
53 | |
54 } // namespace rtcp | |
55 } // namespace webrtc | |
56 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_NTP_TIME_H_ | |
OLD | NEW |