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 // SourceBufferStream is a data structure that stores media Buffers in ranges. | 5 // SourceBufferStream is a data structure that stores media Buffers in ranges. |
6 // Buffers can be appended out of presentation order. Buffers are retrieved by | 6 // Buffers can be appended out of presentation order. Buffers are retrieved by |
7 // seeking to the desired start point and calling GetNextBuffer(). Buffers are | 7 // seeking to the desired start point and calling GetNextBuffer(). Buffers are |
8 // returned in sequential presentation order. | 8 // returned in sequential presentation order. |
9 | 9 |
10 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 10 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Notifies this object that the video config has changed and buffers in | 96 // Notifies this object that the video config has changed and buffers in |
97 // future Append() calls should be associated with this new config. | 97 // future Append() calls should be associated with this new config. |
98 bool UpdateVideoConfig(const VideoDecoderConfig& config); | 98 bool UpdateVideoConfig(const VideoDecoderConfig& config); |
99 | 99 |
100 // Returns the largest distance between two adjacent buffers in this stream, | 100 // Returns the largest distance between two adjacent buffers in this stream, |
101 // or an estimate if no two adjacent buffers have been appended to the stream | 101 // or an estimate if no two adjacent buffers have been appended to the stream |
102 // yet. | 102 // yet. |
103 base::TimeDelta GetMaxInterbufferDistance() const; | 103 base::TimeDelta GetMaxInterbufferDistance() const; |
104 | 104 |
105 private: | 105 private: |
| 106 friend class SourceBufferStreamTest; |
106 typedef std::list<SourceBufferRange*> RangeList; | 107 typedef std::list<SourceBufferRange*> RangeList; |
107 | 108 |
| 109 void set_memory_limit(int memory_limit) { memory_limit_ = memory_limit; } |
| 110 |
| 111 // Frees up space if the SourceBufferStream is taking up too much memory. |
| 112 void GarbageCollectIfNeeded(); |
| 113 |
108 // Appends |new_buffers| into |range_for_new_buffers_itr|, handling start and | 114 // Appends |new_buffers| into |range_for_new_buffers_itr|, handling start and |
109 // end overlaps if necessary. | 115 // end overlaps if necessary. |
110 // |deleted_next_buffer| is an output parameter that is true if the next | 116 // |deleted_next_buffer| is an output parameter that is true if the next |
111 // buffer that would have been returned from GetNextBuffer() was deleted | 117 // buffer that would have been returned from GetNextBuffer() was deleted |
112 // during this call. | 118 // during this call. |
113 // |deleted_buffers| is an output parameter containing candidates for | 119 // |deleted_buffers| is an output parameter containing candidates for |
114 // |track_buffer_|. | 120 // |track_buffer_|. |
115 void InsertIntoExistingRange( | 121 void InsertIntoExistingRange( |
116 const RangeList::iterator& range_for_new_buffers_itr, | 122 const RangeList::iterator& range_for_new_buffers_itr, |
117 const BufferQueue& new_buffers, | 123 const BufferQueue& new_buffers, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // True when the next call to Append() begins a new media segment. | 251 // True when the next call to Append() begins a new media segment. |
246 bool new_media_segment_; | 252 bool new_media_segment_; |
247 | 253 |
248 // The timestamp of the last buffer appended to the media segment, set to | 254 // The timestamp of the last buffer appended to the media segment, set to |
249 // kNoTimestamp() if the beginning of the segment. | 255 // kNoTimestamp() if the beginning of the segment. |
250 base::TimeDelta last_buffer_timestamp_; | 256 base::TimeDelta last_buffer_timestamp_; |
251 | 257 |
252 // Stores the largest distance between two adjacent buffers in this stream. | 258 // Stores the largest distance between two adjacent buffers in this stream. |
253 base::TimeDelta max_interbuffer_distance_; | 259 base::TimeDelta max_interbuffer_distance_; |
254 | 260 |
| 261 // The maximum amount of data in bytes the stream will keep in memory. |
| 262 int memory_limit_; |
| 263 |
255 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); | 264 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); |
256 }; | 265 }; |
257 | 266 |
258 } // namespace media | 267 } // namespace media |
259 | 268 |
260 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 269 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
OLD | NEW |