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 #ifndef MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 5 #ifndef MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
6 #define MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 6 #define MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "media/base/byte_queue.h" | 14 #include "media/base/byte_queue.h" |
15 #include "media/base/demuxer.h" | 15 #include "media/base/demuxer.h" |
16 #include "media/base/ranges.h" | 16 #include "media/base/ranges.h" |
17 #include "media/base/stream_parser.h" | 17 #include "media/base/stream_parser.h" |
18 #include "media/base/text_track.h" | |
19 #include "media/filters/source_buffer_stream.h" | 18 #include "media/filters/source_buffer_stream.h" |
20 | 19 |
21 namespace media { | 20 namespace media { |
22 | 21 |
23 class ChunkDemuxerStream; | 22 class ChunkDemuxerStream; |
24 class FFmpegURLProtocol; | 23 class FFmpegURLProtocol; |
25 class SourceState; | 24 class SourceState; |
26 | 25 |
27 // Demuxer implementation that allows chunks of media data to be passed | 26 // Demuxer implementation that allows chunks of media data to be passed |
28 // from JavaScript to the media stack. | 27 // from JavaScript to the media stack. |
29 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { | 28 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { |
30 public: | 29 public: |
31 enum Status { | 30 enum Status { |
32 kOk, // ID added w/o error. | 31 kOk, // ID added w/o error. |
33 kNotSupported, // Type specified is not supported. | 32 kNotSupported, // Type specified is not supported. |
34 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. | 33 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. |
35 }; | 34 }; |
36 | 35 |
37 // |open_cb| Run when Initialize() is called to signal that the demuxer | 36 // |open_cb| Run when Initialize() is called to signal that the demuxer |
38 // is ready to receive media data via AppenData(). | 37 // is ready to receive media data via AppenData(). |
39 // |need_key_cb| Run when the demuxer determines that an encryption key is | 38 // |need_key_cb| Run when the demuxer determines that an encryption key is |
40 // needed to decrypt the content. | 39 // needed to decrypt the content. |
41 // |add_text_track_cb| Run when demuxer detects the presence of an inband | 40 // |enable_text| Process inband text tracks in the normal way when true, |
42 // text track. | 41 // otherwise ignore them. |
43 // |log_cb| Run when parsing error messages need to be logged to the error | 42 // |log_cb| Run when parsing error messages need to be logged to the error |
44 // console. | 43 // console. |
45 ChunkDemuxer(const base::Closure& open_cb, | 44 ChunkDemuxer(const base::Closure& open_cb, |
46 const NeedKeyCB& need_key_cb, | 45 const NeedKeyCB& need_key_cb, |
47 const AddTextTrackCB& add_text_track_cb, | |
48 const LogCB& log_cb); | 46 const LogCB& log_cb); |
49 virtual ~ChunkDemuxer(); | 47 virtual ~ChunkDemuxer(); |
50 | 48 |
51 // Demuxer implementation. | 49 // Demuxer implementation. |
52 virtual void Initialize(DemuxerHost* host, | 50 virtual void Initialize(DemuxerHost* host, |
53 const PipelineStatusCB& cb) OVERRIDE; | 51 const PipelineStatusCB& cb, |
| 52 bool enable_text_tracks) OVERRIDE; |
54 virtual void Stop(const base::Closure& callback) OVERRIDE; | 53 virtual void Stop(const base::Closure& callback) OVERRIDE; |
55 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 54 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
56 virtual void OnAudioRendererDisabled() OVERRIDE; | 55 virtual void OnAudioRendererDisabled() OVERRIDE; |
57 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; | 56 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; |
58 virtual base::TimeDelta GetStartTime() const OVERRIDE; | 57 virtual base::TimeDelta GetStartTime() const OVERRIDE; |
59 | 58 |
60 // Methods used by an external object to control this demuxer. | 59 // Methods used by an external object to control this demuxer. |
61 // | 60 // |
62 // Indicates that a new Seek() call is on its way. Any pending Reads on the | 61 // Indicates that a new Seek() call is on its way. Any pending Reads on the |
63 // DemuxerStream objects should be aborted immediately inside this call and | 62 // DemuxerStream objects should be aborted immediately inside this call and |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 bool CanEndOfStream_Locked() const; | 169 bool CanEndOfStream_Locked() const; |
171 | 170 |
172 // SourceState callbacks. | 171 // SourceState callbacks. |
173 void OnSourceInitDone(bool success, base::TimeDelta duration); | 172 void OnSourceInitDone(bool success, base::TimeDelta duration); |
174 | 173 |
175 // Creates a DemuxerStream for the specified |type|. | 174 // Creates a DemuxerStream for the specified |type|. |
176 // Returns a new ChunkDemuxerStream instance if a stream of this type | 175 // Returns a new ChunkDemuxerStream instance if a stream of this type |
177 // has not been created before. Returns NULL otherwise. | 176 // has not been created before. Returns NULL otherwise. |
178 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); | 177 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); |
179 | 178 |
180 bool OnTextBuffers(TextTrack* text_track, | 179 void OnNewTextTrack(ChunkDemuxerStream* text_stream, |
181 const StreamParser::BufferQueue& buffers); | 180 const TextTrackConfig& config); |
182 void OnNewMediaSegment(const std::string& source_id, | 181 void OnNewMediaSegment(const std::string& source_id, |
183 base::TimeDelta start_timestamp); | 182 base::TimeDelta start_timestamp); |
184 | 183 |
185 // Computes the intersection between the video & audio | 184 // Computes the intersection between the video & audio |
186 // buffered ranges. | 185 // buffered ranges. |
187 Ranges<base::TimeDelta> ComputeIntersection() const; | 186 Ranges<base::TimeDelta> ComputeIntersection() const; |
188 | 187 |
189 // Applies |time_offset| to the timestamps of |buffers|. | 188 // Applies |time_offset| to the timestamps of |buffers|. |
190 void AdjustBufferTimestamps(const StreamParser::BufferQueue& buffers, | 189 void AdjustBufferTimestamps(const StreamParser::BufferQueue& buffers, |
191 base::TimeDelta timestamp_offset); | 190 base::TimeDelta timestamp_offset); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // Seeks all SourceBufferStreams to |seek_time|. | 222 // Seeks all SourceBufferStreams to |seek_time|. |
224 void SeekAllSources(base::TimeDelta seek_time); | 223 void SeekAllSources(base::TimeDelta seek_time); |
225 | 224 |
226 mutable base::Lock lock_; | 225 mutable base::Lock lock_; |
227 State state_; | 226 State state_; |
228 bool cancel_next_seek_; | 227 bool cancel_next_seek_; |
229 | 228 |
230 DemuxerHost* host_; | 229 DemuxerHost* host_; |
231 base::Closure open_cb_; | 230 base::Closure open_cb_; |
232 NeedKeyCB need_key_cb_; | 231 NeedKeyCB need_key_cb_; |
233 AddTextTrackCB add_text_track_cb_; | 232 bool enable_text_; |
234 // Callback used to report error strings that can help the web developer | 233 // Callback used to report error strings that can help the web developer |
235 // figure out what is wrong with the content. | 234 // figure out what is wrong with the content. |
236 LogCB log_cb_; | 235 LogCB log_cb_; |
237 | 236 |
238 PipelineStatusCB init_cb_; | 237 PipelineStatusCB init_cb_; |
239 // Callback to execute upon seek completion. | 238 // Callback to execute upon seek completion. |
240 // TODO(wolenetz/acolwell): Protect against possible double-locking by first | 239 // TODO(wolenetz/acolwell): Protect against possible double-locking by first |
241 // releasing |lock_| before executing this callback. See | 240 // releasing |lock_| before executing this callback. See |
242 // http://crbug.com/308226 | 241 // http://crbug.com/308226 |
243 PipelineStatusCB seek_cb_; | 242 PipelineStatusCB seek_cb_; |
(...skipping 21 matching lines...) Expand all Loading... |
265 // removed with RemoveID() but can not be re-added (yet). | 264 // removed with RemoveID() but can not be re-added (yet). |
266 std::string source_id_audio_; | 265 std::string source_id_audio_; |
267 std::string source_id_video_; | 266 std::string source_id_video_; |
268 | 267 |
269 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 268 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
270 }; | 269 }; |
271 | 270 |
272 } // namespace media | 271 } // namespace media |
273 | 272 |
274 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 273 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
OLD | NEW |