| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // ChunkDemuxerStreams managed by this object. | 131 // ChunkDemuxerStreams managed by this object. |
| 132 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); | 132 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); |
| 133 | 133 |
| 134 // Returns true if currently parsing a media segment, or false otherwise. | 134 // Returns true if currently parsing a media segment, or false otherwise. |
| 135 bool parsing_media_segment() const { return parsing_media_segment_; } | 135 bool parsing_media_segment() const { return parsing_media_segment_; } |
| 136 | 136 |
| 137 // Sets |frame_processor_|'s sequence mode to |sequence_mode|. | 137 // Sets |frame_processor_|'s sequence mode to |sequence_mode|. |
| 138 void SetSequenceMode(bool sequence_mode); | 138 void SetSequenceMode(bool sequence_mode); |
| 139 | 139 |
| 140 // Returns the range of buffered data in this source, capped at |duration|. | 140 // Returns the range of buffered data in this source, capped at |duration|. |
| 141 // |ended| - Set to true if end of stream has been signalled and the special | 141 // |ended| - Set to true if end of stream has been signaled and the special |
| 142 // end of stream range logic needs to be executed. | 142 // end of stream range logic needs to be executed. |
| 143 Ranges<TimeDelta> GetBufferedRanges(TimeDelta duration, bool ended) const; | 143 Ranges<TimeDelta> GetBufferedRanges(TimeDelta duration, bool ended) const; |
| 144 | 144 |
| 145 // Returns the highest buffered duration across all streams managed | 145 // Returns the highest buffered duration across all streams managed |
| 146 // by this object. | 146 // by this object. |
| 147 // Returns TimeDelta() if none of the streams contain buffered data. | 147 // Returns TimeDelta() if none of the streams contain buffered data. |
| 148 TimeDelta GetMaxBufferedDuration() const; | 148 TimeDelta GetMaxBufferedDuration() const; |
| 149 | 149 |
| 150 // Helper methods that call methods with similar names on all the | 150 // Helper methods that call methods with similar names on all the |
| 151 // ChunkDemuxerStreams managed by this object. | 151 // ChunkDemuxerStreams managed by this object. |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 SeekAllSources(seek_time); | 1099 SeekAllSources(seek_time); |
| 1100 | 1100 |
| 1101 if (seek_cb_.is_null()) { | 1101 if (seek_cb_.is_null()) { |
| 1102 cancel_next_seek_ = true; | 1102 cancel_next_seek_ = true; |
| 1103 return; | 1103 return; |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); | 1106 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 ChunkDemuxer::Status ChunkDemuxer::AddId(const std::string& id, | 1109 ChunkDemuxer::Status ChunkDemuxer::AddId( |
| 1110 const std::string& type, | 1110 const std::string& id, |
| 1111 std::vector<std::string>& codecs) { | 1111 const std::string& type, |
| 1112 std::vector<std::string>& codecs, |
| 1113 const bool use_legacy_frame_processor) { |
| 1112 base::AutoLock auto_lock(lock_); | 1114 base::AutoLock auto_lock(lock_); |
| 1113 | 1115 |
| 1114 if ((state_ != WAITING_FOR_INIT && state_ != INITIALIZING) || IsValidId(id)) | 1116 if ((state_ != WAITING_FOR_INIT && state_ != INITIALIZING) || IsValidId(id)) |
| 1115 return kReachedIdLimit; | 1117 return kReachedIdLimit; |
| 1116 | 1118 |
| 1117 bool has_audio = false; | 1119 bool has_audio = false; |
| 1118 bool has_video = false; | 1120 bool has_video = false; |
| 1119 scoped_ptr<media::StreamParser> stream_parser( | 1121 scoped_ptr<media::StreamParser> stream_parser( |
| 1120 StreamParserFactory::Create(type, codecs, log_cb_, | 1122 StreamParserFactory::Create(type, codecs, log_cb_, |
| 1121 &has_audio, &has_video)); | 1123 &has_audio, &has_video)); |
| 1122 | 1124 |
| 1123 if (!stream_parser) | 1125 if (!stream_parser) |
| 1124 return ChunkDemuxer::kNotSupported; | 1126 return ChunkDemuxer::kNotSupported; |
| 1125 | 1127 |
| 1126 if ((has_audio && !source_id_audio_.empty()) || | 1128 if ((has_audio && !source_id_audio_.empty()) || |
| 1127 (has_video && !source_id_video_.empty())) | 1129 (has_video && !source_id_video_.empty())) |
| 1128 return kReachedIdLimit; | 1130 return kReachedIdLimit; |
| 1129 | 1131 |
| 1130 if (has_audio) | 1132 if (has_audio) |
| 1131 source_id_audio_ = id; | 1133 source_id_audio_ = id; |
| 1132 | 1134 |
| 1133 if (has_video) | 1135 if (has_video) |
| 1134 source_id_video_ = id; | 1136 source_id_video_ = id; |
| 1135 | 1137 |
| 1138 if (!use_legacy_frame_processor) { |
| 1139 DLOG(WARNING) << "New frame processor is not yet supported. Using legacy."; |
| 1140 } |
| 1141 |
| 1136 scoped_ptr<FrameProcessorBase> frame_processor(new LegacyFrameProcessor( | 1142 scoped_ptr<FrameProcessorBase> frame_processor(new LegacyFrameProcessor( |
| 1137 base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, | 1143 base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, |
| 1138 base::Unretained(this)))); | 1144 base::Unretained(this)))); |
| 1139 | 1145 |
| 1140 scoped_ptr<SourceState> source_state( | 1146 scoped_ptr<SourceState> source_state( |
| 1141 new SourceState(stream_parser.Pass(), | 1147 new SourceState(stream_parser.Pass(), |
| 1142 frame_processor.Pass(), log_cb_, | 1148 frame_processor.Pass(), log_cb_, |
| 1143 base::Bind(&ChunkDemuxer::CreateDemuxerStream, | 1149 base::Bind(&ChunkDemuxer::CreateDemuxerStream, |
| 1144 base::Unretained(this)))); | 1150 base::Unretained(this)))); |
| 1145 | 1151 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 } | 1644 } |
| 1639 | 1645 |
| 1640 void ChunkDemuxer::ShutdownAllStreams() { | 1646 void ChunkDemuxer::ShutdownAllStreams() { |
| 1641 for (SourceStateMap::iterator itr = source_state_map_.begin(); | 1647 for (SourceStateMap::iterator itr = source_state_map_.begin(); |
| 1642 itr != source_state_map_.end(); ++itr) { | 1648 itr != source_state_map_.end(); ++itr) { |
| 1643 itr->second->Shutdown(); | 1649 itr->second->Shutdown(); |
| 1644 } | 1650 } |
| 1645 } | 1651 } |
| 1646 | 1652 |
| 1647 } // namespace media | 1653 } // namespace media |
| OLD | NEW |