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 | 10 |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 return true; | 695 return true; |
696 } | 696 } |
697 | 697 |
698 void SourceState::OnSourceInitDone(bool success, | 698 void SourceState::OnSourceInitDone(bool success, |
699 TimeDelta duration, | 699 TimeDelta duration, |
700 bool auto_update_timestamp_offset) { | 700 bool auto_update_timestamp_offset) { |
701 auto_update_timestamp_offset_ = auto_update_timestamp_offset; | 701 auto_update_timestamp_offset_ = auto_update_timestamp_offset; |
702 base::ResetAndReturn(&init_cb_).Run(success, duration); | 702 base::ResetAndReturn(&init_cb_).Run(success, duration); |
703 } | 703 } |
704 | 704 |
705 ChunkDemuxerStream::ChunkDemuxerStream(Type type) | 705 ChunkDemuxerStream::ChunkDemuxerStream(Type type, bool splice_frames_enabled) |
706 : type_(type), | 706 : type_(type), |
707 state_(UNINITIALIZED) { | 707 state_(UNINITIALIZED), |
708 } | 708 splice_frames_enabled_(splice_frames_enabled) {} |
709 | 709 |
710 void ChunkDemuxerStream::StartReturningData() { | 710 void ChunkDemuxerStream::StartReturningData() { |
711 DVLOG(1) << "ChunkDemuxerStream::StartReturningData()"; | 711 DVLOG(1) << "ChunkDemuxerStream::StartReturningData()"; |
712 base::AutoLock auto_lock(lock_); | 712 base::AutoLock auto_lock(lock_); |
713 DCHECK(read_cb_.is_null()); | 713 DCHECK(read_cb_.is_null()); |
714 ChangeState_Locked(RETURNING_DATA_FOR_READS); | 714 ChangeState_Locked(RETURNING_DATA_FOR_READS); |
715 } | 715 } |
716 | 716 |
717 void ChunkDemuxerStream::AbortReads() { | 717 void ChunkDemuxerStream::AbortReads() { |
718 DVLOG(1) << "ChunkDemuxerStream::AbortReads()"; | 718 DVLOG(1) << "ChunkDemuxerStream::AbortReads()"; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 stream_->OnNewMediaSegment(start_timestamp); | 829 stream_->OnNewMediaSegment(start_timestamp); |
830 } | 830 } |
831 | 831 |
832 bool ChunkDemuxerStream::UpdateAudioConfig(const AudioDecoderConfig& config, | 832 bool ChunkDemuxerStream::UpdateAudioConfig(const AudioDecoderConfig& config, |
833 const LogCB& log_cb) { | 833 const LogCB& log_cb) { |
834 DCHECK(config.IsValidConfig()); | 834 DCHECK(config.IsValidConfig()); |
835 DCHECK_EQ(type_, AUDIO); | 835 DCHECK_EQ(type_, AUDIO); |
836 base::AutoLock auto_lock(lock_); | 836 base::AutoLock auto_lock(lock_); |
837 if (!stream_) { | 837 if (!stream_) { |
838 DCHECK_EQ(state_, UNINITIALIZED); | 838 DCHECK_EQ(state_, UNINITIALIZED); |
839 stream_.reset(new SourceBufferStream(config, log_cb)); | 839 stream_.reset( |
| 840 new SourceBufferStream(config, log_cb, splice_frames_enabled_)); |
840 return true; | 841 return true; |
841 } | 842 } |
842 | 843 |
843 return stream_->UpdateAudioConfig(config); | 844 return stream_->UpdateAudioConfig(config); |
844 } | 845 } |
845 | 846 |
846 bool ChunkDemuxerStream::UpdateVideoConfig(const VideoDecoderConfig& config, | 847 bool ChunkDemuxerStream::UpdateVideoConfig(const VideoDecoderConfig& config, |
847 const LogCB& log_cb) { | 848 const LogCB& log_cb) { |
848 DCHECK(config.IsValidConfig()); | 849 DCHECK(config.IsValidConfig()); |
849 DCHECK_EQ(type_, VIDEO); | 850 DCHECK_EQ(type_, VIDEO); |
850 base::AutoLock auto_lock(lock_); | 851 base::AutoLock auto_lock(lock_); |
851 | 852 |
852 if (!stream_) { | 853 if (!stream_) { |
853 DCHECK_EQ(state_, UNINITIALIZED); | 854 DCHECK_EQ(state_, UNINITIALIZED); |
854 stream_.reset(new SourceBufferStream(config, log_cb)); | 855 stream_.reset( |
| 856 new SourceBufferStream(config, log_cb, splice_frames_enabled_)); |
855 return true; | 857 return true; |
856 } | 858 } |
857 | 859 |
858 return stream_->UpdateVideoConfig(config); | 860 return stream_->UpdateVideoConfig(config); |
859 } | 861 } |
860 | 862 |
861 void ChunkDemuxerStream::UpdateTextConfig(const TextTrackConfig& config, | 863 void ChunkDemuxerStream::UpdateTextConfig(const TextTrackConfig& config, |
862 const LogCB& log_cb) { | 864 const LogCB& log_cb) { |
863 DCHECK_EQ(type_, TEXT); | 865 DCHECK_EQ(type_, TEXT); |
864 base::AutoLock auto_lock(lock_); | 866 base::AutoLock auto_lock(lock_); |
865 DCHECK(!stream_); | 867 DCHECK(!stream_); |
866 DCHECK_EQ(state_, UNINITIALIZED); | 868 DCHECK_EQ(state_, UNINITIALIZED); |
867 stream_.reset(new SourceBufferStream(config, log_cb)); | 869 stream_.reset(new SourceBufferStream(config, log_cb, splice_frames_enabled_)); |
868 } | 870 } |
869 | 871 |
870 void ChunkDemuxerStream::MarkEndOfStream() { | 872 void ChunkDemuxerStream::MarkEndOfStream() { |
871 base::AutoLock auto_lock(lock_); | 873 base::AutoLock auto_lock(lock_); |
872 stream_->MarkEndOfStream(); | 874 stream_->MarkEndOfStream(); |
873 } | 875 } |
874 | 876 |
875 void ChunkDemuxerStream::UnmarkEndOfStream() { | 877 void ChunkDemuxerStream::UnmarkEndOfStream() { |
876 base::AutoLock auto_lock(lock_); | 878 base::AutoLock auto_lock(lock_); |
877 stream_->UnmarkEndOfStream(); | 879 stream_->UnmarkEndOfStream(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 status = DemuxerStream::kOk; | 965 status = DemuxerStream::kOk; |
964 buffer = StreamParserBuffer::CreateEOSBuffer(); | 966 buffer = StreamParserBuffer::CreateEOSBuffer(); |
965 break; | 967 break; |
966 } | 968 } |
967 | 969 |
968 base::ResetAndReturn(&read_cb_).Run(status, buffer); | 970 base::ResetAndReturn(&read_cb_).Run(status, buffer); |
969 } | 971 } |
970 | 972 |
971 ChunkDemuxer::ChunkDemuxer(const base::Closure& open_cb, | 973 ChunkDemuxer::ChunkDemuxer(const base::Closure& open_cb, |
972 const NeedKeyCB& need_key_cb, | 974 const NeedKeyCB& need_key_cb, |
973 const LogCB& log_cb) | 975 const LogCB& log_cb, |
| 976 bool splice_frames_enabled) |
974 : state_(WAITING_FOR_INIT), | 977 : state_(WAITING_FOR_INIT), |
975 cancel_next_seek_(false), | 978 cancel_next_seek_(false), |
976 host_(NULL), | 979 host_(NULL), |
977 open_cb_(open_cb), | 980 open_cb_(open_cb), |
978 need_key_cb_(need_key_cb), | 981 need_key_cb_(need_key_cb), |
979 enable_text_(false), | 982 enable_text_(false), |
980 log_cb_(log_cb), | 983 log_cb_(log_cb), |
981 duration_(kNoTimestamp()), | 984 duration_(kNoTimestamp()), |
982 user_specified_duration_(-1) { | 985 user_specified_duration_(-1), |
| 986 splice_frames_enabled_(splice_frames_enabled) { |
983 DCHECK(!open_cb_.is_null()); | 987 DCHECK(!open_cb_.is_null()); |
984 DCHECK(!need_key_cb_.is_null()); | 988 DCHECK(!need_key_cb_.is_null()); |
985 } | 989 } |
986 | 990 |
987 void ChunkDemuxer::Initialize( | 991 void ChunkDemuxer::Initialize( |
988 DemuxerHost* host, | 992 DemuxerHost* host, |
989 const PipelineStatusCB& cb, | 993 const PipelineStatusCB& cb, |
990 bool enable_text_tracks) { | 994 bool enable_text_tracks) { |
991 DVLOG(1) << "Init()"; | 995 DVLOG(1) << "Init()"; |
992 | 996 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 ChangeState_Locked(INITIALIZED); | 1508 ChangeState_Locked(INITIALIZED); |
1505 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 1509 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
1506 } | 1510 } |
1507 | 1511 |
1508 ChunkDemuxerStream* | 1512 ChunkDemuxerStream* |
1509 ChunkDemuxer::CreateDemuxerStream(DemuxerStream::Type type) { | 1513 ChunkDemuxer::CreateDemuxerStream(DemuxerStream::Type type) { |
1510 switch (type) { | 1514 switch (type) { |
1511 case DemuxerStream::AUDIO: | 1515 case DemuxerStream::AUDIO: |
1512 if (audio_) | 1516 if (audio_) |
1513 return NULL; | 1517 return NULL; |
1514 audio_.reset(new ChunkDemuxerStream(DemuxerStream::AUDIO)); | 1518 audio_.reset( |
| 1519 new ChunkDemuxerStream(DemuxerStream::AUDIO, splice_frames_enabled_)); |
1515 return audio_.get(); | 1520 return audio_.get(); |
1516 break; | 1521 break; |
1517 case DemuxerStream::VIDEO: | 1522 case DemuxerStream::VIDEO: |
1518 if (video_) | 1523 if (video_) |
1519 return NULL; | 1524 return NULL; |
1520 video_.reset(new ChunkDemuxerStream(DemuxerStream::VIDEO)); | 1525 video_.reset( |
| 1526 new ChunkDemuxerStream(DemuxerStream::VIDEO, splice_frames_enabled_)); |
1521 return video_.get(); | 1527 return video_.get(); |
1522 break; | 1528 break; |
1523 case DemuxerStream::TEXT: { | 1529 case DemuxerStream::TEXT: { |
1524 return new ChunkDemuxerStream(DemuxerStream::TEXT); | 1530 return new ChunkDemuxerStream(DemuxerStream::TEXT, |
| 1531 splice_frames_enabled_); |
1525 break; | 1532 break; |
1526 } | 1533 } |
1527 case DemuxerStream::UNKNOWN: | 1534 case DemuxerStream::UNKNOWN: |
1528 case DemuxerStream::NUM_TYPES: | 1535 case DemuxerStream::NUM_TYPES: |
1529 NOTREACHED(); | 1536 NOTREACHED(); |
1530 return NULL; | 1537 return NULL; |
1531 } | 1538 } |
1532 NOTREACHED(); | 1539 NOTREACHED(); |
1533 return NULL; | 1540 return NULL; |
1534 } | 1541 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 } | 1640 } |
1634 | 1641 |
1635 void ChunkDemuxer::ShutdownAllStreams() { | 1642 void ChunkDemuxer::ShutdownAllStreams() { |
1636 for (SourceStateMap::iterator itr = source_state_map_.begin(); | 1643 for (SourceStateMap::iterator itr = source_state_map_.begin(); |
1637 itr != source_state_map_.end(); ++itr) { | 1644 itr != source_state_map_.end(); ++itr) { |
1638 itr->second->Shutdown(); | 1645 itr->second->Shutdown(); |
1639 } | 1646 } |
1640 } | 1647 } |
1641 | 1648 |
1642 } // namespace media | 1649 } // namespace media |
OLD | NEW |