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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 &CdmAdapter::SendPromiseRejectedInternal, | 708 &CdmAdapter::SendPromiseRejectedInternal, |
709 promise_id, | 709 promise_id, |
710 SessionError(error, system_code, error_message))); | 710 SessionError(error, system_code, error_message))); |
711 } | 711 } |
712 | 712 |
713 // cdm::Host_7 only. | 713 // cdm::Host_7 only. |
714 void CdmAdapter::OnSessionMessage(const char* session_id, | 714 void CdmAdapter::OnSessionMessage(const char* session_id, |
715 uint32_t session_id_size, | 715 uint32_t session_id_size, |
716 cdm::MessageType message_type, | 716 cdm::MessageType message_type, |
717 const char* message, | 717 const char* message, |
718 uint32_t message_size) { | 718 uint32_t message_size, |
719 const char* legacy_destination_url, | |
720 uint32_t legacy_destination_url_size) { | |
721 // Only license renewals should specify |legacy_destination_url|. | |
722 // |legacy_destination_url| is not passed to unprefixed EME applications, | |
723 // so it can be removed when the prefixed API is removed. | |
724 PP_DCHECK(legacy_destination_url_size == 0 || | |
725 message_type == cdm::MessageType::kLicenseRenewal); | |
726 | |
719 PostOnMain(callback_factory_.NewCallback( | 727 PostOnMain(callback_factory_.NewCallback( |
720 &CdmAdapter::SendSessionMessageInternal, | 728 &CdmAdapter::SendSessionMessageInternal, |
721 std::string(session_id, session_id_size), message_type, | 729 SessionMessage( |
722 std::vector<uint8_t>(message, message + message_size))); | 730 std::string(session_id, session_id_size), message_type, |
731 std::vector<uint8_t>(message, message + message_size), | |
dmichael (off chromium)
2015/01/13 21:15:15
You have to allocate and copy here, but you alloca
jrummell
2015/01/13 21:41:45
Changed constructor to avoid double copy.
| |
732 std::string(legacy_destination_url, legacy_destination_url_size)))); | |
723 } | 733 } |
724 | 734 |
725 // cdm::Host_6 only. | 735 // cdm::Host_6 only. |
726 void CdmAdapter::OnSessionMessage(const char* session_id, | 736 void CdmAdapter::OnSessionMessage(const char* session_id, |
727 uint32_t session_id_size, | 737 uint32_t session_id_size, |
728 const char* message, | 738 const char* message, |
729 uint32_t message_size, | 739 uint32_t message_size, |
730 const char* destination_url, | 740 const char* destination_url, |
731 uint32_t destination_url_size) { | 741 uint32_t destination_url_size) { |
732 // |destination_url| is no longer passed to EME applications, so it is | 742 // |destination_url| is no longer passed to unprefixed EME applications, |
733 // dropped. All messages will appear as license renewals if |destination_url| | 743 // so it will be dropped. All messages will appear as license renewals |
734 // is provided, license request if not. | 744 // if |destination_url| is provided, license request if not. |
735 cdm::MessageType message_type = (destination_url_size > 0) | 745 cdm::MessageType message_type = (destination_url_size > 0) |
736 ? cdm::MessageType::kLicenseRenewal | 746 ? cdm::MessageType::kLicenseRenewal |
737 : cdm::MessageType::kLicenseRequest; | 747 : cdm::MessageType::kLicenseRequest; |
738 PostOnMain(callback_factory_.NewCallback( | 748 PostOnMain(callback_factory_.NewCallback( |
739 &CdmAdapter::SendSessionMessageInternal, | 749 &CdmAdapter::SendSessionMessageInternal, |
740 std::string(session_id, session_id_size), message_type, | 750 SessionMessage(std::string(session_id, session_id_size), message_type, |
741 std::vector<uint8_t>(message, message + message_size))); | 751 std::vector<uint8_t>(message, message + message_size), |
752 std::string(destination_url, destination_url_size)))); | |
742 } | 753 } |
743 | 754 |
744 // cdm::Host_7 only. | 755 // cdm::Host_7 only. |
745 void CdmAdapter::OnSessionKeysChange(const char* session_id, | 756 void CdmAdapter::OnSessionKeysChange(const char* session_id, |
746 uint32_t session_id_size, | 757 uint32_t session_id_size, |
747 bool has_additional_usable_key, | 758 bool has_additional_usable_key, |
748 const cdm::KeyInformation* keys_info, | 759 const cdm::KeyInformation* keys_info, |
749 uint32_t keys_info_count) { | 760 uint32_t keys_info_count) { |
750 std::vector<PP_KeyInformation> key_information; | 761 std::vector<PP_KeyInformation> key_information; |
751 for (uint32_t i = 0; i < keys_info_count; ++i) { | 762 for (uint32_t i = 0; i < keys_info_count; ++i) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 uint32_t promise_id, | 855 uint32_t promise_id, |
845 const SessionError& error) { | 856 const SessionError& error) { |
846 PP_DCHECK(result == PP_OK); | 857 PP_DCHECK(result == PP_OK); |
847 pp::ContentDecryptor_Private::PromiseRejected( | 858 pp::ContentDecryptor_Private::PromiseRejected( |
848 promise_id, | 859 promise_id, |
849 CdmExceptionTypeToPpCdmExceptionType(error.error), | 860 CdmExceptionTypeToPpCdmExceptionType(error.error), |
850 error.system_code, | 861 error.system_code, |
851 error.error_description); | 862 error.error_description); |
852 } | 863 } |
853 | 864 |
854 void CdmAdapter::SendSessionMessageInternal( | 865 void CdmAdapter::SendSessionMessageInternal(int32_t result, |
855 int32_t result, | 866 const SessionMessage& message) { |
856 const std::string& session_id, | |
857 cdm::MessageType message_type, | |
858 const std::vector<uint8_t>& message) { | |
859 PP_DCHECK(result == PP_OK); | 867 PP_DCHECK(result == PP_OK); |
860 | 868 |
861 pp::VarArrayBuffer message_array_buffer(message.size()); | 869 pp::VarArrayBuffer message_array_buffer(message.message.size()); |
862 if (message.size() > 0) { | 870 if (message.message.size() > 0) { |
863 memcpy(message_array_buffer.Map(), message.data(), message.size()); | 871 memcpy(message_array_buffer.Map(), message.message.data(), |
872 message.message.size()); | |
864 } | 873 } |
865 | 874 |
866 pp::ContentDecryptor_Private::SessionMessage( | 875 pp::ContentDecryptor_Private::SessionMessage( |
867 session_id, CdmMessageTypeToPpMessageType(message_type), | 876 message.session_id, CdmMessageTypeToPpMessageType(message.message_type), |
868 message_array_buffer); | 877 message_array_buffer, message.legacy_destination_url); |
869 } | 878 } |
870 | 879 |
871 void CdmAdapter::SendSessionClosedInternal(int32_t result, | 880 void CdmAdapter::SendSessionClosedInternal(int32_t result, |
872 const std::string& session_id) { | 881 const std::string& session_id) { |
873 PP_DCHECK(result == PP_OK); | 882 PP_DCHECK(result == PP_OK); |
874 pp::ContentDecryptor_Private::SessionClosed(session_id); | 883 pp::ContentDecryptor_Private::SessionClosed(session_id); |
875 } | 884 } |
876 | 885 |
877 void CdmAdapter::SendSessionErrorInternal(int32_t result, | 886 void CdmAdapter::SendSessionErrorInternal(int32_t result, |
878 const std::string& session_id, | 887 const std::string& session_id, |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1293 ReportOutputProtectionQueryResult(); | 1302 ReportOutputProtectionQueryResult(); |
1294 } | 1303 } |
1295 | 1304 |
1296 cdm_->OnQueryOutputProtectionStatus(query_result, output_link_mask_, | 1305 cdm_->OnQueryOutputProtectionStatus(query_result, output_link_mask_, |
1297 output_protection_mask_); | 1306 output_protection_mask_); |
1298 } | 1307 } |
1299 #endif | 1308 #endif |
1300 | 1309 |
1301 CdmAdapter::SessionError::SessionError(cdm::Error error, | 1310 CdmAdapter::SessionError::SessionError(cdm::Error error, |
1302 uint32_t system_code, | 1311 uint32_t system_code, |
1303 std::string error_description) | 1312 const std::string& error_description) |
1304 : error(error), | 1313 : error(error), |
1305 system_code(system_code), | 1314 system_code(system_code), |
1306 error_description(error_description) { | 1315 error_description(error_description) { |
1307 } | 1316 } |
1308 | 1317 |
1318 CdmAdapter::SessionMessage::SessionMessage( | |
1319 const std::string& session_id, | |
1320 cdm::MessageType message_type, | |
1321 const std::vector<uint8_t>& message, | |
1322 const std::string& legacy_destination_url) | |
1323 : session_id(session_id), | |
1324 message_type(message_type), | |
1325 message(message), | |
1326 legacy_destination_url(legacy_destination_url) { | |
1327 } | |
1328 | |
1309 void* GetCdmHost(int host_interface_version, void* user_data) { | 1329 void* GetCdmHost(int host_interface_version, void* user_data) { |
1310 if (!host_interface_version || !user_data) | 1330 if (!host_interface_version || !user_data) |
1311 return NULL; | 1331 return NULL; |
1312 | 1332 |
1313 static_assert( | 1333 static_assert( |
1314 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_7::kVersion, | 1334 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_7::kVersion, |
1315 "update the code below"); | 1335 "update the code below"); |
1316 | 1336 |
1317 // Ensure IsSupportedCdmHostVersion matches implementation of this function. | 1337 // Ensure IsSupportedCdmHostVersion matches implementation of this function. |
1318 // Always update this DCHECK when updating this function. | 1338 // Always update this DCHECK when updating this function. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1367 } // namespace media | 1387 } // namespace media |
1368 | 1388 |
1369 namespace pp { | 1389 namespace pp { |
1370 | 1390 |
1371 // Factory function for your specialization of the Module object. | 1391 // Factory function for your specialization of the Module object. |
1372 Module* CreateModule() { | 1392 Module* CreateModule() { |
1373 return new media::CdmAdapterModule(); | 1393 return new media::CdmAdapterModule(); |
1374 } | 1394 } |
1375 | 1395 |
1376 } // namespace pp | 1396 } // namespace pp |
OLD | NEW |