Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_CLOCK_H_ | 5 #ifndef MEDIA_BASE_CLOCK_H_ |
| 6 #define MEDIA_BASE_CLOCK_H_ | 6 #define MEDIA_BASE_CLOCK_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 base::TimeDelta Play(); | 41 base::TimeDelta Play(); |
| 42 | 42 |
| 43 // Stops the clock and returns the current media time, which will remain | 43 // Stops the clock and returns the current media time, which will remain |
| 44 // constant until Play() is called. | 44 // constant until Play() is called. |
| 45 base::TimeDelta Pause(); | 45 base::TimeDelta Pause(); |
| 46 | 46 |
| 47 // Sets a new playback rate. The rate at which the media time will increase | 47 // Sets a new playback rate. The rate at which the media time will increase |
| 48 // will now change. | 48 // will now change. |
| 49 void SetPlaybackRate(float playback_rate); | 49 void SetPlaybackRate(float playback_rate); |
| 50 | 50 |
| 51 // Forcefully sets the media time to the given time. This should only be used | 51 // Forcefully sets the media time to |current_time|. The second parameter is |
| 52 // where a discontinuity in the media is found (i.e., seeking). | 52 // the |max_time| that the clock should progress after a call to Play(). This |
| 53 void SetTime(const base::TimeDelta& time); | 53 // value is often the time of the end of the last frame buffered and decoded. |
| 54 void SetTime(base::TimeDelta current_time, base::TimeDelta max_time); | |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
Comment should mention that the values are clamped
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Done.
| |
| 55 | |
| 56 void set_max_time(base::TimeDelta max_time) { | |
| 57 max_time_ = max_time; | |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
Implementation should be in .cc & should be clampe
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Done.
| |
| 58 } | |
| 54 | 59 |
| 55 // Returns the current elapsed media time. | 60 // Returns the current elapsed media time. |
| 56 base::TimeDelta Elapsed() const; | 61 base::TimeDelta Elapsed() const; |
| 57 | 62 |
| 63 void set_media_duration(base::TimeDelta duration) { duration_ = duration; } | |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
How about dropping media?
Impl in .cc & DCHECK(dur
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Done.
| |
| 64 base::TimeDelta media_duration() { return duration_; } | |
| 65 | |
| 58 private: | 66 private: |
| 59 // Returns the current media time treating the given time as the latest | 67 // Returns the current media time treating the given time as the latest |
| 60 // value as returned by |time_provider_|. | 68 // value as returned by |time_provider_|. |
| 61 base::TimeDelta ElapsedViaProvidedTime(const base::Time& time) const; | 69 base::TimeDelta ElapsedViaProvidedTime(const base::Time& time) const; |
| 62 | 70 |
| 63 base::Time GetTimeFromProvider() const; | 71 base::Time GetTimeFromProvider() const; |
| 64 | 72 |
| 65 // Function returning current time in base::Time units. | 73 // Function returning current time in base::Time units. |
| 66 TimeProvider* time_provider_; | 74 TimeProvider* time_provider_; |
| 67 | 75 |
| 68 // Whether the clock is running. | 76 // Whether the clock is running. |
| 69 bool playing_; | 77 bool playing_; |
| 70 | 78 |
| 71 // The system clock time when this clock last starting playing or had its | 79 // The system clock time when this clock last starting playing or had its |
| 72 // time set via SetTime(). | 80 // time set via SetTime(). |
| 73 base::Time reference_; | 81 base::Time reference_; |
| 74 | 82 |
| 75 // Current accumulated amount of media time. The remaining portion must be | 83 // Current accumulated amount of media time. The remaining portion must be |
| 76 // calculated by comparing the system time to the reference time. | 84 // calculated by comparing the system time to the reference time. |
| 77 base::TimeDelta media_time_; | 85 base::TimeDelta media_time_; |
| 78 | 86 |
| 79 // Current playback rate. | 87 // Current playback rate. |
| 80 float playback_rate_; | 88 float playback_rate_; |
| 81 | 89 |
| 90 // The maximum time that can be returned by calls to GetCurrentTime. | |
| 91 base::TimeDelta max_time_; | |
| 92 | |
| 93 // Duration of the media. | |
| 94 base::TimeDelta duration_; | |
| 95 | |
| 82 DISALLOW_COPY_AND_ASSIGN(Clock); | 96 DISALLOW_COPY_AND_ASSIGN(Clock); |
| 83 }; | 97 }; |
| 84 | 98 |
| 85 } // namespace media | 99 } // namespace media |
| 86 | 100 |
| 87 #endif // MEDIA_BASE_CLOCK_H_ | 101 #endif // MEDIA_BASE_CLOCK_H_ |
| OLD | NEW |