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

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

Issue 1670033002: Reland: MSE: Relax the 'media segment must begin with keyframe' requirement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase plus interim patch set with a new test demonstrating there's more failure that needs fixing Created 4 years, 10 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 bool splice_frames_enabled); 61 bool splice_frames_enabled);
62 SourceBufferStream(const VideoDecoderConfig& video_config, 62 SourceBufferStream(const VideoDecoderConfig& video_config,
63 const scoped_refptr<MediaLog>& media_log, 63 const scoped_refptr<MediaLog>& media_log,
64 bool splice_frames_enabled); 64 bool splice_frames_enabled);
65 SourceBufferStream(const TextTrackConfig& text_config, 65 SourceBufferStream(const TextTrackConfig& text_config,
66 const scoped_refptr<MediaLog>& media_log, 66 const scoped_refptr<MediaLog>& media_log,
67 bool splice_frames_enabled); 67 bool splice_frames_enabled);
68 68
69 ~SourceBufferStream(); 69 ~SourceBufferStream();
70 70
71 // Signals that the next buffers appended are part of a new media segment 71 // Signals that the next buffers appended are part of a new coded frame group
72 // starting at |media_segment_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 OnNewMediaSegment(DecodeTimestamp media_segment_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) 82 // TODO(vrk): Implement garbage collection. (crbug.com/125070)
83 bool Append(const BufferQueue& buffers); 83 bool Append(const BufferQueue& buffers);
84 84
85 // Removes buffers between |start| and |end| according to the steps 85 // Removes buffers between |start| and |end| according to the steps
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Returns true if |second_timestamp| is the timestamp of the next buffer in 204 // Returns true if |second_timestamp| is the timestamp of the next buffer in
205 // sequence after |first_timestamp|, false otherwise. 205 // sequence after |first_timestamp|, false otherwise.
206 bool AreAdjacentInSequence( 206 bool AreAdjacentInSequence(
207 DecodeTimestamp first_timestamp, DecodeTimestamp second_timestamp) const; 207 DecodeTimestamp first_timestamp, DecodeTimestamp second_timestamp) const;
208 208
209 // Helper method that returns the timestamp for the next buffer that 209 // Helper method that returns the timestamp for the next buffer that
210 // |selected_range_| will return from GetNextBuffer() call, or kNoTimestamp() 210 // |selected_range_| will return from GetNextBuffer() call, or kNoTimestamp()
211 // if in between seeking (i.e. |selected_range_| is null). 211 // if in between seeking (i.e. |selected_range_| is null).
212 DecodeTimestamp GetNextBufferTimestamp(); 212 DecodeTimestamp GetNextBufferTimestamp();
213 213
214 // Finds the range that should contain a media segment that begins with 214 // Finds the range that should contain a coded frame group that begins with
215 // |start_timestamp| and returns the iterator pointing to it. Returns 215 // |start_timestamp| and returns the iterator pointing to it. Returns
216 // |ranges_.end()| if there's no such existing range. 216 // |ranges_.end()| if there's no such existing range.
217 RangeList::iterator FindExistingRangeFor(DecodeTimestamp start_timestamp); 217 RangeList::iterator FindExistingRangeFor(DecodeTimestamp start_timestamp);
218 218
219 // Inserts |new_range| into |ranges_| preserving sorted order. Returns an 219 // Inserts |new_range| into |ranges_| preserving sorted order. Returns an
220 // iterator in |ranges_| that points to |new_range|. 220 // iterator in |ranges_| that points to |new_range|.
221 RangeList::iterator AddToRanges(SourceBufferRange* new_range); 221 RangeList::iterator AddToRanges(SourceBufferRange* new_range);
222 222
223 // Returns an iterator that points to the place in |ranges_| where 223 // Returns an iterator that points to the place in |ranges_| where
224 // |selected_range_| lives. 224 // |selected_range_| lives.
225 RangeList::iterator GetSelectedRangeItr(); 225 RangeList::iterator GetSelectedRangeItr();
226 226
227 // Sets the |selected_range_| to |range| and resets the next buffer position 227 // Sets the |selected_range_| to |range| and resets the next buffer position
228 // for the previous |selected_range_|. 228 // for the previous |selected_range_|.
229 void SetSelectedRange(SourceBufferRange* range); 229 void SetSelectedRange(SourceBufferRange* range);
230 230
231 // Seeks |range| to |seek_timestamp| and then calls SetSelectedRange() with 231 // Seeks |range| to |seek_timestamp| and then calls SetSelectedRange() with
232 // |range|. 232 // |range|.
233 void SeekAndSetSelectedRange(SourceBufferRange* range, 233 void SeekAndSetSelectedRange(SourceBufferRange* range,
234 DecodeTimestamp seek_timestamp); 234 DecodeTimestamp seek_timestamp);
235 235
236 // Resets this stream back to an unseeked state. 236 // Resets this stream back to an unseeked state.
237 void ResetSeekState(); 237 void ResetSeekState();
238 238
239 // Returns true if |seek_timestamp| refers to the beginning of the first range 239 // Returns true if |seek_timestamp| refers to the beginning of the first range
240 // in |ranges_|, false otherwise or if |ranges_| is empty. 240 // in |ranges_|, false otherwise or if |ranges_| is empty.
241 bool ShouldSeekToStartOfBuffered(base::TimeDelta seek_timestamp) const; 241 bool ShouldSeekToStartOfBuffered(base::TimeDelta seek_timestamp) const;
242 242
243 // Returns true if the timestamps of |buffers| are monotonically increasing 243 // Returns true if the timestamps of |buffers| are monotonically increasing
244 // since the previous append to the media segment, false otherwise. 244 // since the previous append to the coded frame group, false otherwise.
245 bool IsMonotonicallyIncreasing(const BufferQueue& buffers) const; 245 bool IsMonotonicallyIncreasing(const BufferQueue& buffers);
246
247 // Returns true if |next_timestamp| and |next_is_keyframe| are valid for
248 // the first buffer after the previous append.
249 bool IsNextTimestampValid(DecodeTimestamp next_timestamp,
250 bool next_is_keyframe) const;
251 246
252 // Returns true if |selected_range_| is the only range in |ranges_| that 247 // Returns true if |selected_range_| is the only range in |ranges_| that
253 // HasNextBufferPosition(). 248 // HasNextBufferPosition().
254 bool OnlySelectedRangeIsSeeked() const; 249 bool OnlySelectedRangeIsSeeked() const;
255 250
256 // Measures the distances between buffer timestamps and tracks the max. 251 // Measures the distances between buffer timestamps and tracks the max.
257 void UpdateMaxInterbufferDistance(const BufferQueue& buffers); 252 void UpdateMaxInterbufferDistance(const BufferQueue& buffers);
258 253
259 // Sets the config ID for each buffer to |append_config_index_|. 254 // Sets the config ID for each buffer to |append_config_index_|.
260 void SetConfigIds(const BufferQueue& buffers); 255 void SetConfigIds(const BufferQueue& buffers);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 SourceBufferRange* selected_range_ = nullptr; 385 SourceBufferRange* selected_range_ = nullptr;
391 386
392 // Queue of the next buffers to be returned from calls to GetNextBuffer(). If 387 // Queue of the next buffers to be returned from calls to GetNextBuffer(). If
393 // |track_buffer_| is empty, return buffers from |selected_range_|. 388 // |track_buffer_| is empty, return buffers from |selected_range_|.
394 BufferQueue track_buffer_; 389 BufferQueue track_buffer_;
395 390
396 // If there has been no intervening Seek, this will be true if the last 391 // If there has been no intervening Seek, this will be true if the last
397 // emitted buffer emptied |track_buffer_|. 392 // emitted buffer emptied |track_buffer_|.
398 bool just_exhausted_track_buffer_ = false; 393 bool just_exhausted_track_buffer_ = false;
399 394
400 // The start time of the current media segment being appended. 395 // The start time of the current coded frame group being appended.
401 DecodeTimestamp media_segment_start_time_; 396 DecodeTimestamp coded_frame_group_start_time_;
402 397
403 // Points to the range containing the current media segment being appended. 398 // Points to the range containing the current coded frame group being
399 // appended.
404 RangeList::iterator range_for_next_append_; 400 RangeList::iterator range_for_next_append_;
405 401
406 // True when the next call to Append() begins a new media segment. 402 // True when the next call to Append() begins a new coded frame group.
407 bool new_media_segment_ = false; 403 // TODO(wolenetz): Simplify by passing this flag into Append().
404 bool new_coded_frame_group_ = false;
408 405
409 // The timestamp of the last buffer appended to the media segment, set to 406 // The timestamp of the last buffer appended to the coded frame group, set to
410 // kNoDecodeTimestamp() if the beginning of the segment. 407 // kNoDecodeTimestamp() if the beginning of the group.
411 DecodeTimestamp last_appended_buffer_timestamp_ = kNoDecodeTimestamp(); 408 DecodeTimestamp last_appended_buffer_timestamp_ = kNoDecodeTimestamp();
412 base::TimeDelta last_appended_buffer_duration_ = kNoTimestamp(); 409 base::TimeDelta last_appended_buffer_duration_ = kNoTimestamp();
413 bool last_appended_buffer_is_keyframe_ = false; 410 bool last_appended_buffer_is_keyframe_ = false;
414 411
415 // The decode timestamp on the last buffer returned by the most recent 412 // The decode timestamp on the last buffer returned by the most recent
416 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't 413 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't
417 // been called yet or a seek has happened since the last GetNextBuffer() call. 414 // been called yet or a seek has happened since the last GetNextBuffer() call.
418 DecodeTimestamp last_output_buffer_timestamp_; 415 DecodeTimestamp last_output_buffer_timestamp_;
419 416
420 // Stores the largest distance between two adjacent buffers in this stream. 417 // Stores the largest distance between two adjacent buffers in this stream.
(...skipping 21 matching lines...) Expand all
442 bool pending_buffers_complete_ = false; 439 bool pending_buffers_complete_ = false;
443 440
444 // Indicates that splice frame generation is enabled. 441 // Indicates that splice frame generation is enabled.
445 const bool splice_frames_enabled_; 442 const bool splice_frames_enabled_;
446 443
447 // To prevent log spam, count the number of warnings and successes logged. 444 // To prevent log spam, count the number of warnings and successes logged.
448 int num_splice_generation_warning_logs_ = 0; 445 int num_splice_generation_warning_logs_ = 0;
449 int num_splice_generation_success_logs_ = 0; 446 int num_splice_generation_success_logs_ = 0;
450 int num_track_buffer_gap_warning_logs_ = 0; 447 int num_track_buffer_gap_warning_logs_ = 0;
451 int num_garbage_collect_algorithm_logs_ = 0; 448 int num_garbage_collect_algorithm_logs_ = 0;
449 int num_strange_same_timestamps_logs_ = 0;
452 450
453 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 451 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
454 }; 452 };
455 453
456 } // namespace media 454 } // namespace media
457 455
458 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 456 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698