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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 | 766 |
767 return true; | 767 return true; |
768 } | 768 } |
769 | 769 |
770 void SourceState::OnSourceInitDone(bool success, | 770 void SourceState::OnSourceInitDone(bool success, |
771 const StreamParser::InitParameters& params) { | 771 const StreamParser::InitParameters& params) { |
772 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; | 772 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; |
773 base::ResetAndReturn(&init_cb_).Run(success, params); | 773 base::ResetAndReturn(&init_cb_).Run(success, params); |
774 } | 774 } |
775 | 775 |
776 ChunkDemuxerStream::ChunkDemuxerStream(Type type, bool splice_frames_enabled) | 776 ChunkDemuxerStream::ChunkDemuxerStream(Type type, |
| 777 Liveness liveness, |
| 778 bool splice_frames_enabled) |
777 : type_(type), | 779 : type_(type), |
| 780 liveness_(liveness), |
778 state_(UNINITIALIZED), | 781 state_(UNINITIALIZED), |
779 splice_frames_enabled_(splice_frames_enabled), | 782 splice_frames_enabled_(splice_frames_enabled), |
780 partial_append_window_trimming_enabled_(false) { | 783 partial_append_window_trimming_enabled_(false) { |
781 } | 784 } |
782 | 785 |
783 void ChunkDemuxerStream::StartReturningData() { | 786 void ChunkDemuxerStream::StartReturningData() { |
784 DVLOG(1) << "ChunkDemuxerStream::StartReturningData()"; | 787 DVLOG(1) << "ChunkDemuxerStream::StartReturningData()"; |
785 base::AutoLock auto_lock(lock_); | 788 base::AutoLock auto_lock(lock_); |
786 DCHECK(read_cb_.is_null()); | 789 DCHECK(read_cb_.is_null()); |
787 ChangeState_Locked(RETURNING_DATA_FOR_READS); | 790 ChangeState_Locked(RETURNING_DATA_FOR_READS); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 // DemuxerStream methods. | 968 // DemuxerStream methods. |
966 void ChunkDemuxerStream::Read(const ReadCB& read_cb) { | 969 void ChunkDemuxerStream::Read(const ReadCB& read_cb) { |
967 base::AutoLock auto_lock(lock_); | 970 base::AutoLock auto_lock(lock_); |
968 DCHECK_NE(state_, UNINITIALIZED); | 971 DCHECK_NE(state_, UNINITIALIZED); |
969 DCHECK(read_cb_.is_null()); | 972 DCHECK(read_cb_.is_null()); |
970 | 973 |
971 read_cb_ = BindToCurrentLoop(read_cb); | 974 read_cb_ = BindToCurrentLoop(read_cb); |
972 CompletePendingReadIfPossible_Locked(); | 975 CompletePendingReadIfPossible_Locked(); |
973 } | 976 } |
974 | 977 |
975 DemuxerStream::Type ChunkDemuxerStream::type() { return type_; } | 978 DemuxerStream::Type ChunkDemuxerStream::type() const { return type_; } |
| 979 |
| 980 DemuxerStream::Liveness ChunkDemuxerStream::liveness() const { |
| 981 return liveness_; |
| 982 } |
976 | 983 |
977 AudioDecoderConfig ChunkDemuxerStream::audio_decoder_config() { | 984 AudioDecoderConfig ChunkDemuxerStream::audio_decoder_config() { |
978 CHECK_EQ(type_, AUDIO); | 985 CHECK_EQ(type_, AUDIO); |
979 base::AutoLock auto_lock(lock_); | 986 base::AutoLock auto_lock(lock_); |
980 return stream_->GetCurrentAudioDecoderConfig(); | 987 return stream_->GetCurrentAudioDecoderConfig(); |
981 } | 988 } |
982 | 989 |
983 VideoDecoderConfig ChunkDemuxerStream::video_decoder_config() { | 990 VideoDecoderConfig ChunkDemuxerStream::video_decoder_config() { |
984 CHECK_EQ(type_, VIDEO); | 991 CHECK_EQ(type_, VIDEO); |
985 base::AutoLock auto_lock(lock_); | 992 base::AutoLock auto_lock(lock_); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 bool splice_frames_enabled) | 1068 bool splice_frames_enabled) |
1062 : state_(WAITING_FOR_INIT), | 1069 : state_(WAITING_FOR_INIT), |
1063 cancel_next_seek_(false), | 1070 cancel_next_seek_(false), |
1064 host_(NULL), | 1071 host_(NULL), |
1065 open_cb_(open_cb), | 1072 open_cb_(open_cb), |
1066 need_key_cb_(need_key_cb), | 1073 need_key_cb_(need_key_cb), |
1067 enable_text_(false), | 1074 enable_text_(false), |
1068 log_cb_(log_cb), | 1075 log_cb_(log_cb), |
1069 duration_(kNoTimestamp()), | 1076 duration_(kNoTimestamp()), |
1070 user_specified_duration_(-1), | 1077 user_specified_duration_(-1), |
1071 liveness_(LIVENESS_UNKNOWN), | 1078 liveness_(DemuxerStream::LIVENESS_UNKNOWN), |
1072 splice_frames_enabled_(splice_frames_enabled) { | 1079 splice_frames_enabled_(splice_frames_enabled) { |
1073 DCHECK(!open_cb_.is_null()); | 1080 DCHECK(!open_cb_.is_null()); |
1074 DCHECK(!need_key_cb_.is_null()); | 1081 DCHECK(!need_key_cb_.is_null()); |
1075 } | 1082 } |
1076 | 1083 |
1077 void ChunkDemuxer::Initialize( | 1084 void ChunkDemuxer::Initialize( |
1078 DemuxerHost* host, | 1085 DemuxerHost* host, |
1079 const PipelineStatusCB& cb, | 1086 const PipelineStatusCB& cb, |
1080 bool enable_text_tracks) { | 1087 bool enable_text_tracks) { |
1081 DVLOG(1) << "Init()"; | 1088 DVLOG(1) << "Init()"; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 if (type == DemuxerStream::AUDIO) | 1152 if (type == DemuxerStream::AUDIO) |
1146 return audio_.get(); | 1153 return audio_.get(); |
1147 | 1154 |
1148 return NULL; | 1155 return NULL; |
1149 } | 1156 } |
1150 | 1157 |
1151 TimeDelta ChunkDemuxer::GetStartTime() const { | 1158 TimeDelta ChunkDemuxer::GetStartTime() const { |
1152 return TimeDelta(); | 1159 return TimeDelta(); |
1153 } | 1160 } |
1154 | 1161 |
1155 Demuxer::Liveness ChunkDemuxer::GetLiveness() const { | |
1156 return liveness_; | |
1157 } | |
1158 | |
1159 void ChunkDemuxer::StartWaitingForSeek(TimeDelta seek_time) { | 1162 void ChunkDemuxer::StartWaitingForSeek(TimeDelta seek_time) { |
1160 DVLOG(1) << "StartWaitingForSeek()"; | 1163 DVLOG(1) << "StartWaitingForSeek()"; |
1161 base::AutoLock auto_lock(lock_); | 1164 base::AutoLock auto_lock(lock_); |
1162 DCHECK(state_ == INITIALIZED || state_ == ENDED || state_ == SHUTDOWN || | 1165 DCHECK(state_ == INITIALIZED || state_ == ENDED || state_ == SHUTDOWN || |
1163 state_ == PARSE_ERROR) << state_; | 1166 state_ == PARSE_ERROR) << state_; |
1164 DCHECK(seek_cb_.is_null()); | 1167 DCHECK(seek_cb_.is_null()); |
1165 | 1168 |
1166 if (state_ == SHUTDOWN || state_ == PARSE_ERROR) | 1169 if (state_ == SHUTDOWN || state_ == PARSE_ERROR) |
1167 return; | 1170 return; |
1168 | 1171 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 params.timeline_offset != timeline_offset_) { | 1632 params.timeline_offset != timeline_offset_) { |
1630 MEDIA_LOG(log_cb_) | 1633 MEDIA_LOG(log_cb_) |
1631 << "Timeline offset is not the same across all SourceBuffers."; | 1634 << "Timeline offset is not the same across all SourceBuffers."; |
1632 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN); | 1635 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN); |
1633 return; | 1636 return; |
1634 } | 1637 } |
1635 | 1638 |
1636 timeline_offset_ = params.timeline_offset; | 1639 timeline_offset_ = params.timeline_offset; |
1637 } | 1640 } |
1638 | 1641 |
1639 if (params.liveness != LIVENESS_UNKNOWN) { | 1642 if (params.liveness != DemuxerStream::LIVENESS_UNKNOWN) { |
1640 if (liveness_ != LIVENESS_UNKNOWN && params.liveness != liveness_) { | 1643 if (liveness_ != DemuxerStream::LIVENESS_UNKNOWN && |
| 1644 params.liveness != liveness_) { |
1641 MEDIA_LOG(log_cb_) | 1645 MEDIA_LOG(log_cb_) |
1642 << "Liveness is not the same across all SourceBuffers."; | 1646 << "Liveness is not the same across all SourceBuffers."; |
1643 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN); | 1647 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN); |
1644 return; | 1648 return; |
1645 } | 1649 } |
1646 | 1650 |
1647 liveness_ = params.liveness; | 1651 liveness_ = params.liveness; |
1648 } | 1652 } |
1649 | 1653 |
1650 // Wait until all streams have initialized. | 1654 // Wait until all streams have initialized. |
(...skipping 12 matching lines...) Expand all Loading... |
1663 ChangeState_Locked(INITIALIZED); | 1667 ChangeState_Locked(INITIALIZED); |
1664 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 1668 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
1665 } | 1669 } |
1666 | 1670 |
1667 ChunkDemuxerStream* | 1671 ChunkDemuxerStream* |
1668 ChunkDemuxer::CreateDemuxerStream(DemuxerStream::Type type) { | 1672 ChunkDemuxer::CreateDemuxerStream(DemuxerStream::Type type) { |
1669 switch (type) { | 1673 switch (type) { |
1670 case DemuxerStream::AUDIO: | 1674 case DemuxerStream::AUDIO: |
1671 if (audio_) | 1675 if (audio_) |
1672 return NULL; | 1676 return NULL; |
1673 audio_.reset( | 1677 audio_.reset(new ChunkDemuxerStream(DemuxerStream::AUDIO, liveness_, |
1674 new ChunkDemuxerStream(DemuxerStream::AUDIO, splice_frames_enabled_)); | 1678 splice_frames_enabled_)); |
1675 return audio_.get(); | 1679 return audio_.get(); |
1676 break; | 1680 break; |
1677 case DemuxerStream::VIDEO: | 1681 case DemuxerStream::VIDEO: |
1678 if (video_) | 1682 if (video_) |
1679 return NULL; | 1683 return NULL; |
1680 video_.reset( | 1684 video_.reset(new ChunkDemuxerStream(DemuxerStream::VIDEO, liveness_, |
1681 new ChunkDemuxerStream(DemuxerStream::VIDEO, splice_frames_enabled_)); | 1685 splice_frames_enabled_)); |
1682 return video_.get(); | 1686 return video_.get(); |
1683 break; | 1687 break; |
1684 case DemuxerStream::TEXT: { | 1688 case DemuxerStream::TEXT: { |
1685 return new ChunkDemuxerStream(DemuxerStream::TEXT, | 1689 return new ChunkDemuxerStream(DemuxerStream::TEXT, liveness_, |
1686 splice_frames_enabled_); | 1690 splice_frames_enabled_); |
1687 break; | 1691 break; |
1688 } | 1692 } |
1689 case DemuxerStream::UNKNOWN: | 1693 case DemuxerStream::UNKNOWN: |
1690 case DemuxerStream::NUM_TYPES: | 1694 case DemuxerStream::NUM_TYPES: |
1691 NOTREACHED(); | 1695 NOTREACHED(); |
1692 return NULL; | 1696 return NULL; |
1693 } | 1697 } |
1694 NOTREACHED(); | 1698 NOTREACHED(); |
1695 return NULL; | 1699 return NULL; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 } | 1805 } |
1802 | 1806 |
1803 void ChunkDemuxer::ShutdownAllStreams() { | 1807 void ChunkDemuxer::ShutdownAllStreams() { |
1804 for (SourceStateMap::iterator itr = source_state_map_.begin(); | 1808 for (SourceStateMap::iterator itr = source_state_map_.begin(); |
1805 itr != source_state_map_.end(); ++itr) { | 1809 itr != source_state_map_.end(); ++itr) { |
1806 itr->second->Shutdown(); | 1810 itr->second->Shutdown(); |
1807 } | 1811 } |
1808 } | 1812 } |
1809 | 1813 |
1810 } // namespace media | 1814 } // namespace media |
OLD | NEW |