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

Side by Side Diff: media/filters/decoder_selector.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 "decoder_selector.h" 5 #include "decoder_selector.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/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (!select_decoder_cb_.is_null()) 67 if (!select_decoder_cb_.is_null())
68 ReturnNullDecoder(); 68 ReturnNullDecoder();
69 69
70 decoder_.reset(); 70 decoder_.reset();
71 decrypted_stream_.reset(); 71 decrypted_stream_.reset();
72 } 72 }
73 73
74 template <DemuxerStream::Type StreamType> 74 template <DemuxerStream::Type StreamType>
75 void DecoderSelector<StreamType>::SelectDecoder( 75 void DecoderSelector<StreamType>::SelectDecoder(
76 DemuxerStream* stream, 76 DemuxerStream* stream,
77 bool low_delay,
78 const SelectDecoderCB& select_decoder_cb, 77 const SelectDecoderCB& select_decoder_cb,
79 const typename Decoder::OutputCB& output_cb) { 78 const typename Decoder::OutputCB& output_cb) {
80 DVLOG(2) << __FUNCTION__; 79 DVLOG(2) << __FUNCTION__;
81 DCHECK(task_runner_->BelongsToCurrentThread()); 80 DCHECK(task_runner_->BelongsToCurrentThread());
82 DCHECK(stream); 81 DCHECK(stream);
83 82
84 // Make sure |select_decoder_cb| runs on a different execution stack. 83 // Make sure |select_decoder_cb| runs on a different execution stack.
85 select_decoder_cb_ = BindToCurrentLoop(select_decoder_cb); 84 select_decoder_cb_ = BindToCurrentLoop(select_decoder_cb);
86 85
87 if (!HasValidStreamConfig(stream)) { 86 if (!HasValidStreamConfig(stream)) {
88 DLOG(ERROR) << "Invalid stream config."; 87 DLOG(ERROR) << "Invalid stream config.";
89 ReturnNullDecoder(); 88 ReturnNullDecoder();
90 return; 89 return;
91 } 90 }
92 91
93 input_stream_ = stream; 92 input_stream_ = stream;
94 low_delay_ = low_delay;
95 output_cb_ = output_cb; 93 output_cb_ = output_cb;
96 94
97 if (!IsStreamEncrypted(input_stream_)) { 95 if (!IsStreamEncrypted(input_stream_)) {
98 InitializeDecoder(); 96 InitializeDecoder();
99 return; 97 return;
100 } 98 }
101 99
102 // This could happen if Encrypted Media Extension (EME) is not enabled. 100 // This could happen if Encrypted Media Extension (EME) is not enabled.
103 if (set_decryptor_ready_cb_.is_null()) { 101 if (set_decryptor_ready_cb_.is_null()) {
104 ReturnNullDecoder(); 102 ReturnNullDecoder();
105 return; 103 return;
106 } 104 }
107 105
108 decoder_.reset(new typename StreamTraits::DecryptingDecoderType( 106 decoder_.reset(new typename StreamTraits::DecryptingDecoderType(
109 task_runner_, set_decryptor_ready_cb_)); 107 task_runner_, set_decryptor_ready_cb_));
110 108
111 DecoderStreamTraits<StreamType>::Initialize( 109 DecoderStreamTraits<StreamType>::InitializeDecoder(
112 decoder_.get(), 110 decoder_.get(), input_stream_,
113 StreamTraits::GetDecoderConfig(*input_stream_),
114 low_delay_,
115 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, 111 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone,
116 weak_ptr_factory_.GetWeakPtr()), 112 weak_ptr_factory_.GetWeakPtr()),
117 output_cb_); 113 output_cb_);
118 } 114 }
119 115
120 template <DemuxerStream::Type StreamType> 116 template <DemuxerStream::Type StreamType>
121 void DecoderSelector<StreamType>::DecryptingDecoderInitDone( 117 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(
122 PipelineStatus status) { 118 PipelineStatus status) {
123 DVLOG(2) << __FUNCTION__; 119 DVLOG(2) << __FUNCTION__;
124 DCHECK(task_runner_->BelongsToCurrentThread()); 120 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 DCHECK(!decoder_); 159 DCHECK(!decoder_);
164 160
165 if (decoders_.empty()) { 161 if (decoders_.empty()) {
166 ReturnNullDecoder(); 162 ReturnNullDecoder();
167 return; 163 return;
168 } 164 }
169 165
170 decoder_.reset(decoders_.front()); 166 decoder_.reset(decoders_.front());
171 decoders_.weak_erase(decoders_.begin()); 167 decoders_.weak_erase(decoders_.begin());
172 168
173 DecoderStreamTraits<StreamType>::Initialize( 169 DecoderStreamTraits<StreamType>::InitializeDecoder(
174 decoder_.get(), 170 decoder_.get(), input_stream_,
175 StreamTraits::GetDecoderConfig(*input_stream_),
176 low_delay_,
177 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone, 171 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone,
178 weak_ptr_factory_.GetWeakPtr()), 172 weak_ptr_factory_.GetWeakPtr()),
179 output_cb_); 173 output_cb_);
180 } 174 }
181 175
182 template <DemuxerStream::Type StreamType> 176 template <DemuxerStream::Type StreamType>
183 void DecoderSelector<StreamType>::DecoderInitDone(PipelineStatus status) { 177 void DecoderSelector<StreamType>::DecoderInitDone(PipelineStatus status) {
184 DVLOG(2) << __FUNCTION__; 178 DVLOG(2) << __FUNCTION__;
185 DCHECK(task_runner_->BelongsToCurrentThread()); 179 DCHECK(task_runner_->BelongsToCurrentThread());
186 180
(...skipping 18 matching lines...) Expand all
205 199
206 // These forward declarations tell the compiler that we will use 200 // These forward declarations tell the compiler that we will use
207 // DecoderSelector with these arguments, allowing us to keep these definitions 201 // DecoderSelector with these arguments, allowing us to keep these definitions
208 // in our .cc without causing linker errors. This also means if anyone tries to 202 // in our .cc without causing linker errors. This also means if anyone tries to
209 // instantiate a DecoderSelector with anything but these two specializations 203 // instantiate a DecoderSelector with anything but these two specializations
210 // they'll most likely get linker errors. 204 // they'll most likely get linker errors.
211 template class DecoderSelector<DemuxerStream::AUDIO>; 205 template class DecoderSelector<DemuxerStream::AUDIO>;
212 template class DecoderSelector<DemuxerStream::VIDEO>; 206 template class DecoderSelector<DemuxerStream::VIDEO>;
213 207
214 } // namespace media 208 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698