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

Side by Side Diff: media/cast/test/skewed_tick_clock.cc

Issue 280993002: [Cast] Repair receiver playout time calculations and frame skip logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/test/receiver.cc ('k') | media/cast/transport/cast_transport_config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/test/skewed_tick_clock.h" 5 #include "media/cast/test/skewed_tick_clock.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 8
9 namespace media { 9 namespace media {
10 namespace cast { 10 namespace cast {
11 namespace test { 11 namespace test {
12 12
13 SkewedTickClock::SkewedTickClock(base::TickClock* clock) 13 SkewedTickClock::SkewedTickClock(base::TickClock* clock)
14 : clock_(clock), 14 : clock_(clock),
15 skew_(1.0), 15 skew_(1.0),
16 last_skew_set_time_(clock_->NowTicks()), 16 last_skew_set_time_(clock_->NowTicks()),
17 skew_clock_at_last_set_(last_skew_set_time_) { 17 skew_clock_at_last_set_(last_skew_set_time_) {
18 } 18 }
19 19
20 base::TimeTicks SkewedTickClock::SkewTicks(base::TimeTicks now) { 20 base::TimeTicks SkewedTickClock::SkewTicks(base::TimeTicks now) {
21 return base::TimeDelta::FromMicroseconds( 21 return base::TimeDelta::FromMicroseconds(
22 (now - last_skew_set_time_).InMicroseconds() * skew_) + 22 (now - last_skew_set_time_).InMicroseconds() * skew_) +
23 skew_clock_at_last_set_; 23 skew_clock_at_last_set_;
24 } 24 }
25 25
26 void SkewedTickClock::SetSkew(double skew, base::TimeDelta offset) { 26 void SkewedTickClock::SetSkew(double skew, base::TimeDelta offset) {
27 base::TimeTicks now = clock_->NowTicks(); 27 base::TimeTicks now = clock_->NowTicks();
28 skew_clock_at_last_set_ = SkewTicks(now) + offset;
29 skew_ = skew;
28 last_skew_set_time_ = now; 30 last_skew_set_time_ = now;
29 skew_clock_at_last_set_ = SkewTicks(now) + offset;
30 } 31 }
31 32
32 base::TimeTicks SkewedTickClock::NowTicks() { 33 base::TimeTicks SkewedTickClock::NowTicks() {
33 return SkewTicks(clock_->NowTicks()); 34 return SkewTicks(clock_->NowTicks());
34 } 35 }
35 36
36 } // namespace test 37 } // namespace test
37 } // namespace cast 38 } // namespace cast
38 } // namespace media 39 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/test/receiver.cc ('k') | media/cast/transport/cast_transport_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698