diff options
author | tomfinegan@chromium.org <tomfinegan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-22 04:06:22 +0000 |
---|---|---|
committer | tomfinegan@chromium.org <tomfinegan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-22 04:06:22 +0000 |
commit | 98ad978a19cde1e63c666502db6e4986a82e476b (patch) | |
tree | 8a6e21b078d73a7f8083d3d4e0d4e3256bfc2f12 /ppapi | |
parent | 26f4694825ed31bd0e01856d2c3654d935d1a1fc (diff) | |
download | chromium_src-98ad978a19cde1e63c666502db6e4986a82e476b.zip chromium_src-98ad978a19cde1e63c666502db6e4986a82e476b.tar.gz chromium_src-98ad978a19cde1e63c666502db6e4986a82e476b.tar.bz2 |
Modify the PPAPI CDM interface to pass more info.
Builds on interface work done by xhwang in issue 10857027.
Add init_data argument to AddKey.
Change the PPP Decrypt methods to take PP_EncryptedBlockInfo structs
instead of simple integer identifiers.
Change the PPB delivery methods to take PP_DecryptedBlockInfo structs
instead of simple integer identifiers.
Update the proxy code accordingly.
BUG=138139
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10854209
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152724 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/private/pp_content_decryptor.idl | 152 | ||||
-rw-r--r-- | ppapi/api/private/ppb_content_decryptor_private.idl | 21 | ||||
-rw-r--r-- | ppapi/api/private/ppp_content_decryptor_private.idl | 23 | ||||
-rw-r--r-- | ppapi/c/private/pp_content_decryptor.h | 178 | ||||
-rw-r--r-- | ppapi/c/private/ppb_content_decryptor_private.h | 39 | ||||
-rw-r--r-- | ppapi/c/private/ppp_content_decryptor_private.h | 36 | ||||
-rw-r--r-- | ppapi/cpp/private/content_decryptor_private.cc | 46 | ||||
-rw-r--r-- | ppapi/cpp/private/content_decryptor_private.h | 17 | ||||
-rw-r--r-- | ppapi/proxy/content_decryptor_private_serializer.h | 56 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 17 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.cc | 73 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.h | 21 | ||||
-rw-r--r-- | ppapi/proxy/ppp_content_decryptor_private_proxy.cc | 67 | ||||
-rw-r--r-- | ppapi/proxy/ppp_content_decryptor_private_proxy.h | 14 | ||||
-rw-r--r-- | ppapi/thunk/ppb_content_decryptor_private_thunk.cc | 12 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_api.h | 8 |
16 files changed, 641 insertions, 139 deletions
diff --git a/ppapi/api/private/pp_content_decryptor.idl b/ppapi/api/private/pp_content_decryptor.idl new file mode 100644 index 0000000..6aa39e3 --- /dev/null +++ b/ppapi/api/private/pp_content_decryptor.idl @@ -0,0 +1,152 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * The <code>PP_DecryptTrackingInfo</code> struct contains necessary information + * that can be used to associate the decrypted block with a decrypt request + * and/or an input block. + */ +[assert_size(16)] +struct PP_DecryptTrackingInfo { + /** + * Client-specified identifier for the associated decrypt request. By using + * this value, the client can associate the decrypted block with a decryption + * request. + */ + uint64_t request_id; + + /** + * Timestamp in microseconds of the associated block. By using this value, + * the client can associate the decrypted (and decoded) data with an input + * block. This is needed because buffers may be delivered out of order and + * not in response to the <code>request_id</code> they were provided with. + */ + int64_t timestamp; +}; + +/** + * The <code>PP_DecryptSubsampleDescription</code> struct contains information + * to support subsample decryption. + * + * An input block can be split into several continuous subsamples. + * A <code>PP_DecryptSubsampleEntry</code> specifies the number of clear and + * cipher bytes in each subsample. For example, the following block has three + * subsamples: + * + * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| + * | clear1 | cipher1 | clear2 | cipher2 | clear3 | cipher3 | + * + * For decryption, all of the cipher bytes in a block should be treated as a + * contiguous (in the subsample order) logical stream. The clear bytes should + * not be considered as part of decryption. + * + * Logical stream to decrypt: | cipher1 | cipher2 | cipher3 | + * Decrypted stream: | decrypted1| decrypted2 | decrypted3 | + * + * After decryption, the decrypted bytes should be copied over the position + * of the corresponding cipher bytes in the original block to form the output + * block. Following the above example, the decrypted block should be: + * + * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| + * | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 | + */ +[assert_size(8)] +struct PP_DecryptSubsampleDescription { + /** + * Size in bytes of clear data in a subsample entry. + */ + uint32_t clear_bytes; + + /** + * Size in bytes of encrypted data in a subsample entry. + */ + uint32_t cipher_bytes; +}; + +/** + * The <code>PP_EncryptedBlockInfo</code> struct contains all the information + * needed to decrypt an encrypted block. + */ +[assert_size(256)] +struct PP_EncryptedBlockInfo { + /** + * Information needed by the client to track the block to be decrypted. + */ + PP_DecryptTrackingInfo tracking_info; + + /** + * Size in bytes of data to be discarded before applying the decryption. + */ + uint32_t data_offset; + + /** + * Key ID of the block to be decrypted. + * + * TODO(xhwang): For WebM the key ID can be as large as 2048 bytes in theory. + * But it's not used in current implementations. If we really need to support + * it, we should move key ID out as a separate parameter, e.g. + * as a <code>PP_Var</code>, or make the whole + * <code>PP_EncryptedBlockInfo</code> as a <code>PP_Resource</code>. + */ + uint8_t[64] key_id; + uint32_t key_id_size; + + /** + * Initialization vector of the block to be decrypted. + */ + uint8_t[16] iv; + uint32_t iv_size; + + /** + * Checksum of the block to be decrypted. + */ + uint8_t[12] checksum; + uint32_t checksum_size; + + /** + * Subsample information of the block to be decrypted. + */ + PP_DecryptSubsampleDescription[16] subsamples; + uint32_t num_subsamples; +}; + +/** + * The <code>PP_DecryptResult</code> enum contains decryption and decoding + * result constants. + */ +[assert_size(4)] +enum PP_DecryptResult { + /** The decryption (and/or decoding) operation finished successfully. */ + PP_DECRYPTRESULT_SUCCESS = 0, + /** The decryptor did not have the necessary decryption key. */ + PP_DECRYPTRESULT_DECRYPT_NOKEY = 1, + /** An unexpected error happened during decryption. */ + PP_DECRYPTRESULT_DECRYPT_ERROR = 2, + /** An unexpected error happened during decoding. */ + PP_DECRYPTRESULT_DECODE_ERROR = 3 +}; + +/** + * The <code>PP_DecryptedBlockInfo</code> struct contains the tracking info and + * the decryption (and/or decoding) result associated with the decrypted block. + */ +[assert_size(24)] +struct PP_DecryptedBlockInfo { + /** + * Information needed by the client to track the block to be decrypted. + */ + PP_DecryptTrackingInfo tracking_info; + + /** + * Result of the decryption (and/or decoding) operation. + */ + PP_DecryptResult result; + + /** + * 4-byte padding to make the size of <code>PP_DecryptedBlockInfo</code> + * a multiple of 8 bytes. The value of this field should not be used. + */ + uint32_t padding; +}; diff --git a/ppapi/api/private/ppb_content_decryptor_private.idl b/ppapi/api/private/ppb_content_decryptor_private.idl index 2a07eae..a07a045 100644 --- a/ppapi/api/private/ppb_content_decryptor_private.idl +++ b/ppapi/api/private/ppb_content_decryptor_private.idl @@ -136,13 +136,14 @@ interface PPB_ContentDecryptor_Private { * <code>PPB_Buffer_Dev</code> resource that contains a decrypted data * block. * - * @param[in] request_id A unique value the browser can use to associate - * decrypted_block with a decrypt call. + * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that + * contains the tracking info and result code associated with the + * <code>decrypted_block</code>. */ void DeliverBlock( [in] PP_Instance instance, [in] PP_Resource decrypted_block, - [in] int32_t request_id); + [in] PP_DecryptedBlockInfo decrypted_block_info); /** * Called after the <code>DecryptAndDecode()</code> method on the @@ -152,13 +153,14 @@ interface PPB_ContentDecryptor_Private { * @param[in] decrypted_frame A <code>PP_Resource</code> corresponding to a * <code>PPB_Buffer_Dev</code> resource that contains a video frame. * - * @param[in] request_id A unique value the browser can use to associate - * decrypted_frame with a decrypt call. + * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that + * contains the tracking info and result code associated with the + * <code>decrypted_block</code>. */ void DeliverFrame( [in] PP_Instance instance, [in] PP_Resource decrypted_frame, - [in] int32_t request_id); + [in] PP_DecryptedBlockInfo decrypted_block_info); /** * Called after the <code>DecryptAndDecode()</code> method on the @@ -170,11 +172,12 @@ interface PPB_ContentDecryptor_Private { * <code>PPB_Buffer_Dev</code> resource that contains a decrypted buffer * of decoded audio samples. * - * @param[in] request_id A unique value the browser can use to associate - * decrypted_samples with a decrypt call. + * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that + * contains the tracking info and result code associated with the + * <code>decrypted_block</code>. */ void DeliverSamples( [in] PP_Instance instance, [in] PP_Resource decrypted_samples, - [in] int32_t request_id); + [in] PP_DecryptedBlockInfo decrypted_block_info); }; diff --git a/ppapi/api/private/ppp_content_decryptor_private.idl b/ppapi/api/private/ppp_content_decryptor_private.idl index bd663a4..81d353f 100644 --- a/ppapi/api/private/ppp_content_decryptor_private.idl +++ b/ppapi/api/private/ppp_content_decryptor_private.idl @@ -59,11 +59,16 @@ interface PPP_ContentDecryptor_Private { * @param[in] key A <code>PP_Var</code> of type * <code>PP_VARTYPE_ARRAYBUFFER</code> containing the decryption key, license, * or other message for the given session ID. + * + * @param[in] init_data A <code>PP_Var</code> of type + * <code>PP_VARTYPE_ARRAYBUFFER</code> containing container specific + * initialization data. */ PP_Bool AddKey( [in] PP_Instance instance, [in] PP_Var session_id, - [in] PP_Var key); + [in] PP_Var key, + [in] PP_Var init_data); /** * Cancels a pending key request for the specified session ID. @@ -85,14 +90,14 @@ interface PPP_ContentDecryptor_Private { * <code>PPB_Buffer_Dev</code> resource that contains an encrypted data * block. * - * @param[in] request_id A value used by the browser to associate data - * returned via the <code>PPB_ContentDecryptor_Private</code> interface with - * decryption method calls. + * @param[in] encrypted_block_info A <code>PP_EncryptedBlockInfo</code> that + * contains all auxiliary information needed for decryption of the + * <code>encrypted_block</code>. */ PP_Bool Decrypt( [in] PP_Instance instance, [in] PP_Resource encrypted_block, - [in] int32_t request_id); + [in] PP_EncryptedBlockInfo encrypted_block_info); /** * Decrypts the block, decodes it, and returns the unencrypted uncompressed @@ -107,12 +112,12 @@ interface PPP_ContentDecryptor_Private { * <code>PPB_Buffer_Dev</code> resource that contains an encrypted data * block. * - * @param[in] request_id A value used by the browser to associate data - * returned via the <code>PPB_ContentDecryptor_Private</code> interface with - * decryption method calls. + * @param[in] encrypted_block_info A <code>PP_EncryptedBlockInfo</code> that + * contains all auxiliary information needed for decryption of the + * <code>encrypted_block</code>. */ PP_Bool DecryptAndDecode( [in] PP_Instance instance, [in] PP_Resource encrypted_block, - [in] int32_t request_id); + [in] PP_EncryptedBlockInfo encrypted_block_info); }; diff --git a/ppapi/c/private/pp_content_decryptor.h b/ppapi/c/private/pp_content_decryptor.h new file mode 100644 index 0000000..8fd8d7c --- /dev/null +++ b/ppapi/c/private/pp_content_decryptor.h @@ -0,0 +1,178 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From private/pp_content_decryptor.idl modified Thu Aug 16 20:21:00 2012. */ + +#ifndef PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ +#define PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ + +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_stdint.h" + +/** + * @file + * The <code>PP_DecryptTrackingInfo</code> struct contains necessary information + * that can be used to associate the decrypted block with a decrypt request + * and/or an input block. + */ + + +/** + * @addtogroup Structs + * @{ + */ +struct PP_DecryptTrackingInfo { + /** + * Client-specified identifier for the associated decrypt request. By using + * this value, the client can associate the decrypted block with a decryption + * request. + */ + uint64_t request_id; + /** + * Timestamp in microseconds of the associated block. By using this value, + * the client can associate the decrypted (and decoded) data with an input + * block. This is needed because buffers may be delivered out of order and + * not in response to the <code>request_id</code> they were provided with. + */ + int64_t timestamp; +}; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptTrackingInfo, 16); + +/** + * The <code>PP_DecryptSubsampleDescription</code> struct contains information + * to support subsample decryption. + * + * An input block can be split into several continuous subsamples. + * A <code>PP_DecryptSubsampleEntry</code> specifies the number of clear and + * cipher bytes in each subsample. For example, the following block has three + * subsamples: + * + * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| + * | clear1 | cipher1 | clear2 | cipher2 | clear3 | cipher3 | + * + * For decryption, all of the cipher bytes in a block should be treated as a + * contiguous (in the subsample order) logical stream. The clear bytes should + * not be considered as part of decryption. + * + * Logical stream to decrypt: | cipher1 | cipher2 | cipher3 | + * Decrypted stream: | decrypted1| decrypted2 | decrypted3 | + * + * After decryption, the decrypted bytes should be copied over the position + * of the corresponding cipher bytes in the original block to form the output + * block. Following the above example, the decrypted block should be: + * + * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| + * | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 | + */ +struct PP_DecryptSubsampleDescription { + /** + * Size in bytes of clear data in a subsample entry. + */ + uint32_t clear_bytes; + /** + * Size in bytes of encrypted data in a subsample entry. + */ + uint32_t cipher_bytes; +}; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptSubsampleDescription, 8); + +/** + * The <code>PP_EncryptedBlockInfo</code> struct contains all the information + * needed to decrypt an encrypted block. + */ +struct PP_EncryptedBlockInfo { + /** + * Information needed by the client to track the block to be decrypted. + */ + struct PP_DecryptTrackingInfo tracking_info; + /** + * Size in bytes of data to be discarded before applying the decryption. + */ + uint32_t data_offset; + /** + * Key ID of the block to be decrypted. + * + * TODO(xhwang): For WebM the key ID can be as large as 2048 bytes in theory. + * But it's not used in current implementations. If we really need to support + * it, we should move key ID out as a separate parameter, e.g. + * as a <code>PP_Var</code>, or make the whole + * <code>PP_EncryptedBlockInfo</code> as a <code>PP_Resource</code>. + */ + uint8_t key_id[64]; + uint32_t key_id_size; + /** + * Initialization vector of the block to be decrypted. + */ + uint8_t iv[16]; + uint32_t iv_size; + /** + * Checksum of the block to be decrypted. + */ + uint8_t checksum[12]; + uint32_t checksum_size; + /** + * Subsample information of the block to be decrypted. + */ + struct PP_DecryptSubsampleDescription subsamples[16]; + uint32_t num_subsamples; +}; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_EncryptedBlockInfo, 256); +/** + * @} + */ + +/** + * @addtogroup Enums + * @{ + */ +/** + * The <code>PP_DecryptResult</code> enum contains decryption and decoding + * result constants. + */ +typedef enum { + /** The decryption (and/or decoding) operation finished successfully. */ + PP_DECRYPTRESULT_SUCCESS = 0, + /** The decryptor did not have the necessary decryption key. */ + PP_DECRYPTRESULT_DECRYPT_NOKEY = 1, + /** An unexpected error happened during decryption. */ + PP_DECRYPTRESULT_DECRYPT_ERROR = 2, + /** An unexpected error happened during decoding. */ + PP_DECRYPTRESULT_DECODE_ERROR = 3 +} PP_DecryptResult; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptResult, 4); +/** + * @} + */ + +/** + * @addtogroup Structs + * @{ + */ +/** + * The <code>PP_DecryptedBlockInfo</code> struct contains the tracking info and + * the decryption (and/or decoding) result associated with the decrypted block. + */ +struct PP_DecryptedBlockInfo { + /** + * Information needed by the client to track the block to be decrypted. + */ + struct PP_DecryptTrackingInfo tracking_info; + /** + * Result of the decryption (and/or decoding) operation. + */ + PP_DecryptResult result; + /** + * 4-byte padding to make the size of <code>PP_DecryptedBlockInfo</code> + * a multiple of 8 bytes. The value of this field should not be used. + */ + uint32_t padding; +}; +PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedBlockInfo, 24); +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ */ + diff --git a/ppapi/c/private/ppb_content_decryptor_private.h b/ppapi/c/private/ppb_content_decryptor_private.h index 7630910..0e9aead 100644 --- a/ppapi/c/private/ppb_content_decryptor_private.h +++ b/ppapi/c/private/ppb_content_decryptor_private.h @@ -4,7 +4,7 @@ */ /* From private/ppb_content_decryptor_private.idl, - * modified Tue Aug 14 11:53:03 2012. + * modified Thu Aug 16 20:19:22 2012. */ #ifndef PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ @@ -16,6 +16,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" +#include "ppapi/c/private/pp_content_decryptor.h" #define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_1 \ "PPB_ContentDecryptor_Private;0.1" @@ -150,12 +151,14 @@ struct PPB_ContentDecryptor_Private_0_1 { * <code>PPB_Buffer_Dev</code> resource that contains a decrypted data * block. * - * @param[in] request_id A unique value the browser can use to associate - * decrypted_block with a decrypt call. + * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that + * contains the tracking info and result code associated with the + * <code>decrypted_block</code>. */ - void (*DeliverBlock)(PP_Instance instance, - PP_Resource decrypted_block, - int32_t request_id); + void (*DeliverBlock)( + PP_Instance instance, + PP_Resource decrypted_block, + const struct PP_DecryptedBlockInfo* decrypted_block_info); /** * Called after the <code>DecryptAndDecode()</code> method on the * <code>PPP_ContentDecryptor_Private</code> interface completes to deliver @@ -164,12 +167,14 @@ struct PPB_ContentDecryptor_Private_0_1 { * @param[in] decrypted_frame A <code>PP_Resource</code> corresponding to a * <code>PPB_Buffer_Dev</code> resource that contains a video frame. * - * @param[in] request_id A unique value the browser can use to associate - * decrypted_frame with a decrypt call. + * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that + * contains the tracking info and result code associated with the + * <code>decrypted_block</code>. */ - void (*DeliverFrame)(PP_Instance instance, - PP_Resource decrypted_frame, - int32_t request_id); + void (*DeliverFrame)( + PP_Instance instance, + PP_Resource decrypted_frame, + const struct PP_DecryptedBlockInfo* decrypted_block_info); /** * Called after the <code>DecryptAndDecode()</code> method on the * <code>PPP_ContentDecryptor_Private</code> interface completes to @@ -180,12 +185,14 @@ struct PPB_ContentDecryptor_Private_0_1 { * <code>PPB_Buffer_Dev</code> resource that contains a decrypted buffer * of decoded audio samples. * - * @param[in] request_id A unique value the browser can use to associate - * decrypted_samples with a decrypt call. + * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that + * contains the tracking info and result code associated with the + * <code>decrypted_block</code>. */ - void (*DeliverSamples)(PP_Instance instance, - PP_Resource decrypted_samples, - int32_t request_id); + void (*DeliverSamples)( + PP_Instance instance, + PP_Resource decrypted_samples, + const struct PP_DecryptedBlockInfo* decrypted_block_info); }; typedef struct PPB_ContentDecryptor_Private_0_1 PPB_ContentDecryptor_Private; diff --git a/ppapi/c/private/ppp_content_decryptor_private.h b/ppapi/c/private/ppp_content_decryptor_private.h index 56b5d85..45c8c0d 100644 --- a/ppapi/c/private/ppp_content_decryptor_private.h +++ b/ppapi/c/private/ppp_content_decryptor_private.h @@ -4,7 +4,7 @@ */ /* From private/ppp_content_decryptor_private.idl, - * modified Tue Aug 14 11:06:05 2012. + * modified Fri Aug 17 09:07:21 2012. */ #ifndef PPAPI_C_PRIVATE_PPP_CONTENT_DECRYPTOR_PRIVATE_H_ @@ -16,6 +16,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" +#include "ppapi/c/private/pp_content_decryptor.h" #define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_1 \ "PPP_ContentDecryptor_Private;0.1" @@ -79,10 +80,15 @@ struct PPP_ContentDecryptor_Private_0_1 { * @param[in] key A <code>PP_Var</code> of type * <code>PP_VARTYPE_ARRAYBUFFER</code> containing the decryption key, license, * or other message for the given session ID. + * + * @param[in] init_data A <code>PP_Var</code> of type + * <code>PP_VARTYPE_ARRAYBUFFER</code> containing container specific + * initialization data. */ PP_Bool (*AddKey)(PP_Instance instance, struct PP_Var session_id, - struct PP_Var key); + struct PP_Var key, + struct PP_Var init_data); /** * Cancels a pending key request for the specified session ID. * @@ -100,13 +106,14 @@ struct PPP_ContentDecryptor_Private_0_1 { * <code>PPB_Buffer_Dev</code> resource that contains an encrypted data * block. * - * @param[in] request_id A value used by the browser to associate data - * returned via the <code>PPB_ContentDecryptor_Private</code> interface with - * decryption method calls. + * @param[in] encrypted_block_info A <code>PP_EncryptedBlockInfo</code> that + * contains all auxiliary information needed for decryption of the + * <code>encrypted_block</code>. */ - PP_Bool (*Decrypt)(PP_Instance instance, - PP_Resource encrypted_block, - int32_t request_id); + PP_Bool (*Decrypt)( + PP_Instance instance, + PP_Resource encrypted_block, + const struct PP_EncryptedBlockInfo* encrypted_block_info); /** * Decrypts the block, decodes it, and returns the unencrypted uncompressed * (decoded) media to the browser via the @@ -120,13 +127,14 @@ struct PPP_ContentDecryptor_Private_0_1 { * <code>PPB_Buffer_Dev</code> resource that contains an encrypted data * block. * - * @param[in] request_id A value used by the browser to associate data - * returned via the <code>PPB_ContentDecryptor_Private</code> interface with - * decryption method calls. + * @param[in] encrypted_block_info A <code>PP_EncryptedBlockInfo</code> that + * contains all auxiliary information needed for decryption of the + * <code>encrypted_block</code>. */ - PP_Bool (*DecryptAndDecode)(PP_Instance instance, - PP_Resource encrypted_block, - int32_t request_id); + PP_Bool (*DecryptAndDecode)( + PP_Instance instance, + PP_Resource encrypted_block, + const struct PP_EncryptedBlockInfo* encrypted_block_info); }; typedef struct PPP_ContentDecryptor_Private_0_1 PPP_ContentDecryptor_Private; diff --git a/ppapi/cpp/private/content_decryptor_private.cc b/ppapi/cpp/private/content_decryptor_private.cc index c2d95ed..633215a 100644 --- a/ppapi/cpp/private/content_decryptor_private.cc +++ b/ppapi/cpp/private/content_decryptor_private.cc @@ -11,6 +11,7 @@ #include "ppapi/c/private/ppp_content_decryptor_private.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/logging.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" #include "ppapi/cpp/var.h" @@ -47,7 +48,8 @@ PP_Bool GenerateKeyRequest(PP_Instance instance, PP_Bool AddKey(PP_Instance instance, PP_Var session_id_arg, - PP_Var key_arg) { + PP_Var key_arg, + PP_Var init_data_arg) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) @@ -62,10 +64,16 @@ PP_Bool AddKey(PP_Instance instance, return PP_FALSE; pp::VarArrayBuffer key(key_var); + pp::Var init_data_var(pp::PASS_REF, init_data_arg); + if (init_data_var.is_array_buffer() == false) + return PP_FALSE; + pp::VarArrayBuffer init_data(init_data_var); + return PP_FromBool( static_cast<ContentDecryptor_Private*>(object)->AddKey( session_id_var.AsString(), - key)); + key, + init_data)); } PP_Bool CancelKeyRequest(PP_Instance instance, @@ -87,7 +95,7 @@ PP_Bool CancelKeyRequest(PP_Instance instance, PP_Bool Decrypt(PP_Instance instance, PP_Resource encrypted_resource, - int32_t request_id) { + const PP_EncryptedBlockInfo* encrypted_block_info) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) @@ -96,13 +104,14 @@ PP_Bool Decrypt(PP_Instance instance, pp::Buffer_Dev encrypted_block(encrypted_resource); return PP_FromBool( - static_cast<ContentDecryptor_Private*>(object)->Decrypt(encrypted_block, - request_id)); + static_cast<ContentDecryptor_Private*>(object)->Decrypt( + encrypted_block, + *encrypted_block_info)); } PP_Bool DecryptAndDecode(PP_Instance instance, PP_Resource encrypted_resource, - int32_t request_id) { + const PP_EncryptedBlockInfo* encrypted_block_info) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) @@ -113,7 +122,7 @@ PP_Bool DecryptAndDecode(PP_Instance instance, return PP_FromBool( static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode( encrypted_block, - request_id)); + *encrypted_block_info)); } const PPP_ContentDecryptor_Private ppp_content_decryptor = { @@ -151,8 +160,6 @@ void ContentDecryptor_Private::NeedKey(const std::string& key_system, pp::Var key_system_var(key_system); pp::Var session_id_var(session_id); - // TODO(tomfinegan): Host to plugin stuff needed for init_data? - get_interface<PPB_ContentDecryptor_Private>()->NeedKey( associated_instance_.pp_instance(), key_system_var.pp_var(), @@ -206,33 +213,36 @@ void ContentDecryptor_Private::KeyError(const std::string& key_system, } } -void ContentDecryptor_Private::DeliverBlock(pp::Buffer_Dev decrypted_block, - int32_t request_id) { +void ContentDecryptor_Private::DeliverBlock( + pp::Buffer_Dev decrypted_block, + const PP_DecryptedBlockInfo& decrypted_block_info) { if (has_interface<PPB_ContentDecryptor_Private>()) { get_interface<PPB_ContentDecryptor_Private>()->DeliverBlock( associated_instance_.pp_instance(), decrypted_block.pp_resource(), - request_id); + &decrypted_block_info); } } -void ContentDecryptor_Private::DeliverFrame(pp::Buffer_Dev decrypted_frame, - int32_t request_id) { +void ContentDecryptor_Private::DeliverFrame( + pp::Buffer_Dev decrypted_frame, + const PP_DecryptedBlockInfo& decrypted_block_info) { if (has_interface<PPB_ContentDecryptor_Private>()) { get_interface<PPB_ContentDecryptor_Private>()->DeliverFrame( associated_instance_.pp_instance(), decrypted_frame.pp_resource(), - request_id); + &decrypted_block_info); } } -void ContentDecryptor_Private::DeliverSamples(pp::Buffer_Dev decrypted_samples, - int32_t request_id) { +void ContentDecryptor_Private::DeliverSamples( + pp::Buffer_Dev decrypted_samples, + const PP_DecryptedBlockInfo& decrypted_block_info) { if (has_interface<PPB_ContentDecryptor_Private>()) { get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( associated_instance_.pp_instance(), decrypted_samples.pp_resource(), - request_id); + &decrypted_block_info); } } diff --git a/ppapi/cpp/private/content_decryptor_private.h b/ppapi/cpp/private/content_decryptor_private.h index f300ea0..e666a72 100644 --- a/ppapi/cpp/private/content_decryptor_private.h +++ b/ppapi/cpp/private/content_decryptor_private.h @@ -5,6 +5,7 @@ #ifndef PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ #define PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ +#include "ppapi/c/private/pp_content_decryptor.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" #include "ppapi/c/private/ppp_content_decryptor_private.h" @@ -30,12 +31,14 @@ class ContentDecryptor_Private { virtual bool GenerateKeyRequest(const std::string& key_system, pp::VarArrayBuffer init_data) = 0; virtual bool AddKey(const std::string& session_id, - pp::VarArrayBuffer key) = 0; + pp::VarArrayBuffer key, + pp::VarArrayBuffer init_data) = 0; virtual bool CancelKeyRequest(const std::string& session_id) = 0; virtual bool Decrypt(pp::Buffer_Dev encrypted_buffer, - int32_t request_id) = 0; - virtual bool DecryptAndDecode(pp::Buffer_Dev encrypted_buffer, - int32_t request_id) = 0; + const PP_EncryptedBlockInfo& encrypted_block_info) = 0; + virtual bool DecryptAndDecode( + pp::Buffer_Dev encrypted_buffer, + const PP_EncryptedBlockInfo& encrypted_block_info) = 0; // PPB_ContentDecryptor_Private methods for passing data from the decryptor // to the browser. @@ -53,11 +56,11 @@ class ContentDecryptor_Private { int32_t media_error, int32_t system_code); void DeliverBlock(pp::Buffer_Dev decrypted_block, - int32_t request_id); + const PP_DecryptedBlockInfo& decrypted_block_info); void DeliverFrame(pp::Buffer_Dev decrypted_frame, - int32_t request_id); + const PP_DecryptedBlockInfo& decrypted_block_info); void DeliverSamples(pp::Buffer_Dev decrypted_samples, - int32_t request_id); + const PP_DecryptedBlockInfo& decrypted_block_info); private: InstanceHandle associated_instance_; diff --git a/ppapi/proxy/content_decryptor_private_serializer.h b/ppapi/proxy/content_decryptor_private_serializer.h new file mode 100644 index 0000000..e8d7213 --- /dev/null +++ b/ppapi/proxy/content_decryptor_private_serializer.h @@ -0,0 +1,56 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_H_ +#define PPAPI_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_H_ + +#include <cstring> +#include <string> + +#include "ppapi/c/private/pp_content_decryptor.h" + +namespace ppapi { +namespace proxy { + +// Serialization/deserialization utility functions for storing/extracting +// PP_{De|En}cryptedBlockInfo structs within std::string's for passing through +// IPC. Both functions return true upon success, and false upon failure. +// +// Note, these functions check the size of |block_info| against the size of +// the "serialized" data stored within |serialized_block_info|, and will report +// failure if expectations are not met. Use of CHECK/DCHECK has been avoided +// because the functions are intended for use on both sides of the IPC proxy. + +template <typename T> +bool SerializeBlockInfo(const T& block_info, + std::string* serialized_block_info) { + if (!serialized_block_info) + return false; + + serialized_block_info->assign(reinterpret_cast<const char*>(&block_info), + sizeof(block_info)); + + if (serialized_block_info->size() != sizeof(block_info)) + return false; + + return true; +} + +template <typename T> +bool DeserializeBlockInfo(const std::string& serialized_block_info, + T* block_info) { + if (!block_info) + return false; + + if (serialized_block_info.size() != sizeof(*block_info)) + return false; + + std::memcpy(block_info, serialized_block_info.data(), sizeof(*block_info)); + return true; +} + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_H_ diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index ded1fa1..3d4a6ed 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -589,21 +589,22 @@ IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, PP_Instance /* instance */, ppapi::proxy::SerializedVar /* key_system, String */, ppapi::proxy::SerializedVar /* init_data, ArrayBuffer */) -IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_AddKey, +IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_AddKey, PP_Instance /* instance */, ppapi::proxy::SerializedVar /* session_id, String */, - ppapi::proxy::SerializedVar /* key, ArrayBuffer */) + ppapi::proxy::SerializedVar /* key, ArrayBuffer */, + ppapi::proxy::SerializedVar /* init_data, ArrayBuffer */) IPC_MESSAGE_ROUTED2(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, PP_Instance /* instance */, ppapi::proxy::SerializedVar /* session_id, String */) IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_Decrypt, PP_Instance /* instance */, ppapi::proxy::PPPDecryptor_Buffer /* buffer */, - int32_t /* request_id */) + std::string /* serialized_block_info */) IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, PP_Instance /* instance */, - ppapi::HostResource /* encrypted_block, PPB_Buffer_Dev */, - int32_t /* request_id */) + ppapi::proxy::PPPDecryptor_Buffer /* buffer */, + std::string /* serialized_block_info */) // PPB_NetworkMonitor_Private. IPC_MESSAGE_ROUTED2(PpapiMsg_PPBNetworkMonitor_NetworkList, @@ -1191,15 +1192,15 @@ IPC_MESSAGE_ROUTED5(PpapiHostMsg_PPBInstance_KeyError, IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_DeliverBlock, PP_Instance /* instance */, PP_Resource /* decrypted_block, PPB_Buffer_Dev */, - int32_t /* request_id */) + std::string /* serialized_block_info */) IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_DeliverFrame, PP_Instance /* instance */, PP_Resource /* decrypted_frame, PPB_Buffer_Dev */, - int32_t /* request_id */) + std::string /* serialized_block_info */) IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_DeliverSamples, PP_Instance /* instance */, PP_Resource /* decrypted_samples, PPB_Buffer_Dev */, - int32_t /* request_id */) + std::string /* serialized_block_info */) // PPB_NetworkMonitor_Private. IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBNetworkMonitor_Start, diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 4960b1e..e9eaf35 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -11,6 +11,8 @@ #include "ppapi/c/ppb_instance.h" #include "ppapi/c/ppb_messaging.h" #include "ppapi/c/ppb_mouse_lock.h" +#include "ppapi/c/private/pp_content_decryptor.h" +#include "ppapi/proxy/content_decryptor_private_serializer.h" #include "ppapi/proxy/enter_proxy.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" @@ -479,45 +481,61 @@ void PPB_Instance_Proxy::KeyError(PP_Instance instance, void PPB_Instance_Proxy::DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, - int32_t request_id) { + const PP_DecryptedBlockInfo* block_info) { Resource* object = PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_block); if (!object || object->pp_instance() != instance) return; + + std::string serialized_block_info; + if (!SerializeBlockInfo(*block_info, &serialized_block_info)) + return; + dispatcher()->Send( new PpapiHostMsg_PPBInstance_DeliverBlock(API_ID_PPB_INSTANCE, instance, object->host_resource().host_resource(), - request_id)); + serialized_block_info)); } void PPB_Instance_Proxy::DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, - int32_t request_id) { + const PP_DecryptedBlockInfo* block_info) { Resource* object = PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_frame); if (!object || object->pp_instance() != instance) return; + + std::string serialized_block_info; + if (!SerializeBlockInfo(*block_info, &serialized_block_info)) + return; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_DeliverFrame( API_ID_PPB_INSTANCE, instance, object->host_resource().host_resource(), - request_id)); + serialized_block_info)); } -void PPB_Instance_Proxy::DeliverSamples(PP_Instance instance, - PP_Resource decrypted_samples, - int32_t request_id) { +void PPB_Instance_Proxy::DeliverSamples( + PP_Instance instance, + PP_Resource decrypted_samples, + const PP_DecryptedBlockInfo* block_info) { Resource* object = PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_samples); if (!object || object->pp_instance() != instance) return; + + std::string serialized_block_info; + if (!SerializeBlockInfo(*block_info, &serialized_block_info)) + return; + dispatcher()->Send( new PpapiHostMsg_PPBInstance_DeliverSamples( API_ID_PPB_INSTANCE, instance, object->host_resource().host_resource(), - request_id)); + serialized_block_info)); } #endif // !defined(OS_NACL) @@ -923,28 +941,43 @@ void PPB_Instance_Proxy::OnHostMsgKeyError( } } -void PPB_Instance_Proxy::OnHostMsgDeliverBlock(PP_Instance instance, - PP_Resource decrypted_block, - int32_t request_id) { +void PPB_Instance_Proxy::OnHostMsgDeliverBlock( + PP_Instance instance, + PP_Resource decrypted_block, + const std::string& serialized_block_info) { + PP_DecryptedBlockInfo block_info; + if (!DeserializeBlockInfo(serialized_block_info, &block_info)) + return; + EnterInstanceNoLock enter(instance); if (enter.succeeded()) - enter.functions()->DeliverBlock(instance, decrypted_block, request_id); + enter.functions()->DeliverBlock(instance, decrypted_block, &block_info); } -void PPB_Instance_Proxy::OnHostMsgDeliverFrame(PP_Instance instance, - PP_Resource decrypted_frame, - int32_t request_id) { +void PPB_Instance_Proxy::OnHostMsgDeliverFrame( + PP_Instance instance, + PP_Resource decrypted_frame, + const std::string& serialized_block_info) { + PP_DecryptedBlockInfo block_info; + if (!DeserializeBlockInfo(serialized_block_info, &block_info)) + return; + EnterInstanceNoLock enter(instance); if (enter.succeeded()) - enter.functions()->DeliverFrame(instance, decrypted_frame, request_id); + enter.functions()->DeliverFrame(instance, decrypted_frame, &block_info); } -void PPB_Instance_Proxy::OnHostMsgDeliverSamples(PP_Instance instance, - PP_Resource decrypted_samples, - int32_t request_id) { +void PPB_Instance_Proxy::OnHostMsgDeliverSamples( + PP_Instance instance, + PP_Resource decrypted_samples, + const std::string& serialized_block_info) { + PP_DecryptedBlockInfo block_info; + if (!DeserializeBlockInfo(serialized_block_info, &block_info)) + return; + EnterInstanceNoLock enter(instance); if (enter.succeeded()) - enter.functions()->DeliverSamples(instance, decrypted_samples, request_id); + enter.functions()->DeliverSamples(instance, decrypted_samples, &block_info); } #endif // !defined(OS_NACL) diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index 1585f75..9da6659 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -5,6 +5,8 @@ #ifndef PPAPI_PROXY_PPB_INSTANCE_PROXY_H_ #define PPAPI_PROXY_PPB_INSTANCE_PROXY_H_ +#include <string> + #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_time.h" @@ -21,6 +23,8 @@ #undef PostMessage #endif +struct PP_DecryptedBlockInfo; + namespace ppapi { namespace proxy { @@ -134,13 +138,13 @@ class PPB_Instance_Proxy : public InterfaceProxy, int32_t system_code) OVERRIDE; virtual void DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, - int32_t request_id) OVERRIDE; + const PP_DecryptedBlockInfo* block_info) OVERRIDE; virtual void DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, - int32_t request_id) OVERRIDE; + const PP_DecryptedBlockInfo* block_info) OVERRIDE; virtual void DeliverSamples(PP_Instance instance, PP_Resource decrypted_samples, - int32_t request_id) OVERRIDE; + const PP_DecryptedBlockInfo* block_info) OVERRIDE; #endif // !defined(OS_NACL) static const ApiID kApiID = API_ID_PPB_INSTANCE; @@ -233,13 +237,14 @@ class PPB_Instance_Proxy : public InterfaceProxy, int32_t system_code); virtual void OnHostMsgDeliverBlock(PP_Instance instance, PP_Resource decrypted_block, - int32_t request_id); + const std::string& serialized_block_info); virtual void OnHostMsgDeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, - int32_t request_id); - virtual void OnHostMsgDeliverSamples(PP_Instance instance, - PP_Resource decrypted_samples, - int32_t request_id); + const std::string& serialized_block_info); + virtual void OnHostMsgDeliverSamples( + PP_Instance instance, + PP_Resource decrypted_samples, + const std::string& serialized_block_info); #endif // !defined(OS_NACL) // Host -> Plugin message handlers. diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc index dd72335..fe6a928 100644 --- a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc +++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc @@ -7,6 +7,7 @@ #include "base/platform_file.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/ppb_core.h" +#include "ppapi/proxy/content_decryptor_private_serializer.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_globals.h" #include "ppapi/proxy/plugin_resource_tracker.h" @@ -93,7 +94,8 @@ PP_Bool GenerateKeyRequest(PP_Instance instance, PP_Bool AddKey(PP_Instance instance, PP_Var session_id, - PP_Var key) { + PP_Var key, + PP_Var init_data) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); @@ -105,7 +107,8 @@ PP_Bool AddKey(PP_Instance instance, API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, SerializedVarSendInput(dispatcher, session_id), - SerializedVarSendInput(dispatcher, key)))); + SerializedVarSendInput(dispatcher, key), + SerializedVarSendInput(dispatcher, init_data)))); } PP_Bool CancelKeyRequest(PP_Instance instance, PP_Var session_id) { @@ -124,7 +127,7 @@ PP_Bool CancelKeyRequest(PP_Instance instance, PP_Var session_id) { PP_Bool Decrypt(PP_Instance instance, PP_Resource encrypted_block, - int32_t request_id) { + const PP_EncryptedBlockInfo* encrypted_block_info) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); @@ -160,17 +163,21 @@ PP_Bool Decrypt(PP_Instance instance, buffer.handle = handle; buffer.size = size; + std::string serialized_block_info; + if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) + return PP_FALSE; + return PP_FromBool(dispatcher->Send( new PpapiMsg_PPPContentDecryptor_Decrypt( API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, buffer, - request_id))); + serialized_block_info))); } PP_Bool DecryptAndDecode(PP_Instance instance, PP_Resource encrypted_block, - int32_t request_id) { + const PP_EncryptedBlockInfo* encrypted_block_info) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); @@ -180,12 +187,31 @@ PP_Bool DecryptAndDecode(PP_Instance instance, HostResource host_resource; host_resource.SetHostResource(instance, encrypted_block); + uint32_t size = 0; + if (DescribeHostBufferResource(encrypted_block, &size) == PP_FALSE) + return PP_FALSE; + + base::SharedMemoryHandle handle; + if (ShareHostBufferResourceToPlugin(dispatcher, + encrypted_block, + &handle) == PP_FALSE) + return PP_FALSE; + + PPPDecryptor_Buffer buffer; + buffer.resource = host_resource; + buffer.handle = handle; + buffer.size = size; + + std::string serialized_block_info; + if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) + return PP_FALSE; + return PP_FromBool(dispatcher->Send( new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, - host_resource, - request_id))); + buffer, + serialized_block_info))); } static const PPP_ContentDecryptor_Private content_decryptor_interface = { @@ -257,12 +283,14 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( void PPP_ContentDecryptor_Private_Proxy::OnMsgAddKey( PP_Instance instance, SerializedVarReceiveInput session_id, - SerializedVarReceiveInput key) { + SerializedVarReceiveInput key, + SerializedVarReceiveInput init_data) { if (ppp_decryptor_impl_) { CallWhileUnlocked(ppp_decryptor_impl_->AddKey, instance, ExtractReceivedVarAndAddRef(dispatcher(), &session_id), - ExtractReceivedVarAndAddRef(dispatcher(), &key)); + ExtractReceivedVarAndAddRef(dispatcher(), &key), + ExtractReceivedVarAndAddRef(dispatcher(), &init_data)); } } @@ -279,31 +307,38 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgCancelKeyRequest( void PPP_ContentDecryptor_Private_Proxy::OnMsgDecrypt( PP_Instance instance, const PPPDecryptor_Buffer& encrypted_buffer, - int32_t request_id) { + const std::string& serialized_block_info) { if (ppp_decryptor_impl_) { PP_Resource plugin_resource = PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, encrypted_buffer.handle, encrypted_buffer.size); + PP_EncryptedBlockInfo block_info; + if (!DeserializeBlockInfo(serialized_block_info, &block_info)) + return; CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, instance, plugin_resource, - request_id); + const_cast<const PP_EncryptedBlockInfo*>(&block_info)); } } void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecode( PP_Instance instance, - const HostResource& encrypted_block, - int32_t request_id) { + const PPPDecryptor_Buffer& encrypted_buffer, + const std::string& serialized_block_info) { if (ppp_decryptor_impl_) { PP_Resource plugin_resource = - PluginGlobals::Get()->plugin_resource_tracker()-> - PluginResourceForHostResource(encrypted_block); + PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, + encrypted_buffer.handle, + encrypted_buffer.size); + PP_EncryptedBlockInfo block_info; + if (!DeserializeBlockInfo(serialized_block_info, &block_info)) + return; CallWhileUnlocked(ppp_decryptor_impl_->DecryptAndDecode, instance, plugin_resource, - request_id); + const_cast<const PP_EncryptedBlockInfo*>(&block_info)); } } diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.h b/ppapi/proxy/ppp_content_decryptor_private_proxy.h index 6ed8d22..a9a8f22 100644 --- a/ppapi/proxy/ppp_content_decryptor_private_proxy.h +++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.h @@ -5,6 +5,8 @@ #ifndef PPAPI_PROXY_PPP_CONTENT_DECRYPTOR_PRIVATE_PROXY_H_ #define PPAPI_PROXY_PPP_CONTENT_DECRYPTOR_PRIVATE_PROXY_H_ +#include <string> + #include "ppapi/c/pp_instance.h" #include "ppapi/c/private/ppp_content_decryptor_private.h" #include "ppapi/proxy/interface_proxy.h" @@ -33,15 +35,17 @@ class PPP_ContentDecryptor_Private_Proxy : public InterfaceProxy { SerializedVarReceiveInput init_data); void OnMsgAddKey(PP_Instance instance, SerializedVarReceiveInput session_id, - SerializedVarReceiveInput key); + SerializedVarReceiveInput key, + SerializedVarReceiveInput init_data); void OnMsgCancelKeyRequest(PP_Instance instance, SerializedVarReceiveInput session_id); void OnMsgDecrypt(PP_Instance instance, const PPPDecryptor_Buffer& encrypted_buffer, - int32_t request_id); - void OnMsgDecryptAndDecode(PP_Instance instance, - const HostResource& encrypted_block, - int32_t request_id); + const std::string& serialized_encrypted_block_info); + void OnMsgDecryptAndDecode( + PP_Instance instance, + const PPPDecryptor_Buffer& encrypted_buffer, + const std::string& serialized_encrypted_block_info); const PPP_ContentDecryptor_Private* ppp_decryptor_impl_; diff --git a/ppapi/thunk/ppb_content_decryptor_private_thunk.cc b/ppapi/thunk/ppb_content_decryptor_private_thunk.cc index e96a990..77760f3 100644 --- a/ppapi/thunk/ppb_content_decryptor_private_thunk.cc +++ b/ppapi/thunk/ppb_content_decryptor_private_thunk.cc @@ -55,26 +55,26 @@ void KeyError(PP_Instance instance, void DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, - int32_t request_id) { + const PP_DecryptedBlockInfo* block_info) { EnterInstance enter(instance); if (enter.succeeded()) - enter.functions()->DeliverBlock(instance, decrypted_block, request_id); + enter.functions()->DeliverBlock(instance, decrypted_block, block_info); } void DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, - int32_t request_id) { + const PP_DecryptedBlockInfo* block_info) { EnterInstance enter(instance); if (enter.succeeded()) - enter.functions()->DeliverFrame(instance, decrypted_frame, request_id); + enter.functions()->DeliverFrame(instance, decrypted_frame, block_info); } void DeliverSamples(PP_Instance instance, PP_Resource decrypted_samples, - int32_t request_id) { + const PP_DecryptedBlockInfo* block_info) { EnterInstance enter(instance); if (enter.succeeded()) - enter.functions()->DeliverSamples(instance, decrypted_samples, request_id); + enter.functions()->DeliverSamples(instance, decrypted_samples, block_info); } const PPB_ContentDecryptor_Private g_ppb_decryption_thunk = { diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 1520e13..10868dd 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -27,6 +27,8 @@ #undef PostMessage #endif +struct PP_DecryptedBlockInfo; + namespace ppapi { class TrackedCallback; @@ -159,13 +161,13 @@ class PPB_Instance_API { int32_t system_error) = 0; virtual void DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, - int32_t request_id) = 0; + const PP_DecryptedBlockInfo* block_info) = 0; virtual void DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, - int32_t request_id) = 0; + const PP_DecryptedBlockInfo* block_info) = 0; virtual void DeliverSamples(PP_Instance instance, PP_Resource decrypted_samples, - int32_t request_id) = 0; + const PP_DecryptedBlockInfo* block_info) = 0; // URLUtil. virtual PP_Var ResolveRelativeToDocument( |