Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Side by Side Diff: media/cdm/ppapi/cdm_adapter.cc

Issue 496143002: Update Pepper interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cdm_promise rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/cdm/ppapi/cdm_file_io_impl.h" 8 #include "media/cdm/ppapi/cdm_file_io_impl.h"
8 #include "media/cdm/ppapi/cdm_helpers.h" 9 #include "media/cdm/ppapi/cdm_helpers.h"
9 #include "media/cdm/ppapi/cdm_logging.h" 10 #include "media/cdm/ppapi/cdm_logging.h"
10 #include "media/cdm/ppapi/supported_cdm_versions.h" 11 #include "media/cdm/ppapi/supported_cdm_versions.h"
11 #include "ppapi/c/ppb_console.h" 12 #include "ppapi/c/ppb_console.h"
12 #include "ppapi/cpp/private/uma_private.h" 13 #include "ppapi/cpp/private/uma_private.h"
13 14
14 #if defined(CHECK_DOCUMENT_URL) 15 #if defined(CHECK_DOCUMENT_URL)
15 #include "ppapi/cpp/dev/url_util_dev.h" 16 #include "ppapi/cpp/dev/url_util_dev.h"
16 #include "ppapi/cpp/instance_handle.h" 17 #include "ppapi/cpp/instance_handle.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 317 }
317 #endif // defined(CHECK_DOCUMENT_URL) 318 #endif // defined(CHECK_DOCUMENT_URL)
318 319
319 if (!cdm_ && !CreateCdmInstance(key_system)) 320 if (!cdm_ && !CreateCdmInstance(key_system))
320 return; 321 return;
321 322
322 PP_DCHECK(cdm_); 323 PP_DCHECK(cdm_);
323 key_system_ = key_system; 324 key_system_ = key_system;
324 } 325 }
325 326
327 void CdmAdapter::SetServerCertificate(uint32_t promise_id,
328 pp::VarArrayBuffer server_certificate) {
329 const uint8_t* server_certificate_ptr =
330 static_cast<const uint8_t*>(server_certificate.Map());
331 const uint32_t server_certificate_size = server_certificate.ByteLength();
332
333 if (!server_certificate_ptr ||
334 server_certificate_size < media::limits::kMinCertificateLength ||
335 server_certificate_size > media::limits::kMinCertificateLength) {
336 RejectPromise(
337 promise_id, cdm::kInvalidAccessError, 0, "Incorrect certificate.");
338 return;
339 }
340
341 // Initialize() doesn't report an error, so SetServerCertificate() can be
342 // called even if Initialize() failed.
343 // TODO(jrummell): Remove this code when prefixed EME gets removed.
344 if (!cdm_) {
345 RejectPromise(promise_id,
346 cdm::kInvalidStateError,
347 0,
348 "CDM has not been initialized.");
349 return;
350 }
351
352 if (!cdm_->SetServerCertificate(
353 promise_id, server_certificate_ptr, server_certificate_size)) {
354 // CDM_4 and CDM_5 don't support this method, so reject the promise.
355 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
356 }
357 }
358
326 void CdmAdapter::CreateSession(uint32_t promise_id, 359 void CdmAdapter::CreateSession(uint32_t promise_id,
327 const std::string& init_data_type, 360 const std::string& init_data_type,
328 pp::VarArrayBuffer init_data, 361 pp::VarArrayBuffer init_data,
329 PP_SessionType session_type) { 362 PP_SessionType session_type) {
330 // Initialize() doesn't report an error, so CreateSession() can be called 363 // Initialize() doesn't report an error, so CreateSession() can be called
331 // even if Initialize() failed. 364 // even if Initialize() failed.
332 // TODO(jrummell): Remove this code when prefixed EME gets removed. 365 // TODO(jrummell): Remove this code when prefixed EME gets removed.
333 // TODO(jrummell): Verify that Initialize() failing does not resolve the 366 // TODO(jrummell): Verify that Initialize() failing does not resolve the
334 // MediaKeys.create() promise. 367 // MediaKeys.create() promise.
335 if (!cdm_) { 368 if (!cdm_) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 418
386 void CdmAdapter::CloseSession(uint32_t promise_id, 419 void CdmAdapter::CloseSession(uint32_t promise_id,
387 const std::string& web_session_id) { 420 const std::string& web_session_id) {
388 if (!cdm_->CloseSession( 421 if (!cdm_->CloseSession(
389 promise_id, web_session_id.data(), web_session_id.length())) { 422 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. 423 // CDM_4 and CDM_5 don't support this method, so reject the promise.
391 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); 424 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
392 } 425 }
393 } 426 }
394 427
395 void CdmAdapter::ReleaseSession(uint32_t promise_id, 428 void CdmAdapter::RemoveSession(uint32_t promise_id,
396 const std::string& web_session_id) { 429 const std::string& web_session_id) {
397 cdm_->RemoveSession( 430 cdm_->RemoveSession(
398 promise_id, web_session_id.data(), web_session_id.length()); 431 promise_id, web_session_id.data(), web_session_id.length());
399 } 432 }
400 433
401 void CdmAdapter::GetUsableKeyIds(uint32_t promise_id, 434 void CdmAdapter::GetUsableKeyIds(uint32_t promise_id,
402 const std::string& web_session_id) { 435 const std::string& web_session_id) {
403 if (!cdm_->GetUsableKeyIds( 436 if (!cdm_->GetUsableKeyIds(
404 promise_id, web_session_id.data(), web_session_id.length())) { 437 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. 438 // CDM_4 and CDM_5 don't support this method, so reject the promise.
406 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); 439 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 PP_DCHECK(result == PP_OK); 871 PP_DCHECK(result == PP_OK);
839 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id, 872 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id,
840 web_session_id); 873 web_session_id);
841 } 874 }
842 875
843 void CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal( 876 void CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal(
844 int32_t result, 877 int32_t result,
845 uint32_t promise_id, 878 uint32_t promise_id,
846 std::vector<std::vector<uint8> > key_ids) { 879 std::vector<std::vector<uint8> > key_ids) {
847 PP_DCHECK(result == PP_OK); 880 PP_DCHECK(result == PP_OK);
848 // TODO(jrummell): Implement this event in subsequent CL. 881 pp::ContentDecryptor_Private::PromiseResolvedWithKeyIds(promise_id, key_ids);
849 // (http://crbug.com/358271).
850 } 882 }
851 883
852 void CdmAdapter::SendPromiseRejectedInternal(int32_t result, 884 void CdmAdapter::SendPromiseRejectedInternal(int32_t result,
853 uint32_t promise_id, 885 uint32_t promise_id,
854 const SessionError& error) { 886 const SessionError& error) {
855 PP_DCHECK(result == PP_OK); 887 PP_DCHECK(result == PP_OK);
856 pp::ContentDecryptor_Private::PromiseRejected( 888 pp::ContentDecryptor_Private::PromiseRejected(
857 promise_id, 889 promise_id,
858 CdmExceptionTypeToPpCdmExceptionType(error.error), 890 CdmExceptionTypeToPpCdmExceptionType(error.error),
859 error.system_code, 891 error.system_code,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 CdmExceptionTypeToPpCdmExceptionType(error.error), 929 CdmExceptionTypeToPpCdmExceptionType(error.error),
898 error.system_code, 930 error.system_code,
899 error.error_description); 931 error.error_description);
900 } 932 }
901 933
902 void CdmAdapter::SendSessionUsableKeysChangeInternal( 934 void CdmAdapter::SendSessionUsableKeysChangeInternal(
903 int32_t result, 935 int32_t result,
904 const std::string& web_session_id, 936 const std::string& web_session_id,
905 bool has_additional_usable_key) { 937 bool has_additional_usable_key) {
906 PP_DCHECK(result == PP_OK); 938 PP_DCHECK(result == PP_OK);
907 // TODO(jrummell): Implement this event in subsequent CL. 939 pp::ContentDecryptor_Private::SessionKeysChange(web_session_id,
908 // (http://crbug.com/358271). 940 has_additional_usable_key);
909 } 941 }
910 942
911 void CdmAdapter::SendExpirationChangeInternal(int32_t result, 943 void CdmAdapter::SendExpirationChangeInternal(int32_t result,
912 const std::string& web_session_id, 944 const std::string& web_session_id,
913 cdm::Time new_expiry_time) { 945 cdm::Time new_expiry_time) {
914 PP_DCHECK(result == PP_OK); 946 PP_DCHECK(result == PP_OK);
915 // TODO(jrummell): Implement this event in subsequent CL. 947 pp::ContentDecryptor_Private::SessionExpirationChange(web_session_id,
916 // (http://crbug.com/358271). 948 new_expiry_time);
917 } 949 }
918 950
919 void CdmAdapter::DeliverBlock(int32_t result, 951 void CdmAdapter::DeliverBlock(int32_t result,
920 const cdm::Status& status, 952 const cdm::Status& status,
921 const LinkedDecryptedBlock& decrypted_block, 953 const LinkedDecryptedBlock& decrypted_block,
922 const PP_DecryptTrackingInfo& tracking_info) { 954 const PP_DecryptTrackingInfo& tracking_info) {
923 PP_DCHECK(result == PP_OK); 955 PP_DCHECK(result == PP_OK);
924 PP_DecryptedBlockInfo decrypted_block_info = {}; 956 PP_DecryptedBlockInfo decrypted_block_info = {};
925 decrypted_block_info.tracking_info = tracking_info; 957 decrypted_block_info.tracking_info = tracking_info;
926 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp(); 958 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp();
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 } // namespace media 1389 } // namespace media
1358 1390
1359 namespace pp { 1391 namespace pp {
1360 1392
1361 // Factory function for your specialization of the Module object. 1393 // Factory function for your specialization of the Module object.
1362 Module* CreateModule() { 1394 Module* CreateModule() {
1363 return new media::CdmAdapterModule(); 1395 return new media::CdmAdapterModule();
1364 } 1396 }
1365 1397
1366 } // namespace pp 1398 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698