| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 int64_t DriftingClock::TimeInMilliseconds() const { | 34 int64_t DriftingClock::TimeInMilliseconds() const { |
| 35 return clock_->TimeInMilliseconds() + Drift() / 1000.; | 35 return clock_->TimeInMilliseconds() + Drift() / 1000.; |
| 36 } | 36 } |
| 37 | 37 |
| 38 int64_t DriftingClock::TimeInMicroseconds() const { | 38 int64_t DriftingClock::TimeInMicroseconds() const { |
| 39 return clock_->TimeInMicroseconds() + Drift(); | 39 return clock_->TimeInMicroseconds() + Drift(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void DriftingClock::CurrentNtp(uint32_t& seconds, uint32_t& fractions) const { | 42 NtpTime DriftingClock::CurrentNtpTime() const { |
| 43 // NTP precision is 1/2^32 seconds, i.e. 2^32 ntp fractions = 1 second. | 43 // NTP precision is 1/2^32 seconds, i.e. 2^32 ntp fractions = 1 second. |
| 44 const double kNtpFracPerMicroSecond = 4294.967296; // = 2^32 / 10^6 | 44 const double kNtpFracPerMicroSecond = 4294.967296; // = 2^32 / 10^6 |
| 45 | 45 |
| 46 clock_->CurrentNtp(seconds, fractions); | 46 NtpTime ntp = clock_->CurrentNtpTime(); |
| 47 uint64_t total_fractions = (static_cast<uint64_t>(seconds) << 32) | fractions; | 47 uint64_t total_fractions = static_cast<uint64_t>(ntp); |
| 48 total_fractions += Drift() * kNtpFracPerMicroSecond; | 48 total_fractions += Drift() * kNtpFracPerMicroSecond; |
| 49 seconds = total_fractions >> 32; | 49 return NtpTime(total_fractions); |
| 50 fractions = static_cast<uint32_t>(total_fractions); | |
| 51 } | 50 } |
| 52 | 51 |
| 53 int64_t DriftingClock::CurrentNtpInMilliseconds() const { | 52 int64_t DriftingClock::CurrentNtpInMilliseconds() const { |
| 54 return clock_->CurrentNtpInMilliseconds() + Drift() / 1000.; | 53 return clock_->CurrentNtpInMilliseconds() + Drift() / 1000.; |
| 55 } | 54 } |
| 56 } // namespace test | 55 } // namespace test |
| 57 } // namespace webrtc | 56 } // namespace webrtc |
| OLD | NEW |