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

Side by Side Diff: media/cast/cast_ntp_tick_clock.cc

Issue 34623008: Change to calculate the real NTP in TimeTicks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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
OLDNEW
(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 CastNtpTickClock::CastNtpTickClock()
15 : tick_clock_(&default_tick_clock_) {
16 // Start time in NTP time; which have its epoch at year 1900.
17 base::Time start_time_ntp =
18 base::Time::Now() - base::TimeDelta::FromSeconds(kNtpEpochDeltaSeconds);
19
20 base::TimeTicks start_time_ntp_in_ticks =
21 base::TimeTicks::FromInternalValue(start_time_ntp.ToInternalValue());
22
23 start_offset_ = start_time_ntp_in_ticks - base::TimeTicks::Now();
24 }
25
26 CastNtpTickClock::~CastNtpTickClock() {}
27
28 void CastNtpTickClock::SetTickClock(base::TickClock* tick_clock) {
29 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.
30 }
31
32 base::TimeTicks CastNtpTickClock::NowTicks() {
33 return tick_clock_->NowTicks() + start_offset_;
34 }
35
36 } // namespace cast
37 } // namespace media
38
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698