Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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. | |
| 4 | |
| 5 #ifndef MEDIA_BASE_TIME_DELTA_INTERPOLATOR_H_ | |
| 6 #define MEDIA_BASE_TIME_DELTA_INTERPOLATOR_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/time/time.h" | |
| 10 #include "media/base/media_export.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class TickClock; | |
| 14 } // namespace base | |
| 15 | |
| 16 namespace media { | |
| 17 | |
| 18 // Interpolates between two TimeDeltas based on the passage of wall clock time | |
| 19 // and the current playback rate. | |
| 20 // | |
| 21 // TimeDeltaInterpolator is not thread-safe and must be externally locked. | |
| 22 class MEDIA_EXPORT TimeDeltaInterpolator { | |
| 23 public: | |
| 24 // Constructs an interpolator initialized to zero with a rate of 1.0. | |
| 25 // | |
| 26 // |tick_clock| is used for sampling wall clock time for interpolating. | |
| 27 explicit TimeDeltaInterpolator(base::TickClock* tick_clock); | |
| 28 ~TimeDeltaInterpolator(); | |
| 29 | |
| 30 bool interpolating() { return interpolating_; } | |
| 31 | |
| 32 // Starts returning interpolated TimeDelta values. | |
| 33 // | |
| 34 // |tick_clock| will be queried for a new reference time value. | |
| 35 base::TimeDelta StartInterpolating(); | |
| 36 | |
| 37 // Stops returning interpolated TimeDelta values. | |
| 38 // | |
| 39 // |tick_clock| will be queried for a new reference time value. | |
| 40 base::TimeDelta StopInterpolating(); | |
| 41 | |
| 42 // Sets a new rate at which to interpolate. | |
| 43 // | |
| 44 // |tick_clock| will be queried for a new reference time value. | |
| 45 void SetPlaybackRate(float playback_rate); | |
| 46 | |
| 47 // Sets the two timestamps to interpolate between at |playback_rate_|. | |
| 48 // |upper_bound| must be greater or equal to |lower_bound|. | |
| 49 // | |
| 50 // |upper_bound| is typically the media timestamp of the last audio frame | |
| 51 // buffered by the audio hardware. | |
| 52 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
| |
| 53 base::TimeDelta upper_bound); | |
| 54 | |
| 55 // Sets the upper bound used for interpolation. Note that if |upper_bound| is | |
| 56 // less than what was previously set via SetTime(), then all future calls | |
| 57 // to GetInterpolatedTime() will return |upper_bound|. | |
| 58 void SetUpperBound(base::TimeDelta upper_bound); | |
| 59 | |
| 60 // Computes an interpolated time based on SetTime(). | |
| 61 base::TimeDelta GetInterpolatedTime(); | |
| 62 | |
| 63 private: | |
| 64 base::TickClock* const tick_clock_; | |
| 65 | |
| 66 bool interpolating_; | |
| 67 | |
| 68 // The range of time to interpolate between. | |
| 69 base::TimeDelta lower_bound_; | |
| 70 base::TimeDelta upper_bound_; | |
| 71 | |
| 72 // The monotonic system clock time used for interpolating between | |
| 73 // |lower_bound_| and |upper_bound_|. | |
| 74 base::TimeTicks reference_; | |
| 75 | |
| 76 float playback_rate_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(TimeDeltaInterpolator); | |
| 79 }; | |
| 80 | |
| 81 } // namespace media | |
| 82 | |
| 83 #endif // MEDIA_BASE_TIME_DELTA_INTERPOLATOR_H_ | |
| OLD | NEW |