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

Unified Diff: webkit/media/crypto/ppapi_decryptor.cc

Issue 10704241: Add PpapiDecryptor which wraps a CDM plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add webkit bug in comments. Created 8 years, 5 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 | « webkit/media/crypto/ppapi_decryptor.h ('k') | webkit/media/crypto/proxy_decryptor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/crypto/ppapi_decryptor.cc
diff --git a/webkit/media/crypto/ppapi_decryptor.cc b/webkit/media/crypto/ppapi_decryptor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..22970559536de607f09e8d61cfdcd1df4ae18b80
--- /dev/null
+++ b/webkit/media/crypto/ppapi_decryptor.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/media/crypto/ppapi_decryptor.h"
+
+#include "base/logging.h"
+#include "media/base/decoder_buffer.h"
+#include "media/base/decryptor_client.h"
+#include "webkit/media/crypto/key_systems.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+
+namespace webkit_media {
+
+PpapiDecryptor::PpapiDecryptor(
+ media::DecryptorClient* client,
+ const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance)
+ : client_(client),
+ cdm_plugin_(plugin_instance) {
+}
+
+PpapiDecryptor::~PpapiDecryptor() {
+}
+
+void PpapiDecryptor::GenerateKeyRequest(const std::string& key_system,
+ const uint8* init_data,
+ int init_data_length) {
+ DCHECK(cdm_plugin_);
+ // TODO(xhwang): Enable the following once we have updated PluginInstance.
+ // if (!cdm_plugin_->GenerateKeyRequest(key_system,
+ // init_data, init_data_length)) {
+ // client_->KeyError(key_system, "", media::Decryptor::kUnknownError, 0);
+ // }
+}
+
+void PpapiDecryptor::AddKey(const std::string& key_system,
+ const uint8* key,
+ int key_length,
+ const uint8* init_data,
+ int init_data_length,
+ const std::string& session_id) {
+ DCHECK(cdm_plugin_);
+ // TODO(xhwang): Enable the following once we have updated PluginInstance.
+ // if (!cdm_plugin_->AddKey(key_system, key, key_length,
+ // init_data, init_data_length, session_id)) {
+ // client_->KeyError(key_system, session_id, Decryptor::kUnknownError, 0);
+ // }
+}
+
+void PpapiDecryptor::CancelKeyRequest(const std::string& key_system,
+ const std::string& session_id) {
+ DCHECK(cdm_plugin_);
+ // TODO(xhwang): Enable the following once we have updated PluginInstance.
+ // if (!cdm_plugin_->CancelKeyRequest(key_system, session_id))
+ // client_->KeyError(key_system, session_id, Decryptor::kUnknownError, 0);
+}
+
+void PpapiDecryptor::Decrypt(
+ const scoped_refptr<media::DecoderBuffer>& encrypted,
+ const DecryptCB& decrypt_cb) {
+ DCHECK(cdm_plugin_);
+ // TODO(xhwang): Enable the following once we have updated PluginInstance.
+ // TODO(xhwang): Need to figure out thread safety about PPP calls.
+ // if (!cdm_plugin_->Decrypt(
+ // encrypted, base::Bind(&PpapiDecryptor::DataReady, this, decrypt_cb))) {
+ // decrypt_cb.Run(kError, NULL);
+ // }
+}
+
+void PpapiDecryptor::DataReady(const DecryptCB& decrypt_cb,
+ const uint8* data, int data_size ) {
+ DCHECK(!decrypt_cb.is_null());
+ scoped_refptr<media::DecoderBuffer> decrypted_data =
+ media::DecoderBuffer::CopyFrom(data, data_size);
+ decrypt_cb.Run(kSuccess, decrypted_data);
+}
+
+} // namespace webkit_media
« no previous file with comments | « webkit/media/crypto/ppapi_decryptor.h ('k') | webkit/media/crypto/proxy_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698