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 <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 | 180 |
181 void ChunkDemuxerStream::OnStartOfCodedFrameGroup( | 181 void ChunkDemuxerStream::OnStartOfCodedFrameGroup( |
182 DecodeTimestamp start_timestamp) { | 182 DecodeTimestamp start_timestamp) { |
183 DVLOG(2) << "ChunkDemuxerStream::OnStartOfCodedFrameGroup(" | 183 DVLOG(2) << "ChunkDemuxerStream::OnStartOfCodedFrameGroup(" |
184 << start_timestamp.InSecondsF() << ")"; | 184 << start_timestamp.InSecondsF() << ")"; |
185 base::AutoLock auto_lock(lock_); | 185 base::AutoLock auto_lock(lock_); |
186 stream_->OnStartOfCodedFrameGroup(start_timestamp); | 186 stream_->OnStartOfCodedFrameGroup(start_timestamp); |
187 } | 187 } |
188 | 188 |
189 bool ChunkDemuxerStream::UpdateAudioConfig( | 189 bool ChunkDemuxerStream::UpdateAudioConfig(const AudioDecoderConfig& config, |
190 const AudioDecoderConfig& config, | 190 MediaLog* media_log) { |
191 const scoped_refptr<MediaLog>& media_log) { | |
192 DCHECK(config.IsValidConfig()); | 191 DCHECK(config.IsValidConfig()); |
193 DCHECK_EQ(type_, AUDIO); | 192 DCHECK_EQ(type_, AUDIO); |
194 base::AutoLock auto_lock(lock_); | 193 base::AutoLock auto_lock(lock_); |
195 if (!stream_) { | 194 if (!stream_) { |
196 DCHECK_EQ(state_, UNINITIALIZED); | 195 DCHECK_EQ(state_, UNINITIALIZED); |
197 | 196 |
198 // Enable partial append window support for most audio codecs (notably: not | 197 // Enable partial append window support for most audio codecs (notably: not |
199 // opus). | 198 // opus). |
200 partial_append_window_trimming_enabled_ = config.codec() == kCodecMP3 || | 199 partial_append_window_trimming_enabled_ = config.codec() == kCodecMP3 || |
201 config.codec() == kCodecAAC || | 200 config.codec() == kCodecAAC || |
202 config.codec() == kCodecVorbis; | 201 config.codec() == kCodecVorbis; |
203 | 202 |
204 stream_.reset(new SourceBufferStream(config, media_log)); | 203 stream_.reset(new SourceBufferStream(config, media_log)); |
205 return true; | 204 return true; |
206 } | 205 } |
207 | 206 |
208 return stream_->UpdateAudioConfig(config); | 207 return stream_->UpdateAudioConfig(config); |
209 } | 208 } |
210 | 209 |
211 bool ChunkDemuxerStream::UpdateVideoConfig( | 210 bool ChunkDemuxerStream::UpdateVideoConfig(const VideoDecoderConfig& config, |
212 const VideoDecoderConfig& config, | 211 MediaLog* media_log) { |
213 const scoped_refptr<MediaLog>& media_log) { | |
214 DCHECK(config.IsValidConfig()); | 212 DCHECK(config.IsValidConfig()); |
215 DCHECK_EQ(type_, VIDEO); | 213 DCHECK_EQ(type_, VIDEO); |
216 base::AutoLock auto_lock(lock_); | 214 base::AutoLock auto_lock(lock_); |
217 | 215 |
218 if (!stream_) { | 216 if (!stream_) { |
219 DCHECK_EQ(state_, UNINITIALIZED); | 217 DCHECK_EQ(state_, UNINITIALIZED); |
220 stream_.reset(new SourceBufferStream(config, media_log)); | 218 stream_.reset(new SourceBufferStream(config, media_log)); |
221 return true; | 219 return true; |
222 } | 220 } |
223 | 221 |
224 return stream_->UpdateVideoConfig(config); | 222 return stream_->UpdateVideoConfig(config); |
225 } | 223 } |
226 | 224 |
227 void ChunkDemuxerStream::UpdateTextConfig( | 225 void ChunkDemuxerStream::UpdateTextConfig(const TextTrackConfig& config, |
228 const TextTrackConfig& config, | 226 MediaLog* media_log) { |
229 const scoped_refptr<MediaLog>& media_log) { | |
230 DCHECK_EQ(type_, TEXT); | 227 DCHECK_EQ(type_, TEXT); |
231 base::AutoLock auto_lock(lock_); | 228 base::AutoLock auto_lock(lock_); |
232 DCHECK(!stream_); | 229 DCHECK(!stream_); |
233 DCHECK_EQ(state_, UNINITIALIZED); | 230 DCHECK_EQ(state_, UNINITIALIZED); |
234 stream_.reset(new SourceBufferStream(config, media_log)); | 231 stream_.reset(new SourceBufferStream(config, media_log)); |
235 } | 232 } |
236 | 233 |
237 void ChunkDemuxerStream::MarkEndOfStream() { | 234 void ChunkDemuxerStream::MarkEndOfStream() { |
238 base::AutoLock auto_lock(lock_); | 235 base::AutoLock auto_lock(lock_); |
239 stream_->MarkEndOfStream(); | 236 stream_->MarkEndOfStream(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 DVLOG(2) << __func__ << ": returning kOk with EOS buffer, type " << type_; | 392 DVLOG(2) << __func__ << ": returning kOk with EOS buffer, type " << type_; |
396 break; | 393 break; |
397 } | 394 } |
398 | 395 |
399 base::ResetAndReturn(&read_cb_).Run(status, buffer); | 396 base::ResetAndReturn(&read_cb_).Run(status, buffer); |
400 } | 397 } |
401 | 398 |
402 ChunkDemuxer::ChunkDemuxer( | 399 ChunkDemuxer::ChunkDemuxer( |
403 const base::Closure& open_cb, | 400 const base::Closure& open_cb, |
404 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 401 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
405 const scoped_refptr<MediaLog>& media_log) | 402 MediaLog* media_log) |
406 : state_(WAITING_FOR_INIT), | 403 : state_(WAITING_FOR_INIT), |
407 cancel_next_seek_(false), | 404 cancel_next_seek_(false), |
408 host_(NULL), | 405 host_(NULL), |
409 open_cb_(open_cb), | 406 open_cb_(open_cb), |
410 encrypted_media_init_data_cb_(encrypted_media_init_data_cb), | 407 encrypted_media_init_data_cb_(encrypted_media_init_data_cb), |
411 enable_text_(false), | 408 enable_text_(false), |
412 media_log_(media_log), | 409 media_log_(media_log), |
413 duration_(kNoTimestamp), | 410 duration_(kNoTimestamp), |
414 user_specified_duration_(-1), | 411 user_specified_duration_(-1), |
415 liveness_(DemuxerStream::LIVENESS_UNKNOWN), | 412 liveness_(DemuxerStream::LIVENESS_UNKNOWN), |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 } | 1347 } |
1351 | 1348 |
1352 void ChunkDemuxer::ShutdownAllStreams() { | 1349 void ChunkDemuxer::ShutdownAllStreams() { |
1353 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); | 1350 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); |
1354 ++itr) { | 1351 ++itr) { |
1355 itr->second->Shutdown(); | 1352 itr->second->Shutdown(); |
1356 } | 1353 } |
1357 } | 1354 } |
1358 | 1355 |
1359 } // namespace media | 1356 } // namespace media |
OLD | NEW |