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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 #include <map> | 12 #include <map> |
| 13 #include <set> |
13 #include <string> | 14 #include <string> |
14 #include <utility> | 15 #include <utility> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
19 #include "media/base/byte_queue.h" | 20 #include "media/base/byte_queue.h" |
20 #include "media/base/demuxer.h" | 21 #include "media/base/demuxer.h" |
21 #include "media/base/demuxer_stream.h" | 22 #include "media/base/demuxer_stream.h" |
22 #include "media/base/media_tracks.h" | 23 #include "media/base/media_tracks.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 void StartWaitingForSeek(base::TimeDelta seek_time) override; | 211 void StartWaitingForSeek(base::TimeDelta seek_time) override; |
211 void CancelPendingSeek(base::TimeDelta seek_time) override; | 212 void CancelPendingSeek(base::TimeDelta seek_time) override; |
212 | 213 |
213 // Registers a new |id| to use for AppendData() calls. |type| indicates | 214 // Registers a new |id| to use for AppendData() calls. |type| indicates |
214 // the MIME type for the data that we intend to append for this ID. | 215 // the MIME type for the data that we intend to append for this ID. |
215 // kOk is returned if the demuxer has enough resources to support another ID | 216 // kOk is returned if the demuxer has enough resources to support another ID |
216 // and supports the format indicated by |type|. | 217 // and supports the format indicated by |type|. |
217 // kNotSupported is returned if |type| is not a supported format. | 218 // kNotSupported is returned if |type| is not a supported format. |
218 // kReachedIdLimit is returned if the demuxer cannot handle another ID right | 219 // kReachedIdLimit is returned if the demuxer cannot handle another ID right |
219 // now. | 220 // now. |
220 Status AddId(const std::string& id, const std::string& type, | 221 Status AddId(const std::string& id, |
221 std::vector<std::string>& codecs); | 222 const std::string& type, |
| 223 const std::string& codecs); |
222 | 224 |
223 // Notifies a caller via |tracks_updated_cb| that the set of media tracks | 225 // Notifies a caller via |tracks_updated_cb| that the set of media tracks |
224 // for a given |id| has changed. | 226 // for a given |id| has changed. |
225 void SetTracksWatcher(const std::string& id, | 227 void SetTracksWatcher(const std::string& id, |
226 const MediaTracksUpdatedCB& tracks_updated_cb); | 228 const MediaTracksUpdatedCB& tracks_updated_cb); |
227 | 229 |
228 // Removed an ID & associated resources that were previously added with | 230 // Removed an ID & associated resources that were previously added with |
229 // AddId(). | 231 // AddId(). |
230 void RemoveId(const std::string& id); | 232 void RemoveId(const std::string& id); |
231 | 233 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 void ReportError_Locked(PipelineStatus error); | 339 void ReportError_Locked(PipelineStatus error); |
338 | 340 |
339 // Returns true if any stream has seeked to a time without buffered data. | 341 // Returns true if any stream has seeked to a time without buffered data. |
340 bool IsSeekWaitingForData_Locked() const; | 342 bool IsSeekWaitingForData_Locked() const; |
341 | 343 |
342 // Returns true if all streams can successfully call EndOfStream, | 344 // Returns true if all streams can successfully call EndOfStream, |
343 // false if any can not. | 345 // false if any can not. |
344 bool CanEndOfStream_Locked() const; | 346 bool CanEndOfStream_Locked() const; |
345 | 347 |
346 // MediaSourceState callbacks. | 348 // MediaSourceState callbacks. |
347 void OnSourceInitDone(const StreamParser::InitParameters& params); | 349 void OnSourceInitDone(const std::string& source_id, |
| 350 const StreamParser::InitParameters& params); |
348 | 351 |
349 // Creates a DemuxerStream for the specified |type|. | 352 // Creates a DemuxerStream for the specified |type|. |
350 // Returns a new ChunkDemuxerStream instance if a stream of this type | 353 // Returns a new ChunkDemuxerStream instance if a stream of this type |
351 // has not been created before. Returns NULL otherwise. | 354 // has not been created before. Returns NULL otherwise. |
352 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); | 355 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); |
353 | 356 |
354 void OnNewTextTrack(ChunkDemuxerStream* text_stream, | 357 void OnNewTextTrack(ChunkDemuxerStream* text_stream, |
355 const TextTrackConfig& config); | 358 const TextTrackConfig& config); |
356 | 359 |
357 // Returns true if |source_id| is valid, false otherwise. | 360 // Returns true if |source_id| is valid, false otherwise. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 // MediaLog for reporting messages and properties to debug content and engine. | 404 // MediaLog for reporting messages and properties to debug content and engine. |
402 scoped_refptr<MediaLog> media_log_; | 405 scoped_refptr<MediaLog> media_log_; |
403 | 406 |
404 PipelineStatusCB init_cb_; | 407 PipelineStatusCB init_cb_; |
405 // Callback to execute upon seek completion. | 408 // Callback to execute upon seek completion. |
406 // TODO(wolenetz/acolwell): Protect against possible double-locking by first | 409 // TODO(wolenetz/acolwell): Protect against possible double-locking by first |
407 // releasing |lock_| before executing this callback. See | 410 // releasing |lock_| before executing this callback. See |
408 // http://crbug.com/308226 | 411 // http://crbug.com/308226 |
409 PipelineStatusCB seek_cb_; | 412 PipelineStatusCB seek_cb_; |
410 | 413 |
411 std::unique_ptr<ChunkDemuxerStream> audio_; | 414 std::vector<std::unique_ptr<ChunkDemuxerStream>> audio_streams_; |
412 std::unique_ptr<ChunkDemuxerStream> video_; | 415 std::vector<std::unique_ptr<ChunkDemuxerStream>> video_streams_; |
413 | 416 |
414 // Counter to ensure that we do not transition too early to INITIALIZED. | 417 // Keep track of which ids still remain uninitialized so that we transition |
415 // Incremented in AddId(), decremented in OnSourceInitDone(). | 418 // into the INITIALIZED only after all ids/SourceBuffers got init segment. |
416 int pending_source_init_done_count_; | 419 std::set<std::string> pending_source_init_ids_; |
417 | 420 |
418 base::TimeDelta duration_; | 421 base::TimeDelta duration_; |
419 | 422 |
420 // The duration passed to the last SetDuration(). If | 423 // The duration passed to the last SetDuration(). If |
421 // SetDuration() is never called or an AppendData() call or | 424 // SetDuration() is never called or an AppendData() call or |
422 // a EndOfStream() call changes |duration_|, then this | 425 // a EndOfStream() call changes |duration_|, then this |
423 // variable is set to < 0 to indicate that the |duration_| represents | 426 // variable is set to < 0 to indicate that the |duration_| represents |
424 // the actual duration instead of a user specified value. | 427 // the actual duration instead of a user specified value. |
425 double user_specified_duration_; | 428 double user_specified_duration_; |
426 | 429 |
427 base::Time timeline_offset_; | 430 base::Time timeline_offset_; |
428 DemuxerStream::Liveness liveness_; | 431 DemuxerStream::Liveness liveness_; |
429 | 432 |
430 typedef std::map<std::string, MediaSourceState*> MediaSourceStateMap; | 433 typedef std::map<std::string, MediaSourceState*> MediaSourceStateMap; |
431 MediaSourceStateMap source_state_map_; | 434 MediaSourceStateMap source_state_map_; |
432 | 435 |
433 // Used to ensure that (1) config data matches the type and codec provided in | |
434 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be | |
435 // removed with RemoveID() but can not be re-added (yet). | |
436 std::string source_id_audio_; | |
437 std::string source_id_video_; | |
438 | |
439 // Indicates that splice frame generation is enabled. | 436 // Indicates that splice frame generation is enabled. |
440 const bool splice_frames_enabled_; | 437 const bool splice_frames_enabled_; |
441 | 438 |
442 // Accumulate, by type, detected track counts across the SourceBuffers. | 439 // Accumulate, by type, detected track counts across the SourceBuffers. |
443 int detected_audio_track_count_; | 440 int detected_audio_track_count_; |
444 int detected_video_track_count_; | 441 int detected_video_track_count_; |
445 int detected_text_track_count_; | 442 int detected_text_track_count_; |
446 | 443 |
447 std::map<MediaTrack::Id, const DemuxerStream*> track_id_to_demux_stream_map_; | 444 std::map<MediaTrack::Id, DemuxerStream*> track_id_to_demux_stream_map_; |
448 | 445 |
449 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 446 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
450 }; | 447 }; |
451 | 448 |
452 } // namespace media | 449 } // namespace media |
453 | 450 |
454 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 451 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
OLD | NEW |