| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc
e.html#sourcebuffer-coded-frame-removal | 84 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc
e.html#sourcebuffer-coded-frame-removal |
| 85 // | 85 // |
| 86 // |duration| is the current duration of the presentation. It is | 86 // |duration| is the current duration of the presentation. It is |
| 87 // required by the computation outlined in the spec. | 87 // required by the computation outlined in the spec. |
| 88 void Remove(base::TimeDelta start, base::TimeDelta end, | 88 void Remove(base::TimeDelta start, base::TimeDelta end, |
| 89 base::TimeDelta duration); | 89 base::TimeDelta duration); |
| 90 | 90 |
| 91 // Frees up space if the SourceBufferStream is taking up too much memory. | 91 // Frees up space if the SourceBufferStream is taking up too much memory. |
| 92 // |media_time| is current playback position. | 92 // |media_time| is current playback position. |
| 93 bool GarbageCollectIfNeeded(DecodeTimestamp media_time, | 93 bool GarbageCollectIfNeeded(DecodeTimestamp media_time, |
| 94 size_t newDataSize); | 94 size_t eviction_size, |
| 95 size_t* bytes_released = nullptr); |
| 95 | 96 |
| 96 // Changes the SourceBufferStream's state so that it will start returning | 97 // Changes the SourceBufferStream's state so that it will start returning |
| 97 // buffers starting from the closest keyframe before |timestamp|. | 98 // buffers starting from the closest keyframe before |timestamp|. |
| 98 void Seek(base::TimeDelta timestamp); | 99 void Seek(base::TimeDelta timestamp); |
| 99 | 100 |
| 100 // Returns true if the SourceBufferStream has seeked to a time without | 101 // Returns true if the SourceBufferStream has seeked to a time without |
| 101 // buffered data and is waiting for more data to be appended. | 102 // buffered data and is waiting for more data to be appended. |
| 102 bool IsSeekPending() const; | 103 bool IsSeekPending() const; |
| 103 | 104 |
| 104 // Notifies the SourceBufferStream that the media duration has been changed to | 105 // Notifies the SourceBufferStream that the media duration has been changed to |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 147 |
| 147 // Notifies this object that the video config has changed and buffers in | 148 // Notifies this object that the video config has changed and buffers in |
| 148 // future Append() calls should be associated with this new config. | 149 // future Append() calls should be associated with this new config. |
| 149 bool UpdateVideoConfig(const VideoDecoderConfig& config); | 150 bool UpdateVideoConfig(const VideoDecoderConfig& config); |
| 150 | 151 |
| 151 // Returns the largest distance between two adjacent buffers in this stream, | 152 // Returns the largest distance between two adjacent buffers in this stream, |
| 152 // or an estimate if no two adjacent buffers have been appended to the stream | 153 // or an estimate if no two adjacent buffers have been appended to the stream |
| 153 // yet. | 154 // yet. |
| 154 base::TimeDelta GetMaxInterbufferDistance() const; | 155 base::TimeDelta GetMaxInterbufferDistance() const; |
| 155 | 156 |
| 157 size_t memory_limit() const { return memory_limit_; } |
| 158 |
| 156 void set_memory_limit(size_t memory_limit) { | 159 void set_memory_limit(size_t memory_limit) { |
| 157 memory_limit_ = memory_limit; | 160 memory_limit_ = memory_limit; |
| 158 } | 161 } |
| 159 | 162 |
| 160 private: | 163 private: |
| 161 friend class SourceBufferStreamTest; | 164 friend class SourceBufferStreamTest; |
| 162 | 165 |
| 163 // Attempts to delete approximately |total_bytes_to_free| amount of data | 166 // Attempts to delete approximately |total_bytes_to_free| amount of data |
| 164 // |ranges_|, starting at the front of |ranges_| and moving linearly forward | 167 // |ranges_|, starting at the front of |ranges_| and moving linearly forward |
| 165 // through the buffers. Deletes starting from the back if |reverse_direction| | 168 // through the buffers. Deletes starting from the back if |reverse_direction| |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 int num_track_buffer_gap_warning_logs_ = 0; | 454 int num_track_buffer_gap_warning_logs_ = 0; |
| 452 int num_garbage_collect_algorithm_logs_ = 0; | 455 int num_garbage_collect_algorithm_logs_ = 0; |
| 453 int num_strange_same_timestamps_logs_ = 0; | 456 int num_strange_same_timestamps_logs_ = 0; |
| 454 | 457 |
| 455 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); | 458 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); |
| 456 }; | 459 }; |
| 457 | 460 |
| 458 } // namespace media | 461 } // namespace media |
| 459 | 462 |
| 460 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 463 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
| OLD | NEW |