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

Unified Diff: webkit/media/crypto/ppapi/clear_key_cdm.cc

Issue 10914028: Add CDM allocator interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: It works, and this removes a copy in Decrypt/DeliverBlock. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: webkit/media/crypto/ppapi/clear_key_cdm.cc
diff --git a/webkit/media/crypto/ppapi/clear_key_cdm.cc b/webkit/media/crypto/ppapi/clear_key_cdm.cc
index 835d06258a28020d9ae7612b75ed15c63a2293a9..8d935d6fcd22fea40ede62050395514b48625c7d 100644
--- a/webkit/media/crypto/ppapi/clear_key_cdm.cc
+++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/time.h"
#include "media/base/decoder_buffer.h"
+#include "webkit/media/crypto/ppapi/cdm_allocator.h"
static const char kClearKeyCdmVersion[] = "0.1.0.0";
@@ -124,10 +125,18 @@ void ClearKeyCdm::Client::NeedKey(const std::string& key_system,
NOTREACHED();
}
-ClearKeyCdm::ClearKeyCdm() : decryptor_(&client_) {}
+ClearKeyCdm::ClearKeyCdm() : decryptor_(&client_), allocator_iface_(NULL) {}
ClearKeyCdm::~ClearKeyCdm() {}
+bool ClearKeyCdm::Initialize(CdmAllocatorInterface* allocator) {
+ if (!allocator) {
+ return false;
+ }
+ allocator_iface_ = allocator;
+ return true;
+}
+
cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data,
int init_data_size,
cdm::KeyMessage* key_request) {
@@ -210,8 +219,14 @@ cdm::Status ClearKeyCdm::Decrypt(
DCHECK(buffer);
int data_size = buffer->GetDataSize();
- decrypted_buffer->data = AllocateAndCopy(buffer->GetData(), data_size);
- decrypted_buffer->data_size = data_size;
+
+ decrypted_buffer->data =
+ allocator_iface_->Allocate(data_size,
+ &decrypted_buffer->buffer_id);
+ memcpy(reinterpret_cast<void*>(decrypted_buffer->data),
+ buffer->GetData(),
+ data_size);
+
decrypted_buffer->timestamp = buffer->GetTimestamp().InMicroseconds();
return cdm::kSuccess;
}

Powered by Google App Engine
This is Rietveld 408576698