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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "media/base/audio_decoder_config.h" | 16 #include "media/base/audio_decoder_config.h" |
17 #include "media/base/bind_to_current_loop.h" | 17 #include "media/base/bind_to_current_loop.h" |
18 #include "media/base/stream_parser_buffer.h" | 18 #include "media/base/stream_parser_buffer.h" |
19 #include "media/base/video_decoder_config.h" | 19 #include "media/base/video_decoder_config.h" |
20 #include "media/filters/frame_processor.h" | 20 #include "media/filters/frame_processor.h" |
21 #include "media/filters/legacy_frame_processor.h" | |
22 #include "media/filters/stream_parser_factory.h" | 21 #include "media/filters/stream_parser_factory.h" |
23 | 22 |
24 using base::TimeDelta; | 23 using base::TimeDelta; |
25 | 24 |
26 namespace media { | 25 namespace media { |
27 | 26 |
28 static TimeDelta EndTimestamp(const StreamParser::BufferQueue& queue) { | 27 static TimeDelta EndTimestamp(const StreamParser::BufferQueue& queue) { |
29 return queue.back()->timestamp() + queue.back()->duration(); | 28 return queue.back()->timestamp() + queue.back()->duration(); |
30 } | 29 } |
31 | 30 |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1133 SeekAllSources(seek_time); | 1132 SeekAllSources(seek_time); |
1134 | 1133 |
1135 if (seek_cb_.is_null()) { | 1134 if (seek_cb_.is_null()) { |
1136 cancel_next_seek_ = true; | 1135 cancel_next_seek_ = true; |
1137 return; | 1136 return; |
1138 } | 1137 } |
1139 | 1138 |
1140 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); | 1139 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); |
1141 } | 1140 } |
1142 | 1141 |
1143 ChunkDemuxer::Status ChunkDemuxer::AddId( | 1142 ChunkDemuxer::Status ChunkDemuxer::AddId(const std::string& id, |
1144 const std::string& id, | 1143 const std::string& type, |
1145 const std::string& type, | 1144 std::vector<std::string>& codecs) { |
1146 std::vector<std::string>& codecs, | |
1147 const bool use_legacy_frame_processor) { | |
1148 base::AutoLock auto_lock(lock_); | 1145 base::AutoLock auto_lock(lock_); |
1149 | 1146 |
1150 if ((state_ != WAITING_FOR_INIT && state_ != INITIALIZING) || IsValidId(id)) | 1147 if ((state_ != WAITING_FOR_INIT && state_ != INITIALIZING) || IsValidId(id)) |
1151 return kReachedIdLimit; | 1148 return kReachedIdLimit; |
1152 | 1149 |
1153 bool has_audio = false; | 1150 bool has_audio = false; |
1154 bool has_video = false; | 1151 bool has_video = false; |
1155 scoped_ptr<media::StreamParser> stream_parser( | 1152 scoped_ptr<media::StreamParser> stream_parser( |
1156 StreamParserFactory::Create(type, codecs, log_cb_, | 1153 StreamParserFactory::Create(type, codecs, log_cb_, |
1157 &has_audio, &has_video)); | 1154 &has_audio, &has_video)); |
1158 | 1155 |
1159 if (!stream_parser) | 1156 if (!stream_parser) |
1160 return ChunkDemuxer::kNotSupported; | 1157 return ChunkDemuxer::kNotSupported; |
1161 | 1158 |
1162 if ((has_audio && !source_id_audio_.empty()) || | 1159 if ((has_audio && !source_id_audio_.empty()) || |
1163 (has_video && !source_id_video_.empty())) | 1160 (has_video && !source_id_video_.empty())) |
1164 return kReachedIdLimit; | 1161 return kReachedIdLimit; |
1165 | 1162 |
1166 if (has_audio) | 1163 if (has_audio) |
1167 source_id_audio_ = id; | 1164 source_id_audio_ = id; |
1168 | 1165 |
1169 if (has_video) | 1166 if (has_video) |
1170 source_id_video_ = id; | 1167 source_id_video_ = id; |
1171 | 1168 |
1172 scoped_ptr<FrameProcessorBase> frame_processor; | 1169 scoped_ptr<FrameProcessorBase> frame_processor( |
acolwell GONE FROM CHROMIUM
2014/06/13 18:26:42
s/Base//?
wolenetz
2014/06/16 20:01:38
Done. I'm leaving the merger of FrameProcessorBase
| |
1173 if (use_legacy_frame_processor) { | 1170 new FrameProcessor(base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, |
1174 frame_processor.reset(new LegacyFrameProcessor( | 1171 base::Unretained(this)))); |
1175 base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, | |
1176 base::Unretained(this)))); | |
1177 } else { | |
1178 frame_processor.reset(new FrameProcessor( | |
1179 base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, | |
1180 base::Unretained(this)))); | |
1181 } | |
1182 | 1172 |
1183 scoped_ptr<SourceState> source_state( | 1173 scoped_ptr<SourceState> source_state( |
1184 new SourceState(stream_parser.Pass(), | 1174 new SourceState(stream_parser.Pass(), |
1185 frame_processor.Pass(), log_cb_, | 1175 frame_processor.Pass(), log_cb_, |
1186 base::Bind(&ChunkDemuxer::CreateDemuxerStream, | 1176 base::Bind(&ChunkDemuxer::CreateDemuxerStream, |
1187 base::Unretained(this)))); | 1177 base::Unretained(this)))); |
1188 | 1178 |
1189 SourceState::NewTextTrackCB new_text_track_cb; | 1179 SourceState::NewTextTrackCB new_text_track_cb; |
1190 | 1180 |
1191 if (enable_text_) { | 1181 if (enable_text_) { |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1744 } | 1734 } |
1745 | 1735 |
1746 void ChunkDemuxer::ShutdownAllStreams() { | 1736 void ChunkDemuxer::ShutdownAllStreams() { |
1747 for (SourceStateMap::iterator itr = source_state_map_.begin(); | 1737 for (SourceStateMap::iterator itr = source_state_map_.begin(); |
1748 itr != source_state_map_.end(); ++itr) { | 1738 itr != source_state_map_.end(); ++itr) { |
1749 itr->second->Shutdown(); | 1739 itr->second->Shutdown(); |
1750 } | 1740 } |
1751 } | 1741 } |
1752 | 1742 |
1753 } // namespace media | 1743 } // namespace media |
OLD | NEW |