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

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

Issue 518353002: Remove CDM_5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::CloseSession(uint32_t promise_id, 386 void CdmAdapter::CloseSession(uint32_t promise_id,
387 const std::string& web_session_id) { 387 const std::string& web_session_id) {
388 if (!cdm_->CloseSession( 388 if (!cdm_->CloseSession(
389 promise_id, web_session_id.data(), web_session_id.length())) { 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. 390 // CDM_4 doesn't support this method, so reject the promise.
391 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); 391 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
392 } 392 }
393 } 393 }
394 394
395 void CdmAdapter::ReleaseSession(uint32_t promise_id, 395 void CdmAdapter::ReleaseSession(uint32_t promise_id,
396 const std::string& web_session_id) { 396 const std::string& web_session_id) {
397 cdm_->RemoveSession( 397 cdm_->RemoveSession(
398 promise_id, web_session_id.data(), web_session_id.length()); 398 promise_id, web_session_id.data(), web_session_id.length());
399 } 399 }
400 400
401 void CdmAdapter::GetUsableKeyIds(uint32_t promise_id, 401 void CdmAdapter::GetUsableKeyIds(uint32_t promise_id,
402 const std::string& web_session_id) { 402 const std::string& web_session_id) {
403 if (!cdm_->GetUsableKeyIds( 403 if (!cdm_->GetUsableKeyIds(
404 promise_id, web_session_id.data(), web_session_id.length())) { 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. 405 // CDM_4 doesn't support this method, so reject the promise.
406 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented."); 406 RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
407 } 407 }
408 } 408 }
409 409
410 // Note: In the following decryption/decoding related functions, errors are NOT 410 // Note: In the following decryption/decoding related functions, errors are NOT
411 // reported via KeyError, but are reported via corresponding PPB calls. 411 // reported via KeyError, but are reported via corresponding PPB calls.
412 412
413 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer, 413 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer,
414 const PP_EncryptedBlockInfo& encrypted_block_info) { 414 const PP_EncryptedBlockInfo& encrypted_block_info) {
415 PP_DCHECK(!encrypted_buffer.is_null()); 415 PP_DCHECK(!encrypted_buffer.is_null());
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 597 }
598 598
599 void CdmAdapter::TimerExpired(int32_t result, void* context) { 599 void CdmAdapter::TimerExpired(int32_t result, void* context) {
600 PP_DCHECK(result == PP_OK); 600 PP_DCHECK(result == PP_OK);
601 cdm_->TimerExpired(context); 601 cdm_->TimerExpired(context);
602 } 602 }
603 603
604 // cdm::Host_4 methods 604 // cdm::Host_4 methods
605 605
606 double CdmAdapter::GetCurrentWallTimeInSeconds() { 606 double CdmAdapter::GetCurrentWallTimeInSeconds() {
607 return GetCurrentTime(); 607 return GetCurrentWallTime();
608 } 608 }
609 609
610 void CdmAdapter::OnSessionCreated(uint32_t session_id, 610 void CdmAdapter::OnSessionCreated(uint32_t session_id,
611 const char* web_session_id, 611 const char* web_session_id,
612 uint32_t web_session_id_length) { 612 uint32_t web_session_id_length) {
613 uint32_t promise_id = cdm_->LookupPromiseId(session_id); 613 uint32_t promise_id = cdm_->LookupPromiseId(session_id);
614 cdm_->AssignWebSessionId(session_id, web_session_id, web_session_id_length); 614 cdm_->AssignWebSessionId(session_id, web_session_id, web_session_id_length);
615 OnResolveNewSessionPromise(promise_id, web_session_id, web_session_id_length); 615 OnResolveNewSessionPromise(promise_id, web_session_id, web_session_id_length);
616 } 616 }
617 617
(...skipping 10 matching lines...) Expand all
628 destination_url, 628 destination_url,
629 destination_url_length); 629 destination_url_length);
630 } 630 }
631 631
632 void CdmAdapter::OnSessionReady(uint32_t session_id) { 632 void CdmAdapter::OnSessionReady(uint32_t session_id) {
633 uint32_t promise_id = cdm_->LookupPromiseId(session_id); 633 uint32_t promise_id = cdm_->LookupPromiseId(session_id);
634 if (promise_id) { 634 if (promise_id) {
635 OnResolvePromise(promise_id); 635 OnResolvePromise(promise_id);
636 } else { 636 } else {
637 std::string web_session_id = cdm_->LookupWebSessionId(session_id); 637 std::string web_session_id = cdm_->LookupWebSessionId(session_id);
638 OnSessionReady(web_session_id.data(), web_session_id.length()); 638 PostOnMain(callback_factory_.NewCallback(
639 &CdmAdapter::SendSessionReadyInternal, web_session_id));
639 } 640 }
640 } 641 }
641 642
642 void CdmAdapter::OnSessionClosed(uint32_t session_id) { 643 void CdmAdapter::OnSessionClosed(uint32_t session_id) {
643 uint32_t promise_id = cdm_->LookupPromiseId(session_id); 644 uint32_t promise_id = cdm_->LookupPromiseId(session_id);
644 std::string web_session_id = cdm_->LookupWebSessionId(session_id); 645 std::string web_session_id = cdm_->LookupWebSessionId(session_id);
645 cdm_->DropWebSessionId(web_session_id); 646 cdm_->DropWebSessionId(web_session_id);
646 if (promise_id) { 647 if (promise_id) {
647 OnResolvePromise(promise_id); 648 OnResolvePromise(promise_id);
648 } else { 649 } else {
(...skipping 29 matching lines...) Expand all
678 std::string web_session_id = cdm_->LookupWebSessionId(session_id); 679 std::string web_session_id = cdm_->LookupWebSessionId(session_id);
679 OnSessionError(web_session_id.data(), 680 OnSessionError(web_session_id.data(),
680 web_session_id.length(), 681 web_session_id.length(),
681 error, 682 error,
682 system_code, 683 system_code,
683 NULL, 684 NULL,
684 0); 685 0);
685 } 686 }
686 } 687 }
687 688
688 // cdm::Host_5 and cdm::Host_6 methods 689 // cdm::Host_6 methods
689
690 cdm::Time CdmAdapter::GetCurrentTime() {
691 return GetCurrentWallTime();
692 }
693 690
694 cdm::Time CdmAdapter::GetCurrentWallTime() { 691 cdm::Time CdmAdapter::GetCurrentWallTime() {
695 return pp::Module::Get()->core()->GetTime(); 692 return pp::Module::Get()->core()->GetTime();
696 } 693 }
697 694
698 void CdmAdapter::OnResolvePromise(uint32_t promise_id) {
699 PostOnMain(callback_factory_.NewCallback(
700 &CdmAdapter::SendPromiseResolvedInternal, promise_id));
701
702 // CDM_5 doesn't support OnSessionKeysChange(), so simulate one if requested.
703 // Passing "true" which may result in false positives for retrying.
704 std::string session_id;
705 if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
706 OnSessionKeysChange(session_id.data(), session_id.length(), true);
707 }
708
709 void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id, 695 void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
710 const char* web_session_id, 696 const char* web_session_id,
711 uint32_t web_session_id_length) { 697 uint32_t web_session_id_length) {
712 PostOnMain(callback_factory_.NewCallback( 698 PostOnMain(callback_factory_.NewCallback(
713 &CdmAdapter::SendPromiseResolvedWithSessionInternal, 699 &CdmAdapter::SendPromiseResolvedWithSessionInternal,
714 promise_id, 700 promise_id,
715 std::string(web_session_id, web_session_id_length))); 701 std::string(web_session_id, web_session_id_length)));
702 }
716 703
717 // CDM_5 doesn't support OnSessionKeysChange(), so simulate one if requested. 704 void CdmAdapter::OnResolvePromise(uint32_t promise_id) {
718 // Passing "true" which may result in false positives for retrying. 705 PostOnMain(callback_factory_.NewCallback(
719 std::string session_id; 706 &CdmAdapter::SendPromiseResolvedInternal, promise_id));
720 if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
721 OnSessionKeysChange(web_session_id, web_session_id_length, true);
722 } 707 }
723 708
724 void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id, 709 void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id,
725 const cdm::BinaryData* usable_key_ids, 710 const cdm::BinaryData* usable_key_ids,
726 uint32_t usable_key_ids_length) { 711 uint32_t usable_key_ids_length) {
727 std::vector<std::vector<uint8> > key_ids; 712 std::vector<std::vector<uint8> > key_ids;
728 for (uint32_t i = 0; i < usable_key_ids_length; ++i) { 713 for (uint32_t i = 0; i < usable_key_ids_length; ++i) {
729 key_ids.push_back( 714 key_ids.push_back(
730 std::vector<uint8>(usable_key_ids[i].data, 715 std::vector<uint8>(usable_key_ids[i].data,
731 usable_key_ids[i].data + usable_key_ids[i].length)); 716 usable_key_ids[i].data + usable_key_ids[i].length));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 uint32_t message_length, 748 uint32_t message_length,
764 const char* destination_url, 749 const char* destination_url,
765 uint32_t destination_url_length) { 750 uint32_t destination_url_length) {
766 PostOnMain(callback_factory_.NewCallback( 751 PostOnMain(callback_factory_.NewCallback(
767 &CdmAdapter::SendSessionMessageInternal, 752 &CdmAdapter::SendSessionMessageInternal,
768 std::string(web_session_id, web_session_id_length), 753 std::string(web_session_id, web_session_id_length),
769 std::vector<uint8>(message, message + message_length), 754 std::vector<uint8>(message, message + message_length),
770 std::string(destination_url, destination_url_length))); 755 std::string(destination_url, destination_url_length)));
771 } 756 }
772 757
773 void CdmAdapter::OnSessionKeysChange(const char* web_session_id,
774 uint32_t web_session_id_length,
775 bool has_additional_usable_key) {
776 OnSessionUsableKeysChange(
777 web_session_id, web_session_id_length, has_additional_usable_key);
778 }
779
780 void CdmAdapter::OnSessionUsableKeysChange(const char* web_session_id, 758 void CdmAdapter::OnSessionUsableKeysChange(const char* web_session_id,
781 uint32_t web_session_id_length, 759 uint32_t web_session_id_length,
782 bool has_additional_usable_key) { 760 bool has_additional_usable_key) {
783 PostOnMain(callback_factory_.NewCallback( 761 PostOnMain(callback_factory_.NewCallback(
784 &CdmAdapter::SendSessionUsableKeysChangeInternal, 762 &CdmAdapter::SendSessionUsableKeysChangeInternal,
785 std::string(web_session_id, web_session_id_length), 763 std::string(web_session_id, web_session_id_length),
786 has_additional_usable_key)); 764 has_additional_usable_key));
787 } 765 }
788 766
789 void CdmAdapter::OnExpirationChange(const char* web_session_id, 767 void CdmAdapter::OnExpirationChange(const char* web_session_id,
790 uint32_t web_session_id_length, 768 uint32_t web_session_id_length,
791 cdm::Time new_expiry_time) { 769 cdm::Time new_expiry_time) {
792 PostOnMain(callback_factory_.NewCallback( 770 PostOnMain(callback_factory_.NewCallback(
793 &CdmAdapter::SendExpirationChangeInternal, 771 &CdmAdapter::SendExpirationChangeInternal,
794 std::string(web_session_id, web_session_id_length), 772 std::string(web_session_id, web_session_id_length),
795 new_expiry_time)); 773 new_expiry_time));
796 } 774 }
797 775
798 void CdmAdapter::OnSessionReady(const char* web_session_id,
799 uint32_t web_session_id_length) {
800 PostOnMain(callback_factory_.NewCallback(
801 &CdmAdapter::SendSessionReadyInternal,
802 std::string(web_session_id, web_session_id_length)));
803 }
804
805 void CdmAdapter::OnSessionClosed(const char* web_session_id, 776 void CdmAdapter::OnSessionClosed(const char* web_session_id,
806 uint32_t web_session_id_length) { 777 uint32_t web_session_id_length) {
807 PostOnMain(callback_factory_.NewCallback( 778 PostOnMain(callback_factory_.NewCallback(
808 &CdmAdapter::SendSessionClosedInternal, 779 &CdmAdapter::SendSessionClosedInternal,
809 std::string(web_session_id, web_session_id_length))); 780 std::string(web_session_id, web_session_id_length)));
810 } 781 }
811 782
812 void CdmAdapter::OnSessionError(const char* web_session_id, 783 void CdmAdapter::OnSessionError(const char* web_session_id,
813 uint32_t web_session_id_length, 784 uint32_t web_session_id_length,
814 cdm::Error error, 785 cdm::Error error,
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 // Ensure IsSupportedCdmHostVersion matches implementation of this function. 1275 // Ensure IsSupportedCdmHostVersion matches implementation of this function.
1305 // Always update this DCHECK when updating this function. 1276 // Always update this DCHECK when updating this function.
1306 // If this check fails, update this function and DCHECK or update 1277 // If this check fails, update this function and DCHECK or update
1307 // IsSupportedCdmHostVersion. 1278 // IsSupportedCdmHostVersion.
1308 1279
1309 PP_DCHECK( 1280 PP_DCHECK(
1310 // Future version is not supported. 1281 // Future version is not supported.
1311 !IsSupportedCdmHostVersion(cdm::Host_6::kVersion + 1) && 1282 !IsSupportedCdmHostVersion(cdm::Host_6::kVersion + 1) &&
1312 // Current version is supported. 1283 // Current version is supported.
1313 IsSupportedCdmHostVersion(cdm::Host_6::kVersion) && 1284 IsSupportedCdmHostVersion(cdm::Host_6::kVersion) &&
1314 // Include all previous supported versions (if any) here. 1285 // Include all previous supported versions (if any) here.
xhwang 2014/08/29 23:40:46 Since this is not contiguous which is unusual, add
jrummell 2014/08/29 23:52:19 Done.
1315 IsSupportedCdmHostVersion(cdm::Host_5::kVersion) &&
1316 IsSupportedCdmHostVersion(cdm::Host_4::kVersion) && 1286 IsSupportedCdmHostVersion(cdm::Host_4::kVersion) &&
1317 // One older than the oldest supported version is not supported. 1287 // One older than the oldest supported version is not supported.
1318 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1)); 1288 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1));
1319 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); 1289 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version));
1320 1290
1321 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); 1291 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data);
1322 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; 1292 CDM_DLOG() << "Create CDM Host with version " << host_interface_version;
1323 switch (host_interface_version) { 1293 switch (host_interface_version) {
1324 case cdm::Host_4::kVersion: 1294 case cdm::Host_4::kVersion:
1325 return static_cast<cdm::Host_4*>(cdm_adapter); 1295 return static_cast<cdm::Host_4*>(cdm_adapter);
1326 case cdm::Host_5::kVersion:
1327 return static_cast<cdm::Host_5*>(cdm_adapter);
1328 case cdm::Host_6::kVersion: 1296 case cdm::Host_6::kVersion:
1329 return static_cast<cdm::Host_6*>(cdm_adapter); 1297 return static_cast<cdm::Host_6*>(cdm_adapter);
1330 default: 1298 default:
1331 PP_NOTREACHED(); 1299 PP_NOTREACHED();
1332 return NULL; 1300 return NULL;
1333 } 1301 }
1334 } 1302 }
1335 1303
1336 // This object is the global object representing this plugin library as long 1304 // This object is the global object representing this plugin library as long
1337 // as it is loaded. 1305 // as it is loaded.
(...skipping 19 matching lines...) Expand all
1357 } // namespace media 1325 } // namespace media
1358 1326
1359 namespace pp { 1327 namespace pp {
1360 1328
1361 // Factory function for your specialization of the Module object. 1329 // Factory function for your specialization of the Module object.
1362 Module* CreateModule() { 1330 Module* CreateModule() {
1363 return new media::CdmAdapterModule(); 1331 return new media::CdmAdapterModule();
1364 } 1332 }
1365 1333
1366 } // namespace pp 1334 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698