Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cdm/ppapi/cdm_adapter.h" | 5 #include "media/cdm/ppapi/cdm_adapter.h" |
| 6 | 6 |
| 7 #include "media/base/limits.h" | 7 #include "media/base/limits.h" |
| 8 #include "media/cdm/ppapi/cdm_file_io_impl.h" | 8 #include "media/cdm/ppapi/cdm_file_io_impl.h" |
| 9 #include "media/cdm/ppapi/cdm_helpers.h" | 9 #include "media/cdm/ppapi/cdm_helpers.h" |
| 10 #include "media/cdm/ppapi/cdm_logging.h" | 10 #include "media/cdm/ppapi/cdm_logging.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 } | 215 } |
| 216 | 216 |
| 217 PP_NOTREACHED(); | 217 PP_NOTREACHED(); |
| 218 return cdm::kStreamTypeVideo; | 218 return cdm::kStreamTypeVideo; |
| 219 } | 219 } |
| 220 | 220 |
| 221 cdm::SessionType PpSessionTypeToCdmSessionType(PP_SessionType session_type) { | 221 cdm::SessionType PpSessionTypeToCdmSessionType(PP_SessionType session_type) { |
| 222 switch (session_type) { | 222 switch (session_type) { |
| 223 case PP_SESSIONTYPE_TEMPORARY: | 223 case PP_SESSIONTYPE_TEMPORARY: |
| 224 return cdm::kTemporary; | 224 return cdm::kTemporary; |
| 225 case PP_SESSIONTYPE_PERSISTENT: | 225 case PP_SESSIONTYPE_PERSISTENT_LICENSE: |
| 226 return cdm::kPersistent; | 226 return cdm::kPersistentLicense; |
| 227 default: | 227 case PP_SESSIONTYPE_PERSISTENT_RELEASE: |
| 228 PP_NOTREACHED(); | 228 return cdm::kPersistentKeyRelease; |
| 229 return cdm::kTemporary; | |
| 230 } | 229 } |
| 230 | |
| 231 PP_NOTREACHED(); | |
| 232 return cdm::kTemporary; | |
| 231 } | 233 } |
| 232 | 234 |
| 233 PP_CdmExceptionCode CdmExceptionTypeToPpCdmExceptionType(cdm::Error error) { | 235 PP_CdmExceptionCode CdmExceptionTypeToPpCdmExceptionType(cdm::Error error) { |
| 234 switch (error) { | 236 switch (error) { |
| 235 case cdm::kNotSupportedError: | 237 case cdm::kNotSupportedError: |
| 236 return PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR; | 238 return PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR; |
| 237 case cdm::kInvalidStateError: | 239 case cdm::kInvalidStateError: |
| 238 return PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR; | 240 return PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR; |
| 239 case cdm::kInvalidAccessError: | 241 case cdm::kInvalidAccessError: |
| 240 return PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR; | 242 return PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR; |
| 241 case cdm::kQuotaExceededError: | 243 case cdm::kQuotaExceededError: |
| 242 return PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR; | 244 return PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR; |
| 243 case cdm::kUnknownError: | 245 case cdm::kUnknownError: |
| 244 return PP_CDMEXCEPTIONCODE_UNKNOWNERROR; | 246 return PP_CDMEXCEPTIONCODE_UNKNOWNERROR; |
| 245 case cdm::kClientError: | 247 case cdm::kClientError: |
| 246 return PP_CDMEXCEPTIONCODE_CLIENTERROR; | 248 return PP_CDMEXCEPTIONCODE_CLIENTERROR; |
| 247 case cdm::kOutputError: | 249 case cdm::kOutputError: |
| 248 return PP_CDMEXCEPTIONCODE_OUTPUTERROR; | 250 return PP_CDMEXCEPTIONCODE_OUTPUTERROR; |
| 249 default: | |
| 250 PP_NOTREACHED(); | |
| 251 return PP_CDMEXCEPTIONCODE_UNKNOWNERROR; | |
| 252 } | 251 } |
| 252 | |
| 253 PP_NOTREACHED(); | |
| 254 return PP_CDMEXCEPTIONCODE_UNKNOWNERROR; | |
| 255 } | |
| 256 | |
| 257 PP_MessageType CdmMessageTypeToPpMessageType(cdm::MessageType message) { | |
| 258 switch (message) { | |
| 259 case cdm::kLicenseRequest: | |
| 260 return PP_MESSAGETYPE_LICENSE_REQUEST; | |
| 261 case cdm::kLicenseRenewal: | |
| 262 return PP_MESSAGETYPE_LICENSE_RENEWAL; | |
| 263 case cdm::kLicenseRelease: | |
| 264 return PP_MESSAGETYPE_LICENSE_RELEASE; | |
| 265 } | |
| 266 | |
| 267 PP_NOTREACHED(); | |
| 268 return PP_MESSAGETYPE_LICENSE_REQUEST; | |
| 269 } | |
| 270 | |
| 271 PP_KeyStatus CdmKeyStatusToPpKeyStatus(cdm::KeyStatus status) { | |
| 272 switch (status) { | |
| 273 case cdm::kUsable: | |
| 274 return PP_KEYSTATUS_USABLE; | |
| 275 case cdm::kInvalid: | |
| 276 return PP_KEYSTATUS_INVALID; | |
| 277 case cdm::kExpired: | |
| 278 return PP_KEYSTATUS_EXPIRED; | |
| 279 case cdm::kOutputNotAllowed: | |
| 280 return PP_KEYSTATUS_OUTPUTNOTALLOWED; | |
| 281 } | |
| 282 | |
| 283 PP_NOTREACHED(); | |
| 284 return PP_KEYSTATUS_INVALID; | |
| 253 } | 285 } |
| 254 | 286 |
| 255 } // namespace | 287 } // namespace |
| 256 | 288 |
| 257 namespace media { | 289 namespace media { |
| 258 | 290 |
| 259 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) | 291 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) |
| 260 : pp::Instance(instance), | 292 : pp::Instance(instance), |
| 261 pp::ContentDecryptor_Private(this), | 293 pp::ContentDecryptor_Private(this), |
| 262 #if defined(OS_CHROMEOS) | 294 #if defined(OS_CHROMEOS) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 cdm::kInvalidStateError, | 386 cdm::kInvalidStateError, |
| 355 0, | 387 0, |
| 356 "CDM has not been initialized."); | 388 "CDM has not been initialized."); |
| 357 return; | 389 return; |
| 358 } | 390 } |
| 359 | 391 |
| 360 cdm_->SetServerCertificate( | 392 cdm_->SetServerCertificate( |
| 361 promise_id, server_certificate_ptr, server_certificate_size); | 393 promise_id, server_certificate_ptr, server_certificate_size); |
| 362 } | 394 } |
| 363 | 395 |
| 364 void CdmAdapter::CreateSession(uint32_t promise_id, | 396 void CdmAdapter::CreateSessionAndGenerateRequest( |
| 365 const std::string& init_data_type, | 397 uint32_t promise_id, |
| 366 pp::VarArrayBuffer init_data, | 398 PP_SessionType session_type, |
| 367 PP_SessionType session_type) { | 399 const std::string& init_data_type, |
| 400 pp::VarArrayBuffer init_data) { | |
| 368 // Initialize() doesn't report an error, so CreateSession() can be called | 401 // Initialize() doesn't report an error, so CreateSession() can be called |
| 369 // even if Initialize() failed. | 402 // even if Initialize() failed. |
| 370 // TODO(jrummell): Remove this code when prefixed EME gets removed. | 403 // TODO(jrummell): Remove this code when prefixed EME gets removed. |
| 371 // TODO(jrummell): Verify that Initialize() failing does not resolve the | 404 // TODO(jrummell): Verify that Initialize() failing does not resolve the |
| 372 // MediaKeys.create() promise. | 405 // MediaKeys.create() promise. |
| 373 if (!cdm_) { | 406 if (!cdm_) { |
| 374 RejectPromise(promise_id, | 407 RejectPromise(promise_id, |
| 375 cdm::kInvalidStateError, | 408 cdm::kInvalidStateError, |
| 376 0, | 409 0, |
| 377 "CDM has not been initialized."); | 410 "CDM has not been initialized."); |
| 378 return; | 411 return; |
| 379 } | 412 } |
| 380 | 413 |
| 381 cdm_->CreateSession(promise_id, | 414 cdm_->CreateSessionAndGenerateRequest( |
| 382 init_data_type.data(), | 415 promise_id, PpSessionTypeToCdmSessionType(session_type), |
| 383 init_data_type.size(), | 416 init_data_type.data(), init_data_type.size(), |
| 384 static_cast<const uint8_t*>(init_data.Map()), | 417 static_cast<const uint8_t*>(init_data.Map()), init_data.ByteLength()); |
| 385 init_data.ByteLength(), | |
| 386 PpSessionTypeToCdmSessionType(session_type)); | |
| 387 } | 418 } |
| 388 | 419 |
| 389 void CdmAdapter::LoadSession(uint32_t promise_id, | 420 void CdmAdapter::LoadSession(uint32_t promise_id, |
| 390 const std::string& web_session_id) { | 421 PP_SessionType session_type, |
| 422 const std::string& session_id) { | |
| 391 // Initialize() doesn't report an error, so LoadSession() can be called | 423 // Initialize() doesn't report an error, so LoadSession() can be called |
| 392 // even if Initialize() failed. | 424 // even if Initialize() failed. |
| 393 // TODO(jrummell): Remove this code when prefixed EME gets removed. | 425 // TODO(jrummell): Remove this code when prefixed EME gets removed. |
| 394 // TODO(jrummell): Verify that Initialize() failing does not resolve the | 426 // TODO(jrummell): Verify that Initialize() failing does not resolve the |
| 395 // MediaKeys.create() promise. | 427 // MediaKeys.create() promise. |
| 396 if (!cdm_) { | 428 if (!cdm_) { |
| 397 RejectPromise(promise_id, | 429 RejectPromise(promise_id, |
| 398 cdm::kInvalidStateError, | 430 cdm::kInvalidStateError, |
| 399 0, | 431 0, |
| 400 "CDM has not been initialized."); | 432 "CDM has not been initialized."); |
| 401 return; | 433 return; |
| 402 } | 434 } |
| 403 | 435 |
| 404 cdm_->LoadSession(promise_id, web_session_id.data(), web_session_id.size()); | 436 cdm_->LoadSession(promise_id, PpSessionTypeToCdmSessionType(session_type), |
| 437 session_id.data(), session_id.size()); | |
| 405 } | 438 } |
| 406 | 439 |
| 407 void CdmAdapter::UpdateSession(uint32_t promise_id, | 440 void CdmAdapter::UpdateSession(uint32_t promise_id, |
| 408 const std::string& web_session_id, | 441 const std::string& session_id, |
| 409 pp::VarArrayBuffer response) { | 442 pp::VarArrayBuffer response) { |
| 410 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map()); | 443 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map()); |
| 411 const uint32_t response_size = response.ByteLength(); | 444 const uint32_t response_size = response.ByteLength(); |
| 412 | 445 |
| 413 PP_DCHECK(!web_session_id.empty()); | 446 PP_DCHECK(!session_id.empty()); |
| 414 PP_DCHECK(response_ptr); | 447 PP_DCHECK(response_ptr); |
| 415 PP_DCHECK(response_size > 0); | 448 PP_DCHECK(response_size > 0); |
| 416 | 449 |
| 417 cdm_->UpdateSession(promise_id, | 450 cdm_->UpdateSession(promise_id, session_id.data(), session_id.length(), |
| 418 web_session_id.data(), | 451 response_ptr, response_size); |
| 419 web_session_id.length(), | |
| 420 response_ptr, | |
| 421 response_size); | |
| 422 } | 452 } |
| 423 | 453 |
| 424 void CdmAdapter::CloseSession(uint32_t promise_id, | 454 void CdmAdapter::CloseSession(uint32_t promise_id, |
| 425 const std::string& web_session_id) { | 455 const std::string& session_id) { |
| 426 cdm_->CloseSession( | 456 cdm_->CloseSession(promise_id, session_id.data(), session_id.length()); |
| 427 promise_id, web_session_id.data(), web_session_id.length()); | |
| 428 } | 457 } |
| 429 | 458 |
| 430 void CdmAdapter::RemoveSession(uint32_t promise_id, | 459 void CdmAdapter::RemoveSession(uint32_t promise_id, |
| 431 const std::string& web_session_id) { | 460 const std::string& session_id) { |
| 432 cdm_->RemoveSession( | 461 cdm_->RemoveSession(promise_id, session_id.data(), session_id.length()); |
| 433 promise_id, web_session_id.data(), web_session_id.length()); | |
| 434 } | |
| 435 | |
| 436 void CdmAdapter::GetUsableKeyIds(uint32_t promise_id, | |
| 437 const std::string& web_session_id) { | |
| 438 cdm_->GetUsableKeyIds( | |
| 439 promise_id, web_session_id.data(), web_session_id.length()); | |
| 440 } | 462 } |
| 441 | 463 |
| 442 // Note: In the following decryption/decoding related functions, errors are NOT | 464 // Note: In the following decryption/decoding related functions, errors are NOT |
| 443 // reported via KeyError, but are reported via corresponding PPB calls. | 465 // reported via KeyError, but are reported via corresponding PPB calls. |
| 444 | 466 |
| 445 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer, | 467 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer, |
| 446 const PP_EncryptedBlockInfo& encrypted_block_info) { | 468 const PP_EncryptedBlockInfo& encrypted_block_info) { |
| 447 PP_DCHECK(!encrypted_buffer.is_null()); | 469 PP_DCHECK(!encrypted_buffer.is_null()); |
| 448 | 470 |
| 449 // Release a buffer that the caller indicated it is finished with. | 471 // Release a buffer that the caller indicated it is finished with. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 void CdmAdapter::TimerExpired(int32_t result, void* context) { | 653 void CdmAdapter::TimerExpired(int32_t result, void* context) { |
| 632 PP_DCHECK(result == PP_OK); | 654 PP_DCHECK(result == PP_OK); |
| 633 cdm_->TimerExpired(context); | 655 cdm_->TimerExpired(context); |
| 634 } | 656 } |
| 635 | 657 |
| 636 cdm::Time CdmAdapter::GetCurrentWallTime() { | 658 cdm::Time CdmAdapter::GetCurrentWallTime() { |
| 637 return pp::Module::Get()->core()->GetTime(); | 659 return pp::Module::Get()->core()->GetTime(); |
| 638 } | 660 } |
| 639 | 661 |
| 640 void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id, | 662 void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id, |
| 641 const char* web_session_id, | 663 const char* session_id, |
| 642 uint32_t web_session_id_length) { | 664 uint32_t session_id_size) { |
| 643 PostOnMain(callback_factory_.NewCallback( | 665 PostOnMain(callback_factory_.NewCallback( |
| 644 &CdmAdapter::SendPromiseResolvedWithSessionInternal, | 666 &CdmAdapter::SendPromiseResolvedWithSessionInternal, promise_id, |
| 645 promise_id, | 667 std::string(session_id, session_id_size))); |
| 646 std::string(web_session_id, web_session_id_length))); | |
| 647 } | 668 } |
| 648 | 669 |
| 649 void CdmAdapter::OnResolvePromise(uint32_t promise_id) { | 670 void CdmAdapter::OnResolvePromise(uint32_t promise_id) { |
| 650 PostOnMain(callback_factory_.NewCallback( | 671 PostOnMain(callback_factory_.NewCallback( |
| 651 &CdmAdapter::SendPromiseResolvedInternal, promise_id)); | 672 &CdmAdapter::SendPromiseResolvedInternal, promise_id)); |
| 652 } | 673 } |
| 653 | 674 |
| 675 // cdm::Host_6 only | |
| 654 void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id, | 676 void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id, |
| 655 const cdm::BinaryData* usable_key_ids, | 677 const cdm::BinaryData* usable_key_ids, |
| 656 uint32_t usable_key_ids_length) { | 678 uint32_t usable_key_ids_size) { |
| 657 std::vector<std::vector<uint8> > key_ids; | 679 // This should never be called as GetUsableKeyIds() has been removed. |
| 658 for (uint32_t i = 0; i < usable_key_ids_length; ++i) { | 680 PP_NOTREACHED(); |
| 659 key_ids.push_back( | |
| 660 std::vector<uint8>(usable_key_ids[i].data, | |
| 661 usable_key_ids[i].data + usable_key_ids[i].length)); | |
| 662 } | |
| 663 PostOnMain(callback_factory_.NewCallback( | |
| 664 &CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal, | |
| 665 promise_id, | |
| 666 key_ids)); | |
| 667 } | 681 } |
| 668 | 682 |
| 669 void CdmAdapter::OnRejectPromise(uint32_t promise_id, | 683 void CdmAdapter::OnRejectPromise(uint32_t promise_id, |
| 670 cdm::Error error, | 684 cdm::Error error, |
| 671 uint32_t system_code, | 685 uint32_t system_code, |
| 672 const char* error_message, | 686 const char* error_message, |
| 673 uint32_t error_message_length) { | 687 uint32_t error_message_size) { |
| 674 // UMA to investigate http://crbug.com/410630 | 688 // UMA to investigate http://crbug.com/410630 |
| 675 // TODO(xhwang): Remove after bug is fixed. | 689 // TODO(xhwang): Remove after bug is fixed. |
| 676 if (system_code == 0x27) { | 690 if (system_code == 0x27) { |
| 677 pp::UMAPrivate uma_interface(this); | 691 pp::UMAPrivate uma_interface(this); |
| 678 uma_interface.HistogramCustomCounts("Media.EME.CdmFileIO.FileSizeKBOnError", | 692 uma_interface.HistogramCustomCounts("Media.EME.CdmFileIO.FileSizeKBOnError", |
| 679 last_read_file_size_kb_, | 693 last_read_file_size_kb_, |
| 680 kSizeKBMin, | 694 kSizeKBMin, |
| 681 kSizeKBMax, | 695 kSizeKBMax, |
| 682 kSizeKBBuckets); | 696 kSizeKBBuckets); |
| 683 } | 697 } |
| 684 | 698 |
| 685 RejectPromise(promise_id, | 699 RejectPromise(promise_id, error, system_code, |
| 686 error, | 700 std::string(error_message, error_message_size)); |
| 687 system_code, | |
| 688 std::string(error_message, error_message_length)); | |
| 689 } | 701 } |
| 690 | 702 |
| 691 void CdmAdapter::RejectPromise(uint32_t promise_id, | 703 void CdmAdapter::RejectPromise(uint32_t promise_id, |
| 692 cdm::Error error, | 704 cdm::Error error, |
| 693 uint32_t system_code, | 705 uint32_t system_code, |
| 694 const std::string& error_message) { | 706 const std::string& error_message) { |
| 695 PostOnMain(callback_factory_.NewCallback( | 707 PostOnMain(callback_factory_.NewCallback( |
| 696 &CdmAdapter::SendPromiseRejectedInternal, | 708 &CdmAdapter::SendPromiseRejectedInternal, |
| 697 promise_id, | 709 promise_id, |
| 698 SessionError(error, system_code, error_message))); | 710 SessionError(error, system_code, error_message))); |
| 699 } | 711 } |
| 700 | 712 |
| 701 void CdmAdapter::OnSessionMessage(const char* web_session_id, | 713 // cdm::Host_7 only. |
| 702 uint32_t web_session_id_length, | 714 void CdmAdapter::OnSessionMessage(const char* session_id, |
| 715 uint32_t session_id_size, | |
| 716 cdm::MessageType message_type, | |
| 703 const char* message, | 717 const char* message, |
| 704 uint32_t message_length, | 718 uint32_t message_size) { |
| 705 const char* destination_url, | |
| 706 uint32_t destination_url_length) { | |
| 707 PostOnMain(callback_factory_.NewCallback( | 719 PostOnMain(callback_factory_.NewCallback( |
| 708 &CdmAdapter::SendSessionMessageInternal, | 720 &CdmAdapter::SendSessionMessageInternal, |
| 709 std::string(web_session_id, web_session_id_length), | 721 std::string(session_id, session_id_size), message_type, |
| 710 std::vector<uint8>(message, message + message_length), | 722 std::vector<uint8>(message, message + message_size))); |
| 711 std::string(destination_url, destination_url_length))); | |
| 712 } | 723 } |
| 713 | 724 |
| 714 void CdmAdapter::OnSessionUsableKeysChange(const char* web_session_id, | 725 // cdm::Host_6 only. |
|
ddorwin
2014/12/17 01:01:15
We should probably note where and how we provide "
jrummell
2014/12/17 19:17:19
Done.
| |
| 715 uint32_t web_session_id_length, | 726 void CdmAdapter::OnSessionMessage(const char* session_id, |
| 727 uint32_t session_id_size, | |
| 728 const char* message, | |
| 729 uint32_t message_size, | |
| 730 const char* destination_url, | |
| 731 uint32_t destination_url_size) { | |
| 732 PostOnMain(callback_factory_.NewCallback( | |
| 733 &CdmAdapter::SendSessionMessageInternal, | |
| 734 std::string(session_id, session_id_size), | |
| 735 cdm::MessageType::kLicenseRequest, | |
| 736 std::vector<uint8>(message, message + message_size))); | |
| 737 } | |
| 738 | |
| 739 // cdm::Host_7 only. | |
| 740 void CdmAdapter::OnSessionUsableKeysChange(const char* session_id, | |
| 741 uint32_t session_id_size, | |
| 742 bool has_additional_usable_key, | |
| 743 const cdm::KeyInformation* keys_info, | |
| 744 uint32_t keys_info_count) { | |
| 745 std::vector<PP_KeyInformation> key_information; | |
| 746 for (uint32_t i = 0; i < keys_info_count; ++i) { | |
| 747 const auto& key_info = keys_info[i]; | |
| 748 PP_KeyInformation next_key; | |
| 749 | |
| 750 if (key_info.key_id_size > sizeof(next_key.key_id)) { | |
| 751 PP_NOTREACHED(); | |
| 752 continue; | |
| 753 } | |
| 754 | |
| 755 // Initialize |next_key|. | |
| 756 memset(&next_key, 0, sizeof(PP_KeyInformation)); | |
| 757 | |
| 758 // Copy key_id into |next_key|. | |
| 759 memcpy(&next_key.key_id, key_info.key_id, key_info.key_id_size); | |
| 760 | |
| 761 // Set remaining fields on |next_key|. | |
| 762 next_key.key_id_size = key_info.key_id_size; | |
| 763 next_key.key_status = CdmKeyStatusToPpKeyStatus(key_info.status); | |
| 764 next_key.system_code = key_info.system_code; | |
| 765 key_information.push_back(next_key); | |
| 766 } | |
| 767 | |
| 768 PostOnMain(callback_factory_.NewCallback( | |
| 769 &CdmAdapter::SendSessionUsableKeysChangeInternal, | |
| 770 std::string(session_id, session_id_size), has_additional_usable_key, | |
| 771 key_information)); | |
| 772 } | |
| 773 | |
| 774 // cdm::Host_6 only. | |
| 775 void CdmAdapter::OnSessionUsableKeysChange(const char* session_id, | |
| 776 uint32_t session_id_size, | |
| 716 bool has_additional_usable_key) { | 777 bool has_additional_usable_key) { |
| 717 PostOnMain(callback_factory_.NewCallback( | 778 PostOnMain(callback_factory_.NewCallback( |
| 718 &CdmAdapter::SendSessionUsableKeysChangeInternal, | 779 &CdmAdapter::SendSessionUsableKeysChangeInternal, |
| 719 std::string(web_session_id, web_session_id_length), | 780 std::string(session_id, session_id_size), has_additional_usable_key, |
| 720 has_additional_usable_key)); | 781 std::vector<PP_KeyInformation>())); |
| 721 } | 782 } |
| 722 | 783 |
| 723 void CdmAdapter::OnExpirationChange(const char* web_session_id, | 784 void CdmAdapter::OnExpirationChange(const char* session_id, |
| 724 uint32_t web_session_id_length, | 785 uint32_t session_id_size, |
| 725 cdm::Time new_expiry_time) { | 786 cdm::Time new_expiry_time) { |
| 726 PostOnMain(callback_factory_.NewCallback( | 787 PostOnMain(callback_factory_.NewCallback( |
| 727 &CdmAdapter::SendExpirationChangeInternal, | 788 &CdmAdapter::SendExpirationChangeInternal, |
| 728 std::string(web_session_id, web_session_id_length), | 789 std::string(session_id, session_id_size), new_expiry_time)); |
| 729 new_expiry_time)); | |
| 730 } | 790 } |
| 731 | 791 |
| 732 void CdmAdapter::OnSessionClosed(const char* web_session_id, | 792 void CdmAdapter::OnSessionClosed(const char* session_id, |
| 733 uint32_t web_session_id_length) { | 793 uint32_t session_id_size) { |
| 734 PostOnMain(callback_factory_.NewCallback( | 794 PostOnMain( |
| 735 &CdmAdapter::SendSessionClosedInternal, | 795 callback_factory_.NewCallback(&CdmAdapter::SendSessionClosedInternal, |
| 736 std::string(web_session_id, web_session_id_length))); | 796 std::string(session_id, session_id_size))); |
| 737 } | 797 } |
| 738 | 798 |
| 739 void CdmAdapter::OnSessionError(const char* web_session_id, | 799 // cdm::Host_6 only. |
| 740 uint32_t web_session_id_length, | 800 void CdmAdapter::OnSessionError(const char* session_id, |
| 801 uint32_t session_id_size, | |
| 741 cdm::Error error, | 802 cdm::Error error, |
| 742 uint32_t system_code, | 803 uint32_t system_code, |
| 743 const char* error_message, | 804 const char* error_message, |
| 744 uint32_t error_message_length) { | 805 uint32_t error_message_size) { |
| 745 PostOnMain(callback_factory_.NewCallback( | 806 PostOnMain(callback_factory_.NewCallback( |
| 746 &CdmAdapter::SendSessionErrorInternal, | 807 &CdmAdapter::SendSessionErrorInternal, |
| 747 std::string(web_session_id, web_session_id_length), | 808 std::string(session_id, session_id_size), |
| 748 SessionError(error, | 809 SessionError(error, system_code, |
| 749 system_code, | 810 std::string(error_message, error_message_size)))); |
| 750 std::string(error_message, error_message_length)))); | |
| 751 } | 811 } |
| 752 | 812 |
| 753 // Helpers to pass the event to Pepper. | 813 // Helpers to pass the event to Pepper. |
| 754 | 814 |
| 755 void CdmAdapter::SendPromiseResolvedInternal(int32_t result, | 815 void CdmAdapter::SendPromiseResolvedInternal(int32_t result, |
| 756 uint32_t promise_id) { | 816 uint32_t promise_id) { |
| 757 PP_DCHECK(result == PP_OK); | 817 PP_DCHECK(result == PP_OK); |
| 758 pp::ContentDecryptor_Private::PromiseResolved(promise_id); | 818 pp::ContentDecryptor_Private::PromiseResolved(promise_id); |
| 759 } | 819 } |
| 760 | 820 |
| 761 void CdmAdapter::SendPromiseResolvedWithSessionInternal( | 821 void CdmAdapter::SendPromiseResolvedWithSessionInternal( |
| 762 int32_t result, | 822 int32_t result, |
| 763 uint32_t promise_id, | 823 uint32_t promise_id, |
| 764 const std::string& web_session_id) { | 824 const std::string& session_id) { |
| 765 PP_DCHECK(result == PP_OK); | 825 PP_DCHECK(result == PP_OK); |
| 766 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id, | 826 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id, |
| 767 web_session_id); | 827 session_id); |
| 768 } | |
| 769 | |
| 770 void CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal( | |
| 771 int32_t result, | |
| 772 uint32_t promise_id, | |
| 773 std::vector<std::vector<uint8> > key_ids) { | |
| 774 PP_DCHECK(result == PP_OK); | |
| 775 pp::ContentDecryptor_Private::PromiseResolvedWithKeyIds(promise_id, key_ids); | |
| 776 } | 828 } |
| 777 | 829 |
| 778 void CdmAdapter::SendPromiseRejectedInternal(int32_t result, | 830 void CdmAdapter::SendPromiseRejectedInternal(int32_t result, |
| 779 uint32_t promise_id, | 831 uint32_t promise_id, |
| 780 const SessionError& error) { | 832 const SessionError& error) { |
| 781 PP_DCHECK(result == PP_OK); | 833 PP_DCHECK(result == PP_OK); |
| 782 pp::ContentDecryptor_Private::PromiseRejected( | 834 pp::ContentDecryptor_Private::PromiseRejected( |
| 783 promise_id, | 835 promise_id, |
| 784 CdmExceptionTypeToPpCdmExceptionType(error.error), | 836 CdmExceptionTypeToPpCdmExceptionType(error.error), |
| 785 error.system_code, | 837 error.system_code, |
| 786 error.error_description); | 838 error.error_description); |
| 787 } | 839 } |
| 788 | 840 |
| 789 void CdmAdapter::SendSessionMessageInternal( | 841 void CdmAdapter::SendSessionMessageInternal(int32_t result, |
| 790 int32_t result, | 842 const std::string& session_id, |
| 791 const std::string& web_session_id, | 843 cdm::MessageType message_type, |
| 792 const std::vector<uint8>& message, | 844 const std::vector<uint8>& message) { |
| 793 const std::string& destination_url) { | |
| 794 PP_DCHECK(result == PP_OK); | 845 PP_DCHECK(result == PP_OK); |
| 795 | 846 |
| 796 pp::VarArrayBuffer message_array_buffer(message.size()); | 847 pp::VarArrayBuffer message_array_buffer(message.size()); |
| 797 if (message.size() > 0) { | 848 if (message.size() > 0) { |
| 798 memcpy(message_array_buffer.Map(), message.data(), message.size()); | 849 memcpy(message_array_buffer.Map(), message.data(), message.size()); |
| 799 } | 850 } |
| 800 | 851 |
| 801 pp::ContentDecryptor_Private::SessionMessage( | 852 pp::ContentDecryptor_Private::SessionMessage( |
| 802 web_session_id, message_array_buffer, destination_url); | 853 session_id, CdmMessageTypeToPpMessageType(message_type), |
| 803 } | 854 message_array_buffer); |
| 804 | |
| 805 void CdmAdapter::SendSessionReadyInternal(int32_t result, | |
| 806 const std::string& web_session_id) { | |
| 807 PP_DCHECK(result == PP_OK); | |
| 808 pp::ContentDecryptor_Private::SessionReady(web_session_id); | |
| 809 } | 855 } |
| 810 | 856 |
| 811 void CdmAdapter::SendSessionClosedInternal(int32_t result, | 857 void CdmAdapter::SendSessionClosedInternal(int32_t result, |
| 812 const std::string& web_session_id) { | 858 const std::string& session_id) { |
| 813 PP_DCHECK(result == PP_OK); | 859 PP_DCHECK(result == PP_OK); |
| 814 pp::ContentDecryptor_Private::SessionClosed(web_session_id); | 860 pp::ContentDecryptor_Private::SessionClosed(session_id); |
| 815 } | 861 } |
| 816 | 862 |
| 817 void CdmAdapter::SendSessionErrorInternal(int32_t result, | 863 void CdmAdapter::SendSessionErrorInternal(int32_t result, |
| 818 const std::string& web_session_id, | 864 const std::string& session_id, |
| 819 const SessionError& error) { | 865 const SessionError& error) { |
| 820 PP_DCHECK(result == PP_OK); | 866 PP_DCHECK(result == PP_OK); |
| 821 pp::ContentDecryptor_Private::SessionError( | 867 pp::ContentDecryptor_Private::SessionError( |
| 822 web_session_id, | 868 session_id, CdmExceptionTypeToPpCdmExceptionType(error.error), |
| 823 CdmExceptionTypeToPpCdmExceptionType(error.error), | 869 error.system_code, error.error_description); |
| 824 error.system_code, | |
| 825 error.error_description); | |
| 826 } | 870 } |
| 827 | 871 |
| 828 void CdmAdapter::SendSessionUsableKeysChangeInternal( | 872 void CdmAdapter::SendSessionUsableKeysChangeInternal( |
| 829 int32_t result, | 873 int32_t result, |
| 830 const std::string& web_session_id, | 874 const std::string& session_id, |
| 831 bool has_additional_usable_key) { | 875 bool has_additional_usable_key, |
| 876 std::vector<PP_KeyInformation> key_info) { | |
| 832 PP_DCHECK(result == PP_OK); | 877 PP_DCHECK(result == PP_OK); |
| 833 pp::ContentDecryptor_Private::SessionKeysChange(web_session_id, | 878 pp::ContentDecryptor_Private::SessionKeysChange( |
| 834 has_additional_usable_key); | 879 session_id, has_additional_usable_key, key_info); |
| 835 } | 880 } |
| 836 | 881 |
| 837 void CdmAdapter::SendExpirationChangeInternal(int32_t result, | 882 void CdmAdapter::SendExpirationChangeInternal(int32_t result, |
| 838 const std::string& web_session_id, | 883 const std::string& session_id, |
| 839 cdm::Time new_expiry_time) { | 884 cdm::Time new_expiry_time) { |
| 840 PP_DCHECK(result == PP_OK); | 885 PP_DCHECK(result == PP_OK); |
| 841 pp::ContentDecryptor_Private::SessionExpirationChange(web_session_id, | 886 pp::ContentDecryptor_Private::SessionExpirationChange(session_id, |
| 842 new_expiry_time); | 887 new_expiry_time); |
| 843 } | 888 } |
| 844 | 889 |
| 845 void CdmAdapter::DeliverBlock(int32_t result, | 890 void CdmAdapter::DeliverBlock(int32_t result, |
| 846 const cdm::Status& status, | 891 const cdm::Status& status, |
| 847 const LinkedDecryptedBlock& decrypted_block, | 892 const LinkedDecryptedBlock& decrypted_block, |
| 848 const PP_DecryptTrackingInfo& tracking_info) { | 893 const PP_DecryptTrackingInfo& tracking_info) { |
| 849 PP_DCHECK(result == PP_OK); | 894 PP_DCHECK(result == PP_OK); |
| 850 PP_DecryptedBlockInfo decrypted_block_info = {}; | 895 PP_DecryptedBlockInfo decrypted_block_info = {}; |
| 851 decrypted_block_info.tracking_info = tracking_info; | 896 decrypted_block_info.tracking_info = tracking_info; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 | 1071 |
| 1027 #if !defined(NDEBUG) | 1072 #if !defined(NDEBUG) |
| 1028 void CdmAdapter::LogToConsole(const pp::Var& value) { | 1073 void CdmAdapter::LogToConsole(const pp::Var& value) { |
| 1029 PP_DCHECK(IsMainThread()); | 1074 PP_DCHECK(IsMainThread()); |
| 1030 const PPB_Console* console = reinterpret_cast<const PPB_Console*>( | 1075 const PPB_Console* console = reinterpret_cast<const PPB_Console*>( |
| 1031 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); | 1076 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); |
| 1032 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var()); | 1077 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var()); |
| 1033 } | 1078 } |
| 1034 #endif // !defined(NDEBUG) | 1079 #endif // !defined(NDEBUG) |
| 1035 | 1080 |
| 1036 void CdmAdapter::SendPlatformChallenge( | 1081 void CdmAdapter::SendPlatformChallenge(const char* service_id, |
| 1037 const char* service_id, uint32_t service_id_length, | 1082 uint32_t service_id_size, |
| 1038 const char* challenge, uint32_t challenge_length) { | 1083 const char* challenge, |
| 1084 uint32_t challenge_size) { | |
| 1039 #if defined(OS_CHROMEOS) | 1085 #if defined(OS_CHROMEOS) |
| 1040 pp::VarArrayBuffer challenge_var(challenge_length); | 1086 pp::VarArrayBuffer challenge_var(challenge_size); |
| 1041 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); | 1087 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); |
| 1042 memcpy(var_data, challenge, challenge_length); | 1088 memcpy(var_data, challenge, challenge_size); |
| 1043 | 1089 |
| 1044 std::string service_id_str(service_id, service_id_length); | 1090 std::string service_id_str(service_id, service_id_size); |
| 1045 | 1091 |
| 1046 linked_ptr<PepperPlatformChallengeResponse> response( | 1092 linked_ptr<PepperPlatformChallengeResponse> response( |
| 1047 new PepperPlatformChallengeResponse()); | 1093 new PepperPlatformChallengeResponse()); |
| 1048 | 1094 |
| 1049 int32_t result = platform_verification_.ChallengePlatform( | 1095 int32_t result = platform_verification_.ChallengePlatform( |
| 1050 pp::Var(service_id_str), | 1096 pp::Var(service_id_str), |
| 1051 challenge_var, | 1097 challenge_var, |
| 1052 &response->signed_data, | 1098 &response->signed_data, |
| 1053 &response->signed_data_signature, | 1099 &response->signed_data_signature, |
| 1054 &response->platform_key_certificate, | 1100 &response->platform_key_certificate, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1091 callback_factory_.NewCallback( | 1137 callback_factory_.NewCallback( |
| 1092 &CdmAdapter::QueryOutputProtectionStatusDone)); | 1138 &CdmAdapter::QueryOutputProtectionStatusDone)); |
| 1093 if (result == PP_OK_COMPLETIONPENDING) { | 1139 if (result == PP_OK_COMPLETIONPENDING) { |
| 1094 query_output_protection_in_progress_ = true; | 1140 query_output_protection_in_progress_ = true; |
| 1095 ReportOutputProtectionQuery(); | 1141 ReportOutputProtectionQuery(); |
| 1096 return; | 1142 return; |
| 1097 } | 1143 } |
| 1098 | 1144 |
| 1099 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). | 1145 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). |
| 1100 PP_DCHECK(result != PP_OK); | 1146 PP_DCHECK(result != PP_OK); |
| 1147 cdm_->OnQueryOutputProtectionStatus(0, 0, result); | |
| 1148 #else | |
| 1149 cdm_->OnQueryOutputProtectionStatus(0, 0, PP_ERROR_NOTSUPPORTED); | |
|
ddorwin
2014/12/17 01:01:15
PP_NOTREACHED()?
jrummell
2014/12/17 19:17:19
Since returning 0,0 is specified as the result if
| |
| 1101 #endif | 1150 #endif |
| 1102 | |
| 1103 cdm_->OnQueryOutputProtectionStatus(0, 0); | |
| 1104 } | 1151 } |
| 1105 | 1152 |
| 1106 void CdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type, | 1153 void CdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type, |
| 1107 cdm::Status decoder_status) { | 1154 cdm::Status decoder_status) { |
| 1108 switch (stream_type) { | 1155 switch (stream_type) { |
| 1109 case cdm::kStreamTypeAudio: | 1156 case cdm::kStreamTypeAudio: |
| 1110 PP_DCHECK(deferred_initialize_audio_decoder_); | 1157 PP_DCHECK(deferred_initialize_audio_decoder_); |
| 1111 CallOnMain( | 1158 CallOnMain( |
| 1112 callback_factory_.NewCallback(&CdmAdapter::DecoderInitializeDone, | 1159 callback_factory_.NewCallback(&CdmAdapter::DecoderInitializeDone, |
| 1113 PP_DECRYPTORSTREAMTYPE_AUDIO, | 1160 PP_DECRYPTORSTREAMTYPE_AUDIO, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1239 : error(error), | 1286 : error(error), |
| 1240 system_code(system_code), | 1287 system_code(system_code), |
| 1241 error_description(error_description) { | 1288 error_description(error_description) { |
| 1242 } | 1289 } |
| 1243 | 1290 |
| 1244 void* GetCdmHost(int host_interface_version, void* user_data) { | 1291 void* GetCdmHost(int host_interface_version, void* user_data) { |
| 1245 if (!host_interface_version || !user_data) | 1292 if (!host_interface_version || !user_data) |
| 1246 return NULL; | 1293 return NULL; |
| 1247 | 1294 |
| 1248 COMPILE_ASSERT( | 1295 COMPILE_ASSERT( |
| 1249 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_6::kVersion, | 1296 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_7::kVersion, |
| 1250 update_code_below); | 1297 update_code_below); |
| 1251 | 1298 |
| 1252 // Ensure IsSupportedCdmHostVersion matches implementation of this function. | 1299 // Ensure IsSupportedCdmHostVersion matches implementation of this function. |
| 1253 // Always update this DCHECK when updating this function. | 1300 // Always update this DCHECK when updating this function. |
| 1254 // If this check fails, update this function and DCHECK or update | 1301 // If this check fails, update this function and DCHECK or update |
| 1255 // IsSupportedCdmHostVersion. | 1302 // IsSupportedCdmHostVersion. |
| 1256 | 1303 |
| 1257 PP_DCHECK( | 1304 PP_DCHECK( |
| 1258 // Future version is not supported. | 1305 // Future version is not supported. |
| 1259 !IsSupportedCdmHostVersion(cdm::Host_6::kVersion + 1) && | 1306 !IsSupportedCdmHostVersion(cdm::Host_7::kVersion + 1) && |
| 1260 // Current version is supported. | 1307 // Current version is supported. |
| 1308 IsSupportedCdmHostVersion(cdm::Host_7::kVersion) && | |
| 1309 // Include all previous supported versions (if any) here. | |
| 1261 IsSupportedCdmHostVersion(cdm::Host_6::kVersion) && | 1310 IsSupportedCdmHostVersion(cdm::Host_6::kVersion) && |
| 1262 // Include all previous supported versions (if any) here. | |
| 1263 // One older than the oldest supported version is not supported. | 1311 // One older than the oldest supported version is not supported. |
| 1264 !IsSupportedCdmHostVersion(cdm::Host_6::kVersion - 1)); | 1312 !IsSupportedCdmHostVersion(cdm::Host_6::kVersion - 1)); |
| 1265 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); | 1313 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); |
| 1266 | 1314 |
| 1267 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); | 1315 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); |
| 1268 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; | 1316 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; |
| 1269 switch (host_interface_version) { | 1317 switch (host_interface_version) { |
| 1318 case cdm::Host_7::kVersion: | |
| 1319 return static_cast<cdm::Host_7*>(cdm_adapter); | |
| 1270 case cdm::Host_6::kVersion: | 1320 case cdm::Host_6::kVersion: |
| 1271 return static_cast<cdm::Host_6*>(cdm_adapter); | 1321 return static_cast<cdm::Host_6*>(cdm_adapter); |
| 1272 default: | 1322 default: |
| 1273 PP_NOTREACHED(); | 1323 PP_NOTREACHED(); |
| 1274 return NULL; | 1324 return NULL; |
| 1275 } | 1325 } |
| 1276 } | 1326 } |
| 1277 | 1327 |
| 1278 // This object is the global object representing this plugin library as long | 1328 // This object is the global object representing this plugin library as long |
| 1279 // as it is loaded. | 1329 // as it is loaded. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1299 } // namespace media | 1349 } // namespace media |
| 1300 | 1350 |
| 1301 namespace pp { | 1351 namespace pp { |
| 1302 | 1352 |
| 1303 // Factory function for your specialization of the Module object. | 1353 // Factory function for your specialization of the Module object. |
| 1304 Module* CreateModule() { | 1354 Module* CreateModule() { |
| 1305 return new media::CdmAdapterModule(); | 1355 return new media::CdmAdapterModule(); |
| 1306 } | 1356 } |
| 1307 | 1357 |
| 1308 } // namespace pp | 1358 } // namespace pp |
| OLD | NEW |