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

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: Fix compile error... not sure what code MSVC was using... ;) Created 8 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
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 94addb4d73bde1a4789b51767f3613e3376793bc..b4b0589f67b8b54c1af9ccbf8160a47df916eaf8 100644
--- a/webkit/media/crypto/ppapi/clear_key_cdm.cc
+++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc
@@ -15,11 +15,12 @@ static const char kClearKeyCdmVersion[] = "0.1.0.0";
static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom(
const cdm::InputBuffer& input_buffer) {
+ // TODO(tomfinegan): Get rid of this copy.
scoped_refptr<media::DecoderBuffer> output_buffer =
media::DecoderBuffer::CopyFrom(input_buffer.data, input_buffer.data_size);
std::vector<media::SubsampleEntry> subsamples;
- for (uint32_t i = 0; i < input_buffer.num_subsamples; ++i) {
+ for (int32_t i = 0; i < input_buffer.num_subsamples; ++i) {
media::SubsampleEntry subsample;
subsample.clear_bytes = input_buffer.subsamples[i].clear_bytes;
subsample.cypher_bytes = input_buffer.subsamples[i].cipher_bytes;
@@ -63,8 +64,8 @@ static Type* AllocateAndCopy(const Type* data, int size) {
return copy;
}
-cdm::ContentDecryptionModule* CreateCdmInstance() {
- return new webkit_media::ClearKeyCdm();
+cdm::ContentDecryptionModule* CreateCdmInstance(cdm::Allocator* allocator) {
+ return new webkit_media::ClearKeyCdm(allocator);
}
void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) {
@@ -124,7 +125,10 @@ void ClearKeyCdm::Client::NeedKey(const std::string& key_system,
NOTREACHED();
}
-ClearKeyCdm::ClearKeyCdm() : decryptor_(&client_) {}
+ClearKeyCdm::ClearKeyCdm(cdm::Allocator* allocator)
+ : decryptor_(&client_), allocator_(allocator) {
+ DCHECK(allocator_);
+}
ClearKeyCdm::~ClearKeyCdm() {}
@@ -140,15 +144,20 @@ cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data,
return cdm::kError;
DCHECK(key_request);
- key_request->session_id = AllocateAndCopy(client_.session_id().data(),
- client_.session_id().size());
- key_request->session_id_size = client_.session_id().size();
- key_request->message = AllocateAndCopy(client_.key_message(),
- client_.key_message_length());
- key_request->message_size = client_.key_message_length();
- key_request->default_url = AllocateAndCopy(client_.default_url().data(),
- client_.default_url().size());
- key_request->default_url_size = client_.default_url().size();
+ key_request->set_session_id(client_.session_id().data(),
+ client_.session_id().size());
+
+ // TODO(tomfinegan): Get rid of this copy.
+ key_request->set_message(allocator_->Allocate(client_.key_message_length()));
+
+ DCHECK(key_request->message());
+ DCHECK_EQ(key_request->message()->size(), client_.key_message_length());
+ memcpy(reinterpret_cast<void*>(key_request->message()->buffer()),
+ reinterpret_cast<const void*>(client_.key_message()),
+ client_.key_message_length());
+
+ key_request->set_default_url(client_.default_url().data(),
+ client_.default_url().size());
return cdm::kSuccess;
}
@@ -210,9 +219,13 @@ 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->timestamp = buffer->GetTimestamp().InMicroseconds();
+
+ decrypted_buffer->set_buffer(allocator_->Allocate(data_size));
+ memcpy(reinterpret_cast<void*>(decrypted_buffer->buffer()->buffer()),
+ buffer->GetData(),
+ data_size);
+
+ decrypted_buffer->set_timestamp(buffer->GetTimestamp().InMicroseconds());
return cdm::kSuccess;
}

Powered by Google App Engine
This is Rietveld 408576698