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_AUDIO_TIMESTAMP_HELPER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_TIMESTAMP_HELPER_H_ |
6 #define MEDIA_BASE_AUDIO_TIMESTAMP_HELPER_H_ | 6 #define MEDIA_BASE_AUDIO_TIMESTAMP_HELPER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 explicit AudioTimestampHelper(int samples_per_second); | 33 explicit AudioTimestampHelper(int samples_per_second); |
34 | 34 |
35 // Sets the base timestamp to |base_timestamp| and the sets count to 0. | 35 // Sets the base timestamp to |base_timestamp| and the sets count to 0. |
36 void SetBaseTimestamp(base::TimeDelta base_timestamp); | 36 void SetBaseTimestamp(base::TimeDelta base_timestamp); |
37 | 37 |
38 base::TimeDelta base_timestamp() const; | 38 base::TimeDelta base_timestamp() const; |
39 int64_t frame_count() const { return frame_count_; } | 39 int64_t frame_count() const { return frame_count_; } |
40 | 40 |
41 // Adds |frame_count| to the frame counter. | 41 // Adds |frame_count| to the frame counter. |
42 // Note: SetBaseTimestamp() must be called with a value other than | 42 // Note: SetBaseTimestamp() must be called with a value other than |
43 // kNoTimestamp() before this method can be called. | 43 // kNoTimestamp before this method can be called. |
44 void AddFrames(int frame_count); | 44 void AddFrames(int frame_count); |
45 | 45 |
46 // Get the current timestamp. This value is computed from the base_timestamp() | 46 // Get the current timestamp. This value is computed from the base_timestamp() |
47 // and the number of sample frames that have been added so far. | 47 // and the number of sample frames that have been added so far. |
48 base::TimeDelta GetTimestamp() const; | 48 base::TimeDelta GetTimestamp() const; |
49 | 49 |
50 // Gets the duration if |frame_count| frames were added to the current | 50 // Gets the duration if |frame_count| frames were added to the current |
51 // timestamp reported by GetTimestamp(). This method ensures that | 51 // timestamp reported by GetTimestamp(). This method ensures that |
52 // (GetTimestamp() + GetFrameDuration(n)) will equal the timestamp that | 52 // (GetTimestamp() + GetFrameDuration(n)) will equal the timestamp that |
53 // GetTimestamp() will return if AddFrames(n) is called. | 53 // GetTimestamp() will return if AddFrames(n) is called. |
(...skipping 12 matching lines...) Expand all Loading... |
66 | 66 |
67 // Number of frames accumulated by AddFrames() calls. | 67 // Number of frames accumulated by AddFrames() calls. |
68 int64_t frame_count_; | 68 int64_t frame_count_; |
69 | 69 |
70 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioTimestampHelper); | 70 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioTimestampHelper); |
71 }; | 71 }; |
72 | 72 |
73 } // namespace media | 73 } // namespace media |
74 | 74 |
75 #endif // MEDIA_BASE_AUDIO_TIMESTAMP_HELPER_H_ | 75 #endif // MEDIA_BASE_AUDIO_TIMESTAMP_HELPER_H_ |
OLD | NEW |