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

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

Issue 789983003: Implement evictFrames() to support MSE's coded frame eviction algorithm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Removes buffers between |start| and |end| according to the steps 82 // Removes buffers between |start| and |end| according to the steps
83 // in the "Coded Frame Removal Algorithm" in the Media Source 83 // in the "Coded Frame Removal Algorithm" in the Media Source
84 // Extensions Spec. 84 // Extensions Spec.
85 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal 85 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal
86 // 86 //
87 // |duration| is the current duration of the presentation. It is 87 // |duration| is the current duration of the presentation. It is
88 // required by the computation outlined in the spec. 88 // required by the computation outlined in the spec.
89 void Remove(base::TimeDelta start, base::TimeDelta end, 89 void Remove(base::TimeDelta start, base::TimeDelta end,
90 base::TimeDelta duration); 90 base::TimeDelta duration);
91 91
92 // Frees up space if the SourceBufferStream is taking up too much memory.
93 bool GarbageCollectIfNeeded();
94
92 // Changes the SourceBufferStream's state so that it will start returning 95 // Changes the SourceBufferStream's state so that it will start returning
93 // buffers starting from the closest keyframe before |timestamp|. 96 // buffers starting from the closest keyframe before |timestamp|.
94 void Seek(base::TimeDelta timestamp); 97 void Seek(base::TimeDelta timestamp);
95 98
96 // Returns true if the SourceBufferStream has seeked to a time without 99 // Returns true if the SourceBufferStream has seeked to a time without
97 // buffered data and is waiting for more data to be appended. 100 // buffered data and is waiting for more data to be appended.
98 bool IsSeekPending() const; 101 bool IsSeekPending() const;
99 102
100 // Notifies the SourceBufferStream that the media duration has been changed to 103 // Notifies the SourceBufferStream that the media duration has been changed to
101 // |duration| so it should drop any data past that point. 104 // |duration| so it should drop any data past that point.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // yet. 145 // yet.
143 base::TimeDelta GetMaxInterbufferDistance() const; 146 base::TimeDelta GetMaxInterbufferDistance() const;
144 147
145 void set_memory_limit(int memory_limit) { 148 void set_memory_limit(int memory_limit) {
146 memory_limit_ = memory_limit; 149 memory_limit_ = memory_limit;
147 } 150 }
148 151
149 private: 152 private:
150 friend class SourceBufferStreamTest; 153 friend class SourceBufferStreamTest;
151 154
152 // Frees up space if the SourceBufferStream is taking up too much memory.
153 void GarbageCollectIfNeeded();
154
155 // Attempts to delete approximately |total_bytes_to_free| amount of data 155 // Attempts to delete approximately |total_bytes_to_free| amount of data
156 // |ranges_|, starting at the front of |ranges_| and moving linearly forward 156 // |ranges_|, starting at the front of |ranges_| and moving linearly forward
157 // through the buffers. Deletes starting from the back if |reverse_direction| 157 // through the buffers. Deletes starting from the back if |reverse_direction|
158 // is true. Returns the number of bytes freed. 158 // is true. Returns the number of bytes freed.
159 int FreeBuffers(int total_bytes_to_free, bool reverse_direction); 159 int FreeBuffers(int total_bytes_to_free, bool reverse_direction);
160 160
161 // Attempts to delete approximately |total_bytes_to_free| amount of data from 161 // Attempts to delete approximately |total_bytes_to_free| amount of data from
162 // |ranges_|, starting after the last appended buffer before the current 162 // |ranges_|, starting after the last appended buffer before the current
163 // playback position. 163 // playback position.
164 int FreeBuffersAfterLastAppended(int total_bytes_to_free); 164 int FreeBuffersAfterLastAppended(int total_bytes_to_free);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 // Indicates that splice frame generation is enabled. 415 // Indicates that splice frame generation is enabled.
416 const bool splice_frames_enabled_; 416 const bool splice_frames_enabled_;
417 417
418 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 418 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
419 }; 419 };
420 420
421 } // namespace media 421 } // namespace media
422 422
423 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 423 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698