| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/decoder_stream.h" | 5 #include "media/filters/decoder_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 stream_ = NULL; | 76 stream_ = NULL; |
| 77 decoder_.reset(); | 77 decoder_.reset(); |
| 78 decrypting_demuxer_stream_.reset(); | 78 decrypting_demuxer_stream_.reset(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 template <DemuxerStream::Type StreamType> | 81 template <DemuxerStream::Type StreamType> |
| 82 void DecoderStream<StreamType>::Initialize( | 82 void DecoderStream<StreamType>::Initialize( |
| 83 DemuxerStream* stream, | 83 DemuxerStream* stream, |
| 84 const InitCB& init_cb, | 84 const InitCB& init_cb, |
| 85 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 85 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 86 const StatisticsCB& statistics_cb) { | 86 const StatisticsCB& statistics_cb, |
| 87 const base::Closure& waiting_for_encryption_key_cb) { |
| 87 FUNCTION_DVLOG(2); | 88 FUNCTION_DVLOG(2); |
| 88 DCHECK(task_runner_->BelongsToCurrentThread()); | 89 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 89 DCHECK_EQ(state_, STATE_UNINITIALIZED); | 90 DCHECK_EQ(state_, STATE_UNINITIALIZED); |
| 90 DCHECK(init_cb_.is_null()); | 91 DCHECK(init_cb_.is_null()); |
| 91 DCHECK(!init_cb.is_null()); | 92 DCHECK(!init_cb.is_null()); |
| 92 | 93 |
| 93 statistics_cb_ = statistics_cb; | 94 statistics_cb_ = statistics_cb; |
| 94 init_cb_ = init_cb; | 95 init_cb_ = init_cb; |
| 96 waiting_for_encryption_key_cb_ = waiting_for_encryption_key_cb; |
| 95 stream_ = stream; | 97 stream_ = stream; |
| 96 | 98 |
| 97 state_ = STATE_INITIALIZING; | 99 state_ = STATE_INITIALIZING; |
| 98 SelectDecoder(set_decryptor_ready_cb); | 100 SelectDecoder(set_decryptor_ready_cb); |
| 99 } | 101 } |
| 100 | 102 |
| 101 template <DemuxerStream::Type StreamType> | 103 template <DemuxerStream::Type StreamType> |
| 102 void DecoderStream<StreamType>::Read(const ReadCB& read_cb) { | 104 void DecoderStream<StreamType>::Read(const ReadCB& read_cb) { |
| 103 FUNCTION_DVLOG(2); | 105 FUNCTION_DVLOG(2); |
| 104 DCHECK(task_runner_->BelongsToCurrentThread()); | 106 DCHECK(task_runner_->BelongsToCurrentThread()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 207 } |
| 206 | 208 |
| 207 template <DemuxerStream::Type StreamType> | 209 template <DemuxerStream::Type StreamType> |
| 208 void DecoderStream<StreamType>::SelectDecoder( | 210 void DecoderStream<StreamType>::SelectDecoder( |
| 209 const SetDecryptorReadyCB& set_decryptor_ready_cb) { | 211 const SetDecryptorReadyCB& set_decryptor_ready_cb) { |
| 210 decoder_selector_->SelectDecoder( | 212 decoder_selector_->SelectDecoder( |
| 211 stream_, set_decryptor_ready_cb, | 213 stream_, set_decryptor_ready_cb, |
| 212 base::Bind(&DecoderStream<StreamType>::OnDecoderSelected, | 214 base::Bind(&DecoderStream<StreamType>::OnDecoderSelected, |
| 213 weak_factory_.GetWeakPtr()), | 215 weak_factory_.GetWeakPtr()), |
| 214 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, | 216 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, |
| 215 weak_factory_.GetWeakPtr())); | 217 weak_factory_.GetWeakPtr()), |
| 218 waiting_for_encryption_key_cb_); |
| 216 } | 219 } |
| 217 | 220 |
| 218 template <DemuxerStream::Type StreamType> | 221 template <DemuxerStream::Type StreamType> |
| 219 void DecoderStream<StreamType>::OnDecoderSelected( | 222 void DecoderStream<StreamType>::OnDecoderSelected( |
| 220 scoped_ptr<Decoder> selected_decoder, | 223 scoped_ptr<Decoder> selected_decoder, |
| 221 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream) { | 224 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream) { |
| 222 FUNCTION_DVLOG(2) << ": " | 225 FUNCTION_DVLOG(2) << ": " |
| 223 << (selected_decoder ? selected_decoder->GetDisplayName() | 226 << (selected_decoder ? selected_decoder->GetDisplayName() |
| 224 : "No decoder selected."); | 227 : "No decoder selected."); |
| 225 DCHECK(task_runner_->BelongsToCurrentThread()); | 228 DCHECK(task_runner_->BelongsToCurrentThread()); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 DCHECK(task_runner_->BelongsToCurrentThread()); | 496 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 494 DCHECK_EQ(state_, STATE_FLUSHING_DECODER); | 497 DCHECK_EQ(state_, STATE_FLUSHING_DECODER); |
| 495 DCHECK_EQ(pending_decode_requests_, 0); | 498 DCHECK_EQ(pending_decode_requests_, 0); |
| 496 | 499 |
| 497 state_ = STATE_REINITIALIZING_DECODER; | 500 state_ = STATE_REINITIALIZING_DECODER; |
| 498 DecoderStreamTraits<StreamType>::InitializeDecoder( | 501 DecoderStreamTraits<StreamType>::InitializeDecoder( |
| 499 decoder_.get(), stream_, | 502 decoder_.get(), stream_, |
| 500 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, | 503 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, |
| 501 weak_factory_.GetWeakPtr()), | 504 weak_factory_.GetWeakPtr()), |
| 502 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, | 505 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, |
| 503 weak_factory_.GetWeakPtr())); | 506 weak_factory_.GetWeakPtr()), |
| 507 waiting_for_encryption_key_cb_); |
| 504 } | 508 } |
| 505 | 509 |
| 506 template <DemuxerStream::Type StreamType> | 510 template <DemuxerStream::Type StreamType> |
| 507 void DecoderStream<StreamType>::OnDecoderReinitialized(PipelineStatus status) { | 511 void DecoderStream<StreamType>::OnDecoderReinitialized(PipelineStatus status) { |
| 508 FUNCTION_DVLOG(2); | 512 FUNCTION_DVLOG(2); |
| 509 DCHECK(task_runner_->BelongsToCurrentThread()); | 513 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 510 DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER); | 514 DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER); |
| 511 | 515 |
| 512 // ReinitializeDecoder() can be called in two cases: | 516 // ReinitializeDecoder() can be called in two cases: |
| 513 // 1, Flushing decoder finished (see OnDecodeOutputReady()). | 517 // 1, Flushing decoder finished (see OnDecodeOutputReady()). |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 586 } |
| 583 | 587 |
| 584 // The resetting process will be continued in OnDecoderReinitialized(). | 588 // The resetting process will be continued in OnDecoderReinitialized(). |
| 585 ReinitializeDecoder(); | 589 ReinitializeDecoder(); |
| 586 } | 590 } |
| 587 | 591 |
| 588 template class DecoderStream<DemuxerStream::VIDEO>; | 592 template class DecoderStream<DemuxerStream::VIDEO>; |
| 589 template class DecoderStream<DemuxerStream::AUDIO>; | 593 template class DecoderStream<DemuxerStream::AUDIO>; |
| 590 | 594 |
| 591 } // namespace media | 595 } // namespace media |
| OLD | NEW |