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

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

Issue 416333011: Allow setContentDecryptionModule() to get called when setting is done. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const & Created 6 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/decrypting_audio_decoder.h" 5 #include "media/filters/decrypting_audio_decoder.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); 159 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB());
160 pending_buffer_to_decode_ = NULL; 160 pending_buffer_to_decode_ = NULL;
161 if (!init_cb_.is_null()) 161 if (!init_cb_.is_null())
162 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); 162 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
163 if (!decode_cb_.is_null()) 163 if (!decode_cb_.is_null())
164 base::ResetAndReturn(&decode_cb_).Run(kAborted); 164 base::ResetAndReturn(&decode_cb_).Run(kAborted);
165 if (!reset_cb_.is_null()) 165 if (!reset_cb_.is_null())
166 base::ResetAndReturn(&reset_cb_).Run(); 166 base::ResetAndReturn(&reset_cb_).Run();
167 } 167 }
168 168
169 void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) { 169 void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor,
170 const base::Closure& done_cb) {
170 DVLOG(2) << "SetDecryptor()"; 171 DVLOG(2) << "SetDecryptor()";
171 DCHECK(task_runner_->BelongsToCurrentThread()); 172 DCHECK(task_runner_->BelongsToCurrentThread());
172 DCHECK_EQ(state_, kDecryptorRequested) << state_; 173 DCHECK_EQ(state_, kDecryptorRequested) << state_;
173 DCHECK(!init_cb_.is_null()); 174 DCHECK(!init_cb_.is_null());
174 DCHECK(!set_decryptor_ready_cb_.is_null()); 175 DCHECK(!set_decryptor_ready_cb_.is_null());
175 176
176 set_decryptor_ready_cb_.Reset(); 177 set_decryptor_ready_cb_.Reset();
177 178
178 if (!decryptor) { 179 if (!decryptor) {
179 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); 180 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
180 state_ = kError; 181 state_ = kError;
182 done_cb.Run();
ddorwin 2014/07/30 22:35:46 Shouldn't this reject the promise? How can we get
jrummell 2014/08/01 22:09:42 This is called with NULL if there is a previous de
181 return; 183 return;
182 } 184 }
183 185
184 decryptor_ = decryptor; 186 decryptor_ = decryptor;
185 187
186 InitializeDecoder(); 188 InitializeDecoder();
189 done_cb.Run();
187 } 190 }
188 191
189 void DecryptingAudioDecoder::InitializeDecoder() { 192 void DecryptingAudioDecoder::InitializeDecoder() {
190 state_ = kPendingDecoderInit; 193 state_ = kPendingDecoderInit;
191 decryptor_->InitializeAudioDecoder( 194 decryptor_->InitializeAudioDecoder(
192 config_, 195 config_,
193 BindToCurrentLoop(base::Bind( 196 BindToCurrentLoop(base::Bind(
194 &DecryptingAudioDecoder::FinishInitialization, weak_this_))); 197 &DecryptingAudioDecoder::FinishInitialization, weak_this_)));
195 } 198 }
196 199
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 353 }
351 354
352 frame->set_timestamp(current_time); 355 frame->set_timestamp(current_time);
353 timestamp_helper_->AddFrames(frame->frame_count()); 356 timestamp_helper_->AddFrames(frame->frame_count());
354 357
355 output_cb_.Run(frame); 358 output_cb_.Run(frame);
356 } 359 }
357 } 360 }
358 361
359 } // namespace media 362 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698