| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 template <DemuxerStream::Type StreamType> | 41 template <DemuxerStream::Type StreamType> |
| 42 DecoderStream<StreamType>::DecoderStream( | 42 DecoderStream<StreamType>::DecoderStream( |
| 43 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 43 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 44 ScopedVector<Decoder> decoders, | 44 ScopedVector<Decoder> decoders, |
| 45 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 45 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 46 const scoped_refptr<MediaLog>& media_log) | 46 const scoped_refptr<MediaLog>& media_log) |
| 47 : task_runner_(task_runner), | 47 : task_runner_(task_runner), |
| 48 media_log_(media_log), | 48 media_log_(media_log), |
| 49 state_(STATE_UNINITIALIZED), | 49 state_(STATE_UNINITIALIZED), |
| 50 stream_(NULL), | 50 stream_(NULL), |
| 51 low_delay_(false), | |
| 52 decoder_selector_( | 51 decoder_selector_( |
| 53 new DecoderSelector<StreamType>(task_runner, | 52 new DecoderSelector<StreamType>(task_runner, |
| 54 decoders.Pass(), | 53 decoders.Pass(), |
| 55 set_decryptor_ready_cb)), | 54 set_decryptor_ready_cb)), |
| 56 active_splice_(false), | 55 active_splice_(false), |
| 57 decoding_eos_(false), | 56 decoding_eos_(false), |
| 58 pending_decode_requests_(0), | 57 pending_decode_requests_(0), |
| 59 weak_factory_(this) {} | 58 weak_factory_(this) {} |
| 60 | 59 |
| 61 template <DemuxerStream::Type StreamType> | 60 template <DemuxerStream::Type StreamType> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 76 if (!reset_cb_.is_null()) | 75 if (!reset_cb_.is_null()) |
| 77 task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&reset_cb_)); | 76 task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&reset_cb_)); |
| 78 | 77 |
| 79 stream_ = NULL; | 78 stream_ = NULL; |
| 80 decoder_.reset(); | 79 decoder_.reset(); |
| 81 decrypting_demuxer_stream_.reset(); | 80 decrypting_demuxer_stream_.reset(); |
| 82 } | 81 } |
| 83 | 82 |
| 84 template <DemuxerStream::Type StreamType> | 83 template <DemuxerStream::Type StreamType> |
| 85 void DecoderStream<StreamType>::Initialize(DemuxerStream* stream, | 84 void DecoderStream<StreamType>::Initialize(DemuxerStream* stream, |
| 86 bool low_delay, | |
| 87 const StatisticsCB& statistics_cb, | 85 const StatisticsCB& statistics_cb, |
| 88 const InitCB& init_cb) { | 86 const InitCB& init_cb) { |
| 89 FUNCTION_DVLOG(2); | 87 FUNCTION_DVLOG(2); |
| 90 DCHECK(task_runner_->BelongsToCurrentThread()); | 88 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 91 DCHECK_EQ(state_, STATE_UNINITIALIZED) << state_; | 89 DCHECK_EQ(state_, STATE_UNINITIALIZED) << state_; |
| 92 DCHECK(init_cb_.is_null()); | 90 DCHECK(init_cb_.is_null()); |
| 93 DCHECK(!init_cb.is_null()); | 91 DCHECK(!init_cb.is_null()); |
| 94 | 92 |
| 95 statistics_cb_ = statistics_cb; | 93 statistics_cb_ = statistics_cb; |
| 96 init_cb_ = init_cb; | 94 init_cb_ = init_cb; |
| 97 stream_ = stream; | 95 stream_ = stream; |
| 98 low_delay_ = low_delay; | |
| 99 | 96 |
| 100 state_ = STATE_INITIALIZING; | 97 state_ = STATE_INITIALIZING; |
| 101 // TODO(xhwang): DecoderSelector only needs a config to select a decoder. | 98 // TODO(xhwang): DecoderSelector only needs a config to select a decoder. |
| 102 decoder_selector_->SelectDecoder( | 99 decoder_selector_->SelectDecoder( |
| 103 stream, low_delay, | 100 stream, |
| 104 base::Bind(&DecoderStream<StreamType>::OnDecoderSelected, | 101 base::Bind(&DecoderStream<StreamType>::OnDecoderSelected, |
| 105 weak_factory_.GetWeakPtr()), | 102 weak_factory_.GetWeakPtr()), |
| 106 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, | 103 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, |
| 107 weak_factory_.GetWeakPtr())); | 104 weak_factory_.GetWeakPtr())); |
| 108 } | 105 } |
| 109 | 106 |
| 110 template <DemuxerStream::Type StreamType> | 107 template <DemuxerStream::Type StreamType> |
| 111 void DecoderStream<StreamType>::Read(const ReadCB& read_cb) { | 108 void DecoderStream<StreamType>::Read(const ReadCB& read_cb) { |
| 112 FUNCTION_DVLOG(2); | 109 FUNCTION_DVLOG(2); |
| 113 DCHECK(task_runner_->BelongsToCurrentThread()); | 110 DCHECK(task_runner_->BelongsToCurrentThread()); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 ReadFromDemuxerStream(); | 469 ReadFromDemuxerStream(); |
| 473 } | 470 } |
| 474 | 471 |
| 475 template <DemuxerStream::Type StreamType> | 472 template <DemuxerStream::Type StreamType> |
| 476 void DecoderStream<StreamType>::ReinitializeDecoder() { | 473 void DecoderStream<StreamType>::ReinitializeDecoder() { |
| 477 FUNCTION_DVLOG(2); | 474 FUNCTION_DVLOG(2); |
| 478 DCHECK(task_runner_->BelongsToCurrentThread()); | 475 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 479 DCHECK_EQ(state_, STATE_FLUSHING_DECODER) << state_; | 476 DCHECK_EQ(state_, STATE_FLUSHING_DECODER) << state_; |
| 480 DCHECK_EQ(pending_decode_requests_, 0); | 477 DCHECK_EQ(pending_decode_requests_, 0); |
| 481 | 478 |
| 482 DCHECK(StreamTraits::GetDecoderConfig(*stream_).IsValidConfig()); | |
| 483 state_ = STATE_REINITIALIZING_DECODER; | 479 state_ = STATE_REINITIALIZING_DECODER; |
| 484 DecoderStreamTraits<StreamType>::Initialize( | 480 DecoderStreamTraits<StreamType>::InitializeDecoder( |
| 485 decoder_.get(), | 481 decoder_.get(), stream_, |
| 486 StreamTraits::GetDecoderConfig(*stream_), | |
| 487 low_delay_, | |
| 488 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, | 482 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, |
| 489 weak_factory_.GetWeakPtr()), | 483 weak_factory_.GetWeakPtr()), |
| 490 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, | 484 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, |
| 491 weak_factory_.GetWeakPtr())); | 485 weak_factory_.GetWeakPtr())); |
| 492 } | 486 } |
| 493 | 487 |
| 494 template <DemuxerStream::Type StreamType> | 488 template <DemuxerStream::Type StreamType> |
| 495 void DecoderStream<StreamType>::OnDecoderReinitialized(PipelineStatus status) { | 489 void DecoderStream<StreamType>::OnDecoderReinitialized(PipelineStatus status) { |
| 496 FUNCTION_DVLOG(2); | 490 FUNCTION_DVLOG(2); |
| 497 DCHECK(task_runner_->BelongsToCurrentThread()); | 491 DCHECK(task_runner_->BelongsToCurrentThread()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 } | 546 } |
| 553 | 547 |
| 554 // The resetting process will be continued in OnDecoderReinitialized(). | 548 // The resetting process will be continued in OnDecoderReinitialized(). |
| 555 ReinitializeDecoder(); | 549 ReinitializeDecoder(); |
| 556 } | 550 } |
| 557 | 551 |
| 558 template class DecoderStream<DemuxerStream::VIDEO>; | 552 template class DecoderStream<DemuxerStream::VIDEO>; |
| 559 template class DecoderStream<DemuxerStream::AUDIO>; | 553 template class DecoderStream<DemuxerStream::AUDIO>; |
| 560 | 554 |
| 561 } // namespace media | 555 } // namespace media |
| OLD | NEW |