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 <set> | |
acolwell GONE FROM CHROMIUM
2013/10/24 18:57:51
nit: Remove? I don't think it is needed anymore.
Matthew Heaney (Chromium)
2013/10/25 03:05:38
Done.
| |
9 #include <string> | 10 #include <string> |
10 #include <utility> | 11 #include <utility> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
14 #include "media/base/byte_queue.h" | 15 #include "media/base/byte_queue.h" |
15 #include "media/base/demuxer.h" | 16 #include "media/base/demuxer.h" |
16 #include "media/base/ranges.h" | 17 #include "media/base/ranges.h" |
17 #include "media/base/stream_parser.h" | 18 #include "media/base/stream_parser.h" |
18 #include "media/base/text_track.h" | |
19 #include "media/filters/source_buffer_stream.h" | 19 #include "media/filters/source_buffer_stream.h" |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 class ChunkDemuxerStream; | 23 class ChunkDemuxerStream; |
24 class FFmpegURLProtocol; | 24 class FFmpegURLProtocol; |
25 class SourceState; | 25 class SourceState; |
26 | 26 |
27 // Demuxer implementation that allows chunks of media data to be passed | 27 // Demuxer implementation that allows chunks of media data to be passed |
28 // from JavaScript to the media stack. | 28 // from JavaScript to the media stack. |
29 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { | 29 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { |
30 public: | 30 public: |
31 enum Status { | 31 enum Status { |
32 kOk, // ID added w/o error. | 32 kOk, // ID added w/o error. |
33 kNotSupported, // Type specified is not supported. | 33 kNotSupported, // Type specified is not supported. |
34 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. | 34 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. |
35 }; | 35 }; |
36 | 36 |
37 // |open_cb| Run when Initialize() is called to signal that the demuxer | 37 // |open_cb| Run when Initialize() is called to signal that the demuxer |
38 // is ready to receive media data via AppenData(). | 38 // is ready to receive media data via AppenData(). |
39 // |need_key_cb| Run when the demuxer determines that an encryption key is | 39 // |need_key_cb| Run when the demuxer determines that an encryption key is |
40 // needed to decrypt the content. | 40 // needed to decrypt the content. |
41 // |add_text_track_cb| Run when demuxer detects the presence of an inband | 41 // |enable_text| Process inband text tracks in the normal way when true, |
42 // text track. | 42 // otherwise ignore them. |
43 // |log_cb| Run when parsing error messages need to be logged to the error | 43 // |log_cb| Run when parsing error messages need to be logged to the error |
44 // console. | 44 // console. |
45 ChunkDemuxer(const base::Closure& open_cb, | 45 ChunkDemuxer(const base::Closure& open_cb, |
46 const NeedKeyCB& need_key_cb, | 46 const NeedKeyCB& need_key_cb, |
47 const AddTextTrackCB& add_text_track_cb, | 47 bool enable_text, |
48 const LogCB& log_cb); | 48 const LogCB& log_cb); |
49 virtual ~ChunkDemuxer(); | 49 virtual ~ChunkDemuxer(); |
50 | 50 |
51 // Demuxer implementation. | 51 // Demuxer implementation. |
52 virtual void Initialize(DemuxerHost* host, | 52 virtual void Initialize(DemuxerHost* host, |
53 const PipelineStatusCB& cb) OVERRIDE; | 53 const PipelineStatusCB& cb) OVERRIDE; |
54 virtual void Stop(const base::Closure& callback) OVERRIDE; | 54 virtual void Stop(const base::Closure& callback) OVERRIDE; |
55 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 55 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
56 virtual void OnAudioRendererDisabled() OVERRIDE; | 56 virtual void OnAudioRendererDisabled() OVERRIDE; |
57 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; | 57 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; | 164 bool CanEndOfStream_Locked() const; |
165 | 165 |
166 // SourceState callbacks. | 166 // SourceState callbacks. |
167 void OnSourceInitDone(bool success, base::TimeDelta duration); | 167 void OnSourceInitDone(bool success, base::TimeDelta duration); |
168 | 168 |
169 // Creates a DemuxerStream for the specified |type|. | 169 // Creates a DemuxerStream for the specified |type|. |
170 // Returns a new ChunkDemuxerStream instance if a stream of this type | 170 // Returns a new ChunkDemuxerStream instance if a stream of this type |
171 // has not been created before. Returns NULL otherwise. | 171 // has not been created before. Returns NULL otherwise. |
172 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); | 172 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); |
173 | 173 |
174 bool OnTextBuffers(TextTrack* text_track, | 174 void OnNewTextTrack(ChunkDemuxerStream* text_stream, |
175 const StreamParser::BufferQueue& buffers); | 175 const TextTrackConfig& config); |
176 void OnNewMediaSegment(const std::string& source_id, | 176 void OnNewMediaSegment(const std::string& source_id, |
177 base::TimeDelta start_timestamp); | 177 base::TimeDelta start_timestamp); |
178 | 178 |
179 // Computes the intersection between the video & audio | 179 // Computes the intersection between the video & audio |
180 // buffered ranges. | 180 // buffered ranges. |
181 Ranges<base::TimeDelta> ComputeIntersection() const; | 181 Ranges<base::TimeDelta> ComputeIntersection() const; |
182 | 182 |
183 // Applies |time_offset| to the timestamps of |buffers|. | 183 // Applies |time_offset| to the timestamps of |buffers|. |
184 void AdjustBufferTimestamps(const StreamParser::BufferQueue& buffers, | 184 void AdjustBufferTimestamps(const StreamParser::BufferQueue& buffers, |
185 base::TimeDelta timestamp_offset); | 185 base::TimeDelta timestamp_offset); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 // Seeks all SourceBufferStreams to |seek_time|. | 217 // Seeks all SourceBufferStreams to |seek_time|. |
218 void SeekAllSources(base::TimeDelta seek_time); | 218 void SeekAllSources(base::TimeDelta seek_time); |
219 | 219 |
220 mutable base::Lock lock_; | 220 mutable base::Lock lock_; |
221 State state_; | 221 State state_; |
222 bool cancel_next_seek_; | 222 bool cancel_next_seek_; |
223 | 223 |
224 DemuxerHost* host_; | 224 DemuxerHost* host_; |
225 base::Closure open_cb_; | 225 base::Closure open_cb_; |
226 NeedKeyCB need_key_cb_; | 226 NeedKeyCB need_key_cb_; |
227 AddTextTrackCB add_text_track_cb_; | 227 bool enable_text_; |
228 // Callback used to report error strings that can help the web developer | 228 // Callback used to report error strings that can help the web developer |
229 // figure out what is wrong with the content. | 229 // figure out what is wrong with the content. |
230 LogCB log_cb_; | 230 LogCB log_cb_; |
231 | 231 |
232 PipelineStatusCB init_cb_; | 232 PipelineStatusCB init_cb_; |
233 PipelineStatusCB seek_cb_; | 233 PipelineStatusCB seek_cb_; |
234 | 234 |
235 scoped_ptr<ChunkDemuxerStream> audio_; | 235 scoped_ptr<ChunkDemuxerStream> audio_; |
236 scoped_ptr<ChunkDemuxerStream> video_; | 236 scoped_ptr<ChunkDemuxerStream> video_; |
237 | 237 |
(...skipping 17 matching lines...) Expand all Loading... | |
255 // removed with RemoveID() but can not be re-added (yet). | 255 // removed with RemoveID() but can not be re-added (yet). |
256 std::string source_id_audio_; | 256 std::string source_id_audio_; |
257 std::string source_id_video_; | 257 std::string source_id_video_; |
258 | 258 |
259 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 259 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
260 }; | 260 }; |
261 | 261 |
262 } // namespace media | 262 } // namespace media |
263 | 263 |
264 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 264 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
OLD | NEW |