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..e67733b583e0f366d17363d1b8c33297a50b6989 |
--- /dev/null |
+++ b/media/cast/cast_ntp_tick_clock.cc |
@@ -0,0 +1,38 @@ |
+// 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); |
+ |
+CastNtpTickClock::CastNtpTickClock() |
+ : tick_clock_(&default_tick_clock_) { |
+ // Start time in NTP time; which have its epoch at year 1900. |
+ base::Time start_time_ntp = |
+ base::Time::Now() - base::TimeDelta::FromSeconds(kNtpEpochDeltaSeconds); |
+ |
+ base::TimeTicks start_time_ntp_in_ticks = |
+ base::TimeTicks::FromInternalValue(start_time_ntp.ToInternalValue()); |
+ |
+ start_offset_ = start_time_ntp_in_ticks - base::TimeTicks::Now(); |
+} |
+ |
+CastNtpTickClock::~CastNtpTickClock() {} |
+ |
+void CastNtpTickClock::SetTickClock(base::TickClock* tick_clock) { |
+ tick_clock_ = tick_clock; |
miu
2013/10/23 18:24:02
start_offset_ needs to be recalculated here. Perh
pwestin
2013/10/23 21:07:49
Done.
|
+} |
+ |
+base::TimeTicks CastNtpTickClock::NowTicks() { |
+ return tick_clock_->NowTicks() + start_offset_; |
+} |
+ |
+} // namespace cast |
+} // namespace media |
+ |