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

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

Issue 23546014: Plumb PPAPI PlatformVerification into CDM.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/cdm/ppapi/clear_key_cdm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <cstring> 5 #include <cstring>
6 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "build/build_config.h"
13 #include "media/cdm/ppapi/api/content_decryption_module.h" 14 #include "media/cdm/ppapi/api/content_decryption_module.h"
ddorwin 2013/09/17 05:26:46 You need a DEPS roll in this CL. (Make sure it's b
14 #include "media/cdm/ppapi/linked_ptr.h" 15 #include "media/cdm/ppapi/linked_ptr.h"
15 #include "ppapi/c/pp_errors.h" 16 #include "ppapi/c/pp_errors.h"
16 #include "ppapi/c/pp_stdint.h" 17 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/private/pp_content_decryptor.h" 18 #include "ppapi/c/private/pp_content_decryptor.h"
18 #include "ppapi/cpp/completion_callback.h" 19 #include "ppapi/cpp/completion_callback.h"
19 #include "ppapi/cpp/core.h" 20 #include "ppapi/cpp/core.h"
20 #include "ppapi/cpp/dev/buffer_dev.h" 21 #include "ppapi/cpp/dev/buffer_dev.h"
21 #include "ppapi/cpp/instance.h" 22 #include "ppapi/cpp/instance.h"
22 #include "ppapi/cpp/logging.h" 23 #include "ppapi/cpp/logging.h"
23 #include "ppapi/cpp/module.h" 24 #include "ppapi/cpp/module.h"
24 #include "ppapi/cpp/pass_ref.h" 25 #include "ppapi/cpp/pass_ref.h"
25 #include "ppapi/cpp/private/content_decryptor_private.h" 26 #include "ppapi/cpp/private/content_decryptor_private.h"
26 #include "ppapi/cpp/resource.h" 27 #include "ppapi/cpp/resource.h"
27 #include "ppapi/cpp/var.h" 28 #include "ppapi/cpp/var.h"
28 #include "ppapi/cpp/var_array_buffer.h" 29 #include "ppapi/cpp/var_array_buffer.h"
29 #include "ppapi/utility/completion_callback_factory.h" 30 #include "ppapi/utility/completion_callback_factory.h"
30 31
31 #if defined(CHECK_DOCUMENT_URL) 32 #if defined(CHECK_DOCUMENT_URL)
32 #include "ppapi/cpp/dev/url_util_dev.h" 33 #include "ppapi/cpp/dev/url_util_dev.h"
33 #include "ppapi/cpp/instance_handle.h" 34 #include "ppapi/cpp/instance_handle.h"
34 #endif // defined(CHECK_DOCUMENT_URL) 35 #endif // defined(CHECK_DOCUMENT_URL)
35 36
37 #if defined(OS_CHROMEOS)
38 #include "ppapi/cpp/private/platform_verification.h"
39 #endif
40
36 namespace { 41 namespace {
37 42
38 bool IsMainThread() { 43 bool IsMainThread() {
39 return pp::Module::Get()->core()->IsMainThread(); 44 return pp::Module::Get()->core()->IsMainThread();
40 } 45 }
41 46
42 // Posts a task to run |cb| on the main thread. The task is posted even if the 47 // Posts a task to run |cb| on the main thread. The task is posted even if the
43 // current thread is the main thread. 48 // current thread is the main thread.
44 void PostOnMain(pp::CompletionCallback cb) { 49 void PostOnMain(pp::CompletionCallback cb) {
45 pp::Module::Get()->core()->CallOnMainThread(0, cb, PP_OK); 50 pp::Module::Get()->core()->CallOnMainThread(0, cb, PP_OK);
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); 483 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl);
479 }; 484 };
480 485
481 // GetCdmHostFunc implementation. 486 // GetCdmHostFunc implementation.
482 void* GetCdmHost(int host_interface_version, void* user_data); 487 void* GetCdmHost(int host_interface_version, void* user_data);
483 488
484 // A wrapper class for abstracting away PPAPI interaction and threading for a 489 // A wrapper class for abstracting away PPAPI interaction and threading for a
485 // Content Decryption Module (CDM). 490 // Content Decryption Module (CDM).
486 class CdmWrapper : public pp::Instance, 491 class CdmWrapper : public pp::Instance,
487 public pp::ContentDecryptor_Private, 492 public pp::ContentDecryptor_Private,
488 public cdm::Host { 493 public cdm::Host_1,
494 public cdm::Host_2 {
dmichael (off chromium) 2013/09/17 20:10:46 Is this just temporary to deal with DEPS? If so, f
DaleCurtis 2013/09/17 20:18:51 Temporary IIUC. Host_1 can be removed in favor of
ddorwin 2013/09/17 23:24:39 Correct. Also, _2 is a version of the Host interfa
489 public: 495 public:
490 CdmWrapper(PP_Instance instance, pp::Module* module); 496 CdmWrapper(PP_Instance instance, pp::Module* module);
491 virtual ~CdmWrapper(); 497 virtual ~CdmWrapper();
492 498
493 // pp::Instance implementation. 499 // pp::Instance implementation.
494 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { 500 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
495 return true; 501 return true;
496 } 502 }
497 503
498 // PPP_ContentDecryptor_Private implementation. 504 // PPP_ContentDecryptor_Private implementation.
(...skipping 17 matching lines...) Expand all
516 pp::Buffer_Dev extra_data_buffer) OVERRIDE; 522 pp::Buffer_Dev extra_data_buffer) OVERRIDE;
517 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, 523 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type,
518 uint32_t request_id) OVERRIDE; 524 uint32_t request_id) OVERRIDE;
519 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, 525 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type,
520 uint32_t request_id) OVERRIDE; 526 uint32_t request_id) OVERRIDE;
521 virtual void DecryptAndDecode( 527 virtual void DecryptAndDecode(
522 PP_DecryptorStreamType decoder_type, 528 PP_DecryptorStreamType decoder_type,
523 pp::Buffer_Dev encrypted_buffer, 529 pp::Buffer_Dev encrypted_buffer,
524 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; 530 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
525 531
526 // cdm::Host implementation. 532 // cdm::Host_1 implementation.
527 virtual cdm::Buffer* Allocate(int32_t capacity) OVERRIDE; 533 virtual cdm::Buffer* Allocate(int32_t capacity) OVERRIDE;
528 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; 534 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE;
529 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; 535 virtual double GetCurrentWallTimeInSeconds() OVERRIDE;
530 virtual void SendKeyMessage( 536 virtual void SendKeyMessage(
531 const char* session_id, int32_t session_id_length, 537 const char* session_id, int32_t session_id_length,
532 const char* message, int32_t message_length, 538 const char* message, int32_t message_length,
533 const char* default_url, int32_t default_url_length) OVERRIDE; 539 const char* default_url, int32_t default_url_length) OVERRIDE;
534 virtual void SendKeyError(const char* session_id, 540 virtual void SendKeyError(const char* session_id,
535 int32_t session_id_length, 541 int32_t session_id_length,
536 cdm::MediaKeyError error_code, 542 cdm::MediaKeyError error_code,
537 uint32_t system_code) OVERRIDE; 543 uint32_t system_code) OVERRIDE;
538 virtual void GetPrivateData(int32_t* instance, 544 virtual void GetPrivateData(int32_t* instance,
539 GetPrivateInterface* get_interface) OVERRIDE; 545 GetPrivateInterface* get_interface) OVERRIDE;
540 546
547 // cdm::Host_2 implementation.
548 virtual void SendPlatformChallenge(
549 const char* service_id, int32_t service_id_length,
550 const char* challenge, int32_t challenge_length) OVERRIDE;
551 virtual void EnableOutputProtection(
552 uint32_t desired_protection_mask) OVERRIDE;
553 virtual void QueryOutputProtectionStatus() OVERRIDE;
554
541 private: 555 private:
542 struct SessionInfo { 556 struct SessionInfo {
543 SessionInfo(const std::string& key_system_in, 557 SessionInfo(const std::string& key_system_in,
544 const std::string& session_id_in) 558 const std::string& session_id_in)
545 : key_system(key_system_in), 559 : key_system(key_system_in),
546 session_id(session_id_in) {} 560 session_id(session_id_in) {}
547 const std::string key_system; 561 const std::string key_system;
548 const std::string session_id; 562 const std::string session_id;
549 }; 563 };
550 564
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 void DeliverSamples(int32_t result, 612 void DeliverSamples(int32_t result,
599 const cdm::Status& status, 613 const cdm::Status& status,
600 const LinkedAudioFrames& audio_frames, 614 const LinkedAudioFrames& audio_frames,
601 const PP_DecryptTrackingInfo& tracking_info); 615 const PP_DecryptTrackingInfo& tracking_info);
602 616
603 // Helper for SetTimer(). 617 // Helper for SetTimer().
604 void TimerExpired(int32_t result, void* context); 618 void TimerExpired(int32_t result, void* context);
605 619
606 bool IsValidVideoFrame(const LinkedVideoFrame& video_frame); 620 bool IsValidVideoFrame(const LinkedVideoFrame& video_frame);
607 621
622 #if defined(OS_CHROMEOS)
623 bool CanChallengePlatform();
624 void CanChallengePlatformDone(int32_t result, bool can_challenge_platform);
ddorwin 2013/09/17 05:26:46 OnCan... ?
DaleCurtis 2013/09/17 18:49:33 Style elsewhere in the file is XxxDone; i.e., Deco
625 void SendPlatformChallengeDone(int32_t result);
626
627 // Since CanChallengePlatform() needs to return its value immediately, we need
628 // to delay GenerateKeyRequest() until its value is available.
629 // TODO(dalecurtis): This stinks. We need to find a way to deliver the value
630 // synchronously. Potentially as part of the new Initialize(), see
631 // http://crbug.com/250049
632 void DelayedGenerateKeyRequest(int32_t result,
633 const std::string& key_system,
634 const std::string& type,
635 pp::VarArrayBuffer init_data);
636
637 pp::PlatformVerification platform_verification_;
638 bool is_can_challenge_platform_set_;
ddorwin 2013/09/17 05:26:46 It's not clear from the name what this does. _init
DaleCurtis 2013/09/23 18:30:57 Done.
639 pp::CompletionCallback delayed_gkr_;
640
641 // Since PPAPI doesn't provide handlers for CompleteCallbacks w/ more than one
ddorwin 2013/09/17 05:26:46 CompletionC...
DaleCurtis 2013/09/23 18:30:57 Done.
642 // output we need to manage our own. These values are read only by
ddorwin 2013/09/17 05:26:46 nit: since this order could be ambiguous, swap rea
DaleCurtis 2013/09/23 18:30:57 Done.
643 // SendPlatformChallengeDone().
644 // TODO(dalecurtis): CompletionCallbackFactory mentions this may not be safe
645 // since the module could be destructed before callbacks complete... True?
dmichael (off chromium) 2013/09/17 20:10:46 Can you point me to the comment you saw that indic
DaleCurtis 2013/09/17 20:18:51 https://code.google.com/p/chromium/codesearch#chro
dmichael (off chromium) 2013/09/17 20:36:58 Ah, thanks. This stuff is confusing, and I still f
DaleCurtis 2013/09/23 18:30:57 Thanks for the explanation. Comment removed.
646 pp::Var signed_data_output_;
647 pp::Var signed_data_signature_output_;
648 pp::Var platform_key_certificate_output_;
649 #endif
650
608 PpbBufferAllocator allocator_; 651 PpbBufferAllocator allocator_;
609 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; 652 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_;
610 cdm::ContentDecryptionModule* cdm_; 653 cdm::ContentDecryptionModule* cdm_;
Rintaro Kuroiwa 2013/09/20 01:55:06 When OS_CHROMEOS is defined, this will error at 12
DaleCurtis 2013/09/23 18:30:57 Yeah I have another change to the CDM.h that switc
611 std::string key_system_; 654 std::string key_system_;
655 bool can_challenge_platform_;
ddorwin 2013/09/17 05:26:46 We don't really need this other than OS_CHROMEOS.
DaleCurtis 2013/09/23 18:30:57 Done.
612 656
613 DISALLOW_COPY_AND_ASSIGN(CdmWrapper); 657 DISALLOW_COPY_AND_ASSIGN(CdmWrapper);
614 }; 658 };
615 659
616 CdmWrapper::CdmWrapper(PP_Instance instance, pp::Module* module) 660 CdmWrapper::CdmWrapper(PP_Instance instance, pp::Module* module)
617 : pp::Instance(instance), 661 : pp::Instance(instance),
618 pp::ContentDecryptor_Private(this), 662 pp::ContentDecryptor_Private(this),
663 #if defined(OS_CHROMEOS)
664 platform_verification_(this),
665 is_can_challenge_platform_set_(false),
666 #endif
619 allocator_(this), 667 allocator_(this),
620 cdm_(NULL) { 668 cdm_(NULL),
669 can_challenge_platform_(false) {
621 callback_factory_.Initialize(this); 670 callback_factory_.Initialize(this);
671 #if defined(OS_CHROMEOS)
672 // Preemptively retrieve the platform challenge status. It will not change.
673 platform_verification_.CanChallengePlatform(
ddorwin 2013/09/17 05:26:46 Re-entrancy from an Instance constructor seems lik
DaleCurtis 2013/09/17 18:49:33 Hmm, it will end up as a post anyways when the IPC
dmichael (off chromium) 2013/09/17 20:10:46 I'm not sure what re-entrancy you're worried about
ddorwin 2013/09/17 23:24:39 I was just worried about re-entrancy when we're in
674 callback_factory_.NewCallbackWithOutput(
675 &CdmWrapper::CanChallengePlatformDone));
676 #endif
622 } 677 }
623 678
624 CdmWrapper::~CdmWrapper() { 679 CdmWrapper::~CdmWrapper() {
625 if (cdm_) 680 if (cdm_)
626 cdm_->Destroy(); 681 cdm_->Destroy();
627 } 682 }
628 683
629 bool CdmWrapper::CreateCdmInstance(const std::string& key_system) { 684 bool CdmWrapper::CreateCdmInstance(const std::string& key_system) {
630 PP_DCHECK(!cdm_); 685 PP_DCHECK(!cdm_);
631 cdm_ = static_cast<cdm::ContentDecryptionModule*>( 686 cdm_ = static_cast<cdm::ContentDecryptionModule*>(
Rintaro Kuroiwa 2013/09/20 01:55:06 How are we going to make cdm_ be an instance of CD
DaleCurtis 2013/09/23 18:30:57 It'll be the default. v1 CDM won't call into meth
632 ::CreateCdmInstance(cdm::kCdmInterfaceVersion, 687 ::CreateCdmInstance(cdm::kCdmInterfaceVersion,
633 key_system.data(), key_system.size(), 688 key_system.data(), key_system.size(),
634 GetCdmHost, this)); 689 GetCdmHost, this));
635 690
636 return (cdm_ != NULL); 691 return (cdm_ != NULL);
637 } 692 }
638 693
639 void CdmWrapper::GenerateKeyRequest(const std::string& key_system, 694 void CdmWrapper::GenerateKeyRequest(const std::string& key_system,
640 const std::string& type, 695 const std::string& type,
641 pp::VarArrayBuffer init_data) { 696 pp::VarArrayBuffer init_data) {
642 PP_DCHECK(!key_system.empty()); 697 PP_DCHECK(!key_system.empty());
643 PP_DCHECK(key_system_.empty() || key_system_ == key_system); 698 PP_DCHECK(key_system_.empty() || key_system_ == key_system);
644 699
645 #if defined(CHECK_DOCUMENT_URL) 700 #if defined(CHECK_DOCUMENT_URL)
646 PP_URLComponents_Dev url_components = {}; 701 PP_URLComponents_Dev url_components = {};
647 pp::Var href = pp::URLUtil_Dev::Get()->GetDocumentURL( 702 pp::Var href = pp::URLUtil_Dev::Get()->GetDocumentURL(
648 pp::InstanceHandle(pp_instance()), &url_components); 703 pp::InstanceHandle(pp_instance()), &url_components);
649 PP_DCHECK(href.is_string()); 704 PP_DCHECK(href.is_string());
650 PP_DCHECK(!href.AsString().empty()); 705 PP_DCHECK(!href.AsString().empty());
651 PP_DCHECK(url_components.host.begin); 706 PP_DCHECK(url_components.host.begin);
652 PP_DCHECK(0 < url_components.host.len); 707 PP_DCHECK(0 < url_components.host.len);
653 #endif // defined(CHECK_DOCUMENT_URL) 708 #endif // defined(CHECK_DOCUMENT_URL)
654 709
710 #if defined(OS_CHROMEOS)
711 // Ensure CanChallengePlatform() has valid data before initializing the CDM;
712 // delaying the GenerateKeyRequest if necessary.
713 if (!is_can_challenge_platform_set_) {
714 delayed_gkr_ = callback_factory_.NewCallback(
ddorwin 2013/09/17 05:26:46 What if you get multiple GKRs at the same time?
DaleCurtis 2013/09/17 18:49:33 Ugh, I didn't realize that was a thing. To handle
DaleCurtis 2013/09/23 18:30:57 Yeah, delay isn't going to work. I've instead cha
715 &CdmWrapper::DelayedGenerateKeyRequest, key_system, type, init_data);
716 return;
717 }
718 #endif
719
655 if (!cdm_) { 720 if (!cdm_) {
656 if (!CreateCdmInstance(key_system)) { 721 if (!CreateCdmInstance(key_system)) {
657 SendUnknownKeyError(key_system, std::string()); 722 SendUnknownKeyError(key_system, std::string());
658 return; 723 return;
659 } 724 }
660 } 725 }
661 PP_DCHECK(cdm_); 726 PP_DCHECK(cdm_);
662 727
663 // Must be set here in case the CDM synchronously calls a cdm::Host method. 728 // Must be set here in case the CDM synchronously calls a cdm::Host method.
664 // Clear below on error. 729 // Clear below on error.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 int32_t session_id_length, 996 int32_t session_id_length,
932 cdm::MediaKeyError error_code, 997 cdm::MediaKeyError error_code,
933 uint32_t system_code) { 998 uint32_t system_code) {
934 SendKeyErrorInternal(key_system_, 999 SendKeyErrorInternal(key_system_,
935 std::string(session_id, session_id_length), 1000 std::string(session_id, session_id_length),
936 error_code, 1001 error_code,
937 system_code); 1002 system_code);
938 } 1003 }
939 1004
940 void CdmWrapper::GetPrivateData(int32_t* instance, 1005 void CdmWrapper::GetPrivateData(int32_t* instance,
941 cdm::Host::GetPrivateInterface* get_interface) { 1006 GetPrivateInterface* get_interface) {
942 *instance = pp_instance(); 1007 *instance = pp_instance();
943 *get_interface = pp::Module::Get()->get_browser_interface(); 1008 *get_interface = pp::Module::Get()->get_browser_interface();
944 } 1009 }
945 1010
946 void CdmWrapper::SendUnknownKeyError(const std::string& key_system, 1011 void CdmWrapper::SendUnknownKeyError(const std::string& key_system,
947 const std::string& session_id) { 1012 const std::string& session_id) {
948 SendKeyErrorInternal(key_system, session_id, cdm::kUnknownError, 0); 1013 SendKeyErrorInternal(key_system, session_id, cdm::kUnknownError, 0);
949 } 1014 }
950 1015
951 void CdmWrapper::SendKeyAdded(const std::string& key_system, 1016 void CdmWrapper::SendKeyAdded(const std::string& key_system,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 static_cast<cdm::VideoFrame::VideoPlane>(i); 1215 static_cast<cdm::VideoFrame::VideoPlane>(i);
1151 if (ppb_buffer->Size() < video_frame->PlaneOffset(plane) + 1216 if (ppb_buffer->Size() < video_frame->PlaneOffset(plane) +
1152 plane_height * video_frame->Stride(plane)) { 1217 plane_height * video_frame->Stride(plane)) {
1153 return false; 1218 return false;
1154 } 1219 }
1155 } 1220 }
1156 1221
1157 return true; 1222 return true;
1158 } 1223 }
1159 1224
1225 bool CdmWrapper::CanChallengePlatform() {
1226 return can_challenge_platform_;
1227 }
1228
1229 void CdmWrapper::SendPlatformChallenge(
1230 const char* service_id, int32_t service_id_length,
1231 const char* challenge, int32_t challenge_length) {
1232 #if defined(OS_CHROMEOS)
1233 // TODO(dalecurtis): Reinitialize member variables to PP_Undefined?
1234
1235 pp::VarArrayBuffer challenge_var(challenge_length);
1236 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map());
1237 memcpy(var_data, challenge, challenge_length);
1238
1239 std::string service_id_str(service_id, service_id_length);
1240 int32_t result = platform_verification_.ChallengePlatform(
1241 pp::Var(service_id_str), challenge_var, &signed_data_output_,
1242 &signed_data_signature_output_, &platform_key_certificate_output_,
ddorwin 2013/09/17 05:26:46 Why are these passed as pointers? Aren't all pp::V
DaleCurtis 2013/09/17 18:49:33 [out] type variables end up as Var* per the PPAPI
dmichael (off chromium) 2013/09/17 20:10:46 ddorwin: I'm not sure what you mean... we try to
1243 callback_factory_.NewCallback(&CdmWrapper::SendPlatformChallengeDone));
1244 challenge_var.Unmap();
1245 #else
1246 PlatformChallengeResponse pcr = {};
ddorwin 2013/09/17 05:26:46 suggest: s/pcr/response/
DaleCurtis 2013/09/23 18:30:57 Done.
1247 cdm_->OnPlatformChallengeResponse(pcr);
1248 #endif
1249 }
1250
1251 #if defined(OS_CHROMEOS)
1252 void CdmWrapper::CanChallengePlatformDone(int32_t result,
1253 bool can_challenge_platform) {
1254 PP_DCHECK(!is_can_challenge_platform_set_);
1255 can_challenge_platform_ = (result == PP_OK) ? can_challenge_platform : false;
1256 is_can_challenge_platform_set_ = true;
1257 if (!delayed_gkr_.IsOptional())
ddorwin 2013/09/17 05:26:46 ? Is the gkr ever optional?
DaleCurtis 2013/09/17 18:49:33 I'm just using it to check if the callback is unin
DaleCurtis 2013/09/23 18:30:57 Removed since now I can just store the key system.
1258 delayed_gkr_.RunAndClear(PP_OK);
1259 }
1260
1261 void CdmWrapper::SendPlatformChallengeDone(int32_t result) {
1262 if (result != PP_OK) {
1263 cdm::PlatformChallengeResponse pcr = {};
ddorwin 2013/09/17 05:26:46 same
DaleCurtis 2013/09/23 18:30:57 Done.
1264 cdm_->OnPlatformChallengeResponse(pcr);
1265 return;
1266 }
1267
1268 pp::VarArrayBuffer signed_data_var(signed_data_output_);
1269 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_);
dmichael (off chromium) 2013/09/17 20:10:46 signed_data_output_ = pp::Var(); signed_data_signa
DaleCurtis 2013/09/23 18:30:57 Done.
1270 std::string pkc_string = platform_key_certificate_output_.AsString();
ddorwin 2013/09/17 05:26:46 nit: "pkc" is not descriptive
DaleCurtis 2013/09/23 18:30:57 Done.
1271
1272 cdm::PlatformChallengeResponse pcr = {
1273 static_cast<uint8_t*>(signed_data_var.Map()),
1274 signed_data_var.ByteLength(),
1275
1276 static_cast<uint8_t*>(signed_data_signature_var.Map()),
1277 signed_data_signature_var.ByteLength(),
1278
1279 reinterpret_cast<const uint8_t*>(pkc_string.c_str()),
dmichael (off chromium) 2013/09/17 20:10:46 static_cast?
DaleCurtis 2013/09/17 20:18:51 Requires reinterpret_cast for char* -> uint8_t*
Rintaro Kuroiwa 2013/09/20 01:55:06 Also need const_cast. The struct needs a non-const
DaleCurtis 2013/09/23 18:30:57 I have another patch which makes these fields cons
1280 pkc_string.length()
1281 };
1282 cdm_->OnPlatformChallengeResponse(pcr);
1283
1284 signed_data_var.Unmap();
1285 signed_data_signature_var.Unmap();
1286 }
1287
1288 void CdmWrapper::DelayedGenerateKeyRequest(int32_t result,
ddorwin 2013/09/17 05:26:46 nit: The function name is a noun not an action
DaleCurtis 2013/09/23 18:30:57 Removed.
1289 const std::string& key_system,
1290 const std::string& type,
1291 pp::VarArrayBuffer init_data) {
dmichael (off chromium) 2013/09/17 20:10:46 It's probably best to pass Var by const-reference,
DaleCurtis 2013/09/23 18:30:57 Removed.
1292 GenerateKeyRequest(key_system, type, init_data);
1293 }
1294 #endif
1295
1296 void CdmWrapper::EnableOutputProtection(uint32_t desired_protection_mask) {
1297 // TODO(dalecurtis): Add implementation once PPAPI has landed.
1298 cdm_->OnQueryOutputProtectionStatus(0, 0);
1299 }
1300
1301 void CdmWrapper::QueryOutputProtectionStatus() {
1302 // TODO(dalecurtis): Add implementation once PPAPI has landed.
1303 cdm_->OnQueryOutputProtectionStatus(0, 0);
1304 }
1305
1160 void* GetCdmHost(int host_interface_version, void* user_data) { 1306 void* GetCdmHost(int host_interface_version, void* user_data) {
1161 if (!host_interface_version || !user_data) 1307 if (!host_interface_version || !user_data)
1162 return NULL; 1308 return NULL;
1163 1309
1164 if (host_interface_version != cdm::kHostInterfaceVersion) 1310 switch (host_interface_version) {
1165 return NULL; 1311 case cdm::kHostInterfaceVersion_1:
1166 1312 return static_cast<cdm::Host_1*>(static_cast<CdmWrapper*>(user_data));
ddorwin 2013/09/17 05:26:46 tiny optional suggestion: It's an extra line but m
DaleCurtis 2013/09/23 18:30:57 Done.
1167 CdmWrapper* cdm_wrapper = static_cast<CdmWrapper*>(user_data); 1313 case cdm::kHostInterfaceVersion_2:
1168 return static_cast<cdm::Host*>(cdm_wrapper); 1314 return static_cast<cdm::Host_2*>(static_cast<CdmWrapper*>(user_data));
1315 default:
1316 return NULL;
ddorwin 2013/09/17 05:26:46 NOTREACHED()
DaleCurtis 2013/09/23 18:30:57 Done.
1317 }
1169 } 1318 }
1170 1319
1171 // This object is the global object representing this plugin library as long 1320 // This object is the global object representing this plugin library as long
1172 // as it is loaded. 1321 // as it is loaded.
1173 class CdmWrapperModule : public pp::Module { 1322 class CdmWrapperModule : public pp::Module {
1174 public: 1323 public:
1175 CdmWrapperModule() : pp::Module() { 1324 CdmWrapperModule() : pp::Module() {
1176 // This function blocks the renderer thread (PluginInstance::Initialize()). 1325 // This function blocks the renderer thread (PluginInstance::Initialize()).
1177 // Move this call to other places if this may be a concern in the future. 1326 // Move this call to other places if this may be a concern in the future.
1178 INITIALIZE_CDM_MODULE(); 1327 INITIALIZE_CDM_MODULE();
(...skipping 10 matching lines...) Expand all
1189 } // namespace media 1338 } // namespace media
1190 1339
1191 namespace pp { 1340 namespace pp {
1192 1341
1193 // Factory function for your specialization of the Module object. 1342 // Factory function for your specialization of the Module object.
1194 Module* CreateModule() { 1343 Module* CreateModule() {
1195 return new media::CdmWrapperModule(); 1344 return new media::CdmWrapperModule();
1196 } 1345 }
1197 1346
1198 } // namespace pp 1347 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | media/cdm/ppapi/clear_key_cdm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698