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

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

Issue 1235403002: Change ChunkDemuxerStream/SourceBufferStream memory limit to size_t type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A few more minor fixes Created 5 years, 5 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
« no previous file with comments | « media/filters/source_buffer_range.cc ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
11 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 11 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
12 12
13 #include <deque> 13 #include <deque>
14 #include <list> 14 #include <list>
15 #include <string> 15 #include <string>
16 #include <utility> 16 #include <utility>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/basictypes.h"
19 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
20 #include "media/base/audio_decoder_config.h" 21 #include "media/base/audio_decoder_config.h"
21 #include "media/base/media_export.h" 22 #include "media/base/media_export.h"
22 #include "media/base/media_log.h" 23 #include "media/base/media_log.h"
23 #include "media/base/ranges.h" 24 #include "media/base/ranges.h"
24 #include "media/base/stream_parser_buffer.h" 25 #include "media/base/stream_parser_buffer.h"
25 #include "media/base/text_track_config.h" 26 #include "media/base/text_track_config.h"
26 #include "media/base/video_decoder_config.h" 27 #include "media/base/video_decoder_config.h"
27 28
28 namespace media { 29 namespace media {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 136
136 // Notifies this object that the video config has changed and buffers in 137 // Notifies this object that the video config has changed and buffers in
137 // future Append() calls should be associated with this new config. 138 // future Append() calls should be associated with this new config.
138 bool UpdateVideoConfig(const VideoDecoderConfig& config); 139 bool UpdateVideoConfig(const VideoDecoderConfig& config);
139 140
140 // Returns the largest distance between two adjacent buffers in this stream, 141 // Returns the largest distance between two adjacent buffers in this stream,
141 // or an estimate if no two adjacent buffers have been appended to the stream 142 // or an estimate if no two adjacent buffers have been appended to the stream
142 // yet. 143 // yet.
143 base::TimeDelta GetMaxInterbufferDistance() const; 144 base::TimeDelta GetMaxInterbufferDistance() const;
144 145
145 void set_memory_limit(int memory_limit) { 146 void set_memory_limit(size_t memory_limit) {
146 memory_limit_ = memory_limit; 147 memory_limit_ = memory_limit;
147 } 148 }
148 149
149 private: 150 private:
150 friend class SourceBufferStreamTest; 151 friend class SourceBufferStreamTest;
151 152
152 // Frees up space if the SourceBufferStream is taking up too much memory. 153 // Frees up space if the SourceBufferStream is taking up too much memory.
153 void GarbageCollectIfNeeded(); 154 void GarbageCollectIfNeeded();
154 155
155 // Attempts to delete approximately |total_bytes_to_free| amount of data 156 // Attempts to delete approximately |total_bytes_to_free| amount of data
156 // |ranges_|, starting at the front of |ranges_| and moving linearly forward 157 // |ranges_|, starting at the front of |ranges_| and moving linearly forward
157 // through the buffers. Deletes starting from the back if |reverse_direction| 158 // through the buffers. Deletes starting from the back if |reverse_direction|
158 // is true. Returns the number of bytes freed. 159 // is true. Returns the number of bytes freed.
159 int FreeBuffers(int total_bytes_to_free, bool reverse_direction); 160 size_t FreeBuffers(size_t total_bytes_to_free, bool reverse_direction);
160 161
161 // Attempts to delete approximately |total_bytes_to_free| amount of data from 162 // Attempts to delete approximately |total_bytes_to_free| amount of data from
162 // |ranges_|, starting after the last appended buffer before the current 163 // |ranges_|, starting after the last appended buffer before the current
163 // playback position. 164 // playback position.
164 int FreeBuffersAfterLastAppended(int total_bytes_to_free); 165 size_t FreeBuffersAfterLastAppended(size_t total_bytes_to_free);
165 166
166 // Gets the removal range to secure |byte_to_free| from 167 // Gets the removal range to secure |byte_to_free| from
167 // [|start_timestamp|, |end_timestamp|). 168 // [|start_timestamp|, |end_timestamp|).
168 // Returns the size of buffers to secure if future 169 // Returns the size of buffers to secure if future
169 // Remove(|start_timestamp|, |removal_end_timestamp|, duration) is called. 170 // Remove(|start_timestamp|, |removal_end_timestamp|, duration) is called.
170 // Will not update |removal_end_timestamp| if the returned size is 0. 171 // Will not update |removal_end_timestamp| if the returned size is 0.
171 int GetRemovalRange(DecodeTimestamp start_timestamp, 172 size_t GetRemovalRange(DecodeTimestamp start_timestamp,
172 DecodeTimestamp end_timestamp, int byte_to_free, 173 DecodeTimestamp end_timestamp, size_t byte_to_free,
173 DecodeTimestamp* removal_end_timestamp); 174 DecodeTimestamp* removal_end_timestamp);
174 175
175 // Prepares |range_for_next_append_| so |new_buffers| can be appended. 176 // Prepares |range_for_next_append_| so |new_buffers| can be appended.
176 // This involves removing buffers between the end of the previous append 177 // This involves removing buffers between the end of the previous append
177 // and any buffers covered by the time range in |new_buffers|. 178 // and any buffers covered by the time range in |new_buffers|.
178 // |deleted_buffers| is an output parameter containing candidates for 179 // |deleted_buffers| is an output parameter containing candidates for
179 // |track_buffer_| if this method ends up removing the current playback 180 // |track_buffer_| if this method ends up removing the current playback
180 // position from the range. 181 // position from the range.
181 void PrepareRangesForNextAppend(const BufferQueue& new_buffers, 182 void PrepareRangesForNextAppend(const BufferQueue& new_buffers,
182 BufferQueue* deleted_buffers); 183 BufferQueue* deleted_buffers);
183 184
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 390
390 // The decode timestamp on the last buffer returned by the most recent 391 // The decode timestamp on the last buffer returned by the most recent
391 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't 392 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't
392 // been called yet or a seek has happened since the last GetNextBuffer() call. 393 // been called yet or a seek has happened since the last GetNextBuffer() call.
393 DecodeTimestamp last_output_buffer_timestamp_; 394 DecodeTimestamp last_output_buffer_timestamp_;
394 395
395 // Stores the largest distance between two adjacent buffers in this stream. 396 // Stores the largest distance between two adjacent buffers in this stream.
396 base::TimeDelta max_interbuffer_distance_; 397 base::TimeDelta max_interbuffer_distance_;
397 398
398 // The maximum amount of data in bytes the stream will keep in memory. 399 // The maximum amount of data in bytes the stream will keep in memory.
399 int memory_limit_; 400 size_t memory_limit_;
400 401
401 // Indicates that a kConfigChanged status has been reported by GetNextBuffer() 402 // Indicates that a kConfigChanged status has been reported by GetNextBuffer()
402 // and GetCurrentXXXDecoderConfig() must be called to update the current 403 // and GetCurrentXXXDecoderConfig() must be called to update the current
403 // config. GetNextBuffer() must not be called again until 404 // config. GetNextBuffer() must not be called again until
404 // GetCurrentXXXDecoderConfig() has been called. 405 // GetCurrentXXXDecoderConfig() has been called.
405 bool config_change_pending_; 406 bool config_change_pending_;
406 407
407 // Used by HandleNextBufferWithSplice() or HandleNextBufferWithPreroll() when 408 // Used by HandleNextBufferWithSplice() or HandleNextBufferWithPreroll() when
408 // a splice frame buffer or buffer with preroll is returned from 409 // a splice frame buffer or buffer with preroll is returned from
409 // GetNextBufferInternal(). 410 // GetNextBufferInternal().
410 scoped_refptr<StreamParserBuffer> pending_buffer_; 411 scoped_refptr<StreamParserBuffer> pending_buffer_;
411 412
412 // Indicates which of the splice buffers in |splice_buffer_| should be 413 // Indicates which of the splice buffers in |splice_buffer_| should be
413 // handled out next. 414 // handled out next.
414 size_t splice_buffers_index_; 415 size_t splice_buffers_index_;
415 416
416 // Indicates that all buffers before |pending_buffer_| have been handed out. 417 // Indicates that all buffers before |pending_buffer_| have been handed out.
417 bool pending_buffers_complete_; 418 bool pending_buffers_complete_;
418 419
419 // Indicates that splice frame generation is enabled. 420 // Indicates that splice frame generation is enabled.
420 const bool splice_frames_enabled_; 421 const bool splice_frames_enabled_;
421 422
422 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 423 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
423 }; 424 };
424 425
425 } // namespace media 426 } // namespace media
426 427
427 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 428 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW
« no previous file with comments | « media/filters/source_buffer_range.cc ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698