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

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

Issue 2343543002: MSE: Replace crossfade splicing overlap trimming. (Closed)
Patch Set: fix compile error 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) If |new_buffers| overlap existing buffers, trims end of
287 // existing buffers to remove overlap. |new_buffers| are not modified.
288 void TrimSpliceOverlap(const BufferQueue& new_buffers);
289
289 // Returns true if end of stream has been reached, i.e. the 290 // Returns true if end of stream has been reached, i.e. the
290 // following conditions are met: 291 // following conditions are met:
291 // 1. end of stream is marked and there is nothing in the track_buffer. 292 // 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, 293 // 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. 294 // or there is a pending seek beyond any existing ranges.
294 bool IsEndOfStreamReached() const; 295 bool IsEndOfStreamReached() const;
295 296
296 // Deletes the range pointed to by |*itr| and removes it from |ranges_|. 297 // 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 298 // 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 299 // NULL. After the range is removed, |*itr| is to the range after the one that
(...skipping 17 matching lines...) Expand all
316 // |*deleted_buffers| - Filled with buffers for the current playback position 317 // |*deleted_buffers| - Filled with buffers for the current playback position
317 // if the removal range included the current playback position. These buffers 318 // if the removal range included the current playback position. These buffers
318 // can be used as candidates for placing in the |track_buffer_|. 319 // can be used as candidates for placing in the |track_buffer_|.
319 void RemoveInternal(DecodeTimestamp start, 320 void RemoveInternal(DecodeTimestamp start,
320 DecodeTimestamp end, 321 DecodeTimestamp end,
321 bool exclude_start, 322 bool exclude_start,
322 BufferQueue* deleted_buffers); 323 BufferQueue* deleted_buffers);
323 324
324 Type GetType() const; 325 Type GetType() const;
325 326
326 // See GetNextBuffer() for additional details. This method handles splice
327 // frame processing.
328 Status HandleNextBufferWithSplice(
329 scoped_refptr<StreamParserBuffer>* out_buffer);
330
331 // See GetNextBuffer() for additional details. This method handles preroll 327 // See GetNextBuffer() for additional details. This method handles preroll
332 // frame processing. 328 // frame processing.
333 Status HandleNextBufferWithPreroll( 329 Status HandleNextBufferWithPreroll(
334 scoped_refptr<StreamParserBuffer>* out_buffer); 330 scoped_refptr<StreamParserBuffer>* out_buffer);
335 331
336 // See GetNextBuffer() for additional details. The internal method hands out 332 // See GetNextBuffer() for additional details. The internal method hands out
337 // single buffers from the |track_buffer_| and |selected_range_| without 333 // single buffers from the |track_buffer_| and |selected_range_| without
338 // additional processing for splice frame or preroll buffers. 334 // additional processing for preroll buffers.
339 Status GetNextBufferInternal(scoped_refptr<StreamParserBuffer>* out_buffer); 335 Status GetNextBufferInternal(scoped_refptr<StreamParserBuffer>* out_buffer);
340 336
341 // If the next buffer's timestamp is significantly beyond the last output 337 // 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 338 // 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 339 // 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 340 // delay. Apps can avoid this behavior by not overlap-appending buffers near
345 // current playback position. 341 // current playback position.
346 void WarnIfTrackBufferExhaustionSkipsForward( 342 void WarnIfTrackBufferExhaustionSkipsForward(
347 const scoped_refptr<StreamParserBuffer>& next_buffer); 343 const scoped_refptr<StreamParserBuffer>& next_buffer);
348 344
349 // Called by PrepareRangesForNextAppend() before pruning overlapped buffers to 345 // If |out_buffer| has preroll, sets |pending_buffer_| to feed out preroll and
350 // generate a splice frame with a small portion of the overlapped buffers. If 346 // returns true. Otherwise returns false.
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_|
356 // appropriately and returns true. Otherwise returns false.
357 bool SetPendingBuffer(scoped_refptr<StreamParserBuffer>* out_buffer); 347 bool SetPendingBuffer(scoped_refptr<StreamParserBuffer>* out_buffer);
358 348
359 // Used to report log messages that can help the web developer figure out what 349 // Used to report log messages that can help the web developer figure out what
360 // is wrong with the content. 350 // is wrong with the content.
361 scoped_refptr<MediaLog> media_log_; 351 scoped_refptr<MediaLog> media_log_;
362 352
363 // List of disjoint buffered ranges, ordered by start time. 353 // List of disjoint buffered ranges, ordered by start time.
364 RangeList ranges_; 354 RangeList ranges_;
365 355
366 // Indicates which decoder config is being used by the decoder. 356 // Indicates which decoder config is being used by the decoder.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 422
433 // The maximum amount of data in bytes the stream will keep in memory. 423 // The maximum amount of data in bytes the stream will keep in memory.
434 size_t memory_limit_; 424 size_t memory_limit_;
435 425
436 // Indicates that a kConfigChanged status has been reported by GetNextBuffer() 426 // Indicates that a kConfigChanged status has been reported by GetNextBuffer()
437 // and GetCurrentXXXDecoderConfig() must be called to update the current 427 // and GetCurrentXXXDecoderConfig() must be called to update the current
438 // config. GetNextBuffer() must not be called again until 428 // config. GetNextBuffer() must not be called again until
439 // GetCurrentXXXDecoderConfig() has been called. 429 // GetCurrentXXXDecoderConfig() has been called.
440 bool config_change_pending_ = false; 430 bool config_change_pending_ = false;
441 431
442 // Used by HandleNextBufferWithSplice() or HandleNextBufferWithPreroll() when 432 // Used by HandleNextBufferWithPreroll() when a buffer with preroll is
443 // a splice frame buffer or buffer with preroll is returned from 433 // returned from GetNextBufferInternal().
444 // GetNextBufferInternal().
445 scoped_refptr<StreamParserBuffer> pending_buffer_; 434 scoped_refptr<StreamParserBuffer> pending_buffer_;
446 435
447 // Indicates which of the splice buffers in |splice_buffer_| should be
448 // handled out next.
449 size_t splice_buffers_index_ = 0;
450
451 // Indicates that all buffers before |pending_buffer_| have been handed out. 436 // Indicates that all buffers before |pending_buffer_| have been handed out.
452 bool pending_buffers_complete_ = false; 437 bool pending_buffers_complete_ = false;
453 438
454 // Indicates that splice frame generation is enabled. 439 // To prevent log spam, count the number of logs for different log scenarios.
455 const bool splice_frames_enabled_; 440 int num_splice_logs_ = 0;
456
457 // To prevent log spam, count the number of warnings and successes logged.
458 int num_splice_generation_warning_logs_ = 0;
459 int num_splice_generation_success_logs_ = 0;
460 int num_track_buffer_gap_warning_logs_ = 0; 441 int num_track_buffer_gap_warning_logs_ = 0;
461 int num_garbage_collect_algorithm_logs_ = 0; 442 int num_garbage_collect_algorithm_logs_ = 0;
462 int num_strange_same_timestamps_logs_ = 0; 443 int num_strange_same_timestamps_logs_ = 0;
463 444
464 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 445 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
465 }; 446 };
466 447
467 } // namespace media 448 } // namespace media
468 449
469 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 450 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698