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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 const scoped_refptr<MediaLog>& media_log) | 49 const scoped_refptr<MediaLog>& media_log) |
50 : traits_(media_log), | 50 : traits_(media_log), |
51 task_runner_(task_runner), | 51 task_runner_(task_runner), |
52 media_log_(media_log), | 52 media_log_(media_log), |
53 state_(STATE_UNINITIALIZED), | 53 state_(STATE_UNINITIALIZED), |
54 stream_(NULL), | 54 stream_(NULL), |
55 decoder_selector_(new DecoderSelector<StreamType>(task_runner, | 55 decoder_selector_(new DecoderSelector<StreamType>(task_runner, |
56 std::move(decoders), | 56 std::move(decoders), |
57 media_log)), | 57 media_log)), |
58 decoded_frames_since_fallback_(0), | 58 decoded_frames_since_fallback_(0), |
59 active_splice_(false), | |
60 decoding_eos_(false), | 59 decoding_eos_(false), |
61 pending_decode_requests_(0), | 60 pending_decode_requests_(0), |
62 duration_tracker_(8), | 61 duration_tracker_(8), |
63 received_config_change_during_reinit_(false), | 62 received_config_change_during_reinit_(false), |
64 pending_demuxer_read_(false), | 63 pending_demuxer_read_(false), |
65 weak_factory_(this), | 64 weak_factory_(this), |
66 fallback_weak_factory_(this) {} | 65 fallback_weak_factory_(this) {} |
67 | 66 |
68 template <DemuxerStream::Type StreamType> | 67 template <DemuxerStream::Type StreamType> |
69 DecoderStream<StreamType>::~DecoderStream() { | 68 DecoderStream<StreamType>::~DecoderStream() { |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 Reset(base::ResetAndReturn(&reset_cb_)); | 658 Reset(base::ResetAndReturn(&reset_cb_)); |
660 return; | 659 return; |
661 } | 660 } |
662 | 661 |
663 if (status == DemuxerStream::kAborted) { | 662 if (status == DemuxerStream::kAborted) { |
664 if (!read_cb_.is_null()) | 663 if (!read_cb_.is_null()) |
665 SatisfyRead(DEMUXER_READ_ABORTED, NULL); | 664 SatisfyRead(DEMUXER_READ_ABORTED, NULL); |
666 return; | 665 return; |
667 } | 666 } |
668 | 667 |
669 if (!splice_observer_cb_.is_null() && !buffer->end_of_stream()) { | |
670 const bool has_splice_ts = buffer->splice_timestamp() != kNoTimestamp; | |
671 if (active_splice_ || has_splice_ts) { | |
672 splice_observer_cb_.Run(buffer->splice_timestamp()); | |
673 active_splice_ = has_splice_ts; | |
674 } | |
675 } | |
676 | |
677 DCHECK(status == DemuxerStream::kOk) << status; | 668 DCHECK(status == DemuxerStream::kOk) << status; |
678 Decode(buffer); | 669 Decode(buffer); |
679 | 670 |
680 // Read more data if the decoder supports multiple parallel decoding requests. | 671 // Read more data if the decoder supports multiple parallel decoding requests. |
681 if (CanDecodeMore()) | 672 if (CanDecodeMore()) |
682 ReadFromDemuxerStream(); | 673 ReadFromDemuxerStream(); |
683 } | 674 } |
684 | 675 |
685 template <DemuxerStream::Type StreamType> | 676 template <DemuxerStream::Type StreamType> |
686 void DecoderStream<StreamType>::ReinitializeDecoder() { | 677 void DecoderStream<StreamType>::ReinitializeDecoder() { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 // before the reset callback is fired. | 762 // before the reset callback is fired. |
772 DCHECK(read_cb_.is_null()); | 763 DCHECK(read_cb_.is_null()); |
773 DCHECK(!reset_cb_.is_null()); | 764 DCHECK(!reset_cb_.is_null()); |
774 | 765 |
775 // Make sure we read directly from the demuxer after a reset. | 766 // Make sure we read directly from the demuxer after a reset. |
776 fallback_buffers_.clear(); | 767 fallback_buffers_.clear(); |
777 pending_buffers_.clear(); | 768 pending_buffers_.clear(); |
778 | 769 |
779 if (state_ != STATE_FLUSHING_DECODER) { | 770 if (state_ != STATE_FLUSHING_DECODER) { |
780 state_ = STATE_NORMAL; | 771 state_ = STATE_NORMAL; |
781 active_splice_ = false; | |
782 base::ResetAndReturn(&reset_cb_).Run(); | 772 base::ResetAndReturn(&reset_cb_).Run(); |
783 return; | 773 return; |
784 } | 774 } |
785 | 775 |
786 // The resetting process will be continued in OnDecoderReinitialized(). | 776 // The resetting process will be continued in OnDecoderReinitialized(). |
787 ReinitializeDecoder(); | 777 ReinitializeDecoder(); |
788 } | 778 } |
789 | 779 |
790 template class DecoderStream<DemuxerStream::VIDEO>; | 780 template class DecoderStream<DemuxerStream::VIDEO>; |
791 template class DecoderStream<DemuxerStream::AUDIO>; | 781 template class DecoderStream<DemuxerStream::AUDIO>; |
792 | 782 |
793 } // namespace media | 783 } // namespace media |
OLD | NEW |