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

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

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: incorporate aaron's comments (11/12) Created 7 years, 1 month 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
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 <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
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Indicates which decoder config to associate with new buffers 304 // Indicates which decoder config to associate with new buffers
301 // being appended. Each new buffer appended has its config ID set 305 // being appended. Each new buffer appended has its config ID set
302 // to the value of this field. 306 // to the value of this field.
303 int append_config_index_; 307 int append_config_index_;
304 308
305 // Holds the audio/video configs for this stream. |current_config_index_| 309 // Holds the audio/video configs for this stream. |current_config_index_|
306 // and |append_config_index_| represent indexes into one of these vectors. 310 // and |append_config_index_| represent indexes into one of these vectors.
307 std::vector<AudioDecoderConfig> audio_configs_; 311 std::vector<AudioDecoderConfig> audio_configs_;
308 std::vector<VideoDecoderConfig> video_configs_; 312 std::vector<VideoDecoderConfig> video_configs_;
309 313
314 // Holds the text config for this stream.
315 TextTrackConfig text_track_config_;
316
310 // True if more data needs to be appended before the Seek() can complete, 317 // True if more data needs to be appended before the Seek() can complete,
311 // false if no Seek() has been requested or the Seek() is completed. 318 // false if no Seek() has been requested or the Seek() is completed.
312 bool seek_pending_; 319 bool seek_pending_;
313 320
314 // True if the end of the stream has been signalled. 321 // True if the end of the stream has been signalled.
315 bool end_of_stream_; 322 bool end_of_stream_;
316 323
317 // Timestamp of the last request to Seek(). 324 // Timestamp of the last request to Seek().
318 base::TimeDelta seek_buffer_timestamp_; 325 base::TimeDelta seek_buffer_timestamp_;
319 326
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // config. GetNextBuffer() must not be called again until 363 // config. GetNextBuffer() must not be called again until
357 // GetCurrentXXXDecoderConfig() has been called. 364 // GetCurrentXXXDecoderConfig() has been called.
358 bool config_change_pending_; 365 bool config_change_pending_;
359 366
360 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 367 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
361 }; 368 };
362 369
363 } // namespace media 370 } // namespace media
364 371
365 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 372 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698