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

Unified Diff: media/base/time_source.h

Issue 1136513004: Switch GetWallClockTime to using vectors for input and output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use vector. Cleanup. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: media/base/time_source.h
diff --git a/media/base/time_source.h b/media/base/time_source.h
index d025de2a6ccb53cdebee6b1f71dd78eab6b11c50..85761517ef104086e5ee8667d30220f233f3f2e2 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
xhwang 2015/05/12 04:46:53 Q for "does not go backwards": Can f(a) == f(b) fo
DaleCurtis 2015/05/12 05:35:42 Not unless there's a rounding error, f(a) != f(b)
xhwang 2015/05/12 05:45:42 nit: "does not go backwards" means a >= b, which s
DaleCurtis 2015/05/12 16:50:04 I'm still not clear on your nit here :) Within a s
xhwang 2015/05/12 17:20:55 Just say the wall clock time is a strictly increas
+ // 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 GetWallClockTime().
//
- // |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 GetWallClockTime(
xhwang 2015/05/12 04:46:53 bike shedding: should it be GetWallClockTime_s_?
DaleCurtis 2015/05/12 05:35:42 Done.
+ const std::vector<base::TimeDelta>& media_timestamps,
+ std::vector<base::TimeTicks>* wall_clock_times) = 0;
};
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698