| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 case PP_SESSIONTYPE_PERSISTENT_LICENSE: | 225 case PP_SESSIONTYPE_PERSISTENT_LICENSE: |
| 226 return cdm::kPersistentLicense; | 226 return cdm::kPersistentLicense; |
| 227 case PP_SESSIONTYPE_PERSISTENT_RELEASE: | 227 case PP_SESSIONTYPE_PERSISTENT_RELEASE: |
| 228 return cdm::kPersistentKeyRelease; | 228 return cdm::kPersistentKeyRelease; |
| 229 } | 229 } |
| 230 | 230 |
| 231 PP_NOTREACHED(); | 231 PP_NOTREACHED(); |
| 232 return cdm::kTemporary; | 232 return cdm::kTemporary; |
| 233 } | 233 } |
| 234 | 234 |
| 235 cdm::InitDataType InitDataTypeToCdmInitDataType( |
| 236 const std::string& init_data_type) { |
| 237 if (init_data_type == "cenc") |
| 238 return cdm::kCenc; |
| 239 if (init_data_type == "webm") |
| 240 return cdm::kWebM; |
| 241 if (init_data_type == "keyids") |
| 242 return cdm::kKeyIds; |
| 243 |
| 244 PP_NOTREACHED(); |
| 245 return cdm::kKeyIds; |
| 246 } |
| 247 |
| 235 PP_CdmExceptionCode CdmExceptionTypeToPpCdmExceptionType(cdm::Error error) { | 248 PP_CdmExceptionCode CdmExceptionTypeToPpCdmExceptionType(cdm::Error error) { |
| 236 switch (error) { | 249 switch (error) { |
| 237 case cdm::kNotSupportedError: | 250 case cdm::kNotSupportedError: |
| 238 return PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR; | 251 return PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR; |
| 239 case cdm::kInvalidStateError: | 252 case cdm::kInvalidStateError: |
| 240 return PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR; | 253 return PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR; |
| 241 case cdm::kInvalidAccessError: | 254 case cdm::kInvalidAccessError: |
| 242 return PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR; | 255 return PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR; |
| 243 case cdm::kQuotaExceededError: | 256 case cdm::kQuotaExceededError: |
| 244 return PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR; | 257 return PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 271 PP_CdmKeyStatus CdmKeyStatusToPpKeyStatus(cdm::KeyStatus status) { | 284 PP_CdmKeyStatus CdmKeyStatusToPpKeyStatus(cdm::KeyStatus status) { |
| 272 switch (status) { | 285 switch (status) { |
| 273 case cdm::kUsable: | 286 case cdm::kUsable: |
| 274 return PP_CDMKEYSTATUS_USABLE; | 287 return PP_CDMKEYSTATUS_USABLE; |
| 275 case cdm::kInternalError: | 288 case cdm::kInternalError: |
| 276 return PP_CDMKEYSTATUS_INVALID; | 289 return PP_CDMKEYSTATUS_INVALID; |
| 277 case cdm::kExpired: | 290 case cdm::kExpired: |
| 278 return PP_CDMKEYSTATUS_EXPIRED; | 291 return PP_CDMKEYSTATUS_EXPIRED; |
| 279 case cdm::kOutputNotAllowed: | 292 case cdm::kOutputNotAllowed: |
| 280 return PP_CDMKEYSTATUS_OUTPUTNOTALLOWED; | 293 return PP_CDMKEYSTATUS_OUTPUTNOTALLOWED; |
| 294 case cdm::kOutputDownscaled: |
| 295 return PP_CDMKEYSTATUS_OUTPUTDOWNSCALED; |
| 296 case cdm::kStatusPending: |
| 297 return PP_CDMKEYSTATUS_STATUSPENDING; |
| 281 } | 298 } |
| 282 | 299 |
| 283 PP_NOTREACHED(); | 300 PP_NOTREACHED(); |
| 284 return PP_CDMKEYSTATUS_INVALID; | 301 return PP_CDMKEYSTATUS_INVALID; |
| 285 } | 302 } |
| 286 | 303 |
| 287 } // namespace | 304 } // namespace |
| 288 | 305 |
| 289 namespace media { | 306 namespace media { |
| 290 | 307 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // "Store this new error object internally with the MediaKeys instance being | 350 // "Store this new error object internally with the MediaKeys instance being |
| 334 // created. This will be used to fire an error against any session created for | 351 // created. This will be used to fire an error against any session created for |
| 335 // this instance." These errors will be reported during session creation | 352 // this instance." These errors will be reported during session creation |
| 336 // (CreateSession()) or session loading (LoadSession()). | 353 // (CreateSession()) or session loading (LoadSession()). |
| 337 // TODO(xhwang): If necessary, we need to store the error here if we want to | 354 // TODO(xhwang): If necessary, we need to store the error here if we want to |
| 338 // support more specific error reporting (other than "Unknown"). | 355 // support more specific error reporting (other than "Unknown"). |
| 339 void CdmAdapter::Initialize(const std::string& key_system, | 356 void CdmAdapter::Initialize(const std::string& key_system, |
| 340 bool allow_distinctive_identifier, | 357 bool allow_distinctive_identifier, |
| 341 bool allow_persistent_state) { | 358 bool allow_persistent_state) { |
| 342 PP_DCHECK(!key_system.empty()); | 359 PP_DCHECK(!key_system.empty()); |
| 360 // TODO(jrummell): Remove this check when CDM creation is asynchronous. |
| 361 // http://crbug.com/469003 |
| 343 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); | 362 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); |
| 344 | 363 |
| 345 #if defined(CHECK_DOCUMENT_URL) | 364 #if defined(CHECK_DOCUMENT_URL) |
| 346 PP_URLComponents_Dev url_components = {}; | 365 PP_URLComponents_Dev url_components = {}; |
| 347 const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); | 366 const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); |
| 348 if (!url_util) | 367 if (!url_util) |
| 349 return; | 368 return; |
| 350 pp::Var href = url_util->GetDocumentURL(pp::InstanceHandle(pp_instance()), | 369 pp::Var href = url_util->GetDocumentURL(pp::InstanceHandle(pp_instance()), |
| 351 &url_components); | 370 &url_components); |
| 352 PP_DCHECK(href.is_string()); | 371 PP_DCHECK(href.is_string()); |
| 353 std::string url = href.AsString(); | 372 std::string url = href.AsString(); |
| 354 PP_DCHECK(!url.empty()); | 373 PP_DCHECK(!url.empty()); |
| 355 std::string url_scheme = | 374 std::string url_scheme = |
| 356 url.substr(url_components.scheme.begin, url_components.scheme.len); | 375 url.substr(url_components.scheme.begin, url_components.scheme.len); |
| 357 if (url_scheme != "file") { | 376 if (url_scheme != "file") { |
| 358 // Skip this check for file:// URLs as they don't have a host component. | 377 // Skip this check for file:// URLs as they don't have a host component. |
| 359 PP_DCHECK(url_components.host.begin); | 378 PP_DCHECK(url_components.host.begin); |
| 360 PP_DCHECK(0 < url_components.host.len); | 379 PP_DCHECK(0 < url_components.host.len); |
| 361 } | 380 } |
| 362 #endif // defined(CHECK_DOCUMENT_URL) | 381 #endif // defined(CHECK_DOCUMENT_URL) |
| 363 | 382 |
| 364 if (!cdm_ && !CreateCdmInstance(key_system)) | 383 if (!cdm_ && !CreateCdmInstance(key_system)) |
| 365 return; | 384 return; |
| 366 | 385 |
| 367 PP_DCHECK(cdm_); | 386 PP_DCHECK(cdm_); |
| 368 key_system_ = key_system; | 387 key_system_ = key_system; |
| 369 allow_distinctive_identifier_ = allow_distinctive_identifier; | 388 allow_distinctive_identifier_ = allow_distinctive_identifier; |
| 370 allow_persistent_state_ = allow_persistent_state; | 389 allow_persistent_state_ = allow_persistent_state; |
| 390 cdm_->Initialize(allow_distinctive_identifier, allow_persistent_state); |
| 371 } | 391 } |
| 372 | 392 |
| 373 void CdmAdapter::SetServerCertificate(uint32_t promise_id, | 393 void CdmAdapter::SetServerCertificate(uint32_t promise_id, |
| 374 pp::VarArrayBuffer server_certificate) { | 394 pp::VarArrayBuffer server_certificate) { |
| 375 const uint8_t* server_certificate_ptr = | 395 const uint8_t* server_certificate_ptr = |
| 376 static_cast<const uint8_t*>(server_certificate.Map()); | 396 static_cast<const uint8_t*>(server_certificate.Map()); |
| 377 const uint32_t server_certificate_size = server_certificate.ByteLength(); | 397 const uint32_t server_certificate_size = server_certificate.ByteLength(); |
| 378 | 398 |
| 379 if (!server_certificate_ptr || | 399 if (!server_certificate_ptr || |
| 380 server_certificate_size < media::limits::kMinCertificateLength || | 400 server_certificate_size < media::limits::kMinCertificateLength || |
| (...skipping 11 matching lines...) Expand all Loading... |
| 392 cdm::kInvalidStateError, | 412 cdm::kInvalidStateError, |
| 393 0, | 413 0, |
| 394 "CDM has not been initialized."); | 414 "CDM has not been initialized."); |
| 395 return; | 415 return; |
| 396 } | 416 } |
| 397 | 417 |
| 398 cdm_->SetServerCertificate( | 418 cdm_->SetServerCertificate( |
| 399 promise_id, server_certificate_ptr, server_certificate_size); | 419 promise_id, server_certificate_ptr, server_certificate_size); |
| 400 } | 420 } |
| 401 | 421 |
| 422 // TODO(jrummell): |init_data_type| should be an enum all the way through |
| 423 // Chromium. http://crbug.com/469228 |
| 402 void CdmAdapter::CreateSessionAndGenerateRequest( | 424 void CdmAdapter::CreateSessionAndGenerateRequest( |
| 403 uint32_t promise_id, | 425 uint32_t promise_id, |
| 404 PP_SessionType session_type, | 426 PP_SessionType session_type, |
| 405 const std::string& init_data_type, | 427 const std::string& init_data_type, |
| 406 pp::VarArrayBuffer init_data) { | 428 pp::VarArrayBuffer init_data) { |
| 407 // Initialize() doesn't report an error, so CreateSession() can be called | 429 // Initialize() doesn't report an error, so CreateSession() can be called |
| 408 // even if Initialize() failed. | 430 // even if Initialize() failed. |
| 409 // TODO(jrummell): Remove this code when prefixed EME gets removed. | 431 // TODO(jrummell): Remove this code when prefixed EME gets removed. |
| 410 // TODO(jrummell): Verify that Initialize() failing does not resolve the | 432 // TODO(jrummell): Verify that Initialize() failing does not resolve the |
| 411 // MediaKeys.create() promise. | 433 // MediaKeys.create() promise. |
| 412 if (!cdm_) { | 434 if (!cdm_) { |
| 413 RejectPromise(promise_id, | 435 RejectPromise(promise_id, |
| 414 cdm::kInvalidStateError, | 436 cdm::kInvalidStateError, |
| 415 0, | 437 0, |
| 416 "CDM has not been initialized."); | 438 "CDM has not been initialized."); |
| 417 return; | 439 return; |
| 418 } | 440 } |
| 419 | 441 |
| 420 cdm_->CreateSessionAndGenerateRequest( | 442 cdm_->CreateSessionAndGenerateRequest( |
| 421 promise_id, PpSessionTypeToCdmSessionType(session_type), | 443 promise_id, PpSessionTypeToCdmSessionType(session_type), |
| 422 init_data_type.data(), init_data_type.size(), | 444 InitDataTypeToCdmInitDataType(init_data_type), |
| 423 static_cast<const uint8_t*>(init_data.Map()), init_data.ByteLength()); | 445 static_cast<const uint8_t*>(init_data.Map()), init_data.ByteLength()); |
| 424 } | 446 } |
| 425 | 447 |
| 426 void CdmAdapter::LoadSession(uint32_t promise_id, | 448 void CdmAdapter::LoadSession(uint32_t promise_id, |
| 427 PP_SessionType session_type, | 449 PP_SessionType session_type, |
| 428 const std::string& session_id) { | 450 const std::string& session_id) { |
| 429 // Initialize() doesn't report an error, so LoadSession() can be called | 451 // Initialize() doesn't report an error, so LoadSession() can be called |
| 430 // even if Initialize() failed. | 452 // even if Initialize() failed. |
| 431 // TODO(jrummell): Remove this code when prefixed EME gets removed. | 453 // TODO(jrummell): Remove this code when prefixed EME gets removed. |
| 432 // TODO(jrummell): Verify that Initialize() failing does not resolve the | 454 // TODO(jrummell): Verify that Initialize() failing does not resolve the |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 PostOnMain(callback_factory_.NewCallback( | 693 PostOnMain(callback_factory_.NewCallback( |
| 672 &CdmAdapter::SendPromiseResolvedWithSessionInternal, promise_id, | 694 &CdmAdapter::SendPromiseResolvedWithSessionInternal, promise_id, |
| 673 std::string(session_id, session_id_size))); | 695 std::string(session_id, session_id_size))); |
| 674 } | 696 } |
| 675 | 697 |
| 676 void CdmAdapter::OnResolvePromise(uint32_t promise_id) { | 698 void CdmAdapter::OnResolvePromise(uint32_t promise_id) { |
| 677 PostOnMain(callback_factory_.NewCallback( | 699 PostOnMain(callback_factory_.NewCallback( |
| 678 &CdmAdapter::SendPromiseResolvedInternal, promise_id)); | 700 &CdmAdapter::SendPromiseResolvedInternal, promise_id)); |
| 679 } | 701 } |
| 680 | 702 |
| 681 // cdm::Host_6 only | |
| 682 void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id, | |
| 683 const cdm::BinaryData* usable_key_ids, | |
| 684 uint32_t usable_key_ids_size) { | |
| 685 // This should never be called as GetUsableKeyIds() has been removed. | |
| 686 PP_NOTREACHED(); | |
| 687 } | |
| 688 | |
| 689 void CdmAdapter::OnRejectPromise(uint32_t promise_id, | 703 void CdmAdapter::OnRejectPromise(uint32_t promise_id, |
| 690 cdm::Error error, | 704 cdm::Error error, |
| 691 uint32_t system_code, | 705 uint32_t system_code, |
| 692 const char* error_message, | 706 const char* error_message, |
| 693 uint32_t error_message_size) { | 707 uint32_t error_message_size) { |
| 694 // UMA to investigate http://crbug.com/410630 | 708 // UMA to investigate http://crbug.com/410630 |
| 695 // TODO(xhwang): Remove after bug is fixed. | 709 // TODO(xhwang): Remove after bug is fixed. |
| 696 if (system_code == 0x27) { | 710 if (system_code == 0x27) { |
| 697 pp::UMAPrivate uma_interface(this); | 711 pp::UMAPrivate uma_interface(this); |
| 698 uma_interface.HistogramCustomCounts("Media.EME.CdmFileIO.FileSizeKBOnError", | 712 uma_interface.HistogramCustomCounts("Media.EME.CdmFileIO.FileSizeKBOnError", |
| (...skipping 10 matching lines...) Expand all Loading... |
| 709 void CdmAdapter::RejectPromise(uint32_t promise_id, | 723 void CdmAdapter::RejectPromise(uint32_t promise_id, |
| 710 cdm::Error error, | 724 cdm::Error error, |
| 711 uint32_t system_code, | 725 uint32_t system_code, |
| 712 const std::string& error_message) { | 726 const std::string& error_message) { |
| 713 PostOnMain(callback_factory_.NewCallback( | 727 PostOnMain(callback_factory_.NewCallback( |
| 714 &CdmAdapter::SendPromiseRejectedInternal, | 728 &CdmAdapter::SendPromiseRejectedInternal, |
| 715 promise_id, | 729 promise_id, |
| 716 SessionError(error, system_code, error_message))); | 730 SessionError(error, system_code, error_message))); |
| 717 } | 731 } |
| 718 | 732 |
| 719 // cdm::Host_7 only. | |
| 720 void CdmAdapter::OnSessionMessage(const char* session_id, | 733 void CdmAdapter::OnSessionMessage(const char* session_id, |
| 721 uint32_t session_id_size, | 734 uint32_t session_id_size, |
| 722 cdm::MessageType message_type, | 735 cdm::MessageType message_type, |
| 723 const char* message, | 736 const char* message, |
| 724 uint32_t message_size, | 737 uint32_t message_size, |
| 725 const char* legacy_destination_url, | 738 const char* legacy_destination_url, |
| 726 uint32_t legacy_destination_url_size) { | 739 uint32_t legacy_destination_url_size) { |
| 727 // License requests should not specify |legacy_destination_url|. | 740 // License requests should not specify |legacy_destination_url|. |
| 728 // |legacy_destination_url| is not passed to unprefixed EME applications, | 741 // |legacy_destination_url| is not passed to unprefixed EME applications, |
| 729 // so it can be removed when the prefixed API is removed. | 742 // so it can be removed when the prefixed API is removed. |
| 730 PP_DCHECK(legacy_destination_url_size == 0 || | 743 PP_DCHECK(legacy_destination_url_size == 0 || |
| 731 message_type != cdm::MessageType::kLicenseRequest); | 744 message_type != cdm::MessageType::kLicenseRequest); |
| 732 | 745 |
| 733 PostOnMain(callback_factory_.NewCallback( | 746 PostOnMain(callback_factory_.NewCallback( |
| 734 &CdmAdapter::SendSessionMessageInternal, | 747 &CdmAdapter::SendSessionMessageInternal, |
| 735 SessionMessage( | 748 SessionMessage( |
| 736 std::string(session_id, session_id_size), message_type, message, | 749 std::string(session_id, session_id_size), message_type, message, |
| 737 message_size, | 750 message_size, |
| 738 std::string(legacy_destination_url, legacy_destination_url_size)))); | 751 std::string(legacy_destination_url, legacy_destination_url_size)))); |
| 739 } | 752 } |
| 740 | 753 |
| 741 // cdm::Host_6 only. | |
| 742 void CdmAdapter::OnSessionMessage(const char* session_id, | |
| 743 uint32_t session_id_size, | |
| 744 const char* message, | |
| 745 uint32_t message_size, | |
| 746 const char* destination_url, | |
| 747 uint32_t destination_url_size) { | |
| 748 // |destination_url| is no longer passed to unprefixed EME applications, | |
| 749 // so it will be dropped. All messages will appear as license renewals | |
| 750 // if |destination_url| is provided, license request if not. | |
| 751 cdm::MessageType message_type = (destination_url_size > 0) | |
| 752 ? cdm::MessageType::kLicenseRenewal | |
| 753 : cdm::MessageType::kLicenseRequest; | |
| 754 PostOnMain(callback_factory_.NewCallback( | |
| 755 &CdmAdapter::SendSessionMessageInternal, | |
| 756 SessionMessage(std::string(session_id, session_id_size), message_type, | |
| 757 message, message_size, | |
| 758 std::string(destination_url, destination_url_size)))); | |
| 759 } | |
| 760 | |
| 761 // cdm::Host_7 only. | |
| 762 void CdmAdapter::OnSessionKeysChange(const char* session_id, | 754 void CdmAdapter::OnSessionKeysChange(const char* session_id, |
| 763 uint32_t session_id_size, | 755 uint32_t session_id_size, |
| 764 bool has_additional_usable_key, | 756 bool has_additional_usable_key, |
| 765 const cdm::KeyInformation* keys_info, | 757 const cdm::KeyInformation* keys_info, |
| 766 uint32_t keys_info_count) { | 758 uint32_t keys_info_count) { |
| 767 std::vector<PP_KeyInformation> key_information; | 759 std::vector<PP_KeyInformation> key_information; |
| 768 for (uint32_t i = 0; i < keys_info_count; ++i) { | 760 for (uint32_t i = 0; i < keys_info_count; ++i) { |
| 769 const auto& key_info = keys_info[i]; | 761 const auto& key_info = keys_info[i]; |
| 770 PP_KeyInformation next_key = {}; | 762 PP_KeyInformation next_key = {}; |
| 771 | 763 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 783 next_key.system_code = key_info.system_code; | 775 next_key.system_code = key_info.system_code; |
| 784 key_information.push_back(next_key); | 776 key_information.push_back(next_key); |
| 785 } | 777 } |
| 786 | 778 |
| 787 PostOnMain(callback_factory_.NewCallback( | 779 PostOnMain(callback_factory_.NewCallback( |
| 788 &CdmAdapter::SendSessionKeysChangeInternal, | 780 &CdmAdapter::SendSessionKeysChangeInternal, |
| 789 std::string(session_id, session_id_size), has_additional_usable_key, | 781 std::string(session_id, session_id_size), has_additional_usable_key, |
| 790 key_information)); | 782 key_information)); |
| 791 } | 783 } |
| 792 | 784 |
| 793 // cdm::Host_6 only. | |
| 794 void CdmAdapter::OnSessionUsableKeysChange(const char* session_id, | |
| 795 uint32_t session_id_size, | |
| 796 bool has_additional_usable_key) { | |
| 797 PostOnMain(callback_factory_.NewCallback( | |
| 798 &CdmAdapter::SendSessionKeysChangeInternal, | |
| 799 std::string(session_id, session_id_size), has_additional_usable_key, | |
| 800 std::vector<PP_KeyInformation>())); | |
| 801 } | |
| 802 | |
| 803 void CdmAdapter::OnExpirationChange(const char* session_id, | 785 void CdmAdapter::OnExpirationChange(const char* session_id, |
| 804 uint32_t session_id_size, | 786 uint32_t session_id_size, |
| 805 cdm::Time new_expiry_time) { | 787 cdm::Time new_expiry_time) { |
| 806 PostOnMain(callback_factory_.NewCallback( | 788 PostOnMain(callback_factory_.NewCallback( |
| 807 &CdmAdapter::SendExpirationChangeInternal, | 789 &CdmAdapter::SendExpirationChangeInternal, |
| 808 std::string(session_id, session_id_size), new_expiry_time)); | 790 std::string(session_id, session_id_size), new_expiry_time)); |
| 809 } | 791 } |
| 810 | 792 |
| 811 void CdmAdapter::OnSessionClosed(const char* session_id, | 793 void CdmAdapter::OnSessionClosed(const char* session_id, |
| 812 uint32_t session_id_size) { | 794 uint32_t session_id_size) { |
| 813 PostOnMain( | 795 PostOnMain( |
| 814 callback_factory_.NewCallback(&CdmAdapter::SendSessionClosedInternal, | 796 callback_factory_.NewCallback(&CdmAdapter::SendSessionClosedInternal, |
| 815 std::string(session_id, session_id_size))); | 797 std::string(session_id, session_id_size))); |
| 816 } | 798 } |
| 817 | 799 |
| 818 // cdm::Host_6 only. | 800 void CdmAdapter::OnLegacySessionError(const char* session_id, |
| 819 void CdmAdapter::OnSessionError(const char* session_id, | 801 uint32_t session_id_size, |
| 820 uint32_t session_id_size, | 802 cdm::Error error, |
| 821 cdm::Error error, | 803 uint32_t system_code, |
| 822 uint32_t system_code, | 804 const char* error_message, |
| 823 const char* error_message, | 805 uint32_t error_message_size) { |
| 824 uint32_t error_message_size) { | |
| 825 PostOnMain(callback_factory_.NewCallback( | 806 PostOnMain(callback_factory_.NewCallback( |
| 826 &CdmAdapter::SendSessionErrorInternal, | 807 &CdmAdapter::SendSessionErrorInternal, |
| 827 std::string(session_id, session_id_size), | 808 std::string(session_id, session_id_size), |
| 828 SessionError(error, system_code, | 809 SessionError(error, system_code, |
| 829 std::string(error_message, error_message_size)))); | 810 std::string(error_message, error_message_size)))); |
| 830 } | 811 } |
| 831 | 812 |
| 832 // cdm::Host_7 only. | |
| 833 void CdmAdapter::OnLegacySessionError(const char* session_id, | |
| 834 uint32_t session_id_size, | |
| 835 cdm::Error error, | |
| 836 uint32_t system_code, | |
| 837 const char* error_message, | |
| 838 uint32_t error_message_size) { | |
| 839 OnSessionError(session_id, session_id_size, error, system_code, error_message, | |
| 840 error_message_size); | |
| 841 } | |
| 842 | |
| 843 // Helpers to pass the event to Pepper. | 813 // Helpers to pass the event to Pepper. |
| 844 | 814 |
| 845 void CdmAdapter::SendPromiseResolvedInternal(int32_t result, | 815 void CdmAdapter::SendPromiseResolvedInternal(int32_t result, |
| 846 uint32_t promise_id) { | 816 uint32_t promise_id) { |
| 847 PP_DCHECK(result == PP_OK); | 817 PP_DCHECK(result == PP_OK); |
| 848 pp::ContentDecryptor_Private::PromiseResolved(promise_id); | 818 pp::ContentDecryptor_Private::PromiseResolved(promise_id); |
| 849 } | 819 } |
| 850 | 820 |
| 851 void CdmAdapter::SendPromiseResolvedWithSessionInternal( | 821 void CdmAdapter::SendPromiseResolvedWithSessionInternal( |
| 852 int32_t result, | 822 int32_t result, |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 message_type(message_type), | 1309 message_type(message_type), |
| 1340 message(message, message + message_size), | 1310 message(message, message + message_size), |
| 1341 legacy_destination_url(legacy_destination_url) { | 1311 legacy_destination_url(legacy_destination_url) { |
| 1342 } | 1312 } |
| 1343 | 1313 |
| 1344 void* GetCdmHost(int host_interface_version, void* user_data) { | 1314 void* GetCdmHost(int host_interface_version, void* user_data) { |
| 1345 if (!host_interface_version || !user_data) | 1315 if (!host_interface_version || !user_data) |
| 1346 return NULL; | 1316 return NULL; |
| 1347 | 1317 |
| 1348 static_assert( | 1318 static_assert( |
| 1349 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_7::kVersion, | 1319 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_8::kVersion, |
| 1350 "update the code below"); | 1320 "update the code below"); |
| 1351 | 1321 |
| 1352 // Ensure IsSupportedCdmHostVersion matches implementation of this function. | 1322 // Ensure IsSupportedCdmHostVersion matches implementation of this function. |
| 1353 // Always update this DCHECK when updating this function. | 1323 // Always update this DCHECK when updating this function. |
| 1354 // If this check fails, update this function and DCHECK or update | 1324 // If this check fails, update this function and DCHECK or update |
| 1355 // IsSupportedCdmHostVersion. | 1325 // IsSupportedCdmHostVersion. |
| 1356 | 1326 |
| 1357 PP_DCHECK( | 1327 PP_DCHECK( |
| 1358 // Future version is not supported. | 1328 // Future version is not supported. |
| 1359 !IsSupportedCdmHostVersion(cdm::Host_7::kVersion + 1) && | 1329 !IsSupportedCdmHostVersion(cdm::Host_8::kVersion + 1) && |
| 1360 // Current version is supported. | 1330 // Current version is supported. |
| 1331 IsSupportedCdmHostVersion(cdm::Host_8::kVersion) && |
| 1332 // Include all previous supported versions (if any) here. |
| 1361 IsSupportedCdmHostVersion(cdm::Host_7::kVersion) && | 1333 IsSupportedCdmHostVersion(cdm::Host_7::kVersion) && |
| 1362 // Include all previous supported versions (if any) here. | |
| 1363 IsSupportedCdmHostVersion(cdm::Host_6::kVersion) && | |
| 1364 // One older than the oldest supported version is not supported. | 1334 // One older than the oldest supported version is not supported. |
| 1365 !IsSupportedCdmHostVersion(cdm::Host_6::kVersion - 1)); | 1335 !IsSupportedCdmHostVersion(cdm::Host_7::kVersion - 1)); |
| 1366 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); | 1336 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); |
| 1367 | 1337 |
| 1368 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); | 1338 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); |
| 1369 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; | 1339 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; |
| 1370 switch (host_interface_version) { | 1340 switch (host_interface_version) { |
| 1341 case cdm::Host_8::kVersion: |
| 1342 return static_cast<cdm::Host_8*>(cdm_adapter); |
| 1371 case cdm::Host_7::kVersion: | 1343 case cdm::Host_7::kVersion: |
| 1372 return static_cast<cdm::Host_7*>(cdm_adapter); | 1344 return static_cast<cdm::Host_7*>(cdm_adapter); |
| 1373 case cdm::Host_6::kVersion: | |
| 1374 return static_cast<cdm::Host_6*>(cdm_adapter); | |
| 1375 default: | 1345 default: |
| 1376 PP_NOTREACHED(); | 1346 PP_NOTREACHED(); |
| 1377 return NULL; | 1347 return NULL; |
| 1378 } | 1348 } |
| 1379 } | 1349 } |
| 1380 | 1350 |
| 1381 // This object is the global object representing this plugin library as long | 1351 // This object is the global object representing this plugin library as long |
| 1382 // as it is loaded. | 1352 // as it is loaded. |
| 1383 class CdmAdapterModule : public pp::Module { | 1353 class CdmAdapterModule : public pp::Module { |
| 1384 public: | 1354 public: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1402 } // namespace media | 1372 } // namespace media |
| 1403 | 1373 |
| 1404 namespace pp { | 1374 namespace pp { |
| 1405 | 1375 |
| 1406 // Factory function for your specialization of the Module object. | 1376 // Factory function for your specialization of the Module object. |
| 1407 Module* CreateModule() { | 1377 Module* CreateModule() { |
| 1408 return new media::CdmAdapterModule(); | 1378 return new media::CdmAdapterModule(); |
| 1409 } | 1379 } |
| 1410 | 1380 |
| 1411 } // namespace pp | 1381 } // namespace pp |
| OLD | NEW |