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 <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "media/base/audio_decoder_config.h" | 20 #include "media/base/audio_decoder_config.h" |
21 #include "media/base/media_export.h" | 21 #include "media/base/media_export.h" |
22 #include "media/base/media_log.h" | 22 #include "media/base/media_log.h" |
23 #include "media/base/ranges.h" | 23 #include "media/base/ranges.h" |
24 #include "media/base/stream_parser_buffer.h" | 24 #include "media/base/stream_parser_buffer.h" |
| 25 #include "media/base/text_track_config.h" |
25 #include "media/base/video_decoder_config.h" | 26 #include "media/base/video_decoder_config.h" |
26 | 27 |
27 namespace media { | 28 namespace media { |
28 | 29 |
29 class SourceBufferRange; | 30 class SourceBufferRange; |
30 | 31 |
31 // See file-level comment for complete description. | 32 // See file-level comment for complete description. |
32 class MEDIA_EXPORT SourceBufferStream { | 33 class MEDIA_EXPORT SourceBufferStream { |
33 public: | 34 public: |
34 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | 35 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
35 | 36 |
36 // Status returned by GetNextBuffer(). | 37 // Status returned by GetNextBuffer(). |
37 // kSuccess: Indicates that the next buffer was returned. | 38 // kSuccess: Indicates that the next buffer was returned. |
38 // kNeedBuffer: Indicates that we need more data before a buffer can be | 39 // kNeedBuffer: Indicates that we need more data before a buffer can be |
39 // returned. | 40 // returned. |
40 // kConfigChange: Indicates that the next buffer requires a config change. | 41 // kConfigChange: Indicates that the next buffer requires a config change. |
41 enum Status { | 42 enum Status { |
42 kSuccess, | 43 kSuccess, |
43 kNeedBuffer, | 44 kNeedBuffer, |
44 kConfigChange, | 45 kConfigChange, |
45 kEndOfStream | 46 kEndOfStream |
46 }; | 47 }; |
47 | 48 |
48 SourceBufferStream(const AudioDecoderConfig& audio_config, | 49 SourceBufferStream(const AudioDecoderConfig& audio_config, |
49 const LogCB& log_cb); | 50 const LogCB& log_cb); |
50 SourceBufferStream(const VideoDecoderConfig& video_config, | 51 SourceBufferStream(const VideoDecoderConfig& video_config, |
51 const LogCB& log_cb); | 52 const LogCB& log_cb); |
| 53 SourceBufferStream(const TextTrackConfig& text_config, |
| 54 const LogCB& log_cb); |
52 | 55 |
53 ~SourceBufferStream(); | 56 ~SourceBufferStream(); |
54 | 57 |
55 // Signals that the next buffers appended are part of a new media segment | 58 // Signals that the next buffers appended are part of a new media segment |
56 // starting at |media_segment_start_time|. | 59 // starting at |media_segment_start_time|. |
57 void OnNewMediaSegment(base::TimeDelta media_segment_start_time); | 60 void OnNewMediaSegment(base::TimeDelta media_segment_start_time); |
58 | 61 |
59 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are | 62 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are |
60 // expected to be in order, but multiple calls to Append() may add buffers out | 63 // expected to be in order, but multiple calls to Append() may add buffers out |
61 // of order or overlapping. Assumes all buffers within |buffers| are in | 64 // of order or overlapping. Assumes all buffers within |buffers| are in |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 Ranges<base::TimeDelta> GetBufferedTime() const; | 103 Ranges<base::TimeDelta> GetBufferedTime() const; |
101 | 104 |
102 // Notifies this object that end of stream has been signalled. | 105 // Notifies this object that end of stream has been signalled. |
103 void MarkEndOfStream(); | 106 void MarkEndOfStream(); |
104 | 107 |
105 // Clear the end of stream state set by MarkEndOfStream(). | 108 // Clear the end of stream state set by MarkEndOfStream(). |
106 void UnmarkEndOfStream(); | 109 void UnmarkEndOfStream(); |
107 | 110 |
108 const AudioDecoderConfig& GetCurrentAudioDecoderConfig(); | 111 const AudioDecoderConfig& GetCurrentAudioDecoderConfig(); |
109 const VideoDecoderConfig& GetCurrentVideoDecoderConfig(); | 112 const VideoDecoderConfig& GetCurrentVideoDecoderConfig(); |
| 113 const TextTrackConfig& GetCurrentTextTrackConfig(); |
110 | 114 |
111 // Notifies this object that the audio config has changed and buffers in | 115 // Notifies this object that the audio config has changed and buffers in |
112 // future Append() calls should be associated with this new config. | 116 // future Append() calls should be associated with this new config. |
113 bool UpdateAudioConfig(const AudioDecoderConfig& config); | 117 bool UpdateAudioConfig(const AudioDecoderConfig& config); |
114 | 118 |
115 // Notifies this object that the video config has changed and buffers in | 119 // Notifies this object that the video config has changed and buffers in |
116 // future Append() calls should be associated with this new config. | 120 // future Append() calls should be associated with this new config. |
117 bool UpdateVideoConfig(const VideoDecoderConfig& config); | 121 bool UpdateVideoConfig(const VideoDecoderConfig& config); |
118 | 122 |
119 // Returns the largest distance between two adjacent buffers in this stream, | 123 // Returns the largest distance between two adjacent buffers in this stream, |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // Indicates which decoder config to associate with new buffers | 319 // Indicates which decoder config to associate with new buffers |
316 // being appended. Each new buffer appended has its config ID set | 320 // being appended. Each new buffer appended has its config ID set |
317 // to the value of this field. | 321 // to the value of this field. |
318 int append_config_index_; | 322 int append_config_index_; |
319 | 323 |
320 // Holds the audio/video configs for this stream. |current_config_index_| | 324 // Holds the audio/video configs for this stream. |current_config_index_| |
321 // and |append_config_index_| represent indexes into one of these vectors. | 325 // and |append_config_index_| represent indexes into one of these vectors. |
322 std::vector<AudioDecoderConfig> audio_configs_; | 326 std::vector<AudioDecoderConfig> audio_configs_; |
323 std::vector<VideoDecoderConfig> video_configs_; | 327 std::vector<VideoDecoderConfig> video_configs_; |
324 | 328 |
| 329 // Holds the text config for this stream. |
| 330 TextTrackConfig text_track_config_; |
| 331 |
325 // True if more data needs to be appended before the Seek() can complete, | 332 // True if more data needs to be appended before the Seek() can complete, |
326 // false if no Seek() has been requested or the Seek() is completed. | 333 // false if no Seek() has been requested or the Seek() is completed. |
327 bool seek_pending_; | 334 bool seek_pending_; |
328 | 335 |
329 // True if the end of the stream has been signalled. | 336 // True if the end of the stream has been signalled. |
330 bool end_of_stream_; | 337 bool end_of_stream_; |
331 | 338 |
332 // Timestamp of the last request to Seek(). | 339 // Timestamp of the last request to Seek(). |
333 base::TimeDelta seek_buffer_timestamp_; | 340 base::TimeDelta seek_buffer_timestamp_; |
334 | 341 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // config. GetNextBuffer() must not be called again until | 378 // config. GetNextBuffer() must not be called again until |
372 // GetCurrentXXXDecoderConfig() has been called. | 379 // GetCurrentXXXDecoderConfig() has been called. |
373 bool config_change_pending_; | 380 bool config_change_pending_; |
374 | 381 |
375 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); | 382 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); |
376 }; | 383 }; |
377 | 384 |
378 } // namespace media | 385 } // namespace media |
379 | 386 |
380 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 387 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
OLD | NEW |