| OLD | NEW |
| 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 #ifndef MEDIA_BASE_TIME_SOURCE_H_ | 5 #ifndef MEDIA_BASE_TIME_SOURCE_H_ |
| 6 #define MEDIA_BASE_TIME_SOURCE_H_ | 6 #define MEDIA_BASE_TIME_SOURCE_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "media/base/media_export.h" | 9 #include "media/base/media_export.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace media { |
| 12 | 12 |
| 13 // A TimeSource is capable of providing the current media time. | 13 // A TimeSource is capable of providing the current media time. |
| 14 class MEDIA_EXPORT TimeSource { | 14 class MEDIA_EXPORT TimeSource { |
| 15 public: | 15 public: |
| 16 TimeSource() {} | 16 TimeSource() {} |
| 17 virtual ~TimeSource() {} | 17 virtual ~TimeSource() {} |
| 18 | 18 |
| 19 // Signal the time source to start ticking. It is expected that values from | 19 // Signal the time source to start ticking. It is expected that values from |
| 20 // CurrentMediaTime() will start increasing. | 20 // CurrentMediaTime() will start increasing. |
| 21 virtual void StartTicking() = 0; | 21 virtual void StartTicking() = 0; |
| 22 | 22 |
| 23 // Signal the time source to stop ticking. It is expected that values from | 23 // Signal the time source to stop ticking. It is expected that values from |
| 24 // CurrentMediaTime() will remain constant. | 24 // CurrentMediaTime() will remain constant. |
| 25 virtual void StopTicking() = 0; | 25 virtual void StopTicking() = 0; |
| 26 | 26 |
| 27 // Updates the current playback rate. It is expected that values from | 27 // Updates the current playback rate. It is expected that values from |
| 28 // CurrentMediaTime() will eventually reflect the new playback rate (e.g., the | 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). | 29 // media time will advance at half speed if the rate was set to 0.5f). |
| 30 virtual void SetPlaybackRate(float playback_rate) = 0; | 30 virtual void SetPlaybackRate(double playback_rate) = 0; |
| 31 | 31 |
| 32 // Sets the media time to start ticking from. Only valid to call while the | 32 // Sets the media time to start ticking from. Only valid to call while the |
| 33 // time source is not ticking. | 33 // time source is not ticking. |
| 34 virtual void SetMediaTime(base::TimeDelta time) = 0; | 34 virtual void SetMediaTime(base::TimeDelta time) = 0; |
| 35 | 35 |
| 36 // Returns the current media timestamp relative to the timestamp set by | 36 // Returns the current media timestamp relative to the timestamp set by |
| 37 // SetMediaTime(). | 37 // SetMediaTime(). |
| 38 // | 38 // |
| 39 // Values returned are intended for informational purposes, such as displaying | 39 // Values returned are intended for informational purposes, such as displaying |
| 40 // UI with the current minute and second count. While it is guaranteed values | 40 // UI with the current minute and second count. While it is guaranteed values |
| 41 // will never go backwards, the frequency at which they update may be low. | 41 // will never go backwards, the frequency at which they update may be low. |
| 42 virtual base::TimeDelta CurrentMediaTime() = 0; | 42 virtual base::TimeDelta CurrentMediaTime() = 0; |
| 43 | 43 |
| 44 // Converts a media timestamp into a wall clock time. If the media time is | 44 // Converts a media timestamp into a wall clock time. If the media time is |
| 45 // stopped, returns a null TimeTicks. | 45 // stopped, returns a null TimeTicks. |
| 46 // | 46 // |
| 47 // |media_time| values too far ahead of the current media time will return an | 47 // |media_time| values too far ahead of the current media time will return an |
| 48 // estimated value; as such, these values may go backwards in time slightly. | 48 // estimated value; as such, these values may go backwards in time slightly. |
| 49 // | 49 // |
| 50 // |media_time| values behind the current media time may be significantly | 50 // |media_time| values behind the current media time may be significantly |
| 51 // incorrect if the playback rate has changed recently. The only guarantee is | 51 // incorrect if the playback rate has changed recently. The only guarantee is |
| 52 // that the returned time will be less than the current wall clock time. | 52 // that the returned time will be less than the current wall clock time. |
| 53 virtual base::TimeTicks GetWallClockTime(base::TimeDelta media_time) = 0; | 53 virtual base::TimeTicks GetWallClockTime(base::TimeDelta media_time) = 0; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace media | 56 } // namespace media |
| 57 | 57 |
| 58 #endif // MEDIA_BASE_TIME_SOURCE_H_ | 58 #endif // MEDIA_BASE_TIME_SOURCE_H_ |
| OLD | NEW |