cc: Request a proactive impl frame in early-out commit case.
[chromium-blink-merge.git] / media / base / time_source.h
blob8ad364b20a2dda21d97d087a93f878bc0bef16e1
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.
5 #ifndef MEDIA_BASE_TIME_SOURCE_H_
6 #define MEDIA_BASE_TIME_SOURCE_H_
8 #include "base/time/time.h"
9 #include "media/base/media_export.h"
11 namespace media {
13 // A TimeSource is capable of providing the current media time.
14 class MEDIA_EXPORT TimeSource {
15 public:
16 TimeSource() {}
17 virtual ~TimeSource() {}
19 // Signal the time source to start ticking. It is expected that values from
20 // CurrentMediaTime() will start increasing.
21 virtual void StartTicking() = 0;
23 // Signal the time source to stop ticking. It is expected that values from
24 // CurrentMediaTime() will remain constant.
25 virtual void StopTicking() = 0;
27 // Updates the current playback rate. It is expected that values from
28 // CurrentMediaTime() will eventually reflect the new playback rate (e.g., the
29 // media time will advance at half speed if the rate was set to 0.5f).
30 virtual void SetPlaybackRate(float playback_rate) = 0;
32 // Sets the media time to start ticking from. Only valid to call while the
33 // time source is not ticking.
34 virtual void SetMediaTime(base::TimeDelta time) = 0;
36 // Returns the current media time.
38 // Values returned are intended for informational purposes, such as displaying
39 // UI with the current minute and second count. While it is guaranteed values
40 // will never go backwards, the frequency at which they update may be low.
41 virtual base::TimeDelta CurrentMediaTime() = 0;
43 // Returns the current media time for use with synchronizing video.
45 // Differences from CurrentMediaTime():
46 // - Values returned update at a much higher frequency (e.g., suitable for
47 // playback of 60 FPS content).
48 // - As a result, values may go slightly backwards depending on the
49 // implementation (e.g., uses interpolation).
51 // TODO(scherkus): Replace with a method that returns wall clock time for a
52 // given media time for use with VideoFrameScheduler http://crbug.com/110814
53 virtual base::TimeDelta CurrentMediaTimeForSyncingVideo() = 0;
56 } // namespace media
58 #endif // MEDIA_BASE_TIME_SOURCE_H_