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

Side by Side Diff: media/filters/decrypting_video_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: ReportCallback 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_video_decoder.h" 5 #include "media/filters/decrypting_video_decoder.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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); 139 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB());
140 pending_buffer_to_decode_ = NULL; 140 pending_buffer_to_decode_ = NULL;
141 if (!init_cb_.is_null()) 141 if (!init_cb_.is_null())
142 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); 142 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
143 if (!decode_cb_.is_null()) 143 if (!decode_cb_.is_null())
144 base::ResetAndReturn(&decode_cb_).Run(kAborted); 144 base::ResetAndReturn(&decode_cb_).Run(kAborted);
145 if (!reset_cb_.is_null()) 145 if (!reset_cb_.is_null())
146 base::ResetAndReturn(&reset_cb_).Run(); 146 base::ResetAndReturn(&reset_cb_).Run();
147 } 147 }
148 148
149 void DecryptingVideoDecoder::SetDecryptor(Decryptor* decryptor) { 149 void DecryptingVideoDecoder::SetDecryptor(
150 Decryptor* decryptor,
151 const DecryptorAttachedCB& attach_done_cb) {
150 DVLOG(2) << "SetDecryptor()"; 152 DVLOG(2) << "SetDecryptor()";
151 DCHECK(task_runner_->BelongsToCurrentThread()); 153 DCHECK(task_runner_->BelongsToCurrentThread());
152 DCHECK_EQ(state_, kDecryptorRequested) << state_; 154 DCHECK_EQ(state_, kDecryptorRequested) << state_;
153 DCHECK(!init_cb_.is_null()); 155 DCHECK(!init_cb_.is_null());
154 DCHECK(!set_decryptor_ready_cb_.is_null()); 156 DCHECK(!set_decryptor_ready_cb_.is_null());
155 set_decryptor_ready_cb_.Reset(); 157 set_decryptor_ready_cb_.Reset();
156 158
157 if (!decryptor) { 159 if (!decryptor) {
158 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); 160 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
159 state_ = kError; 161 state_ = kError;
162 attach_done_cb.Run(false);
xhwang 2014/08/09 00:56:03 For the record, SetDecryptor is posted from main t
jrummell 2014/08/11 21:47:15 Acknowledged.
160 return; 163 return;
161 } 164 }
162 165
163 decryptor_ = decryptor; 166 decryptor_ = decryptor;
164 167
165 state_ = kPendingDecoderInit; 168 state_ = kPendingDecoderInit;
166 decryptor_->InitializeVideoDecoder( 169 decryptor_->InitializeVideoDecoder(
167 config_, 170 config_,
168 BindToCurrentLoop(base::Bind( 171 BindToCurrentLoop(base::Bind(
169 &DecryptingVideoDecoder::FinishInitialization, weak_this_))); 172 &DecryptingVideoDecoder::FinishInitialization, weak_this_)));
173 attach_done_cb.Run(true);
170 } 174 }
171 175
172 void DecryptingVideoDecoder::FinishInitialization(bool success) { 176 void DecryptingVideoDecoder::FinishInitialization(bool success) {
173 DVLOG(2) << "FinishInitialization()"; 177 DVLOG(2) << "FinishInitialization()";
174 DCHECK(task_runner_->BelongsToCurrentThread()); 178 DCHECK(task_runner_->BelongsToCurrentThread());
175 DCHECK_EQ(state_, kPendingDecoderInit) << state_; 179 DCHECK_EQ(state_, kPendingDecoderInit) << state_;
176 DCHECK(!init_cb_.is_null()); 180 DCHECK(!init_cb_.is_null());
177 DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. 181 DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished.
178 DCHECK(decode_cb_.is_null()); // No Decode() before initialization finished. 182 DCHECK(decode_cb_.is_null()); // No Decode() before initialization finished.
179 183
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 308 }
305 309
306 void DecryptingVideoDecoder::DoReset() { 310 void DecryptingVideoDecoder::DoReset() {
307 DCHECK(init_cb_.is_null()); 311 DCHECK(init_cb_.is_null());
308 DCHECK(decode_cb_.is_null()); 312 DCHECK(decode_cb_.is_null());
309 state_ = kIdle; 313 state_ = kIdle;
310 base::ResetAndReturn(&reset_cb_).Run(); 314 base::ResetAndReturn(&reset_cb_).Run();
311 } 315 }
312 316
313 } // namespace media 317 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698