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

Unified Diff: media/base/time_delta_interpolator.h

Issue 376013003: Rename media::Clock to media::TimeDeltaInterpolator and update API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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_delta_interpolator.h
diff --git a/media/base/time_delta_interpolator.h b/media/base/time_delta_interpolator.h
new file mode 100644
index 0000000000000000000000000000000000000000..f09d48d9a5ac80c8c629b49bd42c855d87e0476f
--- /dev/null
+++ b/media/base/time_delta_interpolator.h
@@ -0,0 +1,83 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_TIME_DELTA_INTERPOLATOR_H_
+#define MEDIA_BASE_TIME_DELTA_INTERPOLATOR_H_
+
+#include "base/basictypes.h"
+#include "base/time/time.h"
+#include "media/base/media_export.h"
+
+namespace base {
+class TickClock;
+} // namespace base
+
+namespace media {
+
+// Interpolates between two TimeDeltas based on the passage of wall clock time
+// and the current playback rate.
+//
+// TimeDeltaInterpolator is not thread-safe and must be externally locked.
+class MEDIA_EXPORT TimeDeltaInterpolator {
+ public:
+ // Constructs an interpolator initialized to zero with a rate of 1.0.
+ //
+ // |tick_clock| is used for sampling wall clock time for interpolating.
+ explicit TimeDeltaInterpolator(base::TickClock* tick_clock);
+ ~TimeDeltaInterpolator();
+
+ bool interpolating() { return interpolating_; }
+
+ // Starts returning interpolated TimeDelta values.
+ //
+ // |tick_clock| will be queried for a new reference time value.
+ base::TimeDelta StartInterpolating();
+
+ // Stops returning interpolated TimeDelta values.
+ //
+ // |tick_clock| will be queried for a new reference time value.
+ base::TimeDelta StopInterpolating();
+
+ // Sets a new rate at which to interpolate.
+ //
+ // |tick_clock| will be queried for a new reference time value.
+ void SetPlaybackRate(float playback_rate);
+
+ // Sets the two timestamps to interpolate between at |playback_rate_|.
+ // |upper_bound| must be greater or equal to |lower_bound|.
+ //
+ // |upper_bound| is typically the media timestamp of the last audio frame
+ // buffered by the audio hardware.
+ void SetInterpolationRange(base::TimeDelta lower_bound,
acolwell GONE FROM CHROMIUM 2014/07/09 20:17:30 nit: How about SetBounds()? Sorry to change my bin
scherkus (not reviewing) 2014/07/09 20:34:21 no worries -- nothing a little "git grep -l SetInt
+ base::TimeDelta upper_bound);
+
+ // Sets the upper bound used for interpolation. Note that if |upper_bound| is
+ // less than what was previously set via SetTime(), then all future calls
+ // to GetInterpolatedTime() will return |upper_bound|.
+ void SetUpperBound(base::TimeDelta upper_bound);
+
+ // Computes an interpolated time based on SetTime().
+ base::TimeDelta GetInterpolatedTime();
+
+ private:
+ base::TickClock* const tick_clock_;
+
+ bool interpolating_;
+
+ // The range of time to interpolate between.
+ base::TimeDelta lower_bound_;
+ base::TimeDelta upper_bound_;
+
+ // The monotonic system clock time used for interpolating between
+ // |lower_bound_| and |upper_bound_|.
+ base::TimeTicks reference_;
+
+ float playback_rate_;
+
+ DISALLOW_COPY_AND_ASSIGN(TimeDeltaInterpolator);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_TIME_DELTA_INTERPOLATOR_H_

Powered by Google App Engine
This is Rietveld 408576698