OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
11 #include "media/base/media_export.h" | |
12 | 11 |
13 namespace media { | 12 namespace media { |
14 | 13 |
15 // A clock represents a single source of time to allow audio and video streams | 14 // A clock represents a single source of time to allow audio and video streams |
16 // to synchronize with each other. Clock essentially tracks the media time with | 15 // to synchronize with each other. Clock essentially tracks the media time with |
17 // respect to some other source of time, whether that may be the system clock or | 16 // respect to some other source of time, whether that may be the system clock or |
18 // updates via SetTime(). Clock uses linear interpolation to calculate the | 17 // updates via SetTime(). Clock uses linear interpolation to calculate the |
19 // current media time since the last time SetTime() was called. | 18 // current media time since the last time SetTime() was called. |
20 // | 19 // |
21 // Clocks start off paused with a playback rate of 1.0f and a media time of 0. | 20 // Clocks start off paused with a playback rate of 1.0f and a media time of 0. |
22 // | 21 // |
23 // Clock is not thread-safe and must be externally locked. | 22 // Clock is not thread-safe and must be externally locked. |
24 // | 23 // |
25 // TODO(scherkus): Clock will some day be responsible for executing callbacks | 24 // TODO(scherkus): Clock will some day be responsible for executing callbacks |
26 // given a media time. This will be used primarily by video renderers. For now | 25 // given a media time. This will be used primarily by video renderers. For now |
27 // we'll keep using a poll-and-sleep solution. | 26 // we'll keep using a poll-and-sleep solution. |
28 class MEDIA_EXPORT Clock { | 27 class Clock { |
29 public: | 28 public: |
30 // Type for a static function pointer that acts as a time source. | 29 // Type for a static function pointer that acts as a time source. |
31 typedef base::Time(TimeProvider)(); | 30 typedef base::Time(TimeProvider)(); |
32 | 31 |
33 Clock(TimeProvider* time_provider); | 32 Clock(TimeProvider* time_provider); |
34 ~Clock(); | 33 ~Clock(); |
35 | 34 |
36 // Starts the clock and returns the current media time, which will increase | 35 // Starts the clock and returns the current media time, which will increase |
37 // with respect to the current playback rate. | 36 // with respect to the current playback rate. |
38 base::TimeDelta Play(); | 37 base::TimeDelta Play(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 74 |
76 // Current playback rate. | 75 // Current playback rate. |
77 float playback_rate_; | 76 float playback_rate_; |
78 | 77 |
79 DISALLOW_COPY_AND_ASSIGN(Clock); | 78 DISALLOW_COPY_AND_ASSIGN(Clock); |
80 }; | 79 }; |
81 | 80 |
82 } // namespace media | 81 } // namespace media |
83 | 82 |
84 #endif // MEDIA_BASE_CLOCK_H_ | 83 #endif // MEDIA_BASE_CLOCK_H_ |
OLD | NEW |