Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: media/filters/decoder_stream.cc

Issue 692323002: Move Liveness from DemuxerStreamProvider to DemuxerStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 ReadFromDemuxerStream(); 468 ReadFromDemuxerStream();
472 } 469 }
473 470
474 template <DemuxerStream::Type StreamType> 471 template <DemuxerStream::Type StreamType>
475 void DecoderStream<StreamType>::ReinitializeDecoder() { 472 void DecoderStream<StreamType>::ReinitializeDecoder() {
476 FUNCTION_DVLOG(2); 473 FUNCTION_DVLOG(2);
477 DCHECK(task_runner_->BelongsToCurrentThread()); 474 DCHECK(task_runner_->BelongsToCurrentThread());
478 DCHECK_EQ(state_, STATE_FLUSHING_DECODER) << state_; 475 DCHECK_EQ(state_, STATE_FLUSHING_DECODER) << state_;
479 DCHECK_EQ(pending_decode_requests_, 0); 476 DCHECK_EQ(pending_decode_requests_, 0);
480 477
481 DCHECK(StreamTraits::GetDecoderConfig(*stream_).IsValidConfig());
482 state_ = STATE_REINITIALIZING_DECODER; 478 state_ = STATE_REINITIALIZING_DECODER;
483 DecoderStreamTraits<StreamType>::Initialize( 479 DecoderStreamTraits<StreamType>::InitializeDecoder(
484 decoder_.get(), 480 decoder_.get(), stream_,
485 StreamTraits::GetDecoderConfig(*stream_),
486 low_delay_,
487 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, 481 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized,
488 weak_factory_.GetWeakPtr()), 482 weak_factory_.GetWeakPtr()),
489 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, 483 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady,
490 weak_factory_.GetWeakPtr())); 484 weak_factory_.GetWeakPtr()));
491 } 485 }
492 486
493 template <DemuxerStream::Type StreamType> 487 template <DemuxerStream::Type StreamType>
494 void DecoderStream<StreamType>::OnDecoderReinitialized(PipelineStatus status) { 488 void DecoderStream<StreamType>::OnDecoderReinitialized(PipelineStatus status) {
495 FUNCTION_DVLOG(2); 489 FUNCTION_DVLOG(2);
496 DCHECK(task_runner_->BelongsToCurrentThread()); 490 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 545 }
552 546
553 // The resetting process will be continued in OnDecoderReinitialized(). 547 // The resetting process will be continued in OnDecoderReinitialized().
554 ReinitializeDecoder(); 548 ReinitializeDecoder();
555 } 549 }
556 550
557 template class DecoderStream<DemuxerStream::VIDEO>; 551 template class DecoderStream<DemuxerStream::VIDEO>;
558 template class DecoderStream<DemuxerStream::AUDIO>; 552 template class DecoderStream<DemuxerStream::AUDIO>;
559 553
560 } // namespace media 554 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698