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

Unified 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: Remove delayed requests. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/cdm/ppapi/clear_key_cdm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/ppapi/cdm_wrapper.cc
diff --git a/media/cdm/ppapi/cdm_wrapper.cc b/media/cdm/ppapi/cdm_wrapper.cc
index 66ae43d4d65917ab4ac609a75ef5fc70f986db19..375d8e082683f118b8a908c523793e0ccc6c76b5 100644
--- a/media/cdm/ppapi/cdm_wrapper.cc
+++ b/media/cdm/ppapi/cdm_wrapper.cc
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "build/build_config.h"
#include "media/cdm/ppapi/api/content_decryption_module.h"
#include "media/cdm/ppapi/linked_ptr.h"
#include "ppapi/c/pp_errors.h"
@@ -33,6 +34,10 @@
#include "ppapi/cpp/instance_handle.h"
#endif // defined(CHECK_DOCUMENT_URL)
+#if defined(OS_CHROMEOS)
+#include "ppapi/cpp/private/platform_verification.h"
+#endif
+
namespace {
bool IsMainThread() {
@@ -485,7 +490,8 @@ void* GetCdmHost(int host_interface_version, void* user_data);
// Content Decryption Module (CDM).
class CdmWrapper : public pp::Instance,
public pp::ContentDecryptor_Private,
- public cdm::Host {
+ public cdm::Host_1,
+ public cdm::Host_2 {
public:
CdmWrapper(PP_Instance instance, pp::Module* module);
virtual ~CdmWrapper();
@@ -524,7 +530,7 @@ class CdmWrapper : public pp::Instance,
pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
- // cdm::Host implementation.
+ // cdm::Host_1 implementation.
virtual cdm::Buffer* Allocate(int32_t capacity) OVERRIDE;
virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE;
virtual double GetCurrentWallTimeInSeconds() OVERRIDE;
@@ -539,6 +545,14 @@ class CdmWrapper : public pp::Instance,
virtual void GetPrivateData(int32_t* instance,
GetPrivateInterface* get_interface) OVERRIDE;
+ // cdm::Host_2 implementation.
+ virtual void SendPlatformChallenge(
+ const char* service_id, int32_t service_id_length,
+ const char* challenge, int32_t challenge_length) OVERRIDE;
+ virtual void EnableOutputProtection(
+ uint32_t desired_protection_mask) OVERRIDE;
+ virtual void QueryOutputProtectionStatus() OVERRIDE;
+
private:
struct SessionInfo {
SessionInfo(const std::string& key_system_in,
@@ -606,6 +620,27 @@ class CdmWrapper : public pp::Instance,
bool IsValidVideoFrame(const LinkedVideoFrame& video_frame);
+#if defined(OS_CHROMEOS)
+ bool CanChallengePlatform();
+ void CanChallengePlatformDone(int32_t result, bool can_challenge_platform);
+ void SendPlatformChallengeDone(int32_t result);
+
+ pp::PlatformVerification platform_verification_;
+
+ // |can_challenge_platform_| is currently set asynchronously, return the value
+ // if we have it, otherwise guess "true" for the most common case...
+ // TODO(jrummell): This stinks. The value should be delivered via the
+ // Initialize() method once plumbed.
+ bool can_challenge_platform_;
+
+ // Since PPAPI doesn't provide handlers for CompletionCallbacks w/ more than
+ // one output we need to manage our own. These values are only read by
+ // SendPlatformChallengeDone().
+ pp::Var signed_data_output_;
+ pp::Var signed_data_signature_output_;
+ pp::Var platform_key_certificate_output_;
+#endif
+
PpbBufferAllocator allocator_;
pp::CompletionCallbackFactory<CdmWrapper> callback_factory_;
cdm::ContentDecryptionModule* cdm_;
@@ -617,9 +652,20 @@ class CdmWrapper : public pp::Instance,
CdmWrapper::CdmWrapper(PP_Instance instance, pp::Module* module)
: pp::Instance(instance),
pp::ContentDecryptor_Private(this),
+#if defined(OS_CHROMEOS)
+ platform_verification_(this),
+ // Err on the side of the most common case...
+ can_challenge_platform_(true),
+#endif
allocator_(this),
cdm_(NULL) {
callback_factory_.Initialize(this);
+#if defined(OS_CHROMEOS)
+ // Preemptively retrieve the platform challenge status. It will not change.
+ platform_verification_.CanChallengePlatform(
+ callback_factory_.NewCallbackWithOutput(
+ &CdmWrapper::CanChallengePlatformDone));
+#endif
}
CdmWrapper::~CdmWrapper() {
@@ -936,7 +982,7 @@ void CdmWrapper::SendKeyError(const char* session_id,
}
void CdmWrapper::GetPrivateData(int32_t* instance,
- cdm::Host::GetPrivateInterface* get_interface) {
+ GetPrivateInterface* get_interface) {
*instance = pp_instance();
*get_interface = pp::Module::Get()->get_browser_interface();
}
@@ -1155,15 +1201,102 @@ bool CdmWrapper::IsValidVideoFrame(const LinkedVideoFrame& video_frame) {
return true;
}
+bool CdmWrapper::CanChallengePlatform() {
+#if defined(OS_CHROMEOS)
+ return can_challenge_platform_;
+#else
+ return false;
+#endif
+}
+
+void CdmWrapper::SendPlatformChallenge(
+ const char* service_id, int32_t service_id_length,
+ const char* challenge, int32_t challenge_length) {
+#if defined(OS_CHROMEOS)
+ pp::VarArrayBuffer challenge_var(challenge_length);
+ uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map());
+ memcpy(var_data, challenge, challenge_length);
+
+ std::string service_id_str(service_id, service_id_length);
+ int32_t result = platform_verification_.ChallengePlatform(
+ pp::Var(service_id_str), challenge_var, &signed_data_output_,
+ &signed_data_signature_output_, &platform_key_certificate_output_,
+ callback_factory_.NewCallback(&CdmWrapper::SendPlatformChallengeDone));
+ challenge_var.Unmap();
+ if (result == PP_OK_COMPLETIONPENDING)
+ return;
+
+ // Fall through on error and issue an empty OnPlatformChallengeResponse().
ddorwin 2013/09/24 06:19:45 DCHECK != PP_OK?
DaleCurtis 2013/09/24 19:55:54 Done.
+#endif
+
+ cdm::PlatformChallengeResponse response = {};
+ cdm_->OnPlatformChallengeResponse(response);
+}
+
+#if defined(OS_CHROMEOS)
+void CdmWrapper::CanChallengePlatformDone(int32_t result,
+ bool can_challenge_platform) {
+ can_challenge_platform_ = (result == PP_OK) ? can_challenge_platform : false;
+}
+
+void CdmWrapper::SendPlatformChallengeDone(int32_t result) {
+ if (result != PP_OK) {
+ cdm::PlatformChallengeResponse response = {};
+ cdm_->OnPlatformChallengeResponse(response);
+ return;
+ }
+
+ pp::VarArrayBuffer signed_data_var(signed_data_output_);
+ pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_);
+ std::string platform_key_certificate_string =
+ platform_key_certificate_output_.AsString();
+
+ cdm::PlatformChallengeResponse response = {
+ static_cast<uint8_t*>(signed_data_var.Map()),
+ signed_data_var.ByteLength(),
+
+ static_cast<uint8_t*>(signed_data_signature_var.Map()),
+ signed_data_signature_var.ByteLength(),
+
+ reinterpret_cast<const uint8_t*>(platform_key_certificate_string.c_str()),
+ platform_key_certificate_string.length()
+ };
+ cdm_->OnPlatformChallengeResponse(response);
+
+ signed_data_var.Unmap();
+ signed_data_signature_var.Unmap();
+
+ // Reset member variables for future ChallengePlatform() calls.
ddorwin 2013/09/24 06:19:45 Do we rely on the CDM to not call ChallengePlatfor
DaleCurtis 2013/09/24 19:55:54 Good idea. Done. I also realized its messy to acc
+ signed_data_output_ = pp::Var();
+ signed_data_signature_output_ = pp::Var();
+ platform_key_certificate_output_ = pp::Var();
+}
+#endif
+
+void CdmWrapper::EnableOutputProtection(uint32_t desired_protection_mask) {
+ // TODO(dalecurtis): Add implementation once PPAPI has landed.
+ cdm_->OnQueryOutputProtectionStatus(0, 0);
+}
+
+void CdmWrapper::QueryOutputProtectionStatus() {
+ // TODO(dalecurtis): Add implementation once PPAPI has landed.
+ cdm_->OnQueryOutputProtectionStatus(0, 0);
+}
+
void* GetCdmHost(int host_interface_version, void* user_data) {
if (!host_interface_version || !user_data)
return NULL;
- if (host_interface_version != cdm::kHostInterfaceVersion)
- return NULL;
-
CdmWrapper* cdm_wrapper = static_cast<CdmWrapper*>(user_data);
- return static_cast<cdm::Host*>(cdm_wrapper);
+ switch (host_interface_version) {
+ case cdm::kHostInterfaceVersion_1:
+ return static_cast<cdm::Host_1*>(cdm_wrapper);
+ case cdm::kHostInterfaceVersion_2:
+ return static_cast<cdm::Host_2*>(cdm_wrapper);
+ default:
+ PP_NOTREACHED();
+ return NULL;
+ }
}
// This object is the global object representing this plugin library as long
« 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