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/cdm/ppapi/cdm_file_io_impl.h" | 7 #include "media/cdm/ppapi/cdm_file_io_impl.h" |
| 8 #include "media/cdm/ppapi/cdm_helpers.h" | 8 #include "media/cdm/ppapi/cdm_helpers.h" |
| 9 #include "media/cdm/ppapi/cdm_logging.h" | 9 #include "media/cdm/ppapi/cdm_logging.h" |
| 10 #include "media/cdm/ppapi/supported_cdm_versions.h" | 10 #include "media/cdm/ppapi/supported_cdm_versions.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 case PP_DECRYPTORSTREAMTYPE_AUDIO: | 203 case PP_DECRYPTORSTREAMTYPE_AUDIO: |
| 204 return cdm::kStreamTypeAudio; | 204 return cdm::kStreamTypeAudio; |
| 205 case PP_DECRYPTORSTREAMTYPE_VIDEO: | 205 case PP_DECRYPTORSTREAMTYPE_VIDEO: |
| 206 return cdm::kStreamTypeVideo; | 206 return cdm::kStreamTypeVideo; |
| 207 } | 207 } |
| 208 | 208 |
| 209 PP_NOTREACHED(); | 209 PP_NOTREACHED(); |
| 210 return cdm::kStreamTypeVideo; | 210 return cdm::kStreamTypeVideo; |
| 211 } | 211 } |
| 212 | 212 |
| 213 cdm::SessionType PpSessionTypeToCdmSessionType(PP_SessionType session_type) { | |
| 214 switch (session_type) { | |
| 215 case PP_SESSIONTYPE_TEMPORARY: | |
| 216 return cdm::SessionType::kTemporary; | |
| 217 case PP_SESSIONTYPE_PERSISTENT: | |
| 218 return cdm::SessionType::kPersistent; | |
| 219 default: | |
| 220 PP_NOTREACHED(); | |
| 221 return cdm::SessionType::kTemporary; | |
| 222 } | |
| 223 } | |
| 224 | |
| 213 } // namespace | 225 } // namespace |
| 214 | 226 |
| 215 namespace media { | 227 namespace media { |
| 216 | 228 |
| 217 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) | 229 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) |
| 218 : pp::Instance(instance), | 230 : pp::Instance(instance), |
| 219 pp::ContentDecryptor_Private(this), | 231 pp::ContentDecryptor_Private(this), |
| 220 #if defined(OS_CHROMEOS) | 232 #if defined(OS_CHROMEOS) |
| 221 output_protection_(this), | 233 output_protection_(this), |
| 222 platform_verification_(this), | 234 platform_verification_(this), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 } | 292 } |
| 281 #endif // defined(CHECK_DOCUMENT_URL) | 293 #endif // defined(CHECK_DOCUMENT_URL) |
| 282 | 294 |
| 283 if (!cdm_ && !CreateCdmInstance(key_system)) | 295 if (!cdm_ && !CreateCdmInstance(key_system)) |
| 284 return; | 296 return; |
| 285 | 297 |
| 286 PP_DCHECK(cdm_); | 298 PP_DCHECK(cdm_); |
| 287 key_system_ = key_system; | 299 key_system_ = key_system; |
| 288 } | 300 } |
| 289 | 301 |
| 290 void CdmAdapter::CreateSession(uint32_t session_id, | 302 void CdmAdapter::CreateSession(uint32_t promise_id, |
| 291 const std::string& content_type, | 303 const std::string& init_data_type, |
| 292 pp::VarArrayBuffer init_data) { | 304 pp::VarArrayBuffer init_data, |
| 305 PP_SessionType session_type) { | |
| 293 // Initialize() doesn't report an error, so CreateSession() can be called | 306 // Initialize() doesn't report an error, so CreateSession() can be called |
| 294 // even if Initialize() failed. | 307 // even if Initialize() failed. |
| 295 if (!cdm_) { | 308 if (!cdm_) { |
| 296 OnSessionError(session_id, cdm::kUnknownError, 0); | 309 RejectPromise( |
| 310 promise_id, "InvalidStateError", 0, "CDM has not been initialized."); | |
| 297 return; | 311 return; |
| 298 } | 312 } |
| 299 | 313 |
| 300 cdm_->CreateSession(session_id, | 314 cdm_->CreateSession(promise_id, |
| 301 content_type.data(), | 315 init_data_type.data(), |
| 302 content_type.size(), | 316 init_data_type.size(), |
| 303 static_cast<const uint8_t*>(init_data.Map()), | 317 static_cast<const uint8_t*>(init_data.Map()), |
| 304 init_data.ByteLength()); | 318 init_data.ByteLength(), |
| 319 PpSessionTypeToCdmSessionType(session_type)); | |
| 305 } | 320 } |
| 306 | 321 |
| 307 void CdmAdapter::LoadSession(uint32_t session_id, | 322 void CdmAdapter::LoadSession(uint32_t promise_id, |
| 308 const std::string& web_session_id) { | 323 const std::string& web_session_id) { |
| 309 // Initialize() doesn't report an error, so LoadSession() can be called | 324 // Initialize() doesn't report an error, so LoadSession() can be called |
| 310 // even if Initialize() failed. | 325 // even if Initialize() failed. |
| 311 if (!cdm_) { | 326 if (!cdm_) { |
| 312 OnSessionError(session_id, cdm::kUnknownError, 0); | 327 RejectPromise( |
| 328 promise_id, "InvalidStateError", 0, "CDM has not been initialized."); | |
| 313 return; | 329 return; |
| 314 } | 330 } |
| 315 | 331 |
| 316 cdm_->LoadSession(session_id, web_session_id.data(), web_session_id.size()); | 332 cdm_->LoadSession(promise_id, web_session_id.data(), web_session_id.size()); |
| 317 } | 333 } |
| 318 | 334 |
| 319 void CdmAdapter::UpdateSession(uint32_t session_id, | 335 void CdmAdapter::UpdateSession(uint32_t promise_id, |
| 336 const std::string& web_session_id, | |
| 320 pp::VarArrayBuffer response) { | 337 pp::VarArrayBuffer response) { |
| 321 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map()); | 338 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map()); |
| 322 const uint32_t response_size = response.ByteLength(); | 339 const uint32_t response_size = response.ByteLength(); |
| 323 | 340 |
| 341 PP_DCHECK(!web_session_id.empty()); | |
| 342 | |
| 324 if (!response_ptr || response_size <= 0) { | 343 if (!response_ptr || response_size <= 0) { |
| 325 OnSessionError(session_id, cdm::kUnknownError, 0); | 344 RejectPromise(promise_id, "SyntaxError", 0, "response is empty."); |
| 326 return; | 345 return; |
| 327 } | 346 } |
| 328 cdm_->UpdateSession(session_id, response_ptr, response_size); | 347 |
| 348 cdm_->UpdateSession(promise_id, | |
| 349 web_session_id.data(), | |
| 350 web_session_id.length(), | |
| 351 response_ptr, | |
| 352 response_size); | |
| 329 } | 353 } |
| 330 | 354 |
| 331 void CdmAdapter::ReleaseSession(uint32_t session_id) { | 355 void CdmAdapter::ReleaseSession(uint32_t promise_id, |
| 332 cdm_->ReleaseSession(session_id); | 356 const std::string& web_session_id) { |
| 357 cdm_->ReleaseSession( | |
| 358 promise_id, web_session_id.data(), web_session_id.length()); | |
| 333 } | 359 } |
| 334 | 360 |
| 335 // Note: In the following decryption/decoding related functions, errors are NOT | 361 // Note: In the following decryption/decoding related functions, errors are NOT |
| 336 // reported via KeyError, but are reported via corresponding PPB calls. | 362 // reported via KeyError, but are reported via corresponding PPB calls. |
| 337 | 363 |
| 338 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer, | 364 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer, |
| 339 const PP_EncryptedBlockInfo& encrypted_block_info) { | 365 const PP_EncryptedBlockInfo& encrypted_block_info) { |
| 340 PP_DCHECK(!encrypted_buffer.is_null()); | 366 PP_DCHECK(!encrypted_buffer.is_null()); |
| 341 | 367 |
| 342 // Release a buffer that the caller indicated it is finished with. | 368 // Release a buffer that the caller indicated it is finished with. |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 | 549 |
| 524 void CdmAdapter::TimerExpired(int32_t result, void* context) { | 550 void CdmAdapter::TimerExpired(int32_t result, void* context) { |
| 525 PP_DCHECK(result == PP_OK); | 551 PP_DCHECK(result == PP_OK); |
| 526 cdm_->TimerExpired(context); | 552 cdm_->TimerExpired(context); |
| 527 } | 553 } |
| 528 | 554 |
| 529 double CdmAdapter::GetCurrentWallTimeInSeconds() { | 555 double CdmAdapter::GetCurrentWallTimeInSeconds() { |
| 530 return pp::Module::Get()->core()->GetTime(); | 556 return pp::Module::Get()->core()->GetTime(); |
| 531 } | 557 } |
| 532 | 558 |
| 559 // cdm::Host_5 methods | |
| 560 | |
| 561 void CdmAdapter::OnResolvePromise(uint32_t promise_id) { | |
| 562 PostOnMain(callback_factory_.NewCallback( | |
| 563 &CdmAdapter::SendPromiseResolvedInternal, promise_id)); | |
| 564 } | |
| 565 | |
| 566 void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id, | |
| 567 const char* web_session_id, | |
| 568 uint32_t web_session_id_length) { | |
| 569 PostOnMain(callback_factory_.NewCallback( | |
| 570 &CdmAdapter::SendPromiseResolvedWithSessionInternal, | |
| 571 promise_id, | |
| 572 std::string(web_session_id, web_session_id_length))); | |
| 573 } | |
| 574 | |
| 575 void CdmAdapter::OnRejectPromise(uint32_t promise_id, | |
| 576 const char* error_name, | |
| 577 uint32_t error_name_length, | |
| 578 uint32_t system_code, | |
| 579 const char* error_message, | |
| 580 uint32_t error_message_length) { | |
| 581 RejectPromise(promise_id, | |
| 582 std::string(error_name, error_name_length), | |
| 583 system_code, | |
| 584 std::string(error_message, error_message_length)); | |
| 585 } | |
| 586 | |
| 587 void CdmAdapter::RejectPromise(uint32_t promise_id, | |
| 588 const std::string& error_name, | |
| 589 uint32_t system_code, | |
| 590 const std::string& error_message) { | |
| 591 PostOnMain(callback_factory_.NewCallback( | |
| 592 &CdmAdapter::SendPromiseRejectedInternal, | |
| 593 promise_id, | |
| 594 SessionError(error_name, system_code, error_message))); | |
| 595 } | |
| 596 | |
| 597 void CdmAdapter::OnSessionMessage(const char* web_session_id, | |
| 598 uint32_t web_session_id_length, | |
| 599 const char* message, | |
| 600 uint32_t message_length, | |
| 601 const char* destination_url, | |
| 602 uint32_t destination_url_length) { | |
| 603 PostOnMain(callback_factory_.NewCallback( | |
| 604 &CdmAdapter::SendSessionMessageInternal, | |
| 605 std::string(web_session_id, web_session_id_length), | |
| 606 std::vector<uint8>(message, message + message_length), | |
| 607 std::string(destination_url, destination_url_length))); | |
| 608 } | |
| 609 | |
| 610 void CdmAdapter::OnSessionReady(const char* web_session_id, | |
| 611 uint32_t web_session_id_length) { | |
| 612 PostOnMain(callback_factory_.NewCallback( | |
| 613 &CdmAdapter::SendSessionReadyInternal, | |
| 614 std::string(web_session_id, web_session_id_length))); | |
| 615 } | |
| 616 | |
| 617 void CdmAdapter::OnSessionClosed(const char* web_session_id, | |
| 618 uint32_t web_session_id_length) { | |
| 619 PostOnMain(callback_factory_.NewCallback( | |
| 620 &CdmAdapter::SendSessionClosedInternal, | |
| 621 std::string(web_session_id, web_session_id_length))); | |
| 622 } | |
| 623 | |
| 624 void CdmAdapter::OnSessionError(const char* web_session_id, | |
| 625 uint32_t web_session_id_length, | |
| 626 const char* error_name, | |
| 627 uint32_t error_name_length, | |
| 628 uint32_t system_code, | |
| 629 const char* error_message, | |
| 630 uint32_t error_message_length) { | |
| 631 PostOnMain(callback_factory_.NewCallback( | |
| 632 &CdmAdapter::SendSessionErrorInternal, | |
| 633 std::string(web_session_id, web_session_id_length), | |
| 634 SessionError(std::string(error_name, error_name_length), | |
| 635 system_code, | |
| 636 std::string(error_message, error_message_length)))); | |
| 637 } | |
| 638 | |
| 639 // cdm::Host_4 methods | |
| 640 | |
| 533 void CdmAdapter::OnSessionCreated(uint32_t session_id, | 641 void CdmAdapter::OnSessionCreated(uint32_t session_id, |
| 534 const char* web_session_id, | 642 const char* web_session_id, |
| 535 uint32_t web_session_id_length) { | 643 uint32_t web_session_id_length) { |
| 536 PostOnMain(callback_factory_.NewCallback( | 644 uint32_t promise_id = cdm_->LookupPromiseId(session_id); |
| 537 &CdmAdapter::SendSessionCreatedInternal, | 645 cdm_->AssignWebSessionId(session_id, web_session_id, web_session_id_length); |
| 538 session_id, | 646 OnResolveNewSessionPromise(promise_id, web_session_id, web_session_id_length); |
| 539 std::string(web_session_id, web_session_id_length))); | |
| 540 } | 647 } |
| 541 | 648 |
| 542 void CdmAdapter::OnSessionMessage(uint32_t session_id, | 649 void CdmAdapter::OnSessionMessage(uint32_t session_id, |
| 543 const char* message, | 650 const char* message, |
| 544 uint32_t message_length, | 651 uint32_t message_length, |
| 545 const char* destination_url, | 652 const char* destination_url, |
| 546 uint32_t destination_url_length) { | 653 uint32_t destination_url_length) { |
| 547 PostOnMain(callback_factory_.NewCallback( | 654 std::string web_session_id = cdm_->LookupWebSessionId(session_id); |
| 548 &CdmAdapter::SendSessionMessageInternal, | 655 OnSessionMessage(web_session_id.data(), |
| 549 session_id, | 656 web_session_id.length(), |
| 550 std::vector<uint8>(message, message + message_length), | 657 message, |
| 551 std::string(destination_url, destination_url_length))); | 658 message_length, |
| 659 destination_url, | |
| 660 destination_url_length); | |
| 552 } | 661 } |
| 553 | 662 |
| 554 void CdmAdapter::OnSessionReady(uint32_t session_id) { | 663 void CdmAdapter::OnSessionReady(uint32_t session_id) { |
| 555 PostOnMain(callback_factory_.NewCallback( | 664 uint32_t promise_id = cdm_->LookupPromiseId(session_id); |
| 556 &CdmAdapter::SendSessionReadyInternal, session_id)); | 665 if (promise_id) { |
| 666 OnResolvePromise(promise_id); | |
| 667 } else { | |
| 668 std::string web_session_id = cdm_->LookupWebSessionId(session_id); | |
| 669 OnSessionReady(web_session_id.data(), web_session_id.length()); | |
| 670 } | |
| 557 } | 671 } |
| 558 | 672 |
| 559 void CdmAdapter::OnSessionClosed(uint32_t session_id) { | 673 void CdmAdapter::OnSessionClosed(uint32_t session_id) { |
| 560 PostOnMain(callback_factory_.NewCallback( | 674 uint32_t promise_id = cdm_->LookupPromiseId(session_id); |
| 561 &CdmAdapter::SendSessionClosedInternal, session_id)); | 675 std::string web_session_id = cdm_->LookupWebSessionId(session_id); |
| 676 cdm_->DropWebSessionId(web_session_id); | |
| 677 if (promise_id) { | |
| 678 OnResolvePromise(promise_id); | |
| 679 } else { | |
| 680 OnSessionClosed(web_session_id.data(), web_session_id.length()); | |
| 681 } | |
| 562 } | 682 } |
| 563 | 683 |
| 564 void CdmAdapter::OnSessionError(uint32_t session_id, | 684 void CdmAdapter::OnSessionError(uint32_t session_id, |
| 565 cdm::MediaKeyError error_code, | 685 cdm::MediaKeyError error_code, |
| 566 uint32_t system_code) { | 686 uint32_t system_code) { |
| 567 PostOnMain(callback_factory_.NewCallback( | 687 uint32_t promise_id = cdm_->LookupPromiseId(session_id); |
| 568 &CdmAdapter::SendSessionErrorInternal, | 688 |
| 569 session_id, | 689 // Existing cdm::MediaKeyError don't map to DOM error names. Convert them |
| 570 error_code, | 690 // into non-standard names so that the prefixed API can extract them. |
| 571 system_code)); | 691 // TODO(jrummell): Remove this conversion and the inverse when CDM4 is gone. |
| 692 std::string error_name; | |
| 693 switch (error_code) { | |
| 694 case cdm::MediaKeyError::kClientError: | |
| 695 error_name = "CDM4ClientError"; | |
| 696 break; | |
| 697 case cdm::MediaKeyError::kOutputError: | |
| 698 error_name = "CDM4OutputError"; | |
| 699 break; | |
| 700 case cdm::MediaKeyError::kUnknownError: | |
| 701 default: | |
| 702 error_name = "CDM4UnknownError"; | |
| 703 break; | |
| 704 } | |
| 705 | |
| 706 if (promise_id) { | |
| 707 RejectPromise(promise_id, error_name, system_code, std::string()); | |
| 708 } else { | |
| 709 std::string web_session_id = cdm_->LookupWebSessionId(session_id); | |
| 710 OnSessionError(web_session_id.data(), | |
| 711 web_session_id.length(), | |
| 712 error_name.data(), | |
| 713 error_name.length(), | |
| 714 system_code, | |
| 715 NULL, | |
| 716 0); | |
| 717 } | |
| 572 } | 718 } |
| 573 | 719 |
| 574 void CdmAdapter::SendSessionCreatedInternal(int32_t result, | 720 // Helpers to pass the event to Pepper. |
| 575 uint32_t session_id, | 721 |
| 576 const std::string& web_session_id) { | 722 void CdmAdapter::SendPromiseResolvedInternal(int32_t result, |
| 723 uint32_t promise_id) { | |
| 577 PP_DCHECK(result == PP_OK); | 724 PP_DCHECK(result == PP_OK); |
| 578 pp::ContentDecryptor_Private::SessionCreated(session_id, web_session_id); | 725 pp::ContentDecryptor_Private::PromiseResolved(promise_id); |
| 579 } | 726 } |
| 580 | 727 |
| 581 void CdmAdapter::SendSessionMessageInternal(int32_t result, | 728 void CdmAdapter::SendPromiseResolvedWithSessionInternal( |
| 582 uint32_t session_id, | 729 int32_t result, |
| 583 const std::vector<uint8>& message, | 730 uint32_t promise_id, |
| 584 const std::string& default_url) { | 731 const std::string& web_session_id) { |
| 732 PP_DCHECK(result == PP_OK); | |
| 733 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id, | |
| 734 web_session_id); | |
| 735 } | |
| 736 | |
| 737 void CdmAdapter::SendPromiseRejectedInternal(int32_t result, | |
| 738 uint32_t promise_id, | |
| 739 const SessionError& error) { | |
| 740 PP_DCHECK(result == PP_OK); | |
| 741 pp::ContentDecryptor_Private::PromiseRejected( | |
| 742 promise_id, error.error_name, error.system_code, error.error_description); | |
| 743 } | |
| 744 | |
| 745 void CdmAdapter::SendSessionMessageInternal( | |
| 746 int32_t result, | |
| 747 const std::string& web_session_id, | |
| 748 const std::vector<uint8>& message, | |
| 749 const std::string& destination_url) { | |
| 585 PP_DCHECK(result == PP_OK); | 750 PP_DCHECK(result == PP_OK); |
| 586 | 751 |
| 587 pp::VarArrayBuffer message_array_buffer(message.size()); | 752 pp::VarArrayBuffer message_array_buffer(message.size()); |
| 588 if (message.size() > 0) { | 753 if (message.size() > 0) { |
| 589 memcpy(message_array_buffer.Map(), message.data(), message.size()); | 754 memcpy(message_array_buffer.Map(), message.data(), message.size()); |
| 590 } | 755 } |
| 591 | 756 |
| 592 pp::ContentDecryptor_Private::SessionMessage( | 757 pp::ContentDecryptor_Private::SessionMessage( |
| 593 session_id, message_array_buffer, default_url); | 758 web_session_id, message_array_buffer, destination_url); |
| 594 } | 759 } |
| 595 | 760 |
| 596 void CdmAdapter::SendSessionReadyInternal(int32_t result, uint32_t session_id) { | 761 void CdmAdapter::SendSessionReadyInternal(int32_t result, |
| 762 const std::string& web_session_id) { | |
| 597 PP_DCHECK(result == PP_OK); | 763 PP_DCHECK(result == PP_OK); |
| 598 pp::ContentDecryptor_Private::SessionReady(session_id); | 764 pp::ContentDecryptor_Private::SessionReady(web_session_id); |
| 599 } | 765 } |
| 600 | 766 |
| 601 void CdmAdapter::SendSessionClosedInternal(int32_t result, | 767 void CdmAdapter::SendSessionClosedInternal(int32_t result, |
| 602 uint32_t session_id) { | 768 const std::string& web_session_id) { |
| 603 PP_DCHECK(result == PP_OK); | 769 PP_DCHECK(result == PP_OK); |
| 604 pp::ContentDecryptor_Private::SessionClosed(session_id); | 770 pp::ContentDecryptor_Private::SessionClosed(web_session_id); |
| 605 } | 771 } |
| 606 | 772 |
| 607 void CdmAdapter::SendSessionErrorInternal(int32_t result, | 773 void CdmAdapter::SendSessionErrorInternal(int32_t result, |
| 608 uint32_t session_id, | 774 const std::string& web_session_id, |
| 609 cdm::MediaKeyError error_code, | 775 const SessionError& error) { |
| 610 uint32_t system_code) { | |
| 611 PP_DCHECK(result == PP_OK); | 776 PP_DCHECK(result == PP_OK); |
| 612 pp::ContentDecryptor_Private::SessionError( | 777 pp::ContentDecryptor_Private::SessionError(web_session_id, |
| 613 session_id, error_code, system_code); | 778 error.error_name, |
| 779 error.system_code, | |
| 780 error.error_description); | |
| 614 } | 781 } |
| 615 | 782 |
| 616 void CdmAdapter::DeliverBlock(int32_t result, | 783 void CdmAdapter::DeliverBlock(int32_t result, |
| 617 const cdm::Status& status, | 784 const cdm::Status& status, |
| 618 const LinkedDecryptedBlock& decrypted_block, | 785 const LinkedDecryptedBlock& decrypted_block, |
| 619 const PP_DecryptTrackingInfo& tracking_info) { | 786 const PP_DecryptTrackingInfo& tracking_info) { |
| 620 PP_DCHECK(result == PP_OK); | 787 PP_DCHECK(result == PP_OK); |
| 621 PP_DecryptedBlockInfo decrypted_block_info; | 788 PP_DecryptedBlockInfo decrypted_block_info; |
| 622 decrypted_block_info.tracking_info = tracking_info; | 789 decrypted_block_info.tracking_info = tracking_info; |
| 623 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp(); | 790 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp(); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 892 cdm_->OnPlatformChallengeResponse(response); | 1059 cdm_->OnPlatformChallengeResponse(response); |
| 893 return; | 1060 return; |
| 894 } | 1061 } |
| 895 | 1062 |
| 896 pp::VarArrayBuffer signed_data_var(signed_data_output_); | 1063 pp::VarArrayBuffer signed_data_var(signed_data_output_); |
| 897 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_); | 1064 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_); |
| 898 std::string platform_key_certificate_string = | 1065 std::string platform_key_certificate_string = |
| 899 platform_key_certificate_output_.AsString(); | 1066 platform_key_certificate_output_.AsString(); |
| 900 | 1067 |
| 901 cdm::PlatformChallengeResponse response = { | 1068 cdm::PlatformChallengeResponse response = { |
| 902 static_cast<uint8_t*>(signed_data_var.Map()), | 1069 static_cast<uint8_t*>(signed_data_var.Map()), |
| 903 signed_data_var.ByteLength(), | 1070 signed_data_var.ByteLength(), |
| 904 | 1071 static_cast<uint8_t*>(signed_data_signature_var.Map()), |
| 905 static_cast<uint8_t*>(signed_data_signature_var.Map()), | 1072 signed_data_signature_var.ByteLength(), |
| 906 signed_data_signature_var.ByteLength(), | 1073 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()), |
| 907 | 1074 static_cast<uint32_t>(platform_key_certificate_string.length())}; |
| 908 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.c_str()), | |
| 909 static_cast<uint32_t>(platform_key_certificate_string.length()) | |
| 910 }; | |
| 911 cdm_->OnPlatformChallengeResponse(response); | 1075 cdm_->OnPlatformChallengeResponse(response); |
| 912 | 1076 |
| 913 signed_data_var.Unmap(); | 1077 signed_data_var.Unmap(); |
| 914 signed_data_signature_var.Unmap(); | 1078 signed_data_signature_var.Unmap(); |
| 915 } | 1079 } |
| 916 | 1080 |
| 917 void CdmAdapter::EnableProtectionDone(int32_t result) { | 1081 void CdmAdapter::EnableProtectionDone(int32_t result) { |
| 918 // Does nothing since clients must call QueryOutputProtectionStatus() to | 1082 // Does nothing since clients must call QueryOutputProtectionStatus() to |
| 919 // inspect the protection status on a regular basis. | 1083 // inspect the protection status on a regular basis. |
| 920 CDM_DLOG() << __FUNCTION__ << " : " << result; | 1084 CDM_DLOG() << __FUNCTION__ << " : " << result; |
| 921 } | 1085 } |
| 922 | 1086 |
| 923 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { | 1087 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { |
| 924 PP_DCHECK(query_output_protection_in_progress_); | 1088 PP_DCHECK(query_output_protection_in_progress_); |
| 925 query_output_protection_in_progress_ = false; | 1089 query_output_protection_in_progress_ = false; |
| 926 | 1090 |
| 927 // Return a protection status of none on error. | 1091 // Return a protection status of none on error. |
| 928 if (result != PP_OK) | 1092 if (result != PP_OK) |
| 929 output_link_mask_ = output_protection_mask_ = 0; | 1093 output_link_mask_ = output_protection_mask_ = 0; |
| 930 | 1094 |
| 931 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, | 1095 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, |
| 932 output_protection_mask_); | 1096 output_protection_mask_); |
| 933 } | 1097 } |
| 934 #endif | 1098 #endif |
| 935 | 1099 |
| 1100 CdmAdapter::SessionError::SessionError(std::string error_name, | |
| 1101 uint32_t system_code, | |
| 1102 std::string error_description) | |
| 1103 : error_name(error_name), | |
|
ddorwin
2014/05/05 18:37:49
How will we transition from CDM_5 to prefixed? The
jrummell
2014/05/08 23:37:45
Done.
| |
| 1104 system_code(system_code), | |
| 1105 error_description(error_description) { | |
| 1106 } | |
| 1107 | |
| 936 void* GetCdmHost(int host_interface_version, void* user_data) { | 1108 void* GetCdmHost(int host_interface_version, void* user_data) { |
| 937 if (!host_interface_version || !user_data) | 1109 if (!host_interface_version || !user_data) |
| 938 return NULL; | 1110 return NULL; |
| 939 | 1111 |
| 940 COMPILE_ASSERT( | 1112 COMPILE_ASSERT( |
| 941 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_4::kVersion, | 1113 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_5::kVersion, |
| 942 update_code_below); | 1114 update_code_below); |
| 943 | 1115 |
| 944 // Ensure IsSupportedCdmHostVersion matches implementation of this function. | 1116 // Ensure IsSupportedCdmHostVersion matches implementation of this function. |
| 945 // Always update this DCHECK when updating this function. | 1117 // Always update this DCHECK when updating this function. |
| 946 // If this check fails, update this function and DCHECK or update | 1118 // If this check fails, update this function and DCHECK or update |
| 947 // IsSupportedCdmHostVersion. | 1119 // IsSupportedCdmHostVersion. |
| 948 | 1120 |
| 949 PP_DCHECK( | 1121 PP_DCHECK( |
| 950 // Future version is not supported. | 1122 // Future version is not supported. |
| 951 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion + 1) && | 1123 !IsSupportedCdmHostVersion(cdm::Host_5::kVersion + 1) && |
| 952 // Current version is supported. | 1124 // Current version is supported. |
| 1125 IsSupportedCdmHostVersion(cdm::Host_5::kVersion) && | |
| 1126 // Include all previous supported versions (if any) here. | |
| 953 IsSupportedCdmHostVersion(cdm::Host_4::kVersion) && | 1127 IsSupportedCdmHostVersion(cdm::Host_4::kVersion) && |
| 954 // Include all previous supported versions (if any) here. | |
| 955 // No supported previous versions. | |
| 956 // One older than the oldest supported version is not supported. | 1128 // One older than the oldest supported version is not supported. |
| 957 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1)); | 1129 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1)); |
| 958 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); | 1130 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); |
| 959 | 1131 |
| 960 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); | 1132 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); |
| 961 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; | 1133 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; |
| 962 switch (host_interface_version) { | 1134 switch (host_interface_version) { |
| 963 case cdm::Host_4::kVersion: | 1135 case cdm::Host_4::kVersion: |
| 964 return static_cast<cdm::Host_4*>(cdm_adapter); | 1136 return static_cast<cdm::Host_4*>(cdm_adapter); |
| 1137 case cdm::Host_5::kVersion: | |
| 1138 return static_cast<cdm::Host_5*>(cdm_adapter); | |
| 965 default: | 1139 default: |
| 966 PP_NOTREACHED(); | 1140 PP_NOTREACHED(); |
| 967 return NULL; | 1141 return NULL; |
| 968 } | 1142 } |
| 969 } | 1143 } |
| 970 | 1144 |
| 971 // This object is the global object representing this plugin library as long | 1145 // This object is the global object representing this plugin library as long |
| 972 // as it is loaded. | 1146 // as it is loaded. |
| 973 class CdmAdapterModule : public pp::Module { | 1147 class CdmAdapterModule : public pp::Module { |
| 974 public: | 1148 public: |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 992 } // namespace media | 1166 } // namespace media |
| 993 | 1167 |
| 994 namespace pp { | 1168 namespace pp { |
| 995 | 1169 |
| 996 // Factory function for your specialization of the Module object. | 1170 // Factory function for your specialization of the Module object. |
| 997 Module* CreateModule() { | 1171 Module* CreateModule() { |
| 998 return new media::CdmAdapterModule(); | 1172 return new media::CdmAdapterModule(); |
| 999 } | 1173 } |
| 1000 | 1174 |
| 1001 } // namespace pp | 1175 } // namespace pp |
| OLD | NEW |