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

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: Some iteratative work plus work related to xhwang's comments. 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..f02054e43de06585bcd1e69593071b938ae70368 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(CdmAllocator* allocator) {
ddorwin 2012/09/04 09:53:15 Is there a reason we can't do this in the construc
Tom Finegan 2012/09/07 00:46:36 Nope, done. Also, I made the default constructor p
+ if (!allocator) {
ddorwin 2012/09/04 09:53:15 Seems like a DCHECK. And can remove return type (o
Tom Finegan 2012/09/07 00:46:36 Moved to constructor, and I put a DCHECK there.
+ 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),
ddorwin 2012/09/04 09:53:15 Copy = boo! Maybe a TODO to make CopyDecoderBuffer
Tom Finegan 2012/09/07 00:46:36 TODO added.
+ buffer->GetData(),
+ data_size);
+
decrypted_buffer->timestamp = buffer->GetTimestamp().InMicroseconds();
return cdm::kSuccess;
}

Powered by Google App Engine
This is Rietveld 408576698