| 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/filters/source_buffer_stream.h" | 18 #include "media/filters/source_buffer_stream.h" |
| 19 | 19 |
| 20 namespace media { | 20 namespace media { |
| 21 | 21 |
| 22 class ChunkDemuxerClient; | |
| 23 class ChunkDemuxerStream; | 22 class ChunkDemuxerStream; |
| 24 class FFmpegURLProtocol; | 23 class FFmpegURLProtocol; |
| 25 | 24 |
| 26 // Demuxer implementation that allows chunks of media data to be passed | 25 // Demuxer implementation that allows chunks of media data to be passed |
| 27 // from JavaScript to the media stack. | 26 // from JavaScript to the media stack. |
| 28 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { | 27 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { |
| 29 public: | 28 public: |
| 30 enum Status { | 29 enum Status { |
| 31 kOk, // ID added w/o error. | 30 kOk, // ID added w/o error. |
| 32 kNotSupported, // Type specified is not supported. | 31 kNotSupported, // Type specified is not supported. |
| 33 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. | 32 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 explicit ChunkDemuxer(ChunkDemuxerClient* client); | 35 typedef base::Callback<void(scoped_array<uint8> init_data, |
| 36 int init_data_size)> NeedKeyCB; |
| 37 |
| 38 // |open_cb| Run when Initialize() is called to signal that the demuxer |
| 39 // is ready to receive media data via AppenData(). |
| 40 // |need_key_cb| Run when the demuxer determines that an encryption key is |
| 41 // needed to decrypt the content. |
| 42 ChunkDemuxer(const base::Closure& open_cb, const NeedKeyCB& need_key_cb); |
| 37 | 43 |
| 38 // Demuxer implementation. | 44 // Demuxer implementation. |
| 39 virtual void Initialize(DemuxerHost* host, | 45 virtual void Initialize(DemuxerHost* host, |
| 40 const PipelineStatusCB& cb) OVERRIDE; | 46 const PipelineStatusCB& cb) OVERRIDE; |
| 41 virtual void Stop(const base::Closure& callback) OVERRIDE; | 47 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 42 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 48 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
| 43 virtual void OnAudioRendererDisabled() OVERRIDE; | 49 virtual void OnAudioRendererDisabled() OVERRIDE; |
| 44 virtual scoped_refptr<DemuxerStream> GetStream( | 50 virtual scoped_refptr<DemuxerStream> GetStream( |
| 45 DemuxerStream::Type type) OVERRIDE; | 51 DemuxerStream::Type type) OVERRIDE; |
| 46 virtual base::TimeDelta GetStartTime() const OVERRIDE; | 52 virtual base::TimeDelta GetStartTime() const OVERRIDE; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // Sets |duration_| to |new_duration| and notifies |host_|. | 159 // Sets |duration_| to |new_duration| and notifies |host_|. |
| 154 void UpdateDuration(base::TimeDelta new_duration); | 160 void UpdateDuration(base::TimeDelta new_duration); |
| 155 | 161 |
| 156 // Returns the ranges representing the buffered data in the demuxer. | 162 // Returns the ranges representing the buffered data in the demuxer. |
| 157 Ranges<base::TimeDelta> GetBufferedRanges() const; | 163 Ranges<base::TimeDelta> GetBufferedRanges() const; |
| 158 | 164 |
| 159 mutable base::Lock lock_; | 165 mutable base::Lock lock_; |
| 160 State state_; | 166 State state_; |
| 161 | 167 |
| 162 DemuxerHost* host_; | 168 DemuxerHost* host_; |
| 163 ChunkDemuxerClient* client_; | 169 base::Closure open_cb_; |
| 170 NeedKeyCB need_key_cb_; |
| 171 |
| 164 PipelineStatusCB init_cb_; | 172 PipelineStatusCB init_cb_; |
| 165 PipelineStatusCB seek_cb_; | 173 PipelineStatusCB seek_cb_; |
| 166 | 174 |
| 167 scoped_refptr<ChunkDemuxerStream> audio_; | 175 scoped_refptr<ChunkDemuxerStream> audio_; |
| 168 scoped_refptr<ChunkDemuxerStream> video_; | 176 scoped_refptr<ChunkDemuxerStream> video_; |
| 169 | 177 |
| 170 base::TimeDelta duration_; | 178 base::TimeDelta duration_; |
| 171 | 179 |
| 172 typedef std::map<std::string, StreamParser*> StreamParserMap; | 180 typedef std::map<std::string, StreamParser*> StreamParserMap; |
| 173 StreamParserMap stream_parser_map_; | 181 StreamParserMap stream_parser_map_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 185 // removed with RemoveID() but can not be re-added (yet). | 193 // removed with RemoveID() but can not be re-added (yet). |
| 186 std::string source_id_audio_; | 194 std::string source_id_audio_; |
| 187 std::string source_id_video_; | 195 std::string source_id_video_; |
| 188 | 196 |
| 189 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 197 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 190 }; | 198 }; |
| 191 | 199 |
| 192 } // namespace media | 200 } // namespace media |
| 193 | 201 |
| 194 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 202 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |