OLD | NEW |
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 Loading... |
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& decryptor_attached_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 decryptor_attached_cb.Run(false); |
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 decryptor_attached_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 Loading... |
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 |
OLD | NEW |