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 "webkit/media/crypto/proxy_decryptor.h" | 5 #include "webkit/media/crypto/proxy_decryptor.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/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 | 145 |
146 void ProxyDecryptor::CancelKeyRequest(const std::string& key_system, | 146 void ProxyDecryptor::CancelKeyRequest(const std::string& key_system, |
147 const std::string& session_id) { | 147 const std::string& session_id) { |
148 DVLOG(1) << "CancelKeyRequest()"; | 148 DVLOG(1) << "CancelKeyRequest()"; |
149 | 149 |
150 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. | 150 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. |
151 decryptor_->CancelKeyRequest(key_system, session_id); | 151 decryptor_->CancelKeyRequest(key_system, session_id); |
152 } | 152 } |
153 | 153 |
154 void ProxyDecryptor::Decrypt( | 154 void ProxyDecryptor::Decrypt( |
155 StreamType stream_type, | |
155 const scoped_refptr<media::DecoderBuffer>& encrypted, | 156 const scoped_refptr<media::DecoderBuffer>& encrypted, |
156 const DecryptCB& decrypt_cb) { | 157 const DecryptCB& decrypt_cb) { |
157 DVLOG(2) << "Decrypt()"; | 158 DVLOG(2) << "Decrypt()"; |
158 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); | 159 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); |
160 DCHECK_EQ(stream_type, kVideo); // Only support video decrypt-only for now. | |
ddorwin
2012/10/17 02:52:33
Is there anything that doesn't work? Maybe there's
xhwang
2012/10/17 22:29:06
Audio decrypt-only is not implemented yet. Later w
| |
159 | 161 |
160 DCHECK(!is_canceling_decrypt_); | 162 DCHECK(!is_canceling_decrypt_); |
161 DCHECK(!pending_buffer_to_decrypt_); | 163 DCHECK(!pending_buffer_to_decrypt_); |
162 DCHECK(pending_decrypt_cb_.is_null()); | 164 DCHECK(pending_decrypt_cb_.is_null()); |
163 | 165 |
164 pending_buffer_to_decrypt_ = encrypted; | 166 pending_buffer_to_decrypt_ = encrypted; |
165 pending_decrypt_cb_ = decrypt_cb; | 167 pending_decrypt_cb_ = decrypt_cb; |
166 | 168 |
167 // This is safe as we do not replace/delete an existing decryptor at run-time. | 169 // This is safe as we do not replace/delete an existing decryptor at run-time. |
168 media::Decryptor* decryptor = NULL; | 170 media::Decryptor* decryptor = NULL; |
169 { | 171 { |
170 base::AutoLock auto_lock(lock_); | 172 base::AutoLock auto_lock(lock_); |
171 decryptor = decryptor_.get(); | 173 decryptor = decryptor_.get(); |
172 } | 174 } |
173 if (!decryptor) { | 175 if (!decryptor) { |
174 DVLOG(1) << "Decrypt(): decryptor not initialized."; | 176 DVLOG(1) << "Decrypt(): decryptor not initialized."; |
175 | 177 |
176 // TODO(xhwang): The same NeedKey may be fired here and multiple times in | 178 // TODO(xhwang): The same NeedKey may be fired here and multiple times in |
177 // OnBufferDecrypted(). While the spec says only one NeedKey should be | 179 // OnBufferDecrypted(). While the spec says only one NeedKey should be |
178 // fired. Leave them as is since the spec about this may change. | 180 // fired. Leave them as is since the spec about this may change. |
179 FireNeedKey(client_, encrypted); | 181 FireNeedKey(client_, encrypted); |
180 return; | 182 return; |
181 } | 183 } |
182 | 184 |
183 DecryptPendingBuffer(); | 185 DecryptPendingBuffer(); |
184 } | 186 } |
185 | 187 |
186 void ProxyDecryptor::CancelDecrypt() { | 188 void ProxyDecryptor::CancelDecrypt(StreamType stream_type) { |
187 DVLOG(1) << "CancelDecrypt()"; | 189 DVLOG(1) << "CancelDecrypt()"; |
188 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); | 190 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); |
191 DCHECK_EQ(stream_type, kVideo); // Only support video decrypt-only for now. | |
ddorwin
2012/10/17 02:52:33
same
xhwang
2012/10/17 22:29:06
ditto
| |
189 | 192 |
190 if (!pending_buffer_to_decrypt_) { | 193 if (!pending_buffer_to_decrypt_) { |
191 DCHECK(pending_decrypt_cb_.is_null()); | 194 DCHECK(pending_decrypt_cb_.is_null()); |
192 DCHECK(!is_waiting_for_decryptor_); | 195 DCHECK(!is_waiting_for_decryptor_); |
193 return; | 196 return; |
194 } | 197 } |
195 | 198 |
196 DecryptCB decrypt_cb; | 199 DecryptCB decrypt_cb; |
197 if (!is_waiting_for_decryptor_) { | 200 if (!is_waiting_for_decryptor_) { |
198 pending_buffer_to_decrypt_ = NULL; | 201 pending_buffer_to_decrypt_ = NULL; |
199 base::ResetAndReturn(&pending_decrypt_cb_).Run(kSuccess, NULL); | 202 base::ResetAndReturn(&pending_decrypt_cb_).Run(kSuccess, NULL); |
200 return; | 203 return; |
201 } | 204 } |
202 | 205 |
203 is_canceling_decrypt_ = true; | 206 is_canceling_decrypt_ = true; |
204 decryptor_->CancelDecrypt(); | 207 decryptor_->CancelDecrypt(stream_type); |
208 } | |
209 | |
210 void ProxyDecryptor::InitializeAudioDecoder( | |
211 scoped_ptr<media::AudioDecoderConfig> config, | |
212 const DecoderInitCB& init_cb, | |
213 const KeyAddedCB& key_added_cb) { | |
214 NOTREACHED() << "ProxyDecryptor does not support audio decoding"; | |
205 } | 215 } |
206 | 216 |
207 void ProxyDecryptor::InitializeVideoDecoder( | 217 void ProxyDecryptor::InitializeVideoDecoder( |
208 scoped_ptr<media::VideoDecoderConfig> config, | 218 scoped_ptr<media::VideoDecoderConfig> config, |
209 const DecoderInitCB& init_cb, | 219 const DecoderInitCB& init_cb, |
210 const KeyAddedCB& key_added_cb) { | 220 const KeyAddedCB& key_added_cb) { |
211 NOTREACHED() << "ProxyDecryptor does not support video decoding"; | 221 NOTREACHED() << "ProxyDecryptor does not support video decoding"; |
212 } | 222 } |
213 | 223 |
224 void ProxyDecryptor::DecryptAndDecodeAudio( | |
225 const scoped_refptr<media::DecoderBuffer>& encrypted, | |
226 const AudioDecodeCB& audio_decode_cb) { | |
227 NOTREACHED() << "ProxyDecryptor does not support audio decoding"; | |
228 } | |
229 | |
214 void ProxyDecryptor::DecryptAndDecodeVideo( | 230 void ProxyDecryptor::DecryptAndDecodeVideo( |
215 const scoped_refptr<media::DecoderBuffer>& encrypted, | 231 const scoped_refptr<media::DecoderBuffer>& encrypted, |
216 const VideoDecodeCB& video_decode_cb) { | 232 const VideoDecodeCB& video_decode_cb) { |
217 NOTREACHED() << "ProxyDecryptor does not support video decoding"; | 233 NOTREACHED() << "ProxyDecryptor does not support video decoding"; |
218 } | 234 } |
219 | 235 |
220 void ProxyDecryptor::CancelDecryptAndDecodeVideo() { | 236 void ProxyDecryptor::ResetDecoder(StreamType stream_type) { |
221 NOTREACHED() << "ProxyDecryptor does not support video decoding"; | 237 NOTREACHED() << "ProxyDecryptor does not support audio/video decoding"; |
222 } | 238 } |
223 | 239 |
224 void ProxyDecryptor::StopVideoDecoder() { | 240 void ProxyDecryptor::DeinitializeDecoder(StreamType stream_type) { |
225 NOTREACHED() << "ProxyDecryptor does not support video decoding"; | 241 NOTREACHED() << "ProxyDecryptor does not support audio/video decoding"; |
226 } | 242 } |
227 | 243 |
228 scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor( | 244 scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor( |
229 const std::string& key_system) { | 245 const std::string& key_system) { |
230 DCHECK(client_); | 246 DCHECK(client_); |
231 DCHECK(web_media_player_client_); | 247 DCHECK(web_media_player_client_); |
232 DCHECK(web_frame_); | 248 DCHECK(web_frame_); |
233 | 249 |
234 std::string plugin_type = GetPluginType(key_system); | 250 std::string plugin_type = GetPluginType(key_system); |
235 DCHECK(!plugin_type.empty()); | 251 DCHECK(!plugin_type.empty()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 } | 299 } |
284 | 300 |
285 void ProxyDecryptor::DecryptPendingBuffer() { | 301 void ProxyDecryptor::DecryptPendingBuffer() { |
286 DVLOG(3) << "DecryptPendingBuffer()"; | 302 DVLOG(3) << "DecryptPendingBuffer()"; |
287 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); | 303 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); |
288 DCHECK(pending_buffer_to_decrypt_); | 304 DCHECK(pending_buffer_to_decrypt_); |
289 DCHECK(!is_waiting_for_decryptor_); | 305 DCHECK(!is_waiting_for_decryptor_); |
290 | 306 |
291 is_waiting_for_decryptor_ = true; | 307 is_waiting_for_decryptor_ = true; |
292 decryptor_->Decrypt( | 308 decryptor_->Decrypt( |
309 kVideo, // Only support video decrypt-only for now. | |
ddorwin
2012/10/17 02:52:33
If we really need this parameter (see earlier comm
xhwang
2012/10/17 22:29:06
see above reply.
| |
293 pending_buffer_to_decrypt_, | 310 pending_buffer_to_decrypt_, |
294 base::Bind(&ProxyDecryptor::OnBufferDecrypted, base::Unretained(this))); | 311 base::Bind(&ProxyDecryptor::OnBufferDecrypted, base::Unretained(this))); |
295 } | 312 } |
296 | 313 |
297 void ProxyDecryptor::OnBufferDecrypted( | 314 void ProxyDecryptor::OnBufferDecrypted( |
298 media::Decryptor::Status status, | 315 media::Decryptor::Status status, |
299 const scoped_refptr<media::DecoderBuffer>& decrypted) { | 316 const scoped_refptr<media::DecoderBuffer>& decrypted) { |
300 if (!decryption_message_loop_->BelongsToCurrentThread()) { | 317 if (!decryption_message_loop_->BelongsToCurrentThread()) { |
301 decryption_message_loop_->PostTask(FROM_HERE, base::Bind( | 318 decryption_message_loop_->PostTask(FROM_HERE, base::Bind( |
302 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), | 319 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 return; | 351 return; |
335 } | 352 } |
336 | 353 |
337 // TODO(xhwang): The same NeedKey may be fired multiple times here and also | 354 // TODO(xhwang): The same NeedKey may be fired multiple times here and also |
338 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave | 355 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave |
339 // them as is since the spec about this may change. | 356 // them as is since the spec about this may change. |
340 FireNeedKey(client_, pending_buffer_to_decrypt_); | 357 FireNeedKey(client_, pending_buffer_to_decrypt_); |
341 } | 358 } |
342 | 359 |
343 } // namespace webkit_media | 360 } // namespace webkit_media |
OLD | NEW |