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

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

Issue 446693004: Add support for CDM_6. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 PP_DCHECK(response_ptr); 376 PP_DCHECK(response_ptr);
377 PP_DCHECK(response_size > 0); 377 PP_DCHECK(response_size > 0);
378 378
379 cdm_->UpdateSession(promise_id, 379 cdm_->UpdateSession(promise_id,
380 web_session_id.data(), 380 web_session_id.data(),
381 web_session_id.length(), 381 web_session_id.length(),
382 response_ptr, 382 response_ptr,
383 response_size); 383 response_size);
384 } 384 }
385 385
386 void CdmAdapter::GetUsableKeyIds(uint32_t promise_id,
387 const std::string& web_session_id) {
388 if (!cdm_->GetUsableKeyIds(
389 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.
391 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not supported.");
ddorwin 2014/08/07 01:34:43 Maybe "Not implemented." "Not supported" is redund
jrummell 2014/08/07 20:44:30 This rejection happens for CDM_4 and CDM_5, which
ddorwin 2014/08/07 22:10:43 Yes, but the message goes to JS, so we want it to
392 }
393 }
394
386 void CdmAdapter::ReleaseSession(uint32_t promise_id, 395 void CdmAdapter::ReleaseSession(uint32_t promise_id,
387 const std::string& web_session_id) { 396 const std::string& web_session_id) {
388 cdm_->ReleaseSession( 397 cdm_->CloseSession(
389 promise_id, web_session_id.data(), web_session_id.length()); 398 promise_id, web_session_id.data(), web_session_id.length());
390 } 399 }
391 400
401 void CdmAdapter::RemoveSession(uint32_t promise_id,
402 const std::string& web_session_id) {
403 if (!cdm_->RemoveSession(
404 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.
406 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not supported.");
ddorwin 2014/08/07 01:34:43 ditto
jrummell 2014/08/07 20:44:30 ditto
407 }
408 }
409
392 // Note: In the following decryption/decoding related functions, errors are NOT 410 // Note: In the following decryption/decoding related functions, errors are NOT
393 // reported via KeyError, but are reported via corresponding PPB calls. 411 // reported via KeyError, but are reported via corresponding PPB calls.
394 412
395 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer, 413 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer,
396 const PP_EncryptedBlockInfo& encrypted_block_info) { 414 const PP_EncryptedBlockInfo& encrypted_block_info) {
397 PP_DCHECK(!encrypted_buffer.is_null()); 415 PP_DCHECK(!encrypted_buffer.is_null());
398 416
399 // Release a buffer that the caller indicated it is finished with. 417 // Release a buffer that the caller indicated it is finished with.
400 allocator_.Release(encrypted_block_info.tracking_info.buffer_id); 418 allocator_.Release(encrypted_block_info.tracking_info.buffer_id);
401 419
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 std::string web_session_id = cdm_->LookupWebSessionId(session_id); 678 std::string web_session_id = cdm_->LookupWebSessionId(session_id);
661 OnSessionError(web_session_id.data(), 679 OnSessionError(web_session_id.data(),
662 web_session_id.length(), 680 web_session_id.length(),
663 error, 681 error,
664 system_code, 682 system_code,
665 NULL, 683 NULL,
666 0); 684 0);
667 } 685 }
668 } 686 }
669 687
670 // cdm::Host_5 methods 688 // cdm::Host_5 methods
ddorwin 2014/08/07 01:34:43 and 6?
jrummell 2014/08/07 20:44:29 Done.
671 689
672 cdm::Time CdmAdapter::GetCurrentTime() { 690 cdm::Time CdmAdapter::GetCurrentTime() {
691 return GetCurrentWallTime();
692 }
693
694 cdm::Time CdmAdapter::GetCurrentWallTime() {
673 return pp::Module::Get()->core()->GetTime(); 695 return pp::Module::Get()->core()->GetTime();
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));
701 std::string session_id;
ddorwin 2014/08/07 01:34:43 Although the Wrapper explains these are for 4 & 5,
jrummell 2014/08/07 20:44:29 Done.
702 if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
703 OnSessionKeysChange(session_id.data(), session_id.length(), true);
679 } 704 }
680 705
681 void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id, 706 void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
682 const char* web_session_id, 707 const char* web_session_id,
683 uint32_t web_session_id_length) { 708 uint32_t web_session_id_length) {
684 PostOnMain(callback_factory_.NewCallback( 709 PostOnMain(callback_factory_.NewCallback(
685 &CdmAdapter::SendPromiseResolvedWithSessionInternal, 710 &CdmAdapter::SendPromiseResolvedWithSessionInternal,
686 promise_id, 711 promise_id,
687 std::string(web_session_id, web_session_id_length))); 712 std::string(web_session_id, web_session_id_length)));
713 std::string session_id;
714 if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
715 OnSessionKeysChange(web_session_id, web_session_id_length, true);
716 }
717
718 void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id,
719 const cdm::BinaryData* usable_key_ids,
720 uint32_t usable_key_ids_length) {
721 std::vector<std::vector<uint8> > key_ids;
722 for (uint32_t i = 0; i < usable_key_ids_length; ++i) {
723 key_ids.push_back(
724 std::vector<uint8>(usable_key_ids[i].data,
725 usable_key_ids[i].data + usable_key_ids[i].length));
726 }
727 PostOnMain(callback_factory_.NewCallback(
728 &CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal,
729 promise_id,
730 key_ids));
688 } 731 }
689 732
690 void CdmAdapter::OnRejectPromise(uint32_t promise_id, 733 void CdmAdapter::OnRejectPromise(uint32_t promise_id,
691 cdm::Error error, 734 cdm::Error error,
692 uint32_t system_code, 735 uint32_t system_code,
693 const char* error_message, 736 const char* error_message,
694 uint32_t error_message_length) { 737 uint32_t error_message_length) {
695 RejectPromise(promise_id, 738 RejectPromise(promise_id,
696 error, 739 error,
697 system_code, 740 system_code,
(...skipping 19 matching lines...) Expand all
717 PostOnMain(callback_factory_.NewCallback( 760 PostOnMain(callback_factory_.NewCallback(
718 &CdmAdapter::SendSessionMessageInternal, 761 &CdmAdapter::SendSessionMessageInternal,
719 std::string(web_session_id, web_session_id_length), 762 std::string(web_session_id, web_session_id_length),
720 std::vector<uint8>(message, message + message_length), 763 std::vector<uint8>(message, message + message_length),
721 std::string(destination_url, destination_url_length))); 764 std::string(destination_url, destination_url_length)));
722 } 765 }
723 766
724 void CdmAdapter::OnSessionKeysChange(const char* web_session_id, 767 void CdmAdapter::OnSessionKeysChange(const char* web_session_id,
725 uint32_t web_session_id_length, 768 uint32_t web_session_id_length,
726 bool has_additional_usable_key) { 769 bool has_additional_usable_key) {
727 // TODO(jrummell): Implement this event in subsequent CL 770 PostOnMain(callback_factory_.NewCallback(
ddorwin 2014/08/07 01:34:43 Just call OnSessionUsableKeysChange?
jrummell 2014/08/07 20:44:29 Done.
728 // (http://crbug.com/370251). 771 &CdmAdapter::SendSessionUsableKeysChangeInternal,
729 PP_NOTREACHED(); 772 std::string(web_session_id, web_session_id_length),
773 has_additional_usable_key));
774 }
775
776 void CdmAdapter::OnSessionUsableKeysChange(const char* web_session_id,
777 uint32_t web_session_id_length,
778 bool has_additional_usable_key) {
779 PostOnMain(callback_factory_.NewCallback(
780 &CdmAdapter::SendSessionUsableKeysChangeInternal,
781 std::string(web_session_id, web_session_id_length),
782 has_additional_usable_key));
730 } 783 }
731 784
732 void CdmAdapter::OnExpirationChange(const char* web_session_id, 785 void CdmAdapter::OnExpirationChange(const char* web_session_id,
733 uint32_t web_session_id_length, 786 uint32_t web_session_id_length,
734 cdm::Time new_expiry_time) { 787 cdm::Time new_expiry_time) {
735 // TODO(jrummell): Implement this event in subsequent CL 788 PostOnMain(callback_factory_.NewCallback(
736 // (http://crbug.com/370251). 789 &CdmAdapter::SendExpirationChangeInternal,
737 PP_NOTREACHED(); 790 std::string(web_session_id, web_session_id_length),
791 new_expiry_time));
738 } 792 }
739 793
740 void CdmAdapter::OnSessionReady(const char* web_session_id, 794 void CdmAdapter::OnSessionReady(const char* web_session_id,
741 uint32_t web_session_id_length) { 795 uint32_t web_session_id_length) {
742 PostOnMain(callback_factory_.NewCallback( 796 PostOnMain(callback_factory_.NewCallback(
743 &CdmAdapter::SendSessionReadyInternal, 797 &CdmAdapter::SendSessionReadyInternal,
744 std::string(web_session_id, web_session_id_length))); 798 std::string(web_session_id, web_session_id_length)));
745 } 799 }
746 800
747 void CdmAdapter::OnSessionClosed(const char* web_session_id, 801 void CdmAdapter::OnSessionClosed(const char* web_session_id,
(...skipping 27 matching lines...) Expand all
775 829
776 void CdmAdapter::SendPromiseResolvedWithSessionInternal( 830 void CdmAdapter::SendPromiseResolvedWithSessionInternal(
777 int32_t result, 831 int32_t result,
778 uint32_t promise_id, 832 uint32_t promise_id,
779 const std::string& web_session_id) { 833 const std::string& web_session_id) {
780 PP_DCHECK(result == PP_OK); 834 PP_DCHECK(result == PP_OK);
781 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id, 835 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id,
782 web_session_id); 836 web_session_id);
783 } 837 }
784 838
839 void CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal(
840 int32_t result,
841 uint32_t promise_id,
842 std::vector<std::vector<uint8> > key_ids) {
843 PP_DCHECK(result == PP_OK);
844 // TODO(jrummell): Implement this event in subsequent CL.
845 // (http://crbug.com/358271).
846 }
847
785 void CdmAdapter::SendPromiseRejectedInternal(int32_t result, 848 void CdmAdapter::SendPromiseRejectedInternal(int32_t result,
786 uint32_t promise_id, 849 uint32_t promise_id,
787 const SessionError& error) { 850 const SessionError& error) {
788 PP_DCHECK(result == PP_OK); 851 PP_DCHECK(result == PP_OK);
789 pp::ContentDecryptor_Private::PromiseRejected( 852 pp::ContentDecryptor_Private::PromiseRejected(
790 promise_id, 853 promise_id,
791 CdmExceptionTypeToPpCdmExceptionType(error.error), 854 CdmExceptionTypeToPpCdmExceptionType(error.error),
792 error.system_code, 855 error.system_code,
793 error.error_description); 856 error.error_description);
794 } 857 }
(...skipping 30 matching lines...) Expand all
825 const std::string& web_session_id, 888 const std::string& web_session_id,
826 const SessionError& error) { 889 const SessionError& error) {
827 PP_DCHECK(result == PP_OK); 890 PP_DCHECK(result == PP_OK);
828 pp::ContentDecryptor_Private::SessionError( 891 pp::ContentDecryptor_Private::SessionError(
829 web_session_id, 892 web_session_id,
830 CdmExceptionTypeToPpCdmExceptionType(error.error), 893 CdmExceptionTypeToPpCdmExceptionType(error.error),
831 error.system_code, 894 error.system_code,
832 error.error_description); 895 error.error_description);
833 } 896 }
834 897
898 void CdmAdapter::SendSessionUsableKeysChangeInternal(
899 int32_t result,
900 const std::string& web_session_id,
901 bool has_additional_usable_key) {
902 PP_DCHECK(result == PP_OK);
903 // TODO(jrummell): Implement this event in subsequent CL.
904 // (http://crbug.com/358271).
905 }
906
907 void CdmAdapter::SendExpirationChangeInternal(int32_t result,
908 const std::string& web_session_id,
909 cdm::Time new_expiry_time) {
910 PP_DCHECK(result == PP_OK);
911 // TODO(jrummell): Implement this event in subsequent CL.
912 // (http://crbug.com/358271).
913 }
914
835 void CdmAdapter::DeliverBlock(int32_t result, 915 void CdmAdapter::DeliverBlock(int32_t result,
836 const cdm::Status& status, 916 const cdm::Status& status,
837 const LinkedDecryptedBlock& decrypted_block, 917 const LinkedDecryptedBlock& decrypted_block,
838 const PP_DecryptTrackingInfo& tracking_info) { 918 const PP_DecryptTrackingInfo& tracking_info) {
839 PP_DCHECK(result == PP_OK); 919 PP_DCHECK(result == PP_OK);
840 PP_DecryptedBlockInfo decrypted_block_info = {}; 920 PP_DecryptedBlockInfo decrypted_block_info = {};
841 decrypted_block_info.tracking_info = tracking_info; 921 decrypted_block_info.tracking_info = tracking_info;
842 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp(); 922 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp();
843 decrypted_block_info.tracking_info.buffer_id = 0; 923 decrypted_block_info.tracking_info.buffer_id = 0;
844 decrypted_block_info.data_size = 0; 924 decrypted_block_info.data_size = 0;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 : error(error), 1287 : error(error),
1208 system_code(system_code), 1288 system_code(system_code),
1209 error_description(error_description) { 1289 error_description(error_description) {
1210 } 1290 }
1211 1291
1212 void* GetCdmHost(int host_interface_version, void* user_data) { 1292 void* GetCdmHost(int host_interface_version, void* user_data) {
1213 if (!host_interface_version || !user_data) 1293 if (!host_interface_version || !user_data)
1214 return NULL; 1294 return NULL;
1215 1295
1216 COMPILE_ASSERT( 1296 COMPILE_ASSERT(
1217 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_5::kVersion, 1297 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_6::kVersion,
1218 update_code_below); 1298 update_code_below);
1219 1299
1220 // Ensure IsSupportedCdmHostVersion matches implementation of this function. 1300 // Ensure IsSupportedCdmHostVersion matches implementation of this function.
1221 // Always update this DCHECK when updating this function. 1301 // Always update this DCHECK when updating this function.
1222 // If this check fails, update this function and DCHECK or update 1302 // If this check fails, update this function and DCHECK or update
1223 // IsSupportedCdmHostVersion. 1303 // IsSupportedCdmHostVersion.
1224 1304
1225 PP_DCHECK( 1305 PP_DCHECK(
1226 // Future version is not supported. 1306 // Future version is not supported.
1227 !IsSupportedCdmHostVersion(cdm::Host_5::kVersion + 1) && 1307 !IsSupportedCdmHostVersion(cdm::Host_6::kVersion + 1) &&
1228 // Current version is supported. 1308 // Current version is supported.
1309 IsSupportedCdmHostVersion(cdm::Host_6::kVersion) &&
1310 // Include all previous supported versions (if any) here.
1229 IsSupportedCdmHostVersion(cdm::Host_5::kVersion) && 1311 IsSupportedCdmHostVersion(cdm::Host_5::kVersion) &&
1230 // Include all previous supported versions (if any) here.
1231 IsSupportedCdmHostVersion(cdm::Host_4::kVersion) && 1312 IsSupportedCdmHostVersion(cdm::Host_4::kVersion) &&
1232 // One older than the oldest supported version is not supported. 1313 // One older than the oldest supported version is not supported.
1233 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1)); 1314 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1));
1234 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); 1315 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version));
1235 1316
1236 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); 1317 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data);
1237 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; 1318 CDM_DLOG() << "Create CDM Host with version " << host_interface_version;
1238 switch (host_interface_version) { 1319 switch (host_interface_version) {
1239 case cdm::Host_4::kVersion: 1320 case cdm::Host_4::kVersion:
1240 return static_cast<cdm::Host_4*>(cdm_adapter); 1321 return static_cast<cdm::Host_4*>(cdm_adapter);
1241 case cdm::Host_5::kVersion: 1322 case cdm::Host_5::kVersion:
1242 return static_cast<cdm::Host_5*>(cdm_adapter); 1323 return static_cast<cdm::Host_5*>(cdm_adapter);
1324 case cdm::Host_6::kVersion:
1325 return static_cast<cdm::Host_6*>(cdm_adapter);
1243 default: 1326 default:
1244 PP_NOTREACHED(); 1327 PP_NOTREACHED();
1245 return NULL; 1328 return NULL;
1246 } 1329 }
1247 } 1330 }
1248 1331
1249 // This object is the global object representing this plugin library as long 1332 // This object is the global object representing this plugin library as long
1250 // as it is loaded. 1333 // as it is loaded.
1251 class CdmAdapterModule : public pp::Module { 1334 class CdmAdapterModule : public pp::Module {
1252 public: 1335 public:
(...skipping 17 matching lines...) Expand all
1270 } // namespace media 1353 } // namespace media
1271 1354
1272 namespace pp { 1355 namespace pp {
1273 1356
1274 // Factory function for your specialization of the Module object. 1357 // Factory function for your specialization of the Module object.
1275 Module* CreateModule() { 1358 Module* CreateModule() {
1276 return new media::CdmAdapterModule(); 1359 return new media::CdmAdapterModule();
1277 } 1360 }
1278 1361
1279 } // namespace pp 1362 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698