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, | 46 bool enable_text, |
48 const LogCB& log_cb); | 47 const LogCB& log_cb); |
49 virtual ~ChunkDemuxer(); | 48 virtual ~ChunkDemuxer(); |
50 | 49 |
51 // Demuxer implementation. | 50 // Demuxer implementation. |
52 virtual void Initialize(DemuxerHost* host, | 51 virtual void Initialize(DemuxerHost* host, |
53 const PipelineStatusCB& cb) OVERRIDE; | 52 const PipelineStatusCB& cb) 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; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 bool CanEndOfStream_Locked() const; | 163 bool CanEndOfStream_Locked() const; |
165 | 164 |
166 // SourceState callbacks. | 165 // SourceState callbacks. |
167 void OnSourceInitDone(bool success, base::TimeDelta duration); | 166 void OnSourceInitDone(bool success, base::TimeDelta duration); |
168 | 167 |
169 // Creates a DemuxerStream for the specified |type|. | 168 // Creates a DemuxerStream for the specified |type|. |
170 // Returns a new ChunkDemuxerStream instance if a stream of this type | 169 // Returns a new ChunkDemuxerStream instance if a stream of this type |
171 // has not been created before. Returns NULL otherwise. | 170 // has not been created before. Returns NULL otherwise. |
172 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); | 171 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); |
173 | 172 |
174 bool OnTextBuffers(TextTrack* text_track, | 173 void OnNewTextTrack(ChunkDemuxerStream* text_stream, |
175 const StreamParser::BufferQueue& buffers); | 174 const TextTrackConfig& config); |
176 void OnNewMediaSegment(const std::string& source_id, | 175 void OnNewMediaSegment(const std::string& source_id, |
177 base::TimeDelta start_timestamp); | 176 base::TimeDelta start_timestamp); |
178 | 177 |
179 // Computes the intersection between the video & audio | 178 // Computes the intersection between the video & audio |
180 // buffered ranges. | 179 // buffered ranges. |
181 Ranges<base::TimeDelta> ComputeIntersection() const; | 180 Ranges<base::TimeDelta> ComputeIntersection() const; |
182 | 181 |
183 // Applies |time_offset| to the timestamps of |buffers|. | 182 // Applies |time_offset| to the timestamps of |buffers|. |
184 void AdjustBufferTimestamps(const StreamParser::BufferQueue& buffers, | 183 void AdjustBufferTimestamps(const StreamParser::BufferQueue& buffers, |
185 base::TimeDelta timestamp_offset); | 184 base::TimeDelta timestamp_offset); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Seeks all SourceBufferStreams to |seek_time|. | 216 // Seeks all SourceBufferStreams to |seek_time|. |
218 void SeekAllSources(base::TimeDelta seek_time); | 217 void SeekAllSources(base::TimeDelta seek_time); |
219 | 218 |
220 mutable base::Lock lock_; | 219 mutable base::Lock lock_; |
221 State state_; | 220 State state_; |
222 bool cancel_next_seek_; | 221 bool cancel_next_seek_; |
223 | 222 |
224 DemuxerHost* host_; | 223 DemuxerHost* host_; |
225 base::Closure open_cb_; | 224 base::Closure open_cb_; |
226 NeedKeyCB need_key_cb_; | 225 NeedKeyCB need_key_cb_; |
227 AddTextTrackCB add_text_track_cb_; | 226 bool enable_text_; |
228 // Callback used to report error strings that can help the web developer | 227 // Callback used to report error strings that can help the web developer |
229 // figure out what is wrong with the content. | 228 // figure out what is wrong with the content. |
230 LogCB log_cb_; | 229 LogCB log_cb_; |
231 | 230 |
232 PipelineStatusCB init_cb_; | 231 PipelineStatusCB init_cb_; |
233 PipelineStatusCB seek_cb_; | 232 PipelineStatusCB seek_cb_; |
234 | 233 |
235 scoped_ptr<ChunkDemuxerStream> audio_; | 234 scoped_ptr<ChunkDemuxerStream> audio_; |
236 scoped_ptr<ChunkDemuxerStream> video_; | 235 scoped_ptr<ChunkDemuxerStream> video_; |
237 | 236 |
(...skipping 17 matching lines...) Expand all Loading... |
255 // removed with RemoveID() but can not be re-added (yet). | 254 // removed with RemoveID() but can not be re-added (yet). |
256 std::string source_id_audio_; | 255 std::string source_id_audio_; |
257 std::string source_id_video_; | 256 std::string source_id_video_; |
258 | 257 |
259 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 258 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
260 }; | 259 }; |
261 | 260 |
262 } // namespace media | 261 } // namespace media |
263 | 262 |
264 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 263 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
OLD | NEW |