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/time/time.h" | 9 #include "base/time/time.h" |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // constant until Play() is called. | 47 // constant until Play() is called. |
48 base::TimeDelta Pause(); | 48 base::TimeDelta Pause(); |
49 | 49 |
50 // Sets a new playback rate. The rate at which the media time will increase | 50 // Sets a new playback rate. The rate at which the media time will increase |
51 // will now change. | 51 // will now change. |
52 void SetPlaybackRate(float playback_rate); | 52 void SetPlaybackRate(float playback_rate); |
53 | 53 |
54 // Forcefully sets the media time to |current_time|. The second parameter is | 54 // Forcefully sets the media time to |current_time|. The second parameter is |
55 // the |max_time| that the clock should progress after a call to Play(). This | 55 // the |max_time| that the clock should progress after a call to Play(). This |
56 // value is often the time of the end of the last frame buffered and decoded. | 56 // value is often the time of the end of the last frame buffered and decoded. |
57 // | |
58 // These values are clamped to the duration of the video, which is initially | |
59 // set to 0 (before SetDuration() is called). | |
60 void SetTime(base::TimeDelta current_time, base::TimeDelta max_time); | 57 void SetTime(base::TimeDelta current_time, base::TimeDelta max_time); |
61 | 58 |
62 // Sets the |max_time| to be returned by a call to Elapsed(). | 59 // Sets the |max_time| to be returned by a call to Elapsed(). |
63 void SetMaxTime(base::TimeDelta max_time); | 60 void SetMaxTime(base::TimeDelta max_time); |
64 | 61 |
65 // Returns the current elapsed media time. Returns 0 if SetDuration() has | 62 // Returns the current elapsed media time. |
66 // never been called. | |
67 base::TimeDelta Elapsed(); | 63 base::TimeDelta Elapsed(); |
68 | 64 |
69 // Sets the duration of the video. Clock expects the duration will be set | |
70 // exactly once. | |
71 void SetDuration(base::TimeDelta duration); | |
72 | |
73 // Returns the duration of the clock, or 0 if not set. | |
74 base::TimeDelta Duration() const; | |
75 | |
76 private: | 65 private: |
77 // Updates the reference points based on the current calculated time. | 66 // Updates the reference points based on the current calculated time. |
78 void UpdateReferencePoints(); | 67 void UpdateReferencePoints(); |
79 | 68 |
80 // Updates the reference points based on the given |current_time|. | 69 // Updates the reference points based on the given |current_time|. |
81 void UpdateReferencePoints(base::TimeDelta current_time); | 70 void UpdateReferencePoints(base::TimeDelta current_time); |
82 | 71 |
83 // Returns the time elapsed based on the current reference points, ignoring | 72 // Returns the time elapsed based on the current reference points, ignoring |
84 // the |max_time_| cap. | 73 // the |max_time_| cap. |
85 base::TimeDelta EstimatedElapsedTime(); | 74 base::TimeDelta EstimatedElapsedTime(); |
(...skipping 20 matching lines...) Expand all Loading... |
106 // Current accumulated amount of media time. The remaining portion must be | 95 // Current accumulated amount of media time. The remaining portion must be |
107 // calculated by comparing the system time to the reference time. | 96 // calculated by comparing the system time to the reference time. |
108 base::TimeDelta media_time_; | 97 base::TimeDelta media_time_; |
109 | 98 |
110 // Current playback rate. | 99 // Current playback rate. |
111 float playback_rate_; | 100 float playback_rate_; |
112 | 101 |
113 // The maximum time that can be returned by calls to Elapsed(). | 102 // The maximum time that can be returned by calls to Elapsed(). |
114 base::TimeDelta max_time_; | 103 base::TimeDelta max_time_; |
115 | 104 |
116 // Duration of the media. | |
117 base::TimeDelta duration_; | |
118 | |
119 DISALLOW_COPY_AND_ASSIGN(Clock); | 105 DISALLOW_COPY_AND_ASSIGN(Clock); |
120 }; | 106 }; |
121 | 107 |
122 } // namespace media | 108 } // namespace media |
123 | 109 |
124 #endif // MEDIA_BASE_CLOCK_H_ | 110 #endif // MEDIA_BASE_CLOCK_H_ |
OLD | NEW |