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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 : task_runner_(task_runner), | 46 : task_runner_(task_runner), |
47 state_(STATE_UNINITIALIZED), | 47 state_(STATE_UNINITIALIZED), |
48 stream_(NULL), | 48 stream_(NULL), |
49 decoder_selector_( | 49 decoder_selector_( |
50 new DecoderSelector<StreamType>(task_runner, | 50 new DecoderSelector<StreamType>(task_runner, |
51 decoders.Pass(), | 51 decoders.Pass(), |
52 set_decryptor_ready_cb)), | 52 set_decryptor_ready_cb)), |
| 53 active_splice_(false), |
53 weak_factory_(this) {} | 54 weak_factory_(this) {} |
54 | 55 |
55 template <DemuxerStream::Type StreamType> | 56 template <DemuxerStream::Type StreamType> |
56 DecoderStream<StreamType>::~DecoderStream() { | 57 DecoderStream<StreamType>::~DecoderStream() { |
57 DCHECK(state_ == STATE_UNINITIALIZED || state_ == STATE_STOPPED) << state_; | 58 DCHECK(state_ == STATE_UNINITIALIZED || state_ == STATE_STOPPED) << state_; |
58 } | 59 } |
59 | 60 |
60 template <DemuxerStream::Type StreamType> | 61 template <DemuxerStream::Type StreamType> |
61 void DecoderStream<StreamType>::Initialize(DemuxerStream* stream, | 62 void DecoderStream<StreamType>::Initialize(DemuxerStream* stream, |
62 const StatisticsCB& statistics_cb, | 63 const StatisticsCB& statistics_cb, |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 if (!decrypting_demuxer_stream_) | 402 if (!decrypting_demuxer_stream_) |
402 Reset(base::ResetAndReturn(&reset_cb_)); | 403 Reset(base::ResetAndReturn(&reset_cb_)); |
403 return; | 404 return; |
404 } | 405 } |
405 | 406 |
406 if (status == DemuxerStream::kAborted) { | 407 if (status == DemuxerStream::kAborted) { |
407 SatisfyRead(DEMUXER_READ_ABORTED, NULL); | 408 SatisfyRead(DEMUXER_READ_ABORTED, NULL); |
408 return; | 409 return; |
409 } | 410 } |
410 | 411 |
411 if (!splice_observer_cb_.is_null() && !buffer->end_of_stream() && | 412 if (!splice_observer_cb_.is_null() && !buffer->end_of_stream()) { |
412 buffer->splice_timestamp() != kNoTimestamp()) { | 413 const bool has_splice_ts = buffer->splice_timestamp() != kNoTimestamp(); |
413 splice_observer_cb_.Run(buffer->splice_timestamp()); | 414 if (active_splice_ || has_splice_ts) { |
| 415 splice_observer_cb_.Run(buffer->splice_timestamp()); |
| 416 active_splice_ = has_splice_ts; |
| 417 } |
414 } | 418 } |
415 | 419 |
416 DCHECK(status == DemuxerStream::kOk) << status; | 420 DCHECK(status == DemuxerStream::kOk) << status; |
417 Decode(buffer); | 421 Decode(buffer); |
418 } | 422 } |
419 | 423 |
420 template <DemuxerStream::Type StreamType> | 424 template <DemuxerStream::Type StreamType> |
421 void DecoderStream<StreamType>::ReinitializeDecoder() { | 425 void DecoderStream<StreamType>::ReinitializeDecoder() { |
422 FUNCTION_DVLOG(2); | 426 FUNCTION_DVLOG(2); |
423 DCHECK(task_runner_->BelongsToCurrentThread()); | 427 DCHECK(task_runner_->BelongsToCurrentThread()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 decrypting_demuxer_stream_.reset(); | 514 decrypting_demuxer_stream_.reset(); |
511 // Post |stop_cb_| because pending |read_cb_| and/or |reset_cb_| are also | 515 // Post |stop_cb_| because pending |read_cb_| and/or |reset_cb_| are also |
512 // posted in Stop(). | 516 // posted in Stop(). |
513 task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&stop_cb_)); | 517 task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&stop_cb_)); |
514 } | 518 } |
515 | 519 |
516 template class DecoderStream<DemuxerStream::VIDEO>; | 520 template class DecoderStream<DemuxerStream::VIDEO>; |
517 template class DecoderStream<DemuxerStream::AUDIO>; | 521 template class DecoderStream<DemuxerStream::AUDIO>; |
518 | 522 |
519 } // namespace media | 523 } // namespace media |
OLD | NEW |