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

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

Issue 10696182: Add config change handling to SourceBufferStream & ChunkDemuxer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added copyright headers to manifest files Created 8 years, 4 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 | « media/filters/chunk_demuxer_unittest.cc ('k') | 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 // 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_
11 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 11 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
12 12
13 #include <deque> 13 #include <deque>
14 #include <list> 14 #include <list>
15 #include <utility> 15 #include <utility>
16 #include <vector>
16 17
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "media/base/audio_decoder_config.h" 19 #include "media/base/audio_decoder_config.h"
19 #include "media/base/media_export.h" 20 #include "media/base/media_export.h"
20 #include "media/base/ranges.h" 21 #include "media/base/ranges.h"
21 #include "media/base/stream_parser_buffer.h" 22 #include "media/base/stream_parser_buffer.h"
22 #include "media/base/video_decoder_config.h" 23 #include "media/base/video_decoder_config.h"
23 24
24 namespace media { 25 namespace media {
25 26
26 class SourceBufferRange; 27 class SourceBufferRange;
27 28
28 // See file-level comment for complete description. 29 // See file-level comment for complete description.
29 class MEDIA_EXPORT SourceBufferStream { 30 class MEDIA_EXPORT SourceBufferStream {
30 public: 31 public:
31 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; 32 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
32 33
34 // Status returned by GetNextBuffer().
35 // kSuccess: Indicates that the next buffer was returned.
36 // kNeedBuffer: Indicates that we need more data before a buffer can be
37 // returned.
38 // kConfigChange: Indicates that the next buffer requires a config change.
39 enum Status {
40 kSuccess,
41 kNeedBuffer,
42 kConfigChange,
43 };
44
33 explicit SourceBufferStream(const AudioDecoderConfig& audio_config); 45 explicit SourceBufferStream(const AudioDecoderConfig& audio_config);
34 explicit SourceBufferStream(const VideoDecoderConfig& video_config); 46 explicit SourceBufferStream(const VideoDecoderConfig& video_config);
35 47
36 ~SourceBufferStream(); 48 ~SourceBufferStream();
37 49
38 // Signals that the next buffers appended are part of a new media segment 50 // Signals that the next buffers appended are part of a new media segment
39 // starting at |media_segment_start_time|. 51 // starting at |media_segment_start_time|.
40 void OnNewMediaSegment(base::TimeDelta media_segment_start_time); 52 void OnNewMediaSegment(base::TimeDelta media_segment_start_time);
41 53
42 // Sets the start time of the stream. 54 // Sets the start time of the stream.
(...skipping 13 matching lines...) Expand all
56 68
57 // Returns true if the SourceBufferStream has seeked to a time without 69 // Returns true if the SourceBufferStream has seeked to a time without
58 // buffered data and is waiting for more data to be appended. 70 // buffered data and is waiting for more data to be appended.
59 bool IsSeekPending() const; 71 bool IsSeekPending() const;
60 72
61 // Fills |out_buffer| with a new buffer. Buffers are presented in order from 73 // Fills |out_buffer| with a new buffer. Buffers are presented in order from
62 // the last call to Seek(), or starting with the first buffer appended if 74 // the last call to Seek(), or starting with the first buffer appended if
63 // Seek() has not been called yet. 75 // Seek() has not been called yet.
64 // |out_buffer|'s timestamp may be earlier than the |timestamp| passed to 76 // |out_buffer|'s timestamp may be earlier than the |timestamp| passed to
65 // the last Seek() call. 77 // the last Seek() call.
66 // Returns true if |out_buffer| is filled with a valid buffer, false if 78 // Returns kSuccess if |out_buffer| is filled with a valid buffer, kNeedBuffer
67 // there is not enough data buffered to fulfill the request. 79 // if there is not enough data buffered to fulfill the request, and
68 bool GetNextBuffer(scoped_refptr<StreamParserBuffer>* out_buffer); 80 // kConfigChange if the next buffer requires a config change.
81 Status GetNextBuffer(scoped_refptr<StreamParserBuffer>* out_buffer);
69 82
70 // Returns a list of the buffered time ranges. 83 // Returns a list of the buffered time ranges.
71 Ranges<base::TimeDelta> GetBufferedTime() const; 84 Ranges<base::TimeDelta> GetBufferedTime() const;
72 85
73 // Returns true if we don't have any ranges or the last range is selected. 86 // Returns true if we don't have any ranges or the last range is selected.
74 bool IsEndSelected() const; 87 bool IsEndSelected() const;
75 88
76 const AudioDecoderConfig& GetCurrentAudioDecoderConfig() { 89 const AudioDecoderConfig& GetCurrentAudioDecoderConfig();
77 return audio_config_; 90 const VideoDecoderConfig& GetCurrentVideoDecoderConfig();
78 } 91
79 const VideoDecoderConfig& GetCurrentVideoDecoderConfig() { 92 // Notifies this object that the audio config has changed and buffers in
80 return video_config_; 93 // future Append() calls should be associated with this new config.
81 } 94 bool UpdateAudioConfig(const AudioDecoderConfig& config);
95
96 // Notifies this object that the video config has changed and buffers in
97 // future Append() calls should be associated with this new config.
98 bool UpdateVideoConfig(const VideoDecoderConfig& config);
82 99
83 // Returns the largest distance between two adjacent buffers in this stream, 100 // Returns the largest distance between two adjacent buffers in this stream,
84 // or an estimate if no two adjacent buffers have been appended to the stream 101 // or an estimate if no two adjacent buffers have been appended to the stream
85 // yet. 102 // yet.
86 base::TimeDelta GetMaxInterbufferDistance() const; 103 base::TimeDelta GetMaxInterbufferDistance() const;
87 104
88 private: 105 private:
89 typedef std::list<SourceBufferRange*> RangeList; 106 typedef std::list<SourceBufferRange*> RangeList;
90 107
91 // Appends |new_buffers| into |range_for_new_buffers_itr|, handling start and 108 // Appends |new_buffers| into |range_for_new_buffers_itr|, handling start and
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // since the previous append to the media segment, false otherwise. 182 // since the previous append to the media segment, false otherwise.
166 bool IsMonotonicallyIncreasing(const BufferQueue& buffers) const; 183 bool IsMonotonicallyIncreasing(const BufferQueue& buffers) const;
167 184
168 // Returns true if |selected_range_| is the only range in |ranges_| that 185 // Returns true if |selected_range_| is the only range in |ranges_| that
169 // HasNextBufferPosition(). 186 // HasNextBufferPosition().
170 bool OnlySelectedRangeIsSeeked() const; 187 bool OnlySelectedRangeIsSeeked() const;
171 188
172 // Measures the distances between buffer timestamps and tracks the max. 189 // Measures the distances between buffer timestamps and tracks the max.
173 void UpdateMaxInterbufferDistance(const BufferQueue& buffers); 190 void UpdateMaxInterbufferDistance(const BufferQueue& buffers);
174 191
192 // Sets the config ID for each buffer to |append_config_index_|.
193 void SetConfigIds(const BufferQueue& buffers);
194
195 // Called to complete a config change. Updates |current_config_index_| to
196 // match the index of the next buffer. Calling this method causes
197 // GetNextBuffer() to stop returning kConfigChange and start returning
198 // kSuccess.
199 void CompleteConfigChange();
200
175 // List of disjoint buffered ranges, ordered by start time. 201 // List of disjoint buffered ranges, ordered by start time.
176 RangeList ranges_; 202 RangeList ranges_;
177 203
178 AudioDecoderConfig audio_config_; 204 // Indicates which decoder config is being used by the decoder.
179 VideoDecoderConfig video_config_; 205 // GetNextBuffer() is only allows to return buffers that have a
206 // config ID that matches this index. If there is a mismatch then
207 // it must signal that a config change is needed.
208 int current_config_index_;
209
210 // Indicates which decoder config to associate with new buffers
211 // being appended. Each new buffer appended has its config ID set
212 // to the value of this field.
213 int append_config_index_;
214
215 // Holds the audio/video configs for this stream. |current_config_index_|
216 // and |append_config_index_| represent indexes into one of these vectors.
217 std::vector<AudioDecoderConfig*> audio_configs_;
218 std::vector<VideoDecoderConfig*> video_configs_;
180 219
181 // The starting time of the stream. 220 // The starting time of the stream.
182 base::TimeDelta stream_start_time_; 221 base::TimeDelta stream_start_time_;
183 222
184 // True if more data needs to be appended before the Seek() can complete, 223 // True if more data needs to be appended before the Seek() can complete,
185 // false if no Seek() has been requested or the Seek() is completed. 224 // false if no Seek() has been requested or the Seek() is completed.
186 bool seek_pending_; 225 bool seek_pending_;
187 226
188 // Timestamp of the last request to Seek(). 227 // Timestamp of the last request to Seek().
189 base::TimeDelta seek_buffer_timestamp_; 228 base::TimeDelta seek_buffer_timestamp_;
(...skipping 22 matching lines...) Expand all
212 251
213 // Stores the largest distance between two adjacent buffers in this stream. 252 // Stores the largest distance between two adjacent buffers in this stream.
214 base::TimeDelta max_interbuffer_distance_; 253 base::TimeDelta max_interbuffer_distance_;
215 254
216 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 255 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
217 }; 256 };
218 257
219 } // namespace media 258 } // namespace media
220 259
221 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 260 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer_unittest.cc ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698