OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_BASE_WALL_CLOCK_TIME_SOURCE_H_ |
| 6 #define MEDIA_BASE_WALL_CLOCK_TIME_SOURCE_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "media/base/media_export.h" |
| 10 #include "media/base/time_source.h" |
| 11 |
| 12 namespace base { |
| 13 class TickClock; |
| 14 } |
| 15 |
| 16 namespace media { |
| 17 |
| 18 // A time source that uses interpolation based on the system clock. |
| 19 class MEDIA_EXPORT WallClockTimeSource : public TimeSource { |
| 20 public: |
| 21 WallClockTimeSource(); |
| 22 virtual ~WallClockTimeSource(); |
| 23 |
| 24 // TimeSource implementation. |
| 25 virtual void StartTicking() OVERRIDE; |
| 26 virtual void StopTicking() OVERRIDE; |
| 27 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; |
| 28 virtual void SetMediaTime(base::TimeDelta time) OVERRIDE; |
| 29 virtual base::TimeDelta CurrentMediaTime() OVERRIDE; |
| 30 |
| 31 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock); |
| 32 |
| 33 private: |
| 34 scoped_ptr<base::TickClock> tick_clock_; |
| 35 bool ticking_; |
| 36 |
| 37 // While ticking we can interpolate the current media time by measuring the |
| 38 // delta between our reference ticks and the current system ticks and scaling |
| 39 // that time by the playback rate. |
| 40 float playback_rate_; |
| 41 base::TimeDelta base_time_; |
| 42 base::TimeTicks reference_wall_ticks_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(WallClockTimeSource); |
| 45 }; |
| 46 |
| 47 } // namespace media |
| 48 |
| 49 #endif // MEDIA_BASE_WALL_CLOCK_TIME_SOURCE_H_ |
OLD | NEW |