Chromium Code Reviews| 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> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 // Removes buffers between |start| and |end| according to the steps | 49 // Removes buffers between |start| and |end| according to the steps |
| 50 // in the "Coded Frame Removal Algorithm" in the Media Source | 50 // in the "Coded Frame Removal Algorithm" in the Media Source |
| 51 // Extensions Spec. | 51 // Extensions Spec. |
| 52 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal | 52 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal |
| 53 // | 53 // |
| 54 // |duration| is the current duration of the presentation. It is | 54 // |duration| is the current duration of the presentation. It is |
| 55 // required by the computation outlined in the spec. | 55 // required by the computation outlined in the spec. |
| 56 void Remove(base::TimeDelta start, base::TimeDelta end, | 56 void Remove(base::TimeDelta start, base::TimeDelta end, |
| 57 base::TimeDelta duration); | 57 base::TimeDelta duration); |
| 58 | 58 |
| 59 // If the buffer is full, runs Frame Removal to try to free up space, as | |
| 60 // specified in the "Coded Frame Eviction Algorithm" in the Media Source | |
| 61 // Extensions Spec. Returns false iff buffer is still full after running | |
| 62 // eviction | |
| 63 // https://w3c.github.io/media-source/#sourcebuffer-coded-frame-eviction | |
| 64 bool EvictFrames(DecodeTimestamp media_time); | |
| 65 | |
| 59 // Signal to the stream that duration has changed to |duration|. | 66 // Signal to the stream that duration has changed to |duration|. |
| 60 void OnSetDuration(base::TimeDelta duration); | 67 void OnSetDuration(base::TimeDelta duration); |
| 61 | 68 |
| 62 // Returns the range of buffered data in this stream, capped at |duration|. | 69 // Returns the range of buffered data in this stream, capped at |duration|. |
| 63 Ranges<base::TimeDelta> GetBufferedRanges(base::TimeDelta duration) const; | 70 Ranges<base::TimeDelta> GetBufferedRanges(base::TimeDelta duration) const; |
| 64 | 71 |
| 65 // Returns the duration of the buffered data. | 72 // Returns the duration of the buffered data. |
| 66 // Returns base::TimeDelta() if the stream has no buffered data. | 73 // Returns base::TimeDelta() if the stream has no buffered data. |
| 67 base::TimeDelta GetBufferedDuration() const; | 74 base::TimeDelta GetBufferedDuration() const; |
| 68 | 75 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { | 145 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { |
| 139 public: | 146 public: |
| 140 enum Status { | 147 enum Status { |
| 141 kOk, // ID added w/o error. | 148 kOk, // ID added w/o error. |
| 142 kNotSupported, // Type specified is not supported. | 149 kNotSupported, // Type specified is not supported. |
| 143 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. | 150 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. |
| 144 }; | 151 }; |
| 145 | 152 |
| 146 typedef base::Closure InitSegmentReceivedCB; | 153 typedef base::Closure InitSegmentReceivedCB; |
| 147 | 154 |
| 155 typedef base::Callback<base::TimeDelta(void)> GetMediaTimeCB; | |
| 156 | |
| 148 // |open_cb| Run when Initialize() is called to signal that the demuxer | 157 // |open_cb| Run when Initialize() is called to signal that the demuxer |
| 149 // is ready to receive media data via AppenData(). | 158 // is ready to receive media data via AppenData(). |
| 150 // |encrypted_media_init_data_cb| Run when the demuxer determines that an | 159 // |encrypted_media_init_data_cb| Run when the demuxer determines that an |
| 151 // encryption key is needed to decrypt the content. | 160 // encryption key is needed to decrypt the content. |
| 152 // |enable_text| Process inband text tracks in the normal way when true, | 161 // |enable_text| Process inband text tracks in the normal way when true, |
| 153 // otherwise ignore them. | 162 // otherwise ignore them. |
| 154 // |log_cb| Run when the demuxer needs to emit MediaLog messages. | 163 // |log_cb| Run when the demuxer needs to emit MediaLog messages. |
| 164 // |get_media_time_cb| Should return current media playback time, which | |
| 165 // is used to ensure unconsumed data in not garbage collected. | |
|
wolenetz
2015/06/04 00:38:57
nit: s/in/is
servolk
2015/06/04 03:03:01
Done.
| |
| 155 // |splice_frames_enabled| Indicates that it's okay to generate splice frames | 166 // |splice_frames_enabled| Indicates that it's okay to generate splice frames |
| 156 // per the MSE specification. Renderers must understand DecoderBuffer's | 167 // per the MSE specification. Renderers must understand DecoderBuffer's |
| 157 // splice_timestamp() field. | 168 // splice_timestamp() field. |
| 158 ChunkDemuxer(const base::Closure& open_cb, | 169 ChunkDemuxer(const base::Closure& open_cb, |
| 159 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 170 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
| 160 const LogCB& log_cb, | 171 const LogCB& log_cb, |
| 172 const GetMediaTimeCB& get_media_time_cb, | |
| 161 const scoped_refptr<MediaLog>& media_log, | 173 const scoped_refptr<MediaLog>& media_log, |
| 162 bool splice_frames_enabled); | 174 bool splice_frames_enabled); |
| 163 ~ChunkDemuxer() override; | 175 ~ChunkDemuxer() override; |
| 164 | 176 |
| 165 // Demuxer implementation. | 177 // Demuxer implementation. |
| 166 void Initialize(DemuxerHost* host, | 178 void Initialize(DemuxerHost* host, |
| 167 const PipelineStatusCB& cb, | 179 const PipelineStatusCB& cb, |
| 168 bool enable_text_tracks) override; | 180 bool enable_text_tracks) override; |
| 169 void Stop() override; | 181 void Stop() override; |
| 170 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; | 182 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 void Abort(const std::string& id, | 246 void Abort(const std::string& id, |
| 235 base::TimeDelta append_window_start, | 247 base::TimeDelta append_window_start, |
| 236 base::TimeDelta append_window_end, | 248 base::TimeDelta append_window_end, |
| 237 base::TimeDelta* timestamp_offset); | 249 base::TimeDelta* timestamp_offset); |
| 238 | 250 |
| 239 // Remove buffers between |start| and |end| for the source buffer | 251 // Remove buffers between |start| and |end| for the source buffer |
| 240 // associated with |id|. | 252 // associated with |id|. |
| 241 void Remove(const std::string& id, base::TimeDelta start, | 253 void Remove(const std::string& id, base::TimeDelta start, |
| 242 base::TimeDelta end); | 254 base::TimeDelta end); |
| 243 | 255 |
| 256 bool EvictFrames(); | |
| 257 | |
| 244 // Returns the current presentation duration. | 258 // Returns the current presentation duration. |
| 245 double GetDuration(); | 259 double GetDuration(); |
| 246 double GetDuration_Locked(); | 260 double GetDuration_Locked(); |
| 247 | 261 |
| 248 // Notifies the demuxer that the duration of the media has changed to | 262 // Notifies the demuxer that the duration of the media has changed to |
| 249 // |duration|. | 263 // |duration|. |
| 250 void SetDuration(double duration); | 264 void SetDuration(double duration); |
| 251 | 265 |
| 252 // Returns true if the source buffer associated with |id| is currently parsing | 266 // Returns true if the source buffer associated with |id| is currently parsing |
| 253 // a media segment, or false otherwise. | 267 // a media segment, or false otherwise. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 State state_; | 369 State state_; |
| 356 bool cancel_next_seek_; | 370 bool cancel_next_seek_; |
| 357 | 371 |
| 358 DemuxerHost* host_; | 372 DemuxerHost* host_; |
| 359 base::Closure open_cb_; | 373 base::Closure open_cb_; |
| 360 EncryptedMediaInitDataCB encrypted_media_init_data_cb_; | 374 EncryptedMediaInitDataCB encrypted_media_init_data_cb_; |
| 361 bool enable_text_; | 375 bool enable_text_; |
| 362 // Callback used to report log messages that can help the web developer | 376 // Callback used to report log messages that can help the web developer |
| 363 // figure out what is wrong with the content. | 377 // figure out what is wrong with the content. |
| 364 LogCB log_cb_; | 378 LogCB log_cb_; |
| 379 GetMediaTimeCB get_media_time_cb_; | |
| 365 scoped_refptr<MediaLog> media_log_; | 380 scoped_refptr<MediaLog> media_log_; |
| 366 | 381 |
| 367 PipelineStatusCB init_cb_; | 382 PipelineStatusCB init_cb_; |
| 368 // Callback to execute upon seek completion. | 383 // Callback to execute upon seek completion. |
| 369 // TODO(wolenetz/acolwell): Protect against possible double-locking by first | 384 // TODO(wolenetz/acolwell): Protect against possible double-locking by first |
| 370 // releasing |lock_| before executing this callback. See | 385 // releasing |lock_| before executing this callback. See |
| 371 // http://crbug.com/308226 | 386 // http://crbug.com/308226 |
| 372 PipelineStatusCB seek_cb_; | 387 PipelineStatusCB seek_cb_; |
| 373 | 388 |
| 374 scoped_ptr<ChunkDemuxerStream> audio_; | 389 scoped_ptr<ChunkDemuxerStream> audio_; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 397 | 412 |
| 398 // Indicates that splice frame generation is enabled. | 413 // Indicates that splice frame generation is enabled. |
| 399 const bool splice_frames_enabled_; | 414 const bool splice_frames_enabled_; |
| 400 | 415 |
| 401 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 416 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 402 }; | 417 }; |
| 403 | 418 |
| 404 } // namespace media | 419 } // namespace media |
| 405 | 420 |
| 406 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 421 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |