| 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" |
| 18 #include "media/filters/source_buffer_stream.h" | 19 #include "media/filters/source_buffer_stream.h" |
| 19 | 20 |
| 20 namespace media { | 21 namespace media { |
| 21 | 22 |
| 22 class ChunkDemuxerStream; | 23 class ChunkDemuxerStream; |
| 23 class FFmpegURLProtocol; | 24 class FFmpegURLProtocol; |
| 24 class SourceState; | 25 class SourceState; |
| 25 | 26 |
| 26 // Demuxer implementation that allows chunks of media data to be passed | 27 // Demuxer implementation that allows chunks of media data to be passed |
| 27 // from JavaScript to the media stack. | 28 // from JavaScript to the media stack. |
| 28 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { | 29 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { |
| 29 public: | 30 public: |
| 30 enum Status { | 31 enum Status { |
| 31 kOk, // ID added w/o error. | 32 kOk, // ID added w/o error. |
| 32 kNotSupported, // Type specified is not supported. | 33 kNotSupported, // Type specified is not supported. |
| 33 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. | 34 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 typedef base::Callback<void(const std::string& type, | 37 typedef base::Callback<void(const std::string& type, |
| 37 scoped_ptr<uint8[]> init_data, | 38 scoped_ptr<uint8[]> init_data, |
| 38 int init_data_size)> NeedKeyCB; | 39 int init_data_size)> NeedKeyCB; |
| 39 | 40 |
| 40 // |open_cb| Run when Initialize() is called to signal that the demuxer | 41 // |open_cb| Run when Initialize() is called to signal that the demuxer |
| 41 // is ready to receive media data via AppenData(). | 42 // is ready to receive media data via AppenData(). |
| 42 // |need_key_cb| Run when the demuxer determines that an encryption key is | 43 // |need_key_cb| Run when the demuxer determines that an encryption key is |
| 43 // needed to decrypt the content. | 44 // needed to decrypt the content. |
| 45 // |add_text_track_cb| Run when demuxer detects the presence of an inband |
| 46 // text track. |
| 44 // |log_cb| Run when parsing error messages need to be logged to the error | 47 // |log_cb| Run when parsing error messages need to be logged to the error |
| 45 // console. | 48 // console. |
| 46 ChunkDemuxer(const base::Closure& open_cb, const NeedKeyCB& need_key_cb, | 49 ChunkDemuxer(const base::Closure& open_cb, |
| 50 const NeedKeyCB& need_key_cb, |
| 51 const AddTextTrackCB& add_text_track_cb, |
| 47 const LogCB& log_cb); | 52 const LogCB& log_cb); |
| 48 virtual ~ChunkDemuxer(); | 53 virtual ~ChunkDemuxer(); |
| 49 | 54 |
| 50 // Demuxer implementation. | 55 // Demuxer implementation. |
| 51 virtual void Initialize(DemuxerHost* host, | 56 virtual void Initialize(DemuxerHost* host, |
| 52 const PipelineStatusCB& cb) OVERRIDE; | 57 const PipelineStatusCB& cb) OVERRIDE; |
| 53 virtual void Stop(const base::Closure& callback) OVERRIDE; | 58 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 54 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 59 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
| 55 virtual void OnAudioRendererDisabled() OVERRIDE; | 60 virtual void OnAudioRendererDisabled() OVERRIDE; |
| 56 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; | 61 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // false if any can not. | 132 // false if any can not. |
| 128 bool CanEndOfStream_Locked() const; | 133 bool CanEndOfStream_Locked() const; |
| 129 | 134 |
| 130 // SourceState callbacks. | 135 // SourceState callbacks. |
| 131 void OnSourceInitDone(bool success, base::TimeDelta duration); | 136 void OnSourceInitDone(bool success, base::TimeDelta duration); |
| 132 bool OnNewConfigs(bool has_audio, bool has_video, | 137 bool OnNewConfigs(bool has_audio, bool has_video, |
| 133 const AudioDecoderConfig& audio_config, | 138 const AudioDecoderConfig& audio_config, |
| 134 const VideoDecoderConfig& video_config); | 139 const VideoDecoderConfig& video_config); |
| 135 bool OnAudioBuffers(const StreamParser::BufferQueue& buffers); | 140 bool OnAudioBuffers(const StreamParser::BufferQueue& buffers); |
| 136 bool OnVideoBuffers(const StreamParser::BufferQueue& buffers); | 141 bool OnVideoBuffers(const StreamParser::BufferQueue& buffers); |
| 142 bool OnTextBuffers(TextTrack* text_track, |
| 143 const StreamParser::BufferQueue& buffers); |
| 137 bool OnNeedKey(const std::string& type, | 144 bool OnNeedKey(const std::string& type, |
| 138 scoped_ptr<uint8[]> init_data, | 145 scoped_ptr<uint8[]> init_data, |
| 139 int init_data_size); | 146 int init_data_size); |
| 140 void OnNewMediaSegment(const std::string& source_id, | 147 void OnNewMediaSegment(const std::string& source_id, |
| 141 base::TimeDelta start_timestamp); | 148 base::TimeDelta start_timestamp); |
| 142 | 149 |
| 143 // Computes the intersection between the video & audio | 150 // Computes the intersection between the video & audio |
| 144 // buffered ranges. | 151 // buffered ranges. |
| 145 Ranges<base::TimeDelta> ComputeIntersection() const; | 152 Ranges<base::TimeDelta> ComputeIntersection() const; |
| 146 | 153 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 168 | 175 |
| 169 // Returns the ranges representing the buffered data in the demuxer. | 176 // Returns the ranges representing the buffered data in the demuxer. |
| 170 Ranges<base::TimeDelta> GetBufferedRanges() const; | 177 Ranges<base::TimeDelta> GetBufferedRanges() const; |
| 171 | 178 |
| 172 mutable base::Lock lock_; | 179 mutable base::Lock lock_; |
| 173 State state_; | 180 State state_; |
| 174 | 181 |
| 175 DemuxerHost* host_; | 182 DemuxerHost* host_; |
| 176 base::Closure open_cb_; | 183 base::Closure open_cb_; |
| 177 NeedKeyCB need_key_cb_; | 184 NeedKeyCB need_key_cb_; |
| 185 AddTextTrackCB add_text_track_cb_; |
| 178 // Callback used to report error strings that can help the web developer | 186 // Callback used to report error strings that can help the web developer |
| 179 // figure out what is wrong with the content. | 187 // figure out what is wrong with the content. |
| 180 LogCB log_cb_; | 188 LogCB log_cb_; |
| 181 | 189 |
| 182 PipelineStatusCB init_cb_; | 190 PipelineStatusCB init_cb_; |
| 183 PipelineStatusCB seek_cb_; | 191 PipelineStatusCB seek_cb_; |
| 184 | 192 |
| 185 scoped_ptr<ChunkDemuxerStream> audio_; | 193 scoped_ptr<ChunkDemuxerStream> audio_; |
| 186 scoped_ptr<ChunkDemuxerStream> video_; | 194 scoped_ptr<ChunkDemuxerStream> video_; |
| 187 | 195 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 205 // removed with RemoveID() but can not be re-added (yet). | 213 // removed with RemoveID() but can not be re-added (yet). |
| 206 std::string source_id_audio_; | 214 std::string source_id_audio_; |
| 207 std::string source_id_video_; | 215 std::string source_id_video_; |
| 208 | 216 |
| 209 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 217 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 210 }; | 218 }; |
| 211 | 219 |
| 212 } // namespace media | 220 } // namespace media |
| 213 | 221 |
| 214 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 222 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |