OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_FILTERS_AUDIO_CLOCK_H_ | 5 #ifndef MEDIA_FILTERS_AUDIO_CLOCK_H_ |
6 #define MEDIA_FILTERS_AUDIO_CLOCK_H_ | 6 #define MEDIA_FILTERS_AUDIO_CLOCK_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // | = 0 ms (media) | = 500 ms (media) | = 250 ms (media) | | 70 // | = 0 ms (media) | = 500 ms (media) | = 250 ms (media) | |
71 // +-----------------------+-----------------------+-----------------------+ | 71 // +-----------------------+-----------------------+-----------------------+ |
72 // ^ ^ | 72 // ^ ^ |
73 // front_timestamp() is equal to back_timestamp() is equal to | 73 // front_timestamp() is equal to back_timestamp() is equal to |
74 // |start_timestamp| since no amount of media frames tracked | 74 // |start_timestamp| since no amount of media frames tracked |
75 // media data has been played yet. by AudioClock, which would be | 75 // media data has been played yet. by AudioClock, which would be |
76 // 1000 + 500 + 250 = 1750 ms. | 76 // 1000 + 500 + 250 = 1750 ms. |
77 base::TimeDelta front_timestamp() const { return front_timestamp_; } | 77 base::TimeDelta front_timestamp() const { return front_timestamp_; } |
78 base::TimeDelta back_timestamp() const { return back_timestamp_; } | 78 base::TimeDelta back_timestamp() const { return back_timestamp_; } |
79 | 79 |
80 // Clients can provide |time_since_writing| to simulate the passage of time | |
81 // since last writing audio to get a more accurate current media timestamp. | |
82 // | |
83 // The value will be bounded between front_timestamp() and back_timestamp(). | |
84 base::TimeDelta TimestampSinceWriting( | |
85 base::TimeDelta time_since_writing) const; | |
86 | |
87 // Returns the amount of wall time until |timestamp| will be played by the | 80 // Returns the amount of wall time until |timestamp| will be played by the |
88 // audio hardware. | 81 // audio hardware. |
89 // | 82 // |
90 // |timestamp| must be within front_timestamp() and back_timestamp(). | 83 // |timestamp| must be within front_timestamp() and back_timestamp(). |
91 base::TimeDelta TimeUntilPlayback(base::TimeDelta timestamp) const; | 84 base::TimeDelta TimeUntilPlayback(base::TimeDelta timestamp) const; |
92 | 85 |
93 // Returns the amount of contiguous media time buffered at the head of the | 86 // Returns the amount of contiguous media time buffered at the head of the |
94 // audio hardware buffer. Silence introduced into the audio hardware buffer is | 87 // audio hardware buffer. Silence introduced into the audio hardware buffer is |
95 // treated as a break in media time. | 88 // treated as a break in media time. |
96 base::TimeDelta contiguous_audio_data_buffered() const { | 89 base::TimeDelta contiguous_audio_data_buffered() const { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Cached results of last call to WroteAudio(). | 126 // Cached results of last call to WroteAudio(). |
134 base::TimeDelta contiguous_audio_data_buffered_; | 127 base::TimeDelta contiguous_audio_data_buffered_; |
135 base::TimeDelta contiguous_audio_data_buffered_at_same_rate_; | 128 base::TimeDelta contiguous_audio_data_buffered_at_same_rate_; |
136 | 129 |
137 DISALLOW_COPY_AND_ASSIGN(AudioClock); | 130 DISALLOW_COPY_AND_ASSIGN(AudioClock); |
138 }; | 131 }; |
139 | 132 |
140 } // namespace media | 133 } // namespace media |
141 | 134 |
142 #endif // MEDIA_FILTERS_AUDIO_CLOCK_H_ | 135 #endif // MEDIA_FILTERS_AUDIO_CLOCK_H_ |
OLD | NEW |