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 <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "media/base/byte_queue.h" | 15 #include "media/base/byte_queue.h" |
16 #include "media/base/demuxer.h" | 16 #include "media/base/demuxer.h" |
17 #include "media/base/ranges.h" | 17 #include "media/base/ranges.h" |
18 #include "media/base/stream_parser.h" | 18 #include "media/base/stream_parser.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 FFmpegURLProtocol; | 23 class FFmpegURLProtocol; |
24 class SourceState; | 24 class SourceState; |
25 | 25 |
26 class ChunkDemuxerStream : public DemuxerStream { | 26 class ChunkDemuxerStream : public DemuxerStream { |
27 public: | 27 public: |
28 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | 28 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
29 | 29 |
30 explicit ChunkDemuxerStream(Type type); | 30 explicit ChunkDemuxerStream(Type type, bool splice_frames_enabled); |
31 virtual ~ChunkDemuxerStream(); | 31 virtual ~ChunkDemuxerStream(); |
32 | 32 |
33 // ChunkDemuxerStream control methods. | 33 // ChunkDemuxerStream control methods. |
34 void StartReturningData(); | 34 void StartReturningData(); |
35 void AbortReads(); | 35 void AbortReads(); |
36 void CompletePendingReadIfPossible(); | 36 void CompletePendingReadIfPossible(); |
37 void Shutdown(); | 37 void Shutdown(); |
38 | 38 |
39 // SourceBufferStream manipulation methods. | 39 // SourceBufferStream manipulation methods. |
40 void Seek(base::TimeDelta time); | 40 void Seek(base::TimeDelta time); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 void CompletePendingReadIfPossible_Locked(); | 110 void CompletePendingReadIfPossible_Locked(); |
111 | 111 |
112 // Specifies the type of the stream. | 112 // Specifies the type of the stream. |
113 Type type_; | 113 Type type_; |
114 | 114 |
115 scoped_ptr<SourceBufferStream> stream_; | 115 scoped_ptr<SourceBufferStream> stream_; |
116 | 116 |
117 mutable base::Lock lock_; | 117 mutable base::Lock lock_; |
118 State state_; | 118 State state_; |
119 ReadCB read_cb_; | 119 ReadCB read_cb_; |
| 120 const bool splice_frames_enabled_; |
120 | 121 |
121 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream); | 122 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream); |
122 }; | 123 }; |
123 | 124 |
124 // Demuxer implementation that allows chunks of media data to be passed | 125 // Demuxer implementation that allows chunks of media data to be passed |
125 // from JavaScript to the media stack. | 126 // from JavaScript to the media stack. |
126 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { | 127 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { |
127 public: | 128 public: |
128 enum Status { | 129 enum Status { |
129 kOk, // ID added w/o error. | 130 kOk, // ID added w/o error. |
130 kNotSupported, // Type specified is not supported. | 131 kNotSupported, // Type specified is not supported. |
131 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. | 132 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. |
132 }; | 133 }; |
133 | 134 |
134 // |open_cb| Run when Initialize() is called to signal that the demuxer | 135 // |open_cb| Run when Initialize() is called to signal that the demuxer |
135 // is ready to receive media data via AppenData(). | 136 // is ready to receive media data via AppenData(). |
136 // |need_key_cb| Run when the demuxer determines that an encryption key is | 137 // |need_key_cb| Run when the demuxer determines that an encryption key is |
137 // needed to decrypt the content. | 138 // needed to decrypt the content. |
138 // |enable_text| Process inband text tracks in the normal way when true, | 139 // |enable_text| Process inband text tracks in the normal way when true, |
139 // otherwise ignore them. | 140 // otherwise ignore them. |
140 // |log_cb| Run when parsing error messages need to be logged to the error | 141 // |log_cb| Run when parsing error messages need to be logged to the error |
141 // console. | 142 // console. |
| 143 // |splice_frames_enabled| Indicates that it's okay to generate splice frames |
| 144 // per the MSE specification. Renderers must understand DecoderBuffer's |
| 145 // splice_timestamp() field. |
142 ChunkDemuxer(const base::Closure& open_cb, | 146 ChunkDemuxer(const base::Closure& open_cb, |
143 const NeedKeyCB& need_key_cb, | 147 const NeedKeyCB& need_key_cb, |
144 const LogCB& log_cb); | 148 const LogCB& log_cb, |
| 149 bool splice_frames_enabled); |
145 virtual ~ChunkDemuxer(); | 150 virtual ~ChunkDemuxer(); |
146 | 151 |
147 // Demuxer implementation. | 152 // Demuxer implementation. |
148 virtual void Initialize(DemuxerHost* host, | 153 virtual void Initialize(DemuxerHost* host, |
149 const PipelineStatusCB& cb, | 154 const PipelineStatusCB& cb, |
150 bool enable_text_tracks) OVERRIDE; | 155 bool enable_text_tracks) OVERRIDE; |
151 virtual void Stop(const base::Closure& callback) OVERRIDE; | 156 virtual void Stop(const base::Closure& callback) OVERRIDE; |
152 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 157 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
153 virtual void OnAudioRendererDisabled() OVERRIDE; | 158 virtual void OnAudioRendererDisabled() OVERRIDE; |
154 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; | 159 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 365 |
361 typedef std::map<std::string, SourceState*> SourceStateMap; | 366 typedef std::map<std::string, SourceState*> SourceStateMap; |
362 SourceStateMap source_state_map_; | 367 SourceStateMap source_state_map_; |
363 | 368 |
364 // Used to ensure that (1) config data matches the type and codec provided in | 369 // Used to ensure that (1) config data matches the type and codec provided in |
365 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be | 370 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be |
366 // removed with RemoveID() but can not be re-added (yet). | 371 // removed with RemoveID() but can not be re-added (yet). |
367 std::string source_id_audio_; | 372 std::string source_id_audio_; |
368 std::string source_id_video_; | 373 std::string source_id_video_; |
369 | 374 |
| 375 // Indicates that splice frame generation is enabled. |
| 376 const bool splice_frames_enabled_; |
| 377 |
370 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 378 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
371 }; | 379 }; |
372 | 380 |
373 } // namespace media | 381 } // namespace media |
374 | 382 |
375 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 383 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
OLD | NEW |