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

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

Issue 10389185: Implement start, end, and middle overlaps for SourceBufferStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase ToT Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 5 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
6 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 6 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 explicit SourceBufferStream(const AudioDecoderConfig& audio_config); 33 explicit SourceBufferStream(const AudioDecoderConfig& audio_config);
34 explicit SourceBufferStream(const VideoDecoderConfig& video_config); 34 explicit SourceBufferStream(const VideoDecoderConfig& video_config);
35 35
36 ~SourceBufferStream(); 36 ~SourceBufferStream();
37 37
38 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are 38 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are
39 // expected to be in order, but multiple calls to Append() may add buffers out 39 // expected to be in order, but multiple calls to Append() may add buffers out
40 // of order or overlapping. Assumes all buffers within |buffers| are in 40 // of order or overlapping. Assumes all buffers within |buffers| are in
41 // presentation order and are non-overlapping. 41 // presentation order and are non-overlapping.
42 // Returns true if Append() was successful, false if |buffers| are not added. 42 // Returns true if Append() was successful, false if |buffers| are not added.
43 // TODO(vrk): Implement proper end-overlapping. (crbug.com/125072)
44 // This may trigger garbage collection.
45 // TODO(vrk): Implement garbage collection. (crbug.com/125070) 43 // TODO(vrk): Implement garbage collection. (crbug.com/125070)
46 bool Append(const BufferQueue& buffers); 44 bool Append(const BufferQueue& buffers);
47 45
48 // Changes the SourceBufferStream's state so that it will start returning 46 // Changes the SourceBufferStream's state so that it will start returning
49 // buffers starting from the closest keyframe before |timestamp|. 47 // buffers starting from the closest keyframe before |timestamp|.
50 void Seek(base::TimeDelta timestamp); 48 void Seek(base::TimeDelta timestamp);
51 49
52 // Returns true if the SourceBufferStream has seeked to a time without 50 // Returns true if the SourceBufferStream has seeked to a time without
53 // buffered data and is waiting for more data to be appended. 51 // buffered data and is waiting for more data to be appended.
54 bool IsSeekPending() const; 52 bool IsSeekPending() const;
(...skipping 22 matching lines...) Expand all
77 const AudioDecoderConfig& GetCurrentAudioDecoderConfig() { 75 const AudioDecoderConfig& GetCurrentAudioDecoderConfig() {
78 return audio_config_; 76 return audio_config_;
79 } 77 }
80 const VideoDecoderConfig& GetCurrentVideoDecoderConfig() { 78 const VideoDecoderConfig& GetCurrentVideoDecoderConfig() {
81 return video_config_; 79 return video_config_;
82 } 80 }
83 81
84 private: 82 private:
85 typedef std::list<SourceBufferRange*> RangeList; 83 typedef std::list<SourceBufferRange*> RangeList;
86 84
85 // Appends |new_buffers| into |range_for_new_buffers_itr|, handling start and
86 // end overlaps if necessary.
87 void InsertIntoExistingRange(
88 const RangeList::iterator& range_for_new_buffers_itr,
89 const BufferQueue& new_buffers);
90
87 // Resolve overlapping ranges such that no ranges overlap anymore. 91 // Resolve overlapping ranges such that no ranges overlap anymore.
88 // |range_itr| points to the iterator in |ranges_| immediately after 92 // |range_with_new_buffers_itr| points to the range that has newly appended
89 // |new_range|. Returns the iterator in |ranges_| immediately after 93 // buffers.
90 // |new_range|, which may be different from the original |range_itr|. 94 void ResolveCompleteOverlaps(
91 RangeList::iterator ResolveCompleteOverlaps( 95 const RangeList::iterator& range_with_new_buffers_itr);
92 const RangeList::iterator& range_itr, SourceBufferRange* new_range); 96 void ResolveEndOverlap(const RangeList::iterator& range_with_new_buffers_itr);
93 RangeList::iterator ResolveEndOverlaps(
94 const RangeList::iterator& range_itr, SourceBufferRange* new_range);
95 97
96 // Checks to see if the range pointed to by |range_itr| can be appended to the 98 // Adds buffers to |track_buffer_| and updates |selected_range_| accordingly.
97 // end of |new_range|, and if so, appends the range and updates |ranges_| to 99 // |range_with_new_buffers_itr| points to the range containing the newly
98 // reflect this. 100 // appended buffers.
101 // |deleted_buffers| contains all the buffers that were deleted as a result
102 // of appending new buffers into |range_with_new_buffers_itr|. |next_buffer|
103 // points to the buffer in |deleted_buffers| that should be returned by the
104 // next call to GetNextBuffer(). Assumes |deleted_buffers| and |next_buffer|
105 // are valid.
106 // TODO(vrk): This is a little crazy! Ideas for cleanup in crbug.com/129623.
107 void UpdateTrackBuffer(
108 const RangeList::iterator& range_with_new_buffers_itr,
109 const BufferQueue& deleted_buffers,
110 const BufferQueue::iterator& next_buffer);
111
112 // Checks to see if |range_with_new_buffers_itr| can be merged with the range
113 // next to it, and merges them if so.
99 void MergeWithAdjacentRangeIfNecessary( 114 void MergeWithAdjacentRangeIfNecessary(
100 const RangeList::iterator& range_itr, SourceBufferRange* new_range); 115 const RangeList::iterator& range_with_new_buffers_itr);
101 116
102 // List of disjoint buffered ranges, ordered by start time. 117 // List of disjoint buffered ranges, ordered by start time.
103 RangeList ranges_; 118 RangeList ranges_;
104 119
105 AudioDecoderConfig audio_config_; 120 AudioDecoderConfig audio_config_;
106 VideoDecoderConfig video_config_; 121 VideoDecoderConfig video_config_;
107 122
108 // True if more data needs to be appended before the Seek() can complete, 123 // True if more data needs to be appended before the Seek() can complete,
109 // false if no Seek() has been requested or the Seek() is completed. 124 // false if no Seek() has been requested or the Seek() is completed.
110 bool seek_pending_; 125 bool seek_pending_;
111 126
112 // Timestamp of the last request to Seek(). 127 // Timestamp of the last request to Seek().
113 base::TimeDelta seek_buffer_timestamp_; 128 base::TimeDelta seek_buffer_timestamp_;
114 129
115 // Pointer to the seeked-to Range. This is the range from which 130 // Pointer to the seeked-to Range. This is the range from which
116 // GetNextBuffer() calls are fulfilled after the |track_buffer_| has been 131 // GetNextBuffer() calls are fulfilled after the |track_buffer_| has been
117 // emptied. 132 // emptied.
118 SourceBufferRange* selected_range_; 133 SourceBufferRange* selected_range_;
119 134
120 // Queue of the next buffers to be returned from calls to GetNextBuffer(). If 135 // Queue of the next buffers to be returned from calls to GetNextBuffer(). If
121 // |track_buffer_| is empty, return buffers from |selected_range_|. 136 // |track_buffer_| is empty, return buffers from |selected_range_|.
122 BufferQueue track_buffer_; 137 BufferQueue track_buffer_;
123 138
124 // True if the next buffer after the end of the |track_buffer_| is not
125 // buffered yet and we need to wait for the next keyframe after
126 // |track_buffer_| to be appended.
127 bool waiting_for_keyframe_;
128
129 // True when EndOfStream() has been called and GetNextBuffer() should return 139 // True when EndOfStream() has been called and GetNextBuffer() should return
130 // EOS buffers for read requests beyond the buffered data. False initially. 140 // EOS buffers for read requests beyond the buffered data. False initially.
131 bool end_of_stream_; 141 bool end_of_stream_;
132 142
133 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 143 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
134 }; 144 };
135 145
136 } // namespace media 146 } // namespace media
137 147
138 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 148 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698