| OLD | NEW |
| 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 #include <vector> |
| 17 | 17 |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "media/base/audio_decoder_config.h" | 19 #include "media/base/audio_decoder_config.h" |
| 20 #include "media/base/media_export.h" | 20 #include "media/base/media_export.h" |
| 21 #include "media/base/media_log.h" |
| 21 #include "media/base/ranges.h" | 22 #include "media/base/ranges.h" |
| 22 #include "media/base/stream_parser_buffer.h" | 23 #include "media/base/stream_parser_buffer.h" |
| 23 #include "media/base/video_decoder_config.h" | 24 #include "media/base/video_decoder_config.h" |
| 24 | 25 |
| 25 namespace media { | 26 namespace media { |
| 26 | 27 |
| 27 class SourceBufferRange; | 28 class SourceBufferRange; |
| 28 | 29 |
| 29 // See file-level comment for complete description. | 30 // See file-level comment for complete description. |
| 30 class MEDIA_EXPORT SourceBufferStream { | 31 class MEDIA_EXPORT SourceBufferStream { |
| 31 public: | 32 public: |
| 32 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | 33 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
| 33 | 34 |
| 34 // Status returned by GetNextBuffer(). | 35 // Status returned by GetNextBuffer(). |
| 35 // kSuccess: Indicates that the next buffer was returned. | 36 // kSuccess: Indicates that the next buffer was returned. |
| 36 // kNeedBuffer: Indicates that we need more data before a buffer can be | 37 // kNeedBuffer: Indicates that we need more data before a buffer can be |
| 37 // returned. | 38 // returned. |
| 38 // kConfigChange: Indicates that the next buffer requires a config change. | 39 // kConfigChange: Indicates that the next buffer requires a config change. |
| 39 enum Status { | 40 enum Status { |
| 40 kSuccess, | 41 kSuccess, |
| 41 kNeedBuffer, | 42 kNeedBuffer, |
| 42 kConfigChange, | 43 kConfigChange, |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 explicit SourceBufferStream(const AudioDecoderConfig& audio_config); | 46 SourceBufferStream(const AudioDecoderConfig& audio_config, |
| 46 explicit SourceBufferStream(const VideoDecoderConfig& video_config); | 47 const LogCB& log_cb); |
| 48 SourceBufferStream(const VideoDecoderConfig& video_config, |
| 49 const LogCB& log_cb); |
| 47 | 50 |
| 48 ~SourceBufferStream(); | 51 ~SourceBufferStream(); |
| 49 | 52 |
| 50 // Signals that the next buffers appended are part of a new media segment | 53 // Signals that the next buffers appended are part of a new media segment |
| 51 // starting at |media_segment_start_time|. | 54 // starting at |media_segment_start_time|. |
| 52 void OnNewMediaSegment(base::TimeDelta media_segment_start_time); | 55 void OnNewMediaSegment(base::TimeDelta media_segment_start_time); |
| 53 | 56 |
| 54 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are | 57 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are |
| 55 // expected to be in order, but multiple calls to Append() may add buffers out | 58 // expected to be in order, but multiple calls to Append() may add buffers out |
| 56 // of order or overlapping. Assumes all buffers within |buffers| are in | 59 // of order or overlapping. Assumes all buffers within |buffers| are in |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 233 |
| 231 // Sets the config ID for each buffer to |append_config_index_|. | 234 // Sets the config ID for each buffer to |append_config_index_|. |
| 232 void SetConfigIds(const BufferQueue& buffers); | 235 void SetConfigIds(const BufferQueue& buffers); |
| 233 | 236 |
| 234 // Called to complete a config change. Updates |current_config_index_| to | 237 // Called to complete a config change. Updates |current_config_index_| to |
| 235 // match the index of the next buffer. Calling this method causes | 238 // match the index of the next buffer. Calling this method causes |
| 236 // GetNextBuffer() to stop returning kConfigChange and start returning | 239 // GetNextBuffer() to stop returning kConfigChange and start returning |
| 237 // kSuccess. | 240 // kSuccess. |
| 238 void CompleteConfigChange(); | 241 void CompleteConfigChange(); |
| 239 | 242 |
| 243 // Callback used to report error strings that can help the web developer |
| 244 // figure out what is wrong with the content. |
| 245 LogCB log_cb_; |
| 246 |
| 240 // List of disjoint buffered ranges, ordered by start time. | 247 // List of disjoint buffered ranges, ordered by start time. |
| 241 RangeList ranges_; | 248 RangeList ranges_; |
| 242 | 249 |
| 243 // Indicates which decoder config is being used by the decoder. | 250 // Indicates which decoder config is being used by the decoder. |
| 244 // GetNextBuffer() is only allows to return buffers that have a | 251 // GetNextBuffer() is only allows to return buffers that have a |
| 245 // config ID that matches this index. If there is a mismatch then | 252 // config ID that matches this index. If there is a mismatch then |
| 246 // it must signal that a config change is needed. | 253 // it must signal that a config change is needed. |
| 247 int current_config_index_; | 254 int current_config_index_; |
| 248 | 255 |
| 249 // Indicates which decoder config to associate with new buffers | 256 // Indicates which decoder config to associate with new buffers |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // config. GetNextBuffer() must not be called again until | 303 // config. GetNextBuffer() must not be called again until |
| 297 // GetCurrentXXXDecoderConfig() has been called. | 304 // GetCurrentXXXDecoderConfig() has been called. |
| 298 bool config_change_pending_; | 305 bool config_change_pending_; |
| 299 | 306 |
| 300 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); | 307 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); |
| 301 }; | 308 }; |
| 302 | 309 |
| 303 } // namespace media | 310 } // namespace media |
| 304 | 311 |
| 305 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 312 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
| OLD | NEW |