| 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 // 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 // Returns the maximum number of bytes that should be kept in the backward | 115 // Returns the maximum number of bytes that should be kept in the backward |
| 116 // direction. | 116 // direction. |
| 117 size_t backward_capacity() const { return backward_capacity_; } | 117 size_t backward_capacity() const { return backward_capacity_; } |
| 118 | 118 |
| 119 // Returns the current timestamp, taking into account current offset. The | 119 // Returns the current timestamp, taking into account current offset. The |
| 120 // value calculated based on the timestamp of the current buffer. If | 120 // value calculated based on the timestamp of the current buffer. If |
| 121 // timestamp for the current buffer is set to 0 or the data was added with | 121 // timestamp for the current buffer is set to 0 or the data was added with |
| 122 // Append(const uint*, size_t), then returns value that corresponds to the | 122 // Append(const uint*, size_t), then returns value that corresponds to the |
| 123 // last position in a buffer that had timestamp set. | 123 // last position in a buffer that had timestamp set. |
| 124 // kNoTimestamp is returned if no buffers we read from had timestamp set. | 124 // kNoTimestamp() is returned if no buffers we read from had timestamp set. |
| 125 base::TimeDelta current_time() const { return current_time_; } | 125 base::TimeDelta current_time() const { return current_time_; } |
| 126 | 126 |
| 127 private: | 127 private: |
| 128 // Definition of the buffer queue. | 128 // Definition of the buffer queue. |
| 129 typedef std::list<scoped_refptr<Buffer> > BufferQueue; | 129 typedef std::list<scoped_refptr<Buffer> > BufferQueue; |
| 130 | 130 |
| 131 // A helper method to evict buffers in the backward direction until backward | 131 // A helper method to evict buffers in the backward direction until backward |
| 132 // bytes is within the backward capacity. | 132 // bytes is within the backward capacity. |
| 133 void EvictBackwardBuffers(); | 133 void EvictBackwardBuffers(); |
| 134 | 134 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // Keeps track of the most recent time we've seen in case the |buffers_| is | 170 // Keeps track of the most recent time we've seen in case the |buffers_| is |
| 171 // empty when our owner asks what time it is. | 171 // empty when our owner asks what time it is. |
| 172 base::TimeDelta current_time_; | 172 base::TimeDelta current_time_; |
| 173 | 173 |
| 174 DISALLOW_COPY_AND_ASSIGN(SeekableBuffer); | 174 DISALLOW_COPY_AND_ASSIGN(SeekableBuffer); |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 } // namespace media | 177 } // namespace media |
| 178 | 178 |
| 179 #endif // MEDIA_BASE_SEEKABLE_BUFFER_H_ | 179 #endif // MEDIA_BASE_SEEKABLE_BUFFER_H_ |
| OLD | NEW |