Chromium Code Reviews| Index: webkit/media/crypto/ppapi/content_decryption_module.h |
| diff --git a/webkit/media/crypto/ppapi/content_decryption_module.h b/webkit/media/crypto/ppapi/content_decryption_module.h |
| index 0f2244a5618b0c9e9c5e2399eb150a1f99f5ded7..94f28380aad7ebc0bfdd10665da2544c730b6bc2 100644 |
| --- a/webkit/media/crypto/ppapi/content_decryption_module.h |
| +++ b/webkit/media/crypto/ppapi/content_decryption_module.h |
| @@ -17,11 +17,13 @@ typedef __int64 int64_t; |
| #include "webkit/media/crypto/ppapi/cdm_export.h" |
| namespace cdm { |
| +class Allocator; |
| class ContentDecryptionModule; |
| } |
| extern "C" { |
| -CDM_EXPORT cdm::ContentDecryptionModule* CreateCdmInstance(); |
| +CDM_EXPORT cdm::ContentDecryptionModule* CreateCdmInstance( |
| + cdm::Allocator* allocator); |
| CDM_EXPORT void DestroyCdmInstance(cdm::ContentDecryptionModule* instance); |
| CDM_EXPORT const char* GetCdmVersion(); |
| } |
| @@ -37,8 +39,6 @@ enum Status { |
| // Represents a key message sent by the CDM. It does not own any pointers in |
| // this struct. |
| -// TODO(xhwang): Use int32_t instead of uint32_t for sizes here and below and |
| -// update checks to include <0. |
| struct KeyMessage { |
| KeyMessage() |
| : session_id(NULL), |
| @@ -49,11 +49,14 @@ struct KeyMessage { |
| default_url_size(0) {} |
| char* session_id; |
| - uint32_t session_id_size; |
| + int32_t session_id_size; |
| + |
| + // TODO(tomfinegan): Replace |message| and |message_size| with a CdmBuffer. |
| uint8_t* message; |
| - uint32_t message_size; |
| + int32_t message_size; |
| + |
| char* default_url; |
| - uint32_t default_url_size; |
| + int32_t default_url_size; |
| }; |
| // An input buffer can be split into several continuous subsamples. |
| @@ -86,6 +89,21 @@ struct SubsampleEntry { |
| uint32_t cipher_bytes; |
| }; |
| +// Encapsulates all data required to interact with buffers allocated by |
| +// Allocator implementations. Note that the buffer described by this object is |
| +// not freed when the object is destroyed. |
| +class Buffer { |
| + public: |
| + Buffer() {} |
|
ddorwin
2012/09/12 23:53:01
Do we need this? It can't be constructed because i
Tom Finegan
2012/09/13 10:33:40
Need it to construct PpbCdmBuffer, but I made it p
|
| + virtual ~Buffer() {} |
| + virtual uint8_t* buffer() const = 0; |
| + virtual int32_t size() const = 0; |
| + |
| + private: |
| + Buffer(const Buffer&); |
| + void operator=(const Buffer&); |
| +}; |
| + |
| // Represents an input buffer to be decrypted (and possibly decoded). It does |
| // own any pointers in this struct. |
| struct InputBuffer { |
| @@ -104,21 +122,21 @@ struct InputBuffer { |
| timestamp(0) {} |
| const uint8_t* data; // Pointer to the beginning of the input data. |
| - uint32_t data_size; // Size (in bytes) of |data|. |
| + int32_t data_size; // Size (in bytes) of |data|. |
| - uint32_t data_offset; // Number of bytes to be discarded before decryption. |
| + int32_t data_offset; // Number of bytes to be discarded before decryption. |
| const uint8_t* key_id; // Key ID to identify the decryption key. |
| - uint32_t key_id_size; // Size (in bytes) of |key_id|. |
| + int32_t key_id_size; // Size (in bytes) of |key_id|. |
| const uint8_t* iv; // Initialization vector. |
| - uint32_t iv_size; // Size (in bytes) of |iv|. |
| + int32_t iv_size; // Size (in bytes) of |iv|. |
| const uint8_t* checksum; |
| - uint32_t checksum_size; // Size (in bytes) of the |checksum|. |
| + int32_t checksum_size; // Size (in bytes) of the |checksum|. |
| const struct SubsampleEntry* subsamples; |
| - uint32_t num_subsamples; // Number of subsamples in |subsamples|. |
| + int32_t num_subsamples; // Number of subsamples in |subsamples|. |
| int64_t timestamp; // Presentation timestamp in microseconds. |
| }; |
| @@ -126,14 +144,11 @@ struct InputBuffer { |
| // Represents an output decrypted buffer. It does not own |data|. |
| struct OutputBuffer { |
| OutputBuffer() |
| - : data(NULL), |
| - data_size(0), |
| - timestamp(0) {} |
| - |
| - const uint8_t* data; // Pointer to the beginning of the output data. |
| - uint32_t data_size; // Size (in bytes) of |data|. |
| + : timestamp(0), |
| + buffer(NULL) {} |
| int64_t timestamp; // Presentation timestamp in microseconds. |
| + cdm::Buffer* buffer; |
| }; |
| // Surface formats based on FOURCC labels, see: |
| @@ -308,6 +323,23 @@ class ContentDecryptionModule { |
| virtual ~ContentDecryptionModule() {} |
| }; |
| +// Interface class that hides cross object memory allocation details from CDMs. |
| +// Allocated buffers should only be freed by the CDM wrapper with the single |
| +// exception noted by the |ReleaseBuffer()| comment. |
|
ddorwin
2012/09/12 23:53:01
Is that really an exception? ReleaseBuffer() frees
Tom Finegan
2012/09/13 10:33:40
Done.
|
| +class Allocator { |
| + public: |
| + Allocator() {} |
| + virtual ~Allocator() {} |
| + |
| + // Returns a Buffer* containing non-zero members upon success, or NULL on |
| + // failure. The caller does not own the Buffer*. |
|
ddorwin
2012/09/12 23:53:01
The caller does own the Buffer* but not the underl
Tom Finegan
2012/09/13 10:33:40
Done.
|
| + virtual Buffer* Allocate(int32_t size) = 0; |
| + |
| + // Used by the CDM to release a buffer that will not be delivered to the CDM |
| + // wrapper. Returns true when |buffer| is valid, and false otherwise. |
|
ddorwin
2012/09/12 23:53:01
No return value now
Tom Finegan
2012/09/13 10:33:40
Done.
|
| + virtual void ReleaseBuffer(const Buffer& buffer) = 0; |
| +}; |
| + |
| } // namespace cdm |
| #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |