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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 } | 316 } |
317 #endif // defined(CHECK_DOCUMENT_URL) | 317 #endif // defined(CHECK_DOCUMENT_URL) |
318 | 318 |
319 if (!cdm_ && !CreateCdmInstance(key_system)) | 319 if (!cdm_ && !CreateCdmInstance(key_system)) |
320 return; | 320 return; |
321 | 321 |
322 PP_DCHECK(cdm_); | 322 PP_DCHECK(cdm_); |
323 key_system_ = key_system; | 323 key_system_ = key_system; |
324 } | 324 } |
325 | 325 |
326 void CdmAdapter::SetServerCertificate(uint32_t promise_id, | |
327 pp::VarArrayBuffer server_certificate) { | |
328 const uint8_t* server_certificate_ptr = | |
329 static_cast<const uint8_t*>(server_certificate.Map()); | |
330 const uint32_t server_certificate_size = server_certificate.ByteLength(); | |
331 | |
332 PP_DCHECK(server_certificate_ptr); | |
333 PP_DCHECK(server_certificate_size > 0); | |
334 | |
335 // Initialize() doesn't report an error, so SetServerCertificate() can be | |
336 // called even if Initialize() failed. | |
ddorwin
2014/08/25 22:55:01
Possible in a code sense, but not possible from an
jrummell
2014/08/26 00:19:23
It appears possible in both prefixed and unprefixe
| |
337 // TODO(jrummell): Remove this code when prefixed EME gets removed. | |
338 if (!cdm_) { | |
339 RejectPromise(promise_id, | |
340 cdm::kInvalidStateError, | |
341 0, | |
342 "CDM has not been initialized."); | |
343 return; | |
344 } | |
345 | |
346 if (!cdm_->SetServerCertificate( | |
347 promise_id, server_certificate_ptr, server_certificate_size)) { | |
348 // CDM_4 and CDM_5 don't support this method, so reject the promise. | |
349 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); | |
350 } | |
351 } | |
352 | |
326 void CdmAdapter::CreateSession(uint32_t promise_id, | 353 void CdmAdapter::CreateSession(uint32_t promise_id, |
327 const std::string& init_data_type, | 354 const std::string& init_data_type, |
328 pp::VarArrayBuffer init_data, | 355 pp::VarArrayBuffer init_data, |
329 PP_SessionType session_type) { | 356 PP_SessionType session_type) { |
330 // Initialize() doesn't report an error, so CreateSession() can be called | 357 // Initialize() doesn't report an error, so CreateSession() can be called |
331 // even if Initialize() failed. | 358 // even if Initialize() failed. |
332 // TODO(jrummell): Remove this code when prefixed EME gets removed. | 359 // TODO(jrummell): Remove this code when prefixed EME gets removed. |
333 // TODO(jrummell): Verify that Initialize() failing does not resolve the | 360 // TODO(jrummell): Verify that Initialize() failing does not resolve the |
334 // MediaKeys.create() promise. | 361 // MediaKeys.create() promise. |
335 if (!cdm_) { | 362 if (!cdm_) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 | 412 |
386 void CdmAdapter::CloseSession(uint32_t promise_id, | 413 void CdmAdapter::CloseSession(uint32_t promise_id, |
387 const std::string& web_session_id) { | 414 const std::string& web_session_id) { |
388 if (!cdm_->CloseSession( | 415 if (!cdm_->CloseSession( |
389 promise_id, web_session_id.data(), web_session_id.length())) { | 416 promise_id, web_session_id.data(), web_session_id.length())) { |
390 // CDM_4 and CDM_5 don't support this method, so reject the promise. | 417 // CDM_4 and CDM_5 don't support this method, so reject the promise. |
391 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); | 418 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); |
392 } | 419 } |
393 } | 420 } |
394 | 421 |
395 void CdmAdapter::ReleaseSession(uint32_t promise_id, | 422 void CdmAdapter::RemoveSession(uint32_t promise_id, |
396 const std::string& web_session_id) { | 423 const std::string& web_session_id) { |
397 cdm_->RemoveSession( | 424 cdm_->RemoveSession( |
398 promise_id, web_session_id.data(), web_session_id.length()); | 425 promise_id, web_session_id.data(), web_session_id.length()); |
399 } | 426 } |
400 | 427 |
401 void CdmAdapter::GetUsableKeyIds(uint32_t promise_id, | 428 void CdmAdapter::GetUsableKeyIds(uint32_t promise_id, |
402 const std::string& web_session_id) { | 429 const std::string& web_session_id) { |
403 if (!cdm_->GetUsableKeyIds( | 430 if (!cdm_->GetUsableKeyIds( |
404 promise_id, web_session_id.data(), web_session_id.length())) { | 431 promise_id, web_session_id.data(), web_session_id.length())) { |
405 // CDM_4 and CDM_5 don't support this method, so reject the promise. | 432 // CDM_4 and CDM_5 don't support this method, so reject the promise. |
406 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); | 433 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 PP_DCHECK(result == PP_OK); | 865 PP_DCHECK(result == PP_OK); |
839 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id, | 866 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id, |
840 web_session_id); | 867 web_session_id); |
841 } | 868 } |
842 | 869 |
843 void CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal( | 870 void CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal( |
844 int32_t result, | 871 int32_t result, |
845 uint32_t promise_id, | 872 uint32_t promise_id, |
846 std::vector<std::vector<uint8> > key_ids) { | 873 std::vector<std::vector<uint8> > key_ids) { |
847 PP_DCHECK(result == PP_OK); | 874 PP_DCHECK(result == PP_OK); |
848 // TODO(jrummell): Implement this event in subsequent CL. | 875 pp::ContentDecryptor_Private::PromiseResolvedWithKeyIds(promise_id, key_ids); |
849 // (http://crbug.com/358271). | |
850 } | 876 } |
851 | 877 |
852 void CdmAdapter::SendPromiseRejectedInternal(int32_t result, | 878 void CdmAdapter::SendPromiseRejectedInternal(int32_t result, |
853 uint32_t promise_id, | 879 uint32_t promise_id, |
854 const SessionError& error) { | 880 const SessionError& error) { |
855 PP_DCHECK(result == PP_OK); | 881 PP_DCHECK(result == PP_OK); |
856 pp::ContentDecryptor_Private::PromiseRejected( | 882 pp::ContentDecryptor_Private::PromiseRejected( |
857 promise_id, | 883 promise_id, |
858 CdmExceptionTypeToPpCdmExceptionType(error.error), | 884 CdmExceptionTypeToPpCdmExceptionType(error.error), |
859 error.system_code, | 885 error.system_code, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
897 CdmExceptionTypeToPpCdmExceptionType(error.error), | 923 CdmExceptionTypeToPpCdmExceptionType(error.error), |
898 error.system_code, | 924 error.system_code, |
899 error.error_description); | 925 error.error_description); |
900 } | 926 } |
901 | 927 |
902 void CdmAdapter::SendSessionUsableKeysChangeInternal( | 928 void CdmAdapter::SendSessionUsableKeysChangeInternal( |
903 int32_t result, | 929 int32_t result, |
904 const std::string& web_session_id, | 930 const std::string& web_session_id, |
905 bool has_additional_usable_key) { | 931 bool has_additional_usable_key) { |
906 PP_DCHECK(result == PP_OK); | 932 PP_DCHECK(result == PP_OK); |
907 // TODO(jrummell): Implement this event in subsequent CL. | 933 pp::ContentDecryptor_Private::SessionKeysChange(web_session_id, |
908 // (http://crbug.com/358271). | 934 has_additional_usable_key); |
909 } | 935 } |
910 | 936 |
911 void CdmAdapter::SendExpirationChangeInternal(int32_t result, | 937 void CdmAdapter::SendExpirationChangeInternal(int32_t result, |
912 const std::string& web_session_id, | 938 const std::string& web_session_id, |
913 cdm::Time new_expiry_time) { | 939 cdm::Time new_expiry_time) { |
914 PP_DCHECK(result == PP_OK); | 940 PP_DCHECK(result == PP_OK); |
915 // TODO(jrummell): Implement this event in subsequent CL. | 941 pp::ContentDecryptor_Private::SessionExpirationChange(web_session_id, |
916 // (http://crbug.com/358271). | 942 new_expiry_time); |
917 } | 943 } |
918 | 944 |
919 void CdmAdapter::DeliverBlock(int32_t result, | 945 void CdmAdapter::DeliverBlock(int32_t result, |
920 const cdm::Status& status, | 946 const cdm::Status& status, |
921 const LinkedDecryptedBlock& decrypted_block, | 947 const LinkedDecryptedBlock& decrypted_block, |
922 const PP_DecryptTrackingInfo& tracking_info) { | 948 const PP_DecryptTrackingInfo& tracking_info) { |
923 PP_DCHECK(result == PP_OK); | 949 PP_DCHECK(result == PP_OK); |
924 PP_DecryptedBlockInfo decrypted_block_info = {}; | 950 PP_DecryptedBlockInfo decrypted_block_info = {}; |
925 decrypted_block_info.tracking_info = tracking_info; | 951 decrypted_block_info.tracking_info = tracking_info; |
926 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp(); | 952 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp(); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1357 } // namespace media | 1383 } // namespace media |
1358 | 1384 |
1359 namespace pp { | 1385 namespace pp { |
1360 | 1386 |
1361 // Factory function for your specialization of the Module object. | 1387 // Factory function for your specialization of the Module object. |
1362 Module* CreateModule() { | 1388 Module* CreateModule() { |
1363 return new media::CdmAdapterModule(); | 1389 return new media::CdmAdapterModule(); |
1364 } | 1390 } |
1365 | 1391 |
1366 } // namespace pp | 1392 } // namespace pp |
OLD | NEW |