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

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: Refactored... quite a bit. Sorry for rebase noise on top of everything else! 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..46ad2264bc6674c98af28d17096b5bb8ae3f2dff 100644
--- a/webkit/media/crypto/ppapi/clear_key_cdm.cc
+++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc
@@ -19,7 +19,7 @@ static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom(
media::DecoderBuffer::CopyFrom(input_buffer.data, input_buffer.data_size);
ddorwin 2012/09/07 09:48:48 We'll want to avoid this copy too. Should .data be
Tom Finegan 2012/09/08 01:02:47 Done, added TODO.
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 +63,8 @@ static Type* AllocateAndCopy(const Type* data, int size) {
return copy;
}
-cdm::ContentDecryptionModule* CreateCdmInstance() {
- return new webkit_media::ClearKeyCdm();
+cdm::ContentDecryptionModule* CreateCdmInstance(cdm::CdmAllocator* allocator) {
+ return new webkit_media::ClearKeyCdm(allocator);
}
void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) {
@@ -124,7 +124,14 @@ void ClearKeyCdm::Client::NeedKey(const std::string& key_system,
NOTREACHED();
}
-ClearKeyCdm::ClearKeyCdm() : decryptor_(&client_) {}
+ClearKeyCdm::ClearKeyCdm() : decryptor_(&client_), allocator_(NULL) {
+ NOTREACHED();
ddorwin 2012/09/07 09:48:48 Why does this constructor exist? If you don't decl
Tom Finegan 2012/09/08 01:02:47 Removed.
+}
+
+ClearKeyCdm::ClearKeyCdm(cdm::CdmAllocator* allocator)
+ : decryptor_(&client_), allocator_(allocator) {
+ DCHECK(allocator_);
+}
ClearKeyCdm::~ClearKeyCdm() {}
@@ -143,9 +150,13 @@ cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data,
key_request->session_id = AllocateAndCopy(client_.session_id().data(),
client_.session_id().size());
key_request->session_id_size = client_.session_id().size();
+
+ // TODO(tomfinegan): Replace this |AllocateAndCopy()|. |message| should be
+ // a CdmBuffer, not a raw pointer.
key_request->message = AllocateAndCopy(client_.key_message(),
- client_.key_message_length());
+ 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();
@@ -210,8 +221,19 @@ 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;
+
+ const cdm::CdmBuffer& cdm_buffer = allocator_->Allocate(data_size);
+ DCHECK(cdm_buffer.buffer());
ddorwin 2012/09/07 09:48:48 This can fail, so you should check and return an e
Tom Finegan 2012/09/08 01:02:47 Done-- also removed the DCHECKs, since they seem l
+ DCHECK_EQ(data_size, cdm_buffer.size());
+ decrypted_buffer->buffer_id = cdm_buffer.id();
ddorwin 2012/09/07 09:48:48 After addressing comment in CDM.h, just copy the C
Tom Finegan 2012/09/08 01:02:47 Done, but it's just a pointer assignment.
+ decrypted_buffer->data = cdm_buffer.buffer();
+
+ // TODO(tomfinegan): Write a CopyDecoderBufferFrom that has a target buffer
ddorwin 2012/09/07 09:48:48 I don't understand this comment. What you really n
Tom Finegan 2012/09/08 01:02:47 Fixed TODO.
+ // argument, and get rid of this memcpy.
+ 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