Index: media/cast/cast_ntp_tick_clock.cc |
diff --git a/media/cast/cast_ntp_tick_clock.cc b/media/cast/cast_ntp_tick_clock.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2ce77b5c08571b891131d5342e4503ac2b1e6746 |
--- /dev/null |
+++ b/media/cast/cast_ntp_tick_clock.cc |
@@ -0,0 +1,43 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "media/cast/cast_ntp_tick_clock.h" |
+ |
+namespace media { |
+namespace cast { |
+ |
+// Network Time Protocol (NTP), which is in seconds relative to 0h UTC on |
+// 1 January 1900. |
+static const int64 kNtpEpochDeltaSeconds = GG_INT64_C(9435484800); |
+ |
+// January 1970, in NTP seconds. |
+// Network Time Protocol (NTP), which is in seconds relative to 0h UTC on |
+// 1 January 1900. |
+static const int64 kUnixEpochInNtpSeconds = GG_INT64_C(2208988800); |
+ |
+ |
+CastNtpTickClock::CastNtpTickClock() { |
+ SetTickClock(&default_tick_clock_); |
+} |
+ |
+CastNtpTickClock::~CastNtpTickClock() {} |
+ |
+void CastNtpTickClock::SetTickClock(base::TickClock* tick_clock) { |
+ tick_clock_ = tick_clock; |
+} |
+ |
+// Ticks relative to 0h UTC on 1 January 1900. |
+base::TimeTicks CastNtpTickClock::NowTicks() { |
+ base::TimeDelta ticks_and_time_offset_at_unix_epoch = |
+ base::TimeTicks::UnixEpoch() - base::TimeTicks(); |
+ base::TimeTicks elapsed_since_unix_epoch = tick_clock_->NowTicks() - |
+ ticks_and_time_offset_at_unix_epoch; |
+ |
+ return elapsed_since_unix_epoch + |
+ base::TimeDelta::FromSeconds(kUnixEpochInNtpSeconds); |
+} |
+ |
+} // namespace cast |
+} // namespace media |
+ |