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

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

Issue 1143223007: media: Reland "Simplify {Audio|Video}Decoder initialization callback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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
« no previous file with comments | « media/filters/decoder_selector.h ('k') | media/filters/decoder_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_)); 112 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_));
113 113
114 DecoderStreamTraits<StreamType>::InitializeDecoder( 114 DecoderStreamTraits<StreamType>::InitializeDecoder(
115 decoder_.get(), input_stream_, 115 decoder_.get(), input_stream_,
116 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, 116 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone,
117 weak_ptr_factory_.GetWeakPtr()), 117 weak_ptr_factory_.GetWeakPtr()),
118 output_cb_); 118 output_cb_);
119 } 119 }
120 120
121 template <DemuxerStream::Type StreamType> 121 template <DemuxerStream::Type StreamType>
122 void DecoderSelector<StreamType>::DecryptingDecoderInitDone( 122 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) {
123 PipelineStatus status) {
124 DVLOG(2) << __FUNCTION__; 123 DVLOG(2) << __FUNCTION__;
125 DCHECK(task_runner_->BelongsToCurrentThread()); 124 DCHECK(task_runner_->BelongsToCurrentThread());
126 125
127 if (status == PIPELINE_OK) { 126 if (success) {
128 base::ResetAndReturn(&select_decoder_cb_) 127 base::ResetAndReturn(&select_decoder_cb_)
129 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); 128 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>());
130 return; 129 return;
131 } 130 }
132 131
133 decoder_.reset(); 132 decoder_.reset();
134 133
135 decrypted_stream_.reset(new DecryptingDemuxerStream( 134 decrypted_stream_.reset(new DecryptingDemuxerStream(
136 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_)); 135 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_));
137 136
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 decoders_.weak_erase(decoders_.begin()); 171 decoders_.weak_erase(decoders_.begin());
173 172
174 DecoderStreamTraits<StreamType>::InitializeDecoder( 173 DecoderStreamTraits<StreamType>::InitializeDecoder(
175 decoder_.get(), input_stream_, 174 decoder_.get(), input_stream_,
176 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone, 175 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone,
177 weak_ptr_factory_.GetWeakPtr()), 176 weak_ptr_factory_.GetWeakPtr()),
178 output_cb_); 177 output_cb_);
179 } 178 }
180 179
181 template <DemuxerStream::Type StreamType> 180 template <DemuxerStream::Type StreamType>
182 void DecoderSelector<StreamType>::DecoderInitDone(PipelineStatus status) { 181 void DecoderSelector<StreamType>::DecoderInitDone(bool success) {
183 DVLOG(2) << __FUNCTION__; 182 DVLOG(2) << __FUNCTION__;
184 DCHECK(task_runner_->BelongsToCurrentThread()); 183 DCHECK(task_runner_->BelongsToCurrentThread());
185 184
186 if (status != PIPELINE_OK) { 185 if (!success) {
187 decoder_.reset(); 186 decoder_.reset();
188 InitializeDecoder(); 187 InitializeDecoder();
189 return; 188 return;
190 } 189 }
191 190
192 base::ResetAndReturn(&select_decoder_cb_) 191 base::ResetAndReturn(&select_decoder_cb_)
193 .Run(decoder_.Pass(), decrypted_stream_.Pass()); 192 .Run(decoder_.Pass(), decrypted_stream_.Pass());
194 } 193 }
195 194
196 template <DemuxerStream::Type StreamType> 195 template <DemuxerStream::Type StreamType>
197 void DecoderSelector<StreamType>::ReturnNullDecoder() { 196 void DecoderSelector<StreamType>::ReturnNullDecoder() {
198 DVLOG(2) << __FUNCTION__; 197 DVLOG(2) << __FUNCTION__;
199 DCHECK(task_runner_->BelongsToCurrentThread()); 198 DCHECK(task_runner_->BelongsToCurrentThread());
200 base::ResetAndReturn(&select_decoder_cb_) 199 base::ResetAndReturn(&select_decoder_cb_)
201 .Run(scoped_ptr<Decoder>(), 200 .Run(scoped_ptr<Decoder>(),
202 scoped_ptr<DecryptingDemuxerStream>()); 201 scoped_ptr<DecryptingDemuxerStream>());
203 } 202 }
204 203
205 // These forward declarations tell the compiler that we will use 204 // These forward declarations tell the compiler that we will use
206 // DecoderSelector with these arguments, allowing us to keep these definitions 205 // DecoderSelector with these arguments, allowing us to keep these definitions
207 // in our .cc without causing linker errors. This also means if anyone tries to 206 // in our .cc without causing linker errors. This also means if anyone tries to
208 // instantiate a DecoderSelector with anything but these two specializations 207 // instantiate a DecoderSelector with anything but these two specializations
209 // they'll most likely get linker errors. 208 // they'll most likely get linker errors.
210 template class DecoderSelector<DemuxerStream::AUDIO>; 209 template class DecoderSelector<DemuxerStream::AUDIO>;
211 template class DecoderSelector<DemuxerStream::VIDEO>; 210 template class DecoderSelector<DemuxerStream::VIDEO>;
212 211
213 } // namespace media 212 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_selector.h ('k') | media/filters/decoder_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698