OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/cast/cast_ntp_tick_clock.h" |
| 6 |
| 7 namespace media { |
| 8 namespace cast { |
| 9 |
| 10 // Network Time Protocol (NTP), which is in seconds relative to 0h UTC on |
| 11 // 1 January 1900. |
| 12 static const int64 kNtpEpochDeltaSeconds = GG_INT64_C(9435484800); |
| 13 |
| 14 // January 1970, in NTP seconds. |
| 15 // Network Time Protocol (NTP), which is in seconds relative to 0h UTC on |
| 16 // 1 January 1900. |
| 17 static const int64 kUnixEpochInNtpSeconds = GG_INT64_C(2208988800); |
| 18 |
| 19 |
| 20 CastNtpTickClock::CastNtpTickClock() { |
| 21 SetTickClock(&default_tick_clock_); |
| 22 } |
| 23 |
| 24 CastNtpTickClock::~CastNtpTickClock() {} |
| 25 |
| 26 void CastNtpTickClock::SetTickClock(base::TickClock* tick_clock) { |
| 27 tick_clock_ = tick_clock; |
| 28 } |
| 29 |
| 30 // Ticks relative to 0h UTC on 1 January 1900. |
| 31 base::TimeTicks CastNtpTickClock::NowTicks() { |
| 32 base::TimeDelta ticks_and_time_offset_at_unix_epoch = |
| 33 base::TimeTicks::UnixEpoch() - base::TimeTicks(); |
| 34 base::TimeTicks elapsed_since_unix_epoch = tick_clock_->NowTicks() - |
| 35 ticks_and_time_offset_at_unix_epoch; |
| 36 |
| 37 return elapsed_since_unix_epoch + |
| 38 base::TimeDelta::FromSeconds(kUnixEpochInNtpSeconds); |
| 39 } |
| 40 |
| 41 } // namespace cast |
| 42 } // namespace media |
| 43 |
OLD | NEW |