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 // SeekableBuffer to support backward and forward seeking in a buffer for | 5 // SeekableBuffer to support backward and forward seeking in a buffer for |
6 // reading a media data source. | 6 // reading a media data source. |
7 // | 7 // |
8 // In order to support backward and forward seeking, this class buffers data in | 8 // In order to support backward and forward seeking, this class buffers data in |
9 // both backward and forward directions, the current read position can be reset | 9 // both backward and forward directions, the current read position can be reset |
10 // to anywhere in the buffered data. | 10 // to anywhere in the buffered data. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 // Returns the maximum number of bytes that should be kept in the backward | 122 // Returns the maximum number of bytes that should be kept in the backward |
123 // direction. | 123 // direction. |
124 int backward_capacity() const { return backward_capacity_; } | 124 int backward_capacity() const { return backward_capacity_; } |
125 | 125 |
126 // Returns the current timestamp, taking into account current offset. The | 126 // Returns the current timestamp, taking into account current offset. The |
127 // value calculated based on the timestamp of the current buffer. If | 127 // value calculated based on the timestamp of the current buffer. If |
128 // timestamp for the current buffer is set to 0 or the data was added with | 128 // timestamp for the current buffer is set to 0 or the data was added with |
129 // Append(const uint*, int), then returns value that corresponds to the | 129 // Append(const uint*, int), then returns value that corresponds to the |
130 // last position in a buffer that had timestamp set. | 130 // last position in a buffer that had timestamp set. |
131 // kNoTimestamp() is returned if no buffers we read from had timestamp set. | 131 // kNoTimestamp is returned if no buffers we read from had timestamp set. |
132 base::TimeDelta current_time() const { return current_time_; } | 132 base::TimeDelta current_time() const { return current_time_; } |
133 | 133 |
134 private: | 134 private: |
135 // Definition of the buffer queue. | 135 // Definition of the buffer queue. |
136 typedef std::list<scoped_refptr<DataBuffer> > BufferQueue; | 136 typedef std::list<scoped_refptr<DataBuffer> > BufferQueue; |
137 | 137 |
138 // A helper method to evict buffers in the backward direction until backward | 138 // A helper method to evict buffers in the backward direction until backward |
139 // bytes is within the backward capacity. | 139 // bytes is within the backward capacity. |
140 void EvictBackwardBuffers(); | 140 void EvictBackwardBuffers(); |
141 | 141 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Keeps track of the most recent time we've seen in case the |buffers_| is | 180 // Keeps track of the most recent time we've seen in case the |buffers_| is |
181 // empty when our owner asks what time it is. | 181 // empty when our owner asks what time it is. |
182 base::TimeDelta current_time_; | 182 base::TimeDelta current_time_; |
183 | 183 |
184 DISALLOW_COPY_AND_ASSIGN(SeekableBuffer); | 184 DISALLOW_COPY_AND_ASSIGN(SeekableBuffer); |
185 }; | 185 }; |
186 | 186 |
187 } // namespace media | 187 } // namespace media |
188 | 188 |
189 #endif // MEDIA_BASE_SEEKABLE_BUFFER_H_ | 189 #endif // MEDIA_BASE_SEEKABLE_BUFFER_H_ |
OLD | NEW |