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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // starting at |coded_frame_group_start_time|. | 72 // starting at |coded_frame_group_start_time|. |
73 // TODO(acolwell/wolenetz): This should be changed to a presentation | 73 // TODO(acolwell/wolenetz): This should be changed to a presentation |
74 // timestamp. See http://crbug.com/402502 | 74 // timestamp. See http://crbug.com/402502 |
75 void OnStartOfCodedFrameGroup(DecodeTimestamp coded_frame_group_start_time); | 75 void OnStartOfCodedFrameGroup(DecodeTimestamp coded_frame_group_start_time); |
76 | 76 |
77 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are | 77 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are |
78 // expected to be in order, but multiple calls to Append() may add buffers out | 78 // expected to be in order, but multiple calls to Append() may add buffers out |
79 // of order or overlapping. Assumes all buffers within |buffers| are in | 79 // of order or overlapping. Assumes all buffers within |buffers| are in |
80 // presentation order and are non-overlapping. | 80 // presentation order and are non-overlapping. |
81 // Returns true if Append() was successful, false if |buffers| are not added. | 81 // Returns true if Append() was successful, false if |buffers| are not added. |
82 // TODO(vrk): Implement garbage collection. (crbug.com/125070) | |
83 bool Append(const BufferQueue& buffers); | 82 bool Append(const BufferQueue& buffers); |
84 | 83 |
85 // Removes buffers between |start| and |end| according to the steps | 84 // Removes buffers between |start| and |end| according to the steps |
86 // in the "Coded Frame Removal Algorithm" in the Media Source | 85 // in the "Coded Frame Removal Algorithm" in the Media Source |
87 // Extensions Spec. | 86 // Extensions Spec. |
88 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc
e.html#sourcebuffer-coded-frame-removal | 87 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc
e.html#sourcebuffer-coded-frame-removal |
89 // | 88 // |
90 // |duration| is the current duration of the presentation. It is | 89 // |duration| is the current duration of the presentation. It is |
91 // required by the computation outlined in the spec. | 90 // required by the computation outlined in the spec. |
92 void Remove(base::TimeDelta start, base::TimeDelta end, | 91 void Remove(base::TimeDelta start, base::TimeDelta end, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 void SetSelectedRange(SourceBufferRange* range); | 232 void SetSelectedRange(SourceBufferRange* range); |
234 | 233 |
235 // Seeks |range| to |seek_timestamp| and then calls SetSelectedRange() with | 234 // Seeks |range| to |seek_timestamp| and then calls SetSelectedRange() with |
236 // |range|. | 235 // |range|. |
237 void SeekAndSetSelectedRange(SourceBufferRange* range, | 236 void SeekAndSetSelectedRange(SourceBufferRange* range, |
238 DecodeTimestamp seek_timestamp); | 237 DecodeTimestamp seek_timestamp); |
239 | 238 |
240 // Resets this stream back to an unseeked state. | 239 // Resets this stream back to an unseeked state. |
241 void ResetSeekState(); | 240 void ResetSeekState(); |
242 | 241 |
| 242 // Reset state tracking various metadata about the last appended buffer. |
| 243 void ResetLastAppendedState(); |
| 244 |
243 // Returns true if |seek_timestamp| refers to the beginning of the first range | 245 // Returns true if |seek_timestamp| refers to the beginning of the first range |
244 // in |ranges_|, false otherwise or if |ranges_| is empty. | 246 // in |ranges_|, false otherwise or if |ranges_| is empty. |
245 bool ShouldSeekToStartOfBuffered(base::TimeDelta seek_timestamp) const; | 247 bool ShouldSeekToStartOfBuffered(base::TimeDelta seek_timestamp) const; |
246 | 248 |
247 // Returns true if the timestamps of |buffers| are monotonically increasing | 249 // Returns true if the timestamps of |buffers| are monotonically increasing |
248 // since the previous append to the coded frame group, false otherwise. | 250 // since the previous append to the coded frame group, false otherwise. |
249 bool IsMonotonicallyIncreasing(const BufferQueue& buffers); | 251 bool IsMonotonicallyIncreasing(const BufferQueue& buffers); |
250 | 252 |
251 // Returns true if |selected_range_| is the only range in |ranges_| that | 253 // Returns true if |selected_range_| is the only range in |ranges_| that |
252 // HasNextBufferPosition(). | 254 // HasNextBufferPosition(). |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // match |start| are not removed. If set to false, buffers with | 316 // match |start| are not removed. If set to false, buffers with |
315 // timestamps that match |start| will be removed. | 317 // timestamps that match |start| will be removed. |
316 // |*deleted_buffers| - Filled with buffers for the current playback position | 318 // |*deleted_buffers| - Filled with buffers for the current playback position |
317 // if the removal range included the current playback position. These buffers | 319 // if the removal range included the current playback position. These buffers |
318 // can be used as candidates for placing in the |track_buffer_|. | 320 // can be used as candidates for placing in the |track_buffer_|. |
319 void RemoveInternal(DecodeTimestamp start, | 321 void RemoveInternal(DecodeTimestamp start, |
320 DecodeTimestamp end, | 322 DecodeTimestamp end, |
321 bool exclude_start, | 323 bool exclude_start, |
322 BufferQueue* deleted_buffers); | 324 BufferQueue* deleted_buffers); |
323 | 325 |
| 326 // Helper function used by RemoveInternal() to evaluate whether remove will |
| 327 // disrupt the last appended GOP. If disruption is expected, reset state |
| 328 // tracking the last append. This will trigger frame filtering in Append() |
| 329 // until a new key frame is provided. |
| 330 void UpdateLastAppendStateForRemove(DecodeTimestamp remove_start, |
| 331 DecodeTimestamp remove_end, |
| 332 bool exclude_start); |
| 333 |
324 Type GetType() const; | 334 Type GetType() const; |
325 | 335 |
326 // See GetNextBuffer() for additional details. This method handles splice | 336 // See GetNextBuffer() for additional details. This method handles splice |
327 // frame processing. | 337 // frame processing. |
328 Status HandleNextBufferWithSplice( | 338 Status HandleNextBufferWithSplice( |
329 scoped_refptr<StreamParserBuffer>* out_buffer); | 339 scoped_refptr<StreamParserBuffer>* out_buffer); |
330 | 340 |
331 // See GetNextBuffer() for additional details. This method handles preroll | 341 // See GetNextBuffer() for additional details. This method handles preroll |
332 // frame processing. | 342 // frame processing. |
333 Status HandleNextBufferWithPreroll( | 343 Status HandleNextBufferWithPreroll( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 int num_track_buffer_gap_warning_logs_ = 0; | 470 int num_track_buffer_gap_warning_logs_ = 0; |
461 int num_garbage_collect_algorithm_logs_ = 0; | 471 int num_garbage_collect_algorithm_logs_ = 0; |
462 int num_strange_same_timestamps_logs_ = 0; | 472 int num_strange_same_timestamps_logs_ = 0; |
463 | 473 |
464 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); | 474 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); |
465 }; | 475 }; |
466 | 476 |
467 } // namespace media | 477 } // namespace media |
468 | 478 |
469 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 479 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
OLD | NEW |