OLD | NEW |
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 "content/renderer/media/crypto/encrypted_media_player_support_impl.h" | 5 #include "content/renderer/media/crypto/encrypted_media_player_support_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (!IsConcreteSupportedKeySystem(key_system)) | 289 if (!IsConcreteSupportedKeySystem(key_system)) |
290 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 290 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
291 | 291 |
292 if (current_key_system_.empty() || key_system != current_key_system_) | 292 if (current_key_system_.empty() || key_system != current_key_system_) |
293 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 293 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
294 | 294 |
295 proxy_decryptor_->CancelKeyRequest(session_id); | 295 proxy_decryptor_->CancelKeyRequest(session_id); |
296 return WebMediaPlayer::MediaKeyExceptionNoError; | 296 return WebMediaPlayer::MediaKeyExceptionNoError; |
297 } | 297 } |
298 | 298 |
| 299 void EncryptedMediaPlayerSupportImpl::SetInitialContentDecryptionModule( |
| 300 blink::WebContentDecryptionModule* initial_cdm) { |
| 301 // Used when loading media and no pipeline/decoder attached yet. |
| 302 DCHECK(decryptor_ready_cb_.is_null()); |
| 303 |
| 304 web_cdm_ = ToWebContentDecryptionModuleImpl(initial_cdm); |
| 305 } |
| 306 |
299 void EncryptedMediaPlayerSupportImpl::SetContentDecryptionModule( | 307 void EncryptedMediaPlayerSupportImpl::SetContentDecryptionModule( |
300 blink::WebContentDecryptionModule* cdm) { | 308 blink::WebContentDecryptionModule* cdm) { |
301 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 | 309 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 |
302 if (!cdm) | 310 if (!cdm) |
303 return; | 311 return; |
304 | 312 |
305 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); | 313 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); |
306 | 314 |
307 if (web_cdm_ && !decryptor_ready_cb_.is_null()) | 315 if (web_cdm_ && !decryptor_ready_cb_.is_null()) |
308 base::ResetAndReturn(&decryptor_ready_cb_) | 316 base::ResetAndReturn(&decryptor_ready_cb_) |
(...skipping 19 matching lines...) Expand all Loading... |
328 .Run(web_cdm_->GetDecryptor(), BIND_TO_RENDER_LOOP1( | 336 .Run(web_cdm_->GetDecryptor(), BIND_TO_RENDER_LOOP1( |
329 &EncryptedMediaPlayerSupportImpl::ContentDecryptionModuleAttached, | 337 &EncryptedMediaPlayerSupportImpl::ContentDecryptionModuleAttached, |
330 result)); | 338 result)); |
331 } else { | 339 } else { |
332 // No pipeline/decoder connected, so resolve the promise. When something | 340 // No pipeline/decoder connected, so resolve the promise. When something |
333 // is connected, setting the CDM will happen in SetDecryptorReadyCB(). | 341 // is connected, setting the CDM will happen in SetDecryptorReadyCB(). |
334 ContentDecryptionModuleAttached(result, true); | 342 ContentDecryptionModuleAttached(result, true); |
335 } | 343 } |
336 } | 344 } |
337 | 345 |
338 void EncryptedMediaPlayerSupportImpl::SetContentDecryptionModuleSync( | |
339 blink::WebContentDecryptionModule* cdm) { | |
340 // Used when loading media and no pipeline/decoder attached yet. | |
341 DCHECK(decryptor_ready_cb_.is_null()); | |
342 | |
343 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); | |
344 } | |
345 | |
346 void EncryptedMediaPlayerSupportImpl::ContentDecryptionModuleAttached( | 346 void EncryptedMediaPlayerSupportImpl::ContentDecryptionModuleAttached( |
347 blink::WebContentDecryptionModuleResult result, | 347 blink::WebContentDecryptionModuleResult result, |
348 bool success) { | 348 bool success) { |
349 if (success) { | 349 if (success) { |
350 result.complete(); | 350 result.complete(); |
351 return; | 351 return; |
352 } | 352 } |
353 | 353 |
354 result.completeWithError( | 354 result.completeWithError( |
355 blink::WebContentDecryptionModuleExceptionNotSupportedError, | 355 blink::WebContentDecryptionModuleExceptionNotSupportedError, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 if (web_cdm_) { | 464 if (web_cdm_) { |
465 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); | 465 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); |
466 return; | 466 return; |
467 } | 467 } |
468 | 468 |
469 decryptor_ready_cb_ = decryptor_ready_cb; | 469 decryptor_ready_cb_ = decryptor_ready_cb; |
470 } | 470 } |
471 | 471 |
472 } // namespace content | 472 } // namespace content |
OLD | NEW |