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