// Signals that the next buffers appended are part of a new media segment
// starting at |media_segment_start_time|.
- void OnNewMediaSegment(base::TimeDelta media_segment_start_time);
+ // TODO(acolwell/wolenetz): This should be changed to a presentation
+ // timestamp. See http://crbug.com/402502
+ void OnNewMediaSegment(DecodeTimestamp media_segment_start_time);
// Add the |buffers| to the SourceBufferStream. Buffers within the queue are
// expected to be in order, but multiple calls to Append() may add buffers out
// yet.
base::TimeDelta GetMaxInterbufferDistance() const;
- void set_memory_limit_for_testing(int memory_limit) {
+ void set_memory_limit(int memory_limit) {
memory_limit_ = memory_limit;
}
// Returns the size of buffers to secure if future
// Remove(|start_timestamp|, |removal_end_timestamp|, duration) is called.
// Will not update |removal_end_timestamp| if the returned size is 0.
- int GetRemovalRange(base::TimeDelta start_timestamp,
- base::TimeDelta end_timestamp, int byte_to_free,
- base::TimeDelta* removal_end_timestamp);
+ int GetRemovalRange(DecodeTimestamp start_timestamp,
+ DecodeTimestamp end_timestamp, int byte_to_free,
+ DecodeTimestamp* removal_end_timestamp);
// Prepares |range_for_next_append_| so |new_buffers| can be appended.
// This involves removing buffers between the end of the previous append
BufferQueue* deleted_buffers);
// Removes buffers, from the |track_buffer_|, that come after |timestamp|.
- void PruneTrackBuffer(const base::TimeDelta timestamp);
+ void PruneTrackBuffer(const DecodeTimestamp timestamp);
// Checks to see if |range_with_new_buffers_itr| can be merged with the range
// next to it, and merges them if so.
// Returns true if |second_timestamp| is the timestamp of the next buffer in
// sequence after |first_timestamp|, false otherwise.
bool AreAdjacentInSequence(
- base::TimeDelta first_timestamp, base::TimeDelta second_timestamp) const;
+ DecodeTimestamp first_timestamp, DecodeTimestamp second_timestamp) const;
// Helper method that returns the timestamp for the next buffer that
// |selected_range_| will return from GetNextBuffer() call, or kNoTimestamp()
// if in between seeking (i.e. |selected_range_| is null).
- base::TimeDelta GetNextBufferTimestamp();
-
- // Returns the timestamp of the last buffer in the |selected_range_| or
- // kNoTimestamp() if |selected_range_| is null.
- base::TimeDelta GetEndBufferTimestamp();
+ DecodeTimestamp GetNextBufferTimestamp();
// Finds the range that should contain a media segment that begins with
// |start_timestamp| and returns the iterator pointing to it. Returns
// |ranges_.end()| if there's no such existing range.
- RangeList::iterator FindExistingRangeFor(base::TimeDelta start_timestamp);
+ RangeList::iterator FindExistingRangeFor(DecodeTimestamp start_timestamp);
// Inserts |new_range| into |ranges_| preserving sorted order. Returns an
// iterator in |ranges_| that points to |new_range|.
// Seeks |range| to |seek_timestamp| and then calls SetSelectedRange() with
// |range|.
void SeekAndSetSelectedRange(SourceBufferRange* range,
- base::TimeDelta seek_timestamp);
+ DecodeTimestamp seek_timestamp);
// Resets this stream back to an unseeked state.
void ResetSeekState();
// Returns true if |next_timestamp| and |next_is_keyframe| are valid for
// the first buffer after the previous append.
- bool IsNextTimestampValid(base::TimeDelta next_timestamp,
+ bool IsNextTimestampValid(DecodeTimestamp next_timestamp,
bool next_is_keyframe) const;
// Returns true if |selected_range_| is the only range in |ranges_| that
// |timestamp| if necessary and possible. This method only attempts to
// set |selected_range_| if |seleted_range_| is null and |track_buffer_|
// is empty.
- void SetSelectedRangeIfNeeded(const base::TimeDelta timestamp);
+ void SetSelectedRangeIfNeeded(const DecodeTimestamp timestamp);
// Find a keyframe timestamp that is >= |start_timestamp| and can be used to
// find a new selected range.
// Returns kNoTimestamp() if an appropriate keyframe timestamp could not be
// found.
- base::TimeDelta FindNewSelectedRangeSeekTimestamp(
- const base::TimeDelta start_timestamp);
+ DecodeTimestamp FindNewSelectedRangeSeekTimestamp(
+ const DecodeTimestamp start_timestamp);
// Searches |ranges_| for the first keyframe timestamp that is >= |timestamp|.
// If |ranges_| doesn't contain a GOP that covers |timestamp| or doesn't
// have a keyframe after |timestamp| then kNoTimestamp() is returned.
- base::TimeDelta FindKeyframeAfterTimestamp(const base::TimeDelta timestamp);
+ DecodeTimestamp FindKeyframeAfterTimestamp(const DecodeTimestamp timestamp);
// Returns "VIDEO" for a video SourceBufferStream, "AUDIO" for an audio
// stream, and "TEXT" for a text stream.
// if the removal range included the current playback position. These buffers
// can be used as candidates for placing in the |track_buffer_|.
void RemoveInternal(
- base::TimeDelta start, base::TimeDelta end, bool is_exclusive,
+ DecodeTimestamp start, DecodeTimestamp end, bool is_exclusive,
BufferQueue* deleted_buffers);
Type GetType() const;
+ // See GetNextBuffer() for additional details. This method handles splice
+ // frame processing.
+ Status HandleNextBufferWithSplice(
+ scoped_refptr<StreamParserBuffer>* out_buffer);
+
+ // See GetNextBuffer() for additional details. This method handles preroll
+ // frame processing.
+ Status HandleNextBufferWithPreroll(
+ scoped_refptr<StreamParserBuffer>* out_buffer);
+
// See GetNextBuffer() for additional details. The internal method hands out
- // buffers from the |track_buffer_| and |selected_range_| without additional
- // processing for splice frame buffers; which is handled by GetNextBuffer().
+ // single buffers from the |track_buffer_| and |selected_range_| without
+ // additional processing for splice frame or preroll buffers.
Status GetNextBufferInternal(scoped_refptr<StreamParserBuffer>* out_buffer);
// Called by PrepareRangesForNextAppend() before pruning overlapped buffers to
// its timestamps, duration, and fade out preroll updated.
void GenerateSpliceFrame(const BufferQueue& new_buffers);
+ // If |out_buffer| has splice buffers or preroll, sets |pending_buffer_|
+ // appropriately and returns true. Otherwise returns false.
+ bool SetPendingBuffer(scoped_refptr<StreamParserBuffer>* out_buffer);
+
// Callback used to report error strings that can help the web developer
// figure out what is wrong with the content.
LogCB log_cb_;
BufferQueue track_buffer_;
// The start time of the current media segment being appended.
- base::TimeDelta media_segment_start_time_;
+ DecodeTimestamp media_segment_start_time_;
// Points to the range containing the current media segment being appended.
RangeList::iterator range_for_next_append_;
bool new_media_segment_;
// The timestamp of the last buffer appended to the media segment, set to
- // kNoTimestamp() if the beginning of the segment.
- base::TimeDelta last_appended_buffer_timestamp_;
+ // kNoDecodeTimestamp() if the beginning of the segment.
+ DecodeTimestamp last_appended_buffer_timestamp_;
bool last_appended_buffer_is_keyframe_;
// The decode timestamp on the last buffer returned by the most recent
// GetNextBuffer() call. Set to kNoTimestamp() if GetNextBuffer() hasn't been
// called yet or a seek has happened since the last GetNextBuffer() call.
- base::TimeDelta last_output_buffer_timestamp_;
+ DecodeTimestamp last_output_buffer_timestamp_;
// Stores the largest distance between two adjacent buffers in this stream.
base::TimeDelta max_interbuffer_distance_;
// GetCurrentXXXDecoderConfig() has been called.
bool config_change_pending_;
- // Used by GetNextBuffer() when a buffer with fade out is returned from
- // GetNextBufferInternal(). Will be set to the returned buffer and will be
- // destroyed after the splice_buffers() section has been exhausted.
- scoped_refptr<StreamParserBuffer> splice_buffer_;
+ // Used by HandleNextBufferWithSplice() or HandleNextBufferWithPreroll() when
+ // a splice frame buffer or buffer with preroll is returned from
+ // GetNextBufferInternal().
+ scoped_refptr<StreamParserBuffer> pending_buffer_;
// Indicates which of the splice buffers in |splice_buffer_| should be
// handled out next.
size_t splice_buffers_index_;
- // Indicates that all pre splice buffers have been handed out.
- bool pre_splice_complete_;
+ // Indicates that all buffers before |pending_buffer_| have been handed out.
+ bool pending_buffers_complete_;
// Indicates that splice frame generation is enabled.
const bool splice_frames_enabled_;