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

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

Issue 2343543002: MSE: Replace crossfade splicing overlap trimming. (Closed)
Patch Set: Created 4 years, 3 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 kEndOfStream 50 kEndOfStream
51 }; 51 };
52 52
53 enum Type { 53 enum Type {
54 kAudio, 54 kAudio,
55 kVideo, 55 kVideo,
56 kText 56 kText
57 }; 57 };
58 58
59 SourceBufferStream(const AudioDecoderConfig& audio_config, 59 SourceBufferStream(const AudioDecoderConfig& audio_config,
60 const scoped_refptr<MediaLog>& media_log, 60 const scoped_refptr<MediaLog>& media_log);
61 bool splice_frames_enabled);
62 SourceBufferStream(const VideoDecoderConfig& video_config, 61 SourceBufferStream(const VideoDecoderConfig& video_config,
63 const scoped_refptr<MediaLog>& media_log, 62 const scoped_refptr<MediaLog>& media_log);
64 bool splice_frames_enabled);
65 SourceBufferStream(const TextTrackConfig& text_config, 63 SourceBufferStream(const TextTrackConfig& text_config,
66 const scoped_refptr<MediaLog>& media_log, 64 const scoped_refptr<MediaLog>& media_log);
67 bool splice_frames_enabled);
68 65
69 ~SourceBufferStream(); 66 ~SourceBufferStream();
70 67
71 // Signals that the next buffers appended are part of a new coded frame group 68 // Signals that the next buffers appended are part of a new coded frame group
72 // starting at |coded_frame_group_start_time|. 69 // starting at |coded_frame_group_start_time|.
73 // TODO(acolwell/wolenetz): This should be changed to a presentation 70 // TODO(acolwell/wolenetz): This should be changed to a presentation
74 // timestamp. See http://crbug.com/402502 71 // timestamp. See http://crbug.com/402502
75 void OnStartOfCodedFrameGroup(DecodeTimestamp coded_frame_group_start_time); 72 void OnStartOfCodedFrameGroup(DecodeTimestamp coded_frame_group_start_time);
76 73
77 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are 74 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 276
280 // Searches |ranges_| for the first keyframe timestamp that is >= |timestamp|. 277 // Searches |ranges_| for the first keyframe timestamp that is >= |timestamp|.
281 // If |ranges_| doesn't contain a GOP that covers |timestamp| or doesn't 278 // If |ranges_| doesn't contain a GOP that covers |timestamp| or doesn't
282 // have a keyframe after |timestamp| then kNoTimestamp is returned. 279 // have a keyframe after |timestamp| then kNoTimestamp is returned.
283 DecodeTimestamp FindKeyframeAfterTimestamp(const DecodeTimestamp timestamp); 280 DecodeTimestamp FindKeyframeAfterTimestamp(const DecodeTimestamp timestamp);
284 281
285 // Returns "VIDEO" for a video SourceBufferStream, "AUDIO" for an audio 282 // Returns "VIDEO" for a video SourceBufferStream, "AUDIO" for an audio
286 // stream, and "TEXT" for a text stream. 283 // stream, and "TEXT" for a text stream.
287 std::string GetStreamTypeName() const; 284 std::string GetStreamTypeName() const;
288 285
286 // (Audio only) Pads |new_buffers| with leading silence if start of
287 // |new_buffers| is found to overlap existing buffers. Any overlapped buffer
288 // will later be removed (see PrepareRangesForNextAppend()) and silence is
289 // added to the front of |new_buffers| to make up the gap.
290 void GenerateSpliceSilence(const BufferQueue& new_buffers);
291
289 // Returns true if end of stream has been reached, i.e. the 292 // Returns true if end of stream has been reached, i.e. the
290 // following conditions are met: 293 // following conditions are met:
291 // 1. end of stream is marked and there is nothing in the track_buffer. 294 // 1. end of stream is marked and there is nothing in the track_buffer.
292 // 2. We don't have any ranges, or the last or no range is selected, 295 // 2. We don't have any ranges, or the last or no range is selected,
293 // or there is a pending seek beyond any existing ranges. 296 // or there is a pending seek beyond any existing ranges.
294 bool IsEndOfStreamReached() const; 297 bool IsEndOfStreamReached() const;
295 298
296 // Deletes the range pointed to by |*itr| and removes it from |ranges_|. 299 // Deletes the range pointed to by |*itr| and removes it from |ranges_|.
297 // If |*itr| points to |selected_range_|, then |selected_range_| is set to 300 // If |*itr| points to |selected_range_|, then |selected_range_| is set to
298 // NULL. After the range is removed, |*itr| is to the range after the one that 301 // NULL. After the range is removed, |*itr| is to the range after the one that
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 Status GetNextBufferInternal(scoped_refptr<StreamParserBuffer>* out_buffer); 342 Status GetNextBufferInternal(scoped_refptr<StreamParserBuffer>* out_buffer);
340 343
341 // If the next buffer's timestamp is significantly beyond the last output 344 // If the next buffer's timestamp is significantly beyond the last output
342 // buffer, and if we just exhausted |track_buffer_| on the previous read, this 345 // buffer, and if we just exhausted |track_buffer_| on the previous read, this
343 // method logs a warning to |media_log_| that there could be perceivable 346 // method logs a warning to |media_log_| that there could be perceivable
344 // delay. Apps can avoid this behavior by not overlap-appending buffers near 347 // delay. Apps can avoid this behavior by not overlap-appending buffers near
345 // current playback position. 348 // current playback position.
346 void WarnIfTrackBufferExhaustionSkipsForward( 349 void WarnIfTrackBufferExhaustionSkipsForward(
347 const scoped_refptr<StreamParserBuffer>& next_buffer); 350 const scoped_refptr<StreamParserBuffer>& next_buffer);
348 351
349 // Called by PrepareRangesForNextAppend() before pruning overlapped buffers to
350 // generate a splice frame with a small portion of the overlapped buffers. If
351 // a splice frame is generated, the first buffer in |new_buffers| will have
352 // its timestamps, duration, and fade out preroll updated.
353 void GenerateSpliceFrame(const BufferQueue& new_buffers);
354
355 // If |out_buffer| has splice buffers or preroll, sets |pending_buffer_| 352 // If |out_buffer| has splice buffers or preroll, sets |pending_buffer_|
356 // appropriately and returns true. Otherwise returns false. 353 // appropriately and returns true. Otherwise returns false.
357 bool SetPendingBuffer(scoped_refptr<StreamParserBuffer>* out_buffer); 354 bool SetPendingBuffer(scoped_refptr<StreamParserBuffer>* out_buffer);
358 355
359 // Used to report log messages that can help the web developer figure out what 356 // Used to report log messages that can help the web developer figure out what
360 // is wrong with the content. 357 // is wrong with the content.
361 scoped_refptr<MediaLog> media_log_; 358 scoped_refptr<MediaLog> media_log_;
362 359
363 // List of disjoint buffered ranges, ordered by start time. 360 // List of disjoint buffered ranges, ordered by start time.
364 RangeList ranges_; 361 RangeList ranges_;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // GetNextBufferInternal(). 441 // GetNextBufferInternal().
445 scoped_refptr<StreamParserBuffer> pending_buffer_; 442 scoped_refptr<StreamParserBuffer> pending_buffer_;
446 443
447 // Indicates which of the splice buffers in |splice_buffer_| should be 444 // Indicates which of the splice buffers in |splice_buffer_| should be
448 // handled out next. 445 // handled out next.
449 size_t splice_buffers_index_ = 0; 446 size_t splice_buffers_index_ = 0;
450 447
451 // Indicates that all buffers before |pending_buffer_| have been handed out. 448 // Indicates that all buffers before |pending_buffer_| have been handed out.
452 bool pending_buffers_complete_ = false; 449 bool pending_buffers_complete_ = false;
453 450
454 // Indicates that splice frame generation is enabled.
455 const bool splice_frames_enabled_;
456
457 // To prevent log spam, count the number of warnings and successes logged. 451 // To prevent log spam, count the number of warnings and successes logged.
458 int num_splice_generation_warning_logs_ = 0; 452 int num_splice_generation_logs_ = 0;
459 int num_splice_generation_success_logs_ = 0;
460 int num_track_buffer_gap_warning_logs_ = 0; 453 int num_track_buffer_gap_warning_logs_ = 0;
461 int num_garbage_collect_algorithm_logs_ = 0; 454 int num_garbage_collect_algorithm_logs_ = 0;
462 int num_strange_same_timestamps_logs_ = 0; 455 int num_strange_same_timestamps_logs_ = 0;
463 456
464 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 457 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
465 }; 458 };
466 459
467 } // namespace media 460 } // namespace media
468 461
469 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 462 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698