From 7ed56ede1867409ebfe39f6d3faf150b4554a19d Mon Sep 17 00:00:00 2001 From: "tomfinegan@chromium.org" Date: Tue, 2 Oct 2012 02:43:27 +0000 Subject: Rename cdm::OutputBuffer to DecryptedBlock. The replacement class is an interface, and is implemented in cdm_wrapper. Also renames cdm::Buffer's buffer method to data for clarity at call sites (former name could result in calls like buffer->buffer()->buffer()). BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/11018007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159626 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/media/crypto/ppapi/cdm_wrapper.cc | 94 +++++++++++----------- webkit/media/crypto/ppapi/clear_key_cdm.cc | 10 +-- webkit/media/crypto/ppapi/clear_key_cdm.h | 8 +- .../media/crypto/ppapi/content_decryption_module.h | 40 ++++----- 4 files changed, 76 insertions(+), 76 deletions(-) (limited to 'webkit') diff --git a/webkit/media/crypto/ppapi/cdm_wrapper.cc b/webkit/media/crypto/ppapi/cdm_wrapper.cc index 407335f..a4640e3 100644 --- a/webkit/media/crypto/ppapi/cdm_wrapper.cc +++ b/webkit/media/crypto/ppapi/cdm_wrapper.cc @@ -66,7 +66,7 @@ class PpbBuffer : public cdm::Buffer { // cdm::Buffer methods. virtual void Destroy() OVERRIDE { delete this; } - virtual uint8_t* buffer() OVERRIDE { + virtual uint8_t* data() OVERRIDE { return static_cast(buffer_.data()); } @@ -102,6 +102,24 @@ class PpbBufferAllocator : public cdm::Allocator { DISALLOW_COPY_AND_ASSIGN(PpbBufferAllocator); }; +class DecryptedBlockImpl : public cdm::DecryptedBlock { + public: + DecryptedBlockImpl() : buffer_(NULL), timestamp_(0) {} + virtual ~DecryptedBlockImpl(); + + virtual void set_buffer(cdm::Buffer* buffer) OVERRIDE; + virtual cdm::Buffer* buffer() OVERRIDE; + + virtual void set_timestamp(int64_t timestamp) OVERRIDE; + virtual int64_t timestamp() const OVERRIDE; + + private: + PpbBuffer* buffer_; + int64_t timestamp_; + + DISALLOW_COPY_AND_ASSIGN(DecryptedBlockImpl); +}; + class KeyMessageImpl : public cdm::KeyMessage { public: KeyMessageImpl() : message_(NULL) {} @@ -113,7 +131,7 @@ class KeyMessageImpl : public cdm::KeyMessage { virtual int32_t session_id_length() const OVERRIDE; virtual void set_message(cdm::Buffer* message) OVERRIDE; - virtual cdm::Buffer* message() const OVERRIDE; + virtual cdm::Buffer* message() OVERRIDE; virtual void set_default_url(const char* default_url, int32_t length) OVERRIDE; @@ -131,23 +149,26 @@ class KeyMessageImpl : public cdm::KeyMessage { DISALLOW_COPY_AND_ASSIGN(KeyMessageImpl); }; -class OutputBufferImpl : public cdm::OutputBuffer { - public: - OutputBufferImpl() : buffer_(NULL), timestamp_(0) {} - virtual ~OutputBufferImpl(); +DecryptedBlockImpl::~DecryptedBlockImpl() { + if (buffer_) + buffer_->Destroy(); +} - virtual void set_buffer(cdm::Buffer* buffer) OVERRIDE; - virtual cdm::Buffer* buffer() const OVERRIDE; +void DecryptedBlockImpl::set_buffer(cdm::Buffer* buffer) { + buffer_ = static_cast(buffer); +} - virtual void set_timestamp(int64_t timestamp) OVERRIDE; - virtual int64_t timestamp() const OVERRIDE; +cdm::Buffer* DecryptedBlockImpl::buffer() { + return buffer_; +} - private: - PpbBuffer* buffer_; - int64_t timestamp_; +void DecryptedBlockImpl::set_timestamp(int64_t timestamp) { + timestamp_ = timestamp; +} - DISALLOW_COPY_AND_ASSIGN(OutputBufferImpl); -}; +int64_t DecryptedBlockImpl::timestamp() const { + return timestamp_; +} KeyMessageImpl::~KeyMessageImpl() { if (message_) @@ -170,7 +191,7 @@ void KeyMessageImpl::set_message(cdm::Buffer* buffer) { message_ = static_cast(buffer); } -cdm::Buffer* KeyMessageImpl::message() const { +cdm::Buffer* KeyMessageImpl::message() { return message_; } @@ -186,27 +207,6 @@ int32_t KeyMessageImpl::default_url_length() const { return default_url_.length(); } -OutputBufferImpl::~OutputBufferImpl() { - if (buffer_) - buffer_->Destroy(); -} - -void OutputBufferImpl::set_buffer(cdm::Buffer* buffer) { - buffer_ = static_cast(buffer); -} - -cdm::Buffer* OutputBufferImpl::buffer() const { - return buffer_; -} - -void OutputBufferImpl::set_timestamp(int64_t timestamp) { - timestamp_ = timestamp; -} - -int64_t OutputBufferImpl::timestamp() const { - return timestamp_; -} - // A wrapper class for abstracting away PPAPI interaction and threading for a // Content Decryption Module (CDM). class CdmWrapper : public pp::Instance, @@ -237,8 +237,8 @@ class CdmWrapper : public pp::Instance, const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; private: + typedef linked_ptr LinkedDecryptedBlock; typedef linked_ptr LinkedKeyMessage; - typedef linked_ptr LinkedOutputBuffer; // PPB_ContentDecryptor_Private dispatchers. These are passed to // callback_factory_ to ensure that calls into @@ -248,7 +248,7 @@ class CdmWrapper : public pp::Instance, void KeyError(int32_t result, const std::string& session_id); void DeliverBlock(int32_t result, const cdm::Status& status, - const LinkedOutputBuffer& output_buffer, + const LinkedDecryptedBlock& decrypted_block, const PP_DecryptTrackingInfo& tracking_info); PpbBufferAllocator allocator_; @@ -390,13 +390,13 @@ void CdmWrapper::Decrypt(pp::Buffer_Dev encrypted_buffer, input_buffer.timestamp = encrypted_block_info.tracking_info.timestamp; - LinkedOutputBuffer output_buffer(new OutputBufferImpl()); - cdm::Status status = cdm_->Decrypt(input_buffer, output_buffer.get()); + LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); + cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); CallOnMain(callback_factory_.NewCallback( &CdmWrapper::DeliverBlock, status, - output_buffer, + decrypted_block, encrypted_block_info.tracking_info)); } @@ -431,16 +431,16 @@ void CdmWrapper::KeyError(int32_t result, const std::string& session_id) { void CdmWrapper::DeliverBlock(int32_t result, const cdm::Status& status, - const LinkedOutputBuffer& output_buffer, + const LinkedDecryptedBlock& decrypted_block, const PP_DecryptTrackingInfo& tracking_info) { PP_DecryptedBlockInfo decrypted_block_info; decrypted_block_info.tracking_info.request_id = tracking_info.request_id; - decrypted_block_info.tracking_info.timestamp = output_buffer->timestamp(); + decrypted_block_info.tracking_info.timestamp = decrypted_block->timestamp(); switch (status) { case cdm::kSuccess: decrypted_block_info.result = PP_DECRYPTRESULT_SUCCESS; - PP_DCHECK(output_buffer.get() && output_buffer->buffer()); + PP_DCHECK(decrypted_block.get() && decrypted_block->buffer()); break; case cdm::kNoKey: decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_NOKEY; @@ -452,8 +452,8 @@ void CdmWrapper::DeliverBlock(int32_t result, } const pp::Buffer_Dev& buffer = - output_buffer.get() && output_buffer->buffer() ? - static_cast(output_buffer->buffer())->buffer_dev() : + decrypted_block.get() && decrypted_block->buffer() ? + static_cast(decrypted_block->buffer())->buffer_dev() : pp::Buffer_Dev(); pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); diff --git a/webkit/media/crypto/ppapi/clear_key_cdm.cc b/webkit/media/crypto/ppapi/clear_key_cdm.cc index 74e117c..a70aa6e 100644 --- a/webkit/media/crypto/ppapi/clear_key_cdm.cc +++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc @@ -150,7 +150,7 @@ cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data, DCHECK(key_request->message()); DCHECK_EQ(key_request->message()->size(), client_.key_message_length()); - memcpy(reinterpret_cast(key_request->message()->buffer()), + memcpy(reinterpret_cast(key_request->message()->data()), reinterpret_cast(client_.key_message()), client_.key_message_length()); @@ -197,7 +197,7 @@ static void CopyDecryptResults( cdm::Status ClearKeyCdm::Decrypt( const cdm::InputBuffer& encrypted_buffer, - cdm::OutputBuffer* decrypted_buffer) { + cdm::DecryptedBlock* decrypted_block) { DVLOG(1) << "Decrypt()"; scoped_refptr decoder_buffer = @@ -218,12 +218,12 @@ cdm::Status ClearKeyCdm::Decrypt( DCHECK(buffer); int data_size = buffer->GetDataSize(); - decrypted_buffer->set_buffer(allocator_->Allocate(data_size)); - memcpy(reinterpret_cast(decrypted_buffer->buffer()->buffer()), + decrypted_block->set_buffer(allocator_->Allocate(data_size)); + memcpy(reinterpret_cast(decrypted_block->buffer()->data()), buffer->GetData(), data_size); - decrypted_buffer->set_timestamp(buffer->GetTimestamp().InMicroseconds()); + decrypted_block->set_timestamp(buffer->GetTimestamp().InMicroseconds()); return cdm::kSuccess; } diff --git a/webkit/media/crypto/ppapi/clear_key_cdm.h b/webkit/media/crypto/ppapi/clear_key_cdm.h index 3c71702..2a67741 100644 --- a/webkit/media/crypto/ppapi/clear_key_cdm.h +++ b/webkit/media/crypto/ppapi/clear_key_cdm.h @@ -29,9 +29,9 @@ class ClearKeyCdm : public cdm::ContentDecryptionModule { // ContentDecryptionModule implementation. virtual cdm::Status GenerateKeyRequest( - const uint8_t* init_data, - int init_data_size, - cdm::KeyMessage* key_request) OVERRIDE; + const uint8_t* init_data, + int init_data_size, + cdm::KeyMessage* key_request) OVERRIDE; virtual cdm::Status AddKey(const char* session_id, int session_id_size, const uint8_t* key, @@ -41,7 +41,7 @@ class ClearKeyCdm : public cdm::ContentDecryptionModule { virtual cdm::Status CancelKeyRequest(const char* session_id, int session_id_size) OVERRIDE; virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, - cdm::OutputBuffer* decrypted_buffer) OVERRIDE; + cdm::DecryptedBlock* decrypted_block) OVERRIDE; virtual cdm::Status InitializeVideoDecoder( const cdm::VideoDecoderConfig& video_decoder_config) OVERRIDE; virtual cdm::Status DecryptAndDecodeVideo( diff --git a/webkit/media/crypto/ppapi/content_decryption_module.h b/webkit/media/crypto/ppapi/content_decryption_module.h index 6ff2892..b5227505 100644 --- a/webkit/media/crypto/ppapi/content_decryption_module.h +++ b/webkit/media/crypto/ppapi/content_decryption_module.h @@ -20,8 +20,8 @@ namespace cdm { class Allocator; class Buffer; class ContentDecryptionModule; +class DecryptedBlock; class KeyMessage; -class OutputBuffer; } extern "C" { @@ -226,7 +226,7 @@ class ContentDecryptionModule { // allocated memory over library boundaries. Fix it after related PPAPI change // and sample CDM are landed. virtual Status Decrypt(const InputBuffer& encrypted_buffer, - OutputBuffer* decrypted_buffer) = 0; + DecryptedBlock* decrypted_buffer) = 0; // Initializes the CDM video decoder with |video_decoder_config|. This // function must be called before DecryptAndDecodeVideo() is called. @@ -282,7 +282,7 @@ class Buffer { // Destroys the buffer in the same context as it was created. virtual void Destroy() = 0; - virtual uint8_t* buffer() = 0; + virtual uint8_t* data() = 0; virtual int32_t size() const = 0; protected: @@ -307,6 +307,22 @@ class Allocator { virtual ~Allocator() {} }; +// Represents a decrypted block that has not been decoded. +class DecryptedBlock { + public: + virtual void set_buffer(Buffer* buffer) = 0; + virtual Buffer* buffer() = 0; + + // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not, + // we can just pass Buffer pointers around. + virtual void set_timestamp(int64_t timestamp) = 0; + virtual int64_t timestamp() const = 0; + + protected: + DecryptedBlock() {} + virtual ~DecryptedBlock() {} +}; + // Represents a key message sent by the CDM. class KeyMessage { public: @@ -315,7 +331,7 @@ class KeyMessage { virtual int32_t session_id_length() const = 0; virtual void set_message(Buffer* message) = 0; - virtual Buffer* message() const = 0; + virtual Buffer* message() = 0; virtual void set_default_url(const char* default_url, int32_t length) = 0; virtual const char* default_url() const = 0; @@ -326,22 +342,6 @@ class KeyMessage { virtual ~KeyMessage() {} }; -// Represents an output decrypted buffer. -class OutputBuffer { - public: - virtual void set_buffer(Buffer* buffer) = 0; - virtual Buffer* buffer() const = 0; - - // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not, - // we can just pass Buffer*s around. - virtual void set_timestamp(int64_t timestamp) = 0; - virtual int64_t timestamp() const = 0; - - protected: - OutputBuffer() {} - virtual ~OutputBuffer() {} -}; - } // namespace cdm #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ -- cgit v1.1