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_ |
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 Loading... | |
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 SetMemoryLimit(size_t memory_limit); |
ddorwin
2015/07/20 21:23:57
If all this does is set a member variable, then th
servolk
2015/07/22 19:02:11
Done.
| |
146 memory_limit_ = memory_limit; | |
147 } | |
148 | 147 |
149 private: | 148 private: |
150 friend class SourceBufferStreamTest; | 149 friend class SourceBufferStreamTest; |
151 | 150 |
152 // Frees up space if the SourceBufferStream is taking up too much memory. | 151 // Frees up space if the SourceBufferStream is taking up too much memory. |
153 void GarbageCollectIfNeeded(); | 152 void GarbageCollectIfNeeded(); |
154 | 153 |
155 // Attempts to delete approximately |total_bytes_to_free| amount of data | 154 // Attempts to delete approximately |total_bytes_to_free| amount of data |
156 // |ranges_|, starting at the front of |ranges_| and moving linearly forward | 155 // |ranges_|, starting at the front of |ranges_| and moving linearly forward |
157 // through the buffers. Deletes starting from the back if |reverse_direction| | 156 // through the buffers. Deletes starting from the back if |reverse_direction| |
158 // is true. Returns the number of bytes freed. | 157 // is true. Returns the number of bytes freed. |
159 int FreeBuffers(int total_bytes_to_free, bool reverse_direction); | 158 size_t FreeBuffers(size_t total_bytes_to_free, bool reverse_direction); |
160 | 159 |
161 // Attempts to delete approximately |total_bytes_to_free| amount of data from | 160 // Attempts to delete approximately |total_bytes_to_free| amount of data from |
162 // |ranges_|, starting after the last appended buffer before the current | 161 // |ranges_|, starting after the last appended buffer before the current |
163 // playback position. | 162 // playback position. |
164 int FreeBuffersAfterLastAppended(int total_bytes_to_free); | 163 size_t FreeBuffersAfterLastAppended(size_t total_bytes_to_free); |
165 | 164 |
166 // Gets the removal range to secure |byte_to_free| from | 165 // Gets the removal range to secure |byte_to_free| from |
167 // [|start_timestamp|, |end_timestamp|). | 166 // [|start_timestamp|, |end_timestamp|). |
168 // Returns the size of buffers to secure if future | 167 // Returns the size of buffers to secure if future |
169 // Remove(|start_timestamp|, |removal_end_timestamp|, duration) is called. | 168 // Remove(|start_timestamp|, |removal_end_timestamp|, duration) is called. |
170 // Will not update |removal_end_timestamp| if the returned size is 0. | 169 // Will not update |removal_end_timestamp| if the returned size is 0. |
171 int GetRemovalRange(DecodeTimestamp start_timestamp, | 170 size_t GetRemovalRange(DecodeTimestamp start_timestamp, |
172 DecodeTimestamp end_timestamp, int byte_to_free, | 171 DecodeTimestamp end_timestamp, size_t byte_to_free, |
173 DecodeTimestamp* removal_end_timestamp); | 172 DecodeTimestamp* removal_end_timestamp); |
174 | 173 |
175 // Prepares |range_for_next_append_| so |new_buffers| can be appended. | 174 // Prepares |range_for_next_append_| so |new_buffers| can be appended. |
176 // This involves removing buffers between the end of the previous append | 175 // This involves removing buffers between the end of the previous append |
177 // and any buffers covered by the time range in |new_buffers|. | 176 // and any buffers covered by the time range in |new_buffers|. |
178 // |deleted_buffers| is an output parameter containing candidates for | 177 // |deleted_buffers| is an output parameter containing candidates for |
179 // |track_buffer_| if this method ends up removing the current playback | 178 // |track_buffer_| if this method ends up removing the current playback |
180 // position from the range. | 179 // position from the range. |
181 void PrepareRangesForNextAppend(const BufferQueue& new_buffers, | 180 void PrepareRangesForNextAppend(const BufferQueue& new_buffers, |
182 BufferQueue* deleted_buffers); | 181 BufferQueue* deleted_buffers); |
183 | 182 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 | 388 |
390 // The decode timestamp on the last buffer returned by the most recent | 389 // The decode timestamp on the last buffer returned by the most recent |
391 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't | 390 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't |
392 // been called yet or a seek has happened since the last GetNextBuffer() call. | 391 // been called yet or a seek has happened since the last GetNextBuffer() call. |
393 DecodeTimestamp last_output_buffer_timestamp_; | 392 DecodeTimestamp last_output_buffer_timestamp_; |
394 | 393 |
395 // Stores the largest distance between two adjacent buffers in this stream. | 394 // Stores the largest distance between two adjacent buffers in this stream. |
396 base::TimeDelta max_interbuffer_distance_; | 395 base::TimeDelta max_interbuffer_distance_; |
397 | 396 |
398 // The maximum amount of data in bytes the stream will keep in memory. | 397 // The maximum amount of data in bytes the stream will keep in memory. |
399 int memory_limit_; | 398 size_t memory_limit_; |
400 | 399 |
401 // Indicates that a kConfigChanged status has been reported by GetNextBuffer() | 400 // Indicates that a kConfigChanged status has been reported by GetNextBuffer() |
402 // and GetCurrentXXXDecoderConfig() must be called to update the current | 401 // and GetCurrentXXXDecoderConfig() must be called to update the current |
403 // config. GetNextBuffer() must not be called again until | 402 // config. GetNextBuffer() must not be called again until |
404 // GetCurrentXXXDecoderConfig() has been called. | 403 // GetCurrentXXXDecoderConfig() has been called. |
405 bool config_change_pending_; | 404 bool config_change_pending_; |
406 | 405 |
407 // Used by HandleNextBufferWithSplice() or HandleNextBufferWithPreroll() when | 406 // Used by HandleNextBufferWithSplice() or HandleNextBufferWithPreroll() when |
408 // a splice frame buffer or buffer with preroll is returned from | 407 // a splice frame buffer or buffer with preroll is returned from |
409 // GetNextBufferInternal(). | 408 // GetNextBufferInternal(). |
410 scoped_refptr<StreamParserBuffer> pending_buffer_; | 409 scoped_refptr<StreamParserBuffer> pending_buffer_; |
411 | 410 |
412 // Indicates which of the splice buffers in |splice_buffer_| should be | 411 // Indicates which of the splice buffers in |splice_buffer_| should be |
413 // handled out next. | 412 // handled out next. |
414 size_t splice_buffers_index_; | 413 size_t splice_buffers_index_; |
415 | 414 |
416 // Indicates that all buffers before |pending_buffer_| have been handed out. | 415 // Indicates that all buffers before |pending_buffer_| have been handed out. |
417 bool pending_buffers_complete_; | 416 bool pending_buffers_complete_; |
418 | 417 |
419 // Indicates that splice frame generation is enabled. | 418 // Indicates that splice frame generation is enabled. |
420 const bool splice_frames_enabled_; | 419 const bool splice_frames_enabled_; |
421 | 420 |
422 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); | 421 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); |
423 }; | 422 }; |
424 | 423 |
425 } // namespace media | 424 } // namespace media |
426 | 425 |
427 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 426 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
OLD | NEW |