Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: media/filters/source_buffer_stream.h

Issue 1008463002: Fix MSE GC, make it less aggressive, more spec-compliant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A bit more informative logging + fixed unit test Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Removes buffers between |start| and |end| according to the steps 83 // Removes buffers between |start| and |end| according to the steps
84 // in the "Coded Frame Removal Algorithm" in the Media Source 84 // in the "Coded Frame Removal Algorithm" in the Media Source
85 // Extensions Spec. 85 // Extensions Spec.
86 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal 86 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal
87 // 87 //
88 // |duration| is the current duration of the presentation. It is 88 // |duration| is the current duration of the presentation. It is
89 // required by the computation outlined in the spec. 89 // required by the computation outlined in the spec.
90 void Remove(base::TimeDelta start, base::TimeDelta end, 90 void Remove(base::TimeDelta start, base::TimeDelta end,
91 base::TimeDelta duration); 91 base::TimeDelta duration);
92 92
93 // Frees up space if the SourceBufferStream is taking up too much memory.
94 // |media_time| is current playback position.
95 bool GarbageCollectIfNeeded(DecodeTimestamp media_time);
96
93 // Changes the SourceBufferStream's state so that it will start returning 97 // Changes the SourceBufferStream's state so that it will start returning
94 // buffers starting from the closest keyframe before |timestamp|. 98 // buffers starting from the closest keyframe before |timestamp|.
95 void Seek(base::TimeDelta timestamp); 99 void Seek(base::TimeDelta timestamp);
96 100
97 // Returns true if the SourceBufferStream has seeked to a time without 101 // Returns true if the SourceBufferStream has seeked to a time without
98 // buffered data and is waiting for more data to be appended. 102 // buffered data and is waiting for more data to be appended.
99 bool IsSeekPending() const; 103 bool IsSeekPending() const;
100 104
101 // Notifies the SourceBufferStream that the media duration has been changed to 105 // Notifies the SourceBufferStream that the media duration has been changed to
102 // |duration| so it should drop any data past that point. 106 // |duration| so it should drop any data past that point.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // yet. 147 // yet.
144 base::TimeDelta GetMaxInterbufferDistance() const; 148 base::TimeDelta GetMaxInterbufferDistance() const;
145 149
146 void set_memory_limit(size_t memory_limit) { 150 void set_memory_limit(size_t memory_limit) {
147 memory_limit_ = memory_limit; 151 memory_limit_ = memory_limit;
148 } 152 }
149 153
150 private: 154 private:
151 friend class SourceBufferStreamTest; 155 friend class SourceBufferStreamTest;
152 156
153 // Frees up space if the SourceBufferStream is taking up too much memory.
154 void GarbageCollectIfNeeded();
155
156 // Attempts to delete approximately |total_bytes_to_free| amount of data 157 // Attempts to delete approximately |total_bytes_to_free| amount of data
157 // |ranges_|, starting at the front of |ranges_| and moving linearly forward 158 // |ranges_|, starting at the front of |ranges_| and moving linearly forward
158 // through the buffers. Deletes starting from the back if |reverse_direction| 159 // through the buffers. Deletes starting from the back if |reverse_direction|
159 // is true. Returns the number of bytes freed. 160 // is true. |media_time| is current playback position.
160 size_t FreeBuffers(size_t total_bytes_to_free, bool reverse_direction); 161 // Returns the number of bytes freed.
162 size_t FreeBuffers(size_t total_bytes_to_free,
163 DecodeTimestamp media_time,
164 bool reverse_direction);
161 165
162 // Attempts to delete approximately |total_bytes_to_free| amount of data from 166 // Attempts to delete approximately |total_bytes_to_free| amount of data from
163 // |ranges_|, starting after the last appended buffer before the current 167 // |ranges_|, starting after the last appended buffer before the current
164 // playback position. 168 // playback position |media_time|.
165 size_t FreeBuffersAfterLastAppended(size_t total_bytes_to_free); 169 size_t FreeBuffersAfterLastAppended(size_t total_bytes_to_free,
170 DecodeTimestamp media_time);
166 171
167 // Gets the removal range to secure |byte_to_free| from 172 // Gets the removal range to secure |byte_to_free| from
168 // [|start_timestamp|, |end_timestamp|). 173 // [|start_timestamp|, |end_timestamp|).
169 // Returns the size of buffers to secure if future 174 // Returns the size of buffers to secure if future
170 // Remove(|start_timestamp|, |removal_end_timestamp|, duration) is called. 175 // Remove(|start_timestamp|, |removal_end_timestamp|, duration) is called.
171 // Will not update |removal_end_timestamp| if the returned size is 0. 176 // Will not update |removal_end_timestamp| if the returned size is 0.
172 size_t GetRemovalRange(DecodeTimestamp start_timestamp, 177 size_t GetRemovalRange(DecodeTimestamp start_timestamp,
173 DecodeTimestamp end_timestamp, size_t byte_to_free, 178 DecodeTimestamp end_timestamp, size_t byte_to_free,
174 DecodeTimestamp* removal_end_timestamp); 179 DecodeTimestamp* removal_end_timestamp);
175 180
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // successes logged. 429 // successes logged.
425 int num_splice_generation_warning_logs_; 430 int num_splice_generation_warning_logs_;
426 int num_splice_generation_success_logs_; 431 int num_splice_generation_success_logs_;
427 432
428 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 433 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
429 }; 434 };
430 435
431 } // namespace media 436 } // namespace media
432 437
433 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 438 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698