diff options
author | dalecurtis <dalecurtis@chromium.org> | 2015-05-11 23:38:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-12 06:38:10 +0000 |
commit | e929345801a5f7ae601bfb09f982054606e3320d (patch) | |
tree | 86c45e6891e13c382a62d216ba551c9f50a811ad /media/base/time_source.h | |
parent | 99e8dd40da33d58d598b000e122939b04272c079 (diff) | |
download | chromium_src-e929345801a5f7ae601bfb09f982054606e3320d.zip chromium_src-e929345801a5f7ae601bfb09f982054606e3320d.tar.gz chromium_src-e929345801a5f7ae601bfb09f982054606e3320d.tar.bz2 |
Switch GetWallClockTime to using vectors for input and output.
Ensures that all converted timestamps will be monotonically increasing
within a single call to GetWallClockTime.
Performance seems unchanged (unit tests take the same amount of time).
As part of this change, also does the following:
- VideoRendererImpl unit test switched to WallClockTimeSource to avoid
having to reimplement the vector conversion routine.
BUG=485042
TEST=new unittest.
Review URL: https://codereview.chromium.org/1136513004
Cr-Commit-Position: refs/heads/master@{#329363}
Diffstat (limited to 'media/base/time_source.h')
-rw-r--r-- | media/base/time_source.h | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/media/base/time_source.h b/media/base/time_source.h index d025de2..d060768 100644 --- a/media/base/time_source.h +++ b/media/base/time_source.h @@ -5,6 +5,9 @@ #ifndef MEDIA_BASE_TIME_SOURCE_H_ #define MEDIA_BASE_TIME_SOURCE_H_ +#include <vector> + +#include "base/callback.h" #include "base/time/time.h" #include "media/base/media_export.h" @@ -13,6 +16,11 @@ namespace media { // A TimeSource is capable of providing the current media time. class MEDIA_EXPORT TimeSource { public: + // Helper alias for converting media timestamps into a wall clock timestamps. + using WallClockTimeCB = + base::Callback<bool(const std::vector<base::TimeDelta>&, + std::vector<base::TimeTicks>*)>; + TimeSource() {} virtual ~TimeSource() {} @@ -26,7 +34,7 @@ class MEDIA_EXPORT TimeSource { // Updates the current playback rate. It is expected that values from // CurrentMediaTime() will eventually reflect the new playback rate (e.g., the - // media time will advance at half speed if the rate was set to 0.5f). + // media time will advance at half speed if the rate was set to 0.5). virtual void SetPlaybackRate(double playback_rate) = 0; // Sets the media time to start ticking from. Only valid to call while the @@ -41,16 +49,27 @@ class MEDIA_EXPORT TimeSource { // will never go backwards, the frequency at which they update may be low. virtual base::TimeDelta CurrentMediaTime() = 0; - // Converts a media timestamp into a wall clock time. If the media time is - // stopped, returns a null TimeTicks. + // Converts a vector of media timestamps into a vector of wall clock times. If + // the media time is stopped, returns false and does not modify the output + // vector. Returns true and converts all timestamps otherwise. Guarantees that + // wall clock time does not go backwards for monotonically increasing media + // timestamps. + // + // Each timestamp converted from |media_timestamps| will be pushed into + // |wall_clock_times| such that after all timestamps are converted, the two + // vectors are parallel (media_timestamps[i] -> wall_clock_times[i]). // - // |media_time| values too far ahead of the current media time will return an - // estimated value; as such, these values may go backwards in time slightly. + // |media_timestamps| values too far ahead of the current media time will + // be converted to an estimated value; as such, these values may go backwards + // in time slightly between calls to GetWallClockTimes(). // - // |media_time| values behind the current media time may be significantly - // incorrect if the playback rate has changed recently. The only guarantee is - // that the returned time will be less than the current wall clock time. - virtual base::TimeTicks GetWallClockTime(base::TimeDelta media_time) = 0; + // |media_timestamps| values behind the current media time may be + // significantly incorrect if the playback rate has changed recently. The only + // guarantee is that the returned time will be less than the current wall + // clock time. + virtual bool GetWallClockTimes( + const std::vector<base::TimeDelta>& media_timestamps, + std::vector<base::TimeTicks>* wall_clock_times) = 0; }; } // namespace media |