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 #include "media/filters/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <list> | 9 #include <list> |
10 #include <utility> | 10 #include <utility> |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 ChunkDemuxer::Status ChunkDemuxer::AddId(const std::string& id, | 506 ChunkDemuxer::Status ChunkDemuxer::AddId(const std::string& id, |
507 const std::string& type, | 507 const std::string& type, |
508 std::vector<std::string>& codecs) { | 508 std::vector<std::string>& codecs) { |
509 base::AutoLock auto_lock(lock_); | 509 base::AutoLock auto_lock(lock_); |
510 | 510 |
511 if ((state_ != WAITING_FOR_INIT && state_ != INITIALIZING) || IsValidId(id)) | 511 if ((state_ != WAITING_FOR_INIT && state_ != INITIALIZING) || IsValidId(id)) |
512 return kReachedIdLimit; | 512 return kReachedIdLimit; |
513 | 513 |
514 bool has_audio = false; | 514 bool has_audio = false; |
515 bool has_video = false; | 515 bool has_video = false; |
516 scoped_ptr<media::StreamParser> stream_parser(StreamParserFactory::Create( | 516 std::unique_ptr<media::StreamParser> stream_parser( |
517 type, codecs, media_log_, &has_audio, &has_video)); | 517 StreamParserFactory::Create(type, codecs, media_log_, &has_audio, |
| 518 &has_video)); |
518 | 519 |
519 if (!stream_parser) | 520 if (!stream_parser) |
520 return ChunkDemuxer::kNotSupported; | 521 return ChunkDemuxer::kNotSupported; |
521 | 522 |
522 if ((has_audio && !source_id_audio_.empty()) || | 523 if ((has_audio && !source_id_audio_.empty()) || |
523 (has_video && !source_id_video_.empty())) | 524 (has_video && !source_id_video_.empty())) |
524 return kReachedIdLimit; | 525 return kReachedIdLimit; |
525 | 526 |
526 if (has_audio) | 527 if (has_audio) |
527 source_id_audio_ = id; | 528 source_id_audio_ = id; |
528 | 529 |
529 if (has_video) | 530 if (has_video) |
530 source_id_video_ = id; | 531 source_id_video_ = id; |
531 | 532 |
532 scoped_ptr<FrameProcessor> frame_processor( | 533 std::unique_ptr<FrameProcessor> frame_processor( |
533 new FrameProcessor(base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, | 534 new FrameProcessor(base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, |
534 base::Unretained(this)), | 535 base::Unretained(this)), |
535 media_log_)); | 536 media_log_)); |
536 | 537 |
537 scoped_ptr<MediaSourceState> source_state(new MediaSourceState( | 538 std::unique_ptr<MediaSourceState> source_state(new MediaSourceState( |
538 std::move(stream_parser), std::move(frame_processor), | 539 std::move(stream_parser), std::move(frame_processor), |
539 base::Bind(&ChunkDemuxer::CreateDemuxerStream, base::Unretained(this)), | 540 base::Bind(&ChunkDemuxer::CreateDemuxerStream, base::Unretained(this)), |
540 media_log_)); | 541 media_log_)); |
541 | 542 |
542 MediaSourceState::NewTextTrackCB new_text_track_cb; | 543 MediaSourceState::NewTextTrackCB new_text_track_cb; |
543 | 544 |
544 if (enable_text_) { | 545 if (enable_text_) { |
545 new_text_track_cb = base::Bind(&ChunkDemuxer::OnNewTextTrack, | 546 new_text_track_cb = base::Bind(&ChunkDemuxer::OnNewTextTrack, |
546 base::Unretained(this)); | 547 base::Unretained(this)); |
547 } | 548 } |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 } | 1140 } |
1140 | 1141 |
1141 void ChunkDemuxer::ShutdownAllStreams() { | 1142 void ChunkDemuxer::ShutdownAllStreams() { |
1142 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); | 1143 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); |
1143 itr != source_state_map_.end(); ++itr) { | 1144 itr != source_state_map_.end(); ++itr) { |
1144 itr->second->Shutdown(); | 1145 itr->second->Shutdown(); |
1145 } | 1146 } |
1146 } | 1147 } |
1147 | 1148 |
1148 } // namespace media | 1149 } // namespace media |
OLD | NEW |