| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 size_t forward_capacity() const { return forward_capacity_; } | 104 size_t forward_capacity() const { return forward_capacity_; } |
| 105 | 105 |
| 106 // Returns the maximum number of bytes that should be kept in the backward | 106 // Returns the maximum number of bytes that should be kept in the backward |
| 107 // direction. | 107 // direction. |
| 108 size_t backward_capacity() const { return backward_capacity_; } | 108 size_t backward_capacity() const { return backward_capacity_; } |
| 109 | 109 |
| 110 // Returns the current timestamp, taking into account current offset. The | 110 // Returns the current timestamp, taking into account current offset. The |
| 111 // value calculated based on the timestamp of the current buffer. If | 111 // value calculated based on the timestamp of the current buffer. If |
| 112 // timestamp for the current buffer is set to 0 or the data was added with | 112 // timestamp for the current buffer is set to 0 or the data was added with |
| 113 // Append(const uint*, size_t), then returns value that corresponds to the | 113 // Append(const uint*, size_t), then returns value that corresponds to the |
| 114 // last position in a buffer that had timestamp set. 0 is returned if no | 114 // last position in a buffer that had timestamp set. |
| 115 // buffers we read from had timestamp set. | 115 // StreamSample::kInvalidTimestamp is returned if no buffers we read |
| 116 // TODO(sergeyu): Use StreamSample::kInvalidTimestamp here. | 116 // from had timestamp set. |
| 117 base::TimeDelta current_time() const { return current_time_; } | 117 base::TimeDelta current_time() const { return current_time_; } |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 // Definition of the buffer queue. | 120 // Definition of the buffer queue. |
| 121 typedef std::list<scoped_refptr<Buffer> > BufferQueue; | 121 typedef std::list<scoped_refptr<Buffer> > BufferQueue; |
| 122 | 122 |
| 123 // A helper method to evict buffers in the backward direction until backward | 123 // A helper method to evict buffers in the backward direction until backward |
| 124 // bytes is within the backward capacity. | 124 // bytes is within the backward capacity. |
| 125 void EvictBackwardBuffers(); | 125 void EvictBackwardBuffers(); |
| 126 | 126 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Keeps track of the most recent time we've seen in case the |buffers_| is | 162 // Keeps track of the most recent time we've seen in case the |buffers_| is |
| 163 // empty when our owner asks what time it is. | 163 // empty when our owner asks what time it is. |
| 164 base::TimeDelta current_time_; | 164 base::TimeDelta current_time_; |
| 165 | 165 |
| 166 DISALLOW_COPY_AND_ASSIGN(SeekableBuffer); | 166 DISALLOW_COPY_AND_ASSIGN(SeekableBuffer); |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 } // namespace media | 169 } // namespace media |
| 170 | 170 |
| 171 #endif // MEDIA_BASE_SEEKABLE_BUFFER_H_ | 171 #endif // MEDIA_BASE_SEEKABLE_BUFFER_H_ |
| OLD | NEW |