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

Side by Side Diff: webrtc/test/drifting_clock.cc

Issue 2733823002: Replace Clock::CurrentNtp with Clock::CurrentNtpTime (Closed)
Patch Set: Remove CurrentNtp instead of deprecate Created 3 years, 9 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/test/drifting_clock.h ('k') | no next file » | 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) 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
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
OLDNEW
« no previous file with comments | « webrtc/test/drifting_clock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698