diff options
author | tomfinegan@chromium.org <tomfinegan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-12 10:48:53 +0000 |
---|---|---|
committer | tomfinegan@chromium.org <tomfinegan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-12 10:48:53 +0000 |
commit | 467434d8392add1af93387ca9214ee966c673a63 (patch) | |
tree | 9634b36adae96aca3aad1f8a5d82505f60306e94 /ppapi | |
parent | e4486338b71884677a6b59e91aff0aeff769d092 (diff) | |
download | chromium_src-467434d8392add1af93387ca9214ee966c673a63.zip chromium_src-467434d8392add1af93387ca9214ee966c673a63.tar.gz chromium_src-467434d8392add1af93387ca9214ee966c673a63.tar.bz2 |
Generalize Pepper CDM API decrypt and decode.
- Removes PP_EncryptedVideoFrameInfo.
- Replaces PPP_ContentDecryptor_Private::DecryptAndDecodeFrame()
with DecryptAndDecode().
BUG=141780
TEST=
Review URL: https://chromiumcodereview.appspot.com/11087044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161551 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/private/pp_content_decryptor.idl | 38 | ||||
-rw-r--r-- | ppapi/api/private/ppp_content_decryptor_private.idl | 28 | ||||
-rw-r--r-- | ppapi/c/private/pp_content_decryptor.h | 50 | ||||
-rw-r--r-- | ppapi/c/private/ppp_content_decryptor_private.h | 30 | ||||
-rw-r--r-- | ppapi/cpp/private/content_decryptor_private.cc | 19 | ||||
-rw-r--r-- | ppapi/cpp/private/content_decryptor_private.h | 7 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 10 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppp_content_decryptor_private_proxy.cc | 48 | ||||
-rw-r--r-- | ppapi/proxy/ppp_content_decryptor_private_proxy.h | 7 |
10 files changed, 88 insertions, 152 deletions
diff --git a/ppapi/api/private/pp_content_decryptor.idl b/ppapi/api/private/pp_content_decryptor.idl index ea05965..24059d42 100644 --- a/ppapi/api/private/pp_content_decryptor.idl +++ b/ppapi/api/private/pp_content_decryptor.idl @@ -134,40 +134,6 @@ enum PP_VideoCodec { }; /** - * <code>PP_EncryptedVideoFrameInfo</code> contains the information required - * to decrypt and decode a video frame. - * TODO(tomfinegan): Revisit necessity of including format information in this - * struct once we decide how to implement video decoder initialization. - */ -[assert_size(256)] -struct PP_EncryptedVideoFrameInfo { - /** - * The decoded video frame format. - */ - PP_DecryptedFrameFormat format; - - /** - * The video frame codec type. - */ - PP_VideoCodec codec; - - /** - * Video frame width in pixels. - */ - int32_t width; - - /** - * Video frame height in pixels. - */ - int32_t height; - - /** - * Information required to decrypt the frame. - */ - PP_EncryptedBlockInfo encryption_info; -}; - -/** * The <code>PP_DecryptResult</code> enum contains decryption and decoding * result constants. */ @@ -196,8 +162,8 @@ struct PP_DecryptedBlockInfo { /** * 4-byte padding to make the size of <code>PP_DecryptedBlockInfo</code> - * a multiple of 8 bytes and make sure |tracking_info| starts on an 8-byte - * boundary. The value of this field should not be used. + * a multiple of 8 bytes, and ensure consistent size on all targets. This + * value should never be used. */ uint32_t padding; diff --git a/ppapi/api/private/ppp_content_decryptor_private.idl b/ppapi/api/private/ppp_content_decryptor_private.idl index 7f490bc..1e9c4d2 100644 --- a/ppapi/api/private/ppp_content_decryptor_private.idl +++ b/ppapi/api/private/ppp_content_decryptor_private.idl @@ -168,21 +168,25 @@ interface PPP_ContentDecryptor_Private { [in] uint32_t request_id); /** - * Decrypts encrypted_video_frame, decodes it, and returns the unencrypted - * uncompressed (decoded) video frame to the browser via the - * <code>DeliverFrame()</code> method on the + * Decrypts encrypted_buffer, decodes it, and returns the unencrypted + * uncompressed (decoded) data to the browser via the + * <code>DeliverFrame()</code> or <code>DeliverSamples()</code> method on the * <code>PPB_ContentDecryptor_Private</code> interface. * - * @param[in] encrypted_video_frame A <code>PP_Resource</code> corresponding - * to a <code>PPB_Buffer_Dev</code> resource that contains an encrypted video - * frame. + * @param[in] decoder_type A <code>PP_DecryptorStreamType</code> that + * specifies the decoder to use after <code>encrypted_buffer</code> is + * decrypted. + * + * @param[in] encrypted_buffer A <code>PP_Resource</code> corresponding to a + * <code>PPB_Buffer_Dev</code> resource that contains encrypted media data. * - * @param[in] encrypted_video_frame_info A - * <code>PP_EncryptedVideoFrameInfo</code> that contains all information - * needed to decrypt and decode <code>encrypted_video_frame</code>. + * @param[in] encrypted_block_info A <code>PP_EncryptedBlockInfo</code> that + * contains all auxiliary information needed for decryption of the + * <code>encrypted_block</code>. */ - void DecryptAndDecodeFrame( + void DecryptAndDecode( [in] PP_Instance instance, - [in] PP_Resource encrypted_video_frame, - [in] PP_EncryptedVideoFrameInfo encrypted_video_frame_info); + [in] PP_DecryptorStreamType decoder_type, + [in] PP_Resource encrypted_buffer, + [in] PP_EncryptedBlockInfo encrypted_block_info); }; diff --git a/ppapi/c/private/pp_content_decryptor.h b/ppapi/c/private/pp_content_decryptor.h index 8a886c0..2ddc107 100644 --- a/ppapi/c/private/pp_content_decryptor.h +++ b/ppapi/c/private/pp_content_decryptor.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/pp_content_decryptor.idl modified Thu Oct 11 21:05:33 2012. */ +/* From private/pp_content_decryptor.idl modified Thu Oct 11 22:13:01 2012. */ #ifndef PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ #define PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ @@ -147,52 +147,8 @@ typedef enum { PP_VIDEOCODEC_VP8 = 1 } PP_VideoCodec; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodec, 4); -/** - * @} - */ - -/** - * @addtogroup Structs - * @{ - */ -/** - * <code>PP_EncryptedVideoFrameInfo</code> contains the information required - * to decrypt and decode a video frame. - * TODO(tomfinegan): Revisit necessity of including format information in this - * struct once we decide how to implement video decoder initialization. - */ -struct PP_EncryptedVideoFrameInfo { - /** - * The decoded video frame format. - */ - PP_DecryptedFrameFormat format; - /** - * The video frame codec type. - */ - PP_VideoCodec codec; - /** - * Video frame width in pixels. - */ - int32_t width; - /** - * Video frame height in pixels. - */ - int32_t height; - /** - * Information required to decrypt the frame. - */ - struct PP_EncryptedBlockInfo encryption_info; -}; -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_EncryptedVideoFrameInfo, 256); -/** - * @} - */ /** - * @addtogroup Enums - * @{ - */ -/** * The <code>PP_DecryptResult</code> enum contains decryption and decoding * result constants. */ @@ -226,8 +182,8 @@ struct PP_DecryptedBlockInfo { PP_DecryptResult result; /** * 4-byte padding to make the size of <code>PP_DecryptedBlockInfo</code> - * a multiple of 8 bytes and make sure |tracking_info| starts on an 8-byte - * boundary. The value of this field should not be used. + * a multiple of 8 bytes, and ensure consistent size on all targets. This + * value should never be used. */ uint32_t padding; /** diff --git a/ppapi/c/private/ppp_content_decryptor_private.h b/ppapi/c/private/ppp_content_decryptor_private.h index f3e5bde..da30fa9 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 Thu Oct 11 20:53:07 2012. + * modified Thu Oct 11 22:28:01 2012. */ #ifndef PPAPI_C_PRIVATE_PPP_CONTENT_DECRYPTOR_PRIVATE_H_ @@ -177,23 +177,27 @@ struct PPP_ContentDecryptor_Private_0_3 { PP_DecryptorStreamType decoder_type, uint32_t request_id); /** - * Decrypts encrypted_video_frame, decodes it, and returns the unencrypted - * uncompressed (decoded) video frame to the browser via the - * <code>DeliverFrame()</code> method on the + * Decrypts encrypted_buffer, decodes it, and returns the unencrypted + * uncompressed (decoded) data to the browser via the + * <code>DeliverFrame()</code> or <code>DeliverSamples()</code> method on the * <code>PPB_ContentDecryptor_Private</code> interface. * - * @param[in] encrypted_video_frame A <code>PP_Resource</code> corresponding - * to a <code>PPB_Buffer_Dev</code> resource that contains an encrypted video - * frame. + * @param[in] decoder_type A <code>PP_DecryptorStreamType</code> that + * specifies the decoder to use after <code>encrypted_buffer</code> is + * decrypted. + * + * @param[in] encrypted_buffer A <code>PP_Resource</code> corresponding to a + * <code>PPB_Buffer_Dev</code> resource that contains encrypted media data. * - * @param[in] encrypted_video_frame_info A - * <code>PP_EncryptedVideoFrameInfo</code> that contains all information - * needed to decrypt and decode <code>encrypted_video_frame</code>. + * @param[in] encrypted_block_info A <code>PP_EncryptedBlockInfo</code> that + * contains all auxiliary information needed for decryption of the + * <code>encrypted_block</code>. */ - void (*DecryptAndDecodeFrame)( + void (*DecryptAndDecode)( PP_Instance instance, - PP_Resource encrypted_video_frame, - const struct PP_EncryptedVideoFrameInfo* encrypted_video_frame_info); + PP_DecryptorStreamType decoder_type, + PP_Resource encrypted_buffer, + const struct PP_EncryptedBlockInfo* encrypted_block_info); }; typedef struct PPP_ContentDecryptor_Private_0_3 PPP_ContentDecryptor_Private; diff --git a/ppapi/cpp/private/content_decryptor_private.cc b/ppapi/cpp/private/content_decryptor_private.cc index 35af5b0..15f3688 100644 --- a/ppapi/cpp/private/content_decryptor_private.cc +++ b/ppapi/cpp/private/content_decryptor_private.cc @@ -144,20 +144,21 @@ void ResetDecoder(PP_Instance instance, request_id); } -void DecryptAndDecodeFrame( - PP_Instance instance, - PP_Resource encrypted_resource, - const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { +void DecryptAndDecode(PP_Instance instance, + PP_DecryptorStreamType decoder_type, + PP_Resource encrypted_resource, + const PP_EncryptedBlockInfo* encrypted_block_info) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) return; - pp::Buffer_Dev encrypted_frame(pp::PassRef(), encrypted_resource); + pp::Buffer_Dev encrypted_buffer(pp::PassRef(), encrypted_resource); - static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecodeFrame( - encrypted_frame, - *encrypted_video_frame_info); + static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode( + decoder_type, + encrypted_buffer, + *encrypted_block_info); } const PPP_ContentDecryptor_Private ppp_content_decryptor = { @@ -168,7 +169,7 @@ const PPP_ContentDecryptor_Private ppp_content_decryptor = { &InitializeVideoDecoder, &DeinitializeDecoder, &ResetDecoder, - &DecryptAndDecodeFrame + &DecryptAndDecode }; template <> const char* interface_name<PPB_ContentDecryptor_Private>() { diff --git a/ppapi/cpp/private/content_decryptor_private.h b/ppapi/cpp/private/content_decryptor_private.h index 198efad..0f5abe5 100644 --- a/ppapi/cpp/private/content_decryptor_private.h +++ b/ppapi/cpp/private/content_decryptor_private.h @@ -43,9 +43,10 @@ class ContentDecryptor_Private { uint32_t request_id) = 0; virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, uint32_t request_id) = 0; - virtual void DecryptAndDecodeFrame( - pp::Buffer_Dev encrypted_frame, - const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) = 0; + virtual void DecryptAndDecode( + PP_DecryptorStreamType decoder_type, + 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. diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 5a76db7..305ce9bf 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* Last generated from IDL: Thu Oct 11 21:05:40 2012. */ +/* Last generated from IDL: Thu Oct 11 22:28:05 2012. */ #include "ppapi/generators/pnacl_shim.h" #include "ppapi/c/ppb.h" @@ -3481,10 +3481,10 @@ static void Pnacl_M24_PPP_ContentDecryptor_Private_ResetDecoder(PP_Instance inst temp_fp(instance, decoder_type, request_id); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_DecryptAndDecodeFrame(PP_Instance instance, PP_Resource encrypted_video_frame, const struct PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { +static void Pnacl_M24_PPP_ContentDecryptor_Private_DecryptAndDecode(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) { const struct PPP_ContentDecryptor_Private_0_3 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_3.real_iface; - void (__attribute__((pnaclcall)) *temp_fp)(PP_Instance instance, PP_Resource encrypted_video_frame, const struct PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) = ((void (__attribute__((pnaclcall)) *)(PP_Instance instance, PP_Resource encrypted_video_frame, const struct PP_EncryptedVideoFrameInfo* encrypted_video_frame_info))iface->DecryptAndDecodeFrame); - temp_fp(instance, encrypted_video_frame, encrypted_video_frame_info); + void (__attribute__((pnaclcall)) *temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) = ((void (__attribute__((pnaclcall)) *)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info))iface->DecryptAndDecode); + temp_fp(instance, decoder_type, encrypted_buffer, encrypted_block_info); } /* End wrapper methods for PPP_ContentDecryptor_Private_0_3 */ @@ -4302,7 +4302,7 @@ struct PPP_ContentDecryptor_Private_0_3 Pnacl_Wrappers_PPP_ContentDecryptor_Priv .InitializeVideoDecoder = (void (*)(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data))&Pnacl_M24_PPP_ContentDecryptor_Private_InitializeVideoDecoder, .DeinitializeDecoder = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M24_PPP_ContentDecryptor_Private_DeinitializeDecoder, .ResetDecoder = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M24_PPP_ContentDecryptor_Private_ResetDecoder, - .DecryptAndDecodeFrame = (void (*)(PP_Instance instance, PP_Resource encrypted_video_frame, const struct PP_EncryptedVideoFrameInfo* encrypted_video_frame_info))&Pnacl_M24_PPP_ContentDecryptor_Private_DecryptAndDecodeFrame + .DecryptAndDecode = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info))&Pnacl_M24_PPP_ContentDecryptor_Private_DecryptAndDecode }; /* Not generating wrapper interface for PPP_Flash_BrowserOperations_1_0 */ diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 3e20695..a8ae9b3 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -642,8 +642,9 @@ IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_ResetDecoder, PP_Instance /* instance */, PP_DecryptorStreamType /* decoder_type */, uint32_t /* request_id */) -IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, +IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, PP_Instance /* instance */, + PP_DecryptorStreamType /* decoder_type */, ppapi::proxy::PPPDecryptor_Buffer /* buffer */, std::string /* serialized_block_info */) diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc index 415180d..7608dfe 100644 --- a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc +++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc @@ -272,10 +272,10 @@ void ResetDecoder(PP_Instance instance, request_id)); } -void DecryptAndDecodeFrame( - PP_Instance instance, - PP_Resource encrypted_frame, - const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { +void DecryptAndDecode(PP_Instance instance, + PP_DecryptorStreamType decoder_type, + PP_Resource encrypted_buffer, + const PP_EncryptedBlockInfo* encrypted_block_info) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { NOTREACHED(); @@ -285,25 +285,25 @@ void DecryptAndDecodeFrame( PPPDecryptor_Buffer buffer; if (!InitializePppDecryptorBuffer(instance, dispatcher, - encrypted_frame, + encrypted_buffer, &buffer)) { NOTREACHED(); return; } - std::string serialized_frame_info; - if (!SerializeBlockInfo(*encrypted_video_frame_info, - &serialized_frame_info)) { + std::string serialized_block_info; + if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) { NOTREACHED(); return; } dispatcher->Send( - new PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame( + new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, + decoder_type, buffer, - serialized_frame_info)); + serialized_block_info)); } static const PPP_ContentDecryptor_Private content_decryptor_interface = { @@ -314,7 +314,7 @@ static const PPP_ContentDecryptor_Private content_decryptor_interface = { &InitializeVideoDecoder, &DeinitializeDecoder, &ResetDecoder, - &DecryptAndDecodeFrame + &DecryptAndDecode }; } // namespace @@ -357,8 +357,8 @@ bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( OnMsgDeinitializeDecoder) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, OnMsgResetDecoder) - IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, - OnMsgDecryptAndDecodeFrame) + IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, + OnMsgDecryptAndDecode) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() DCHECK(handled); @@ -472,23 +472,25 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgResetDecoder( } } -void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( +void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecode( PP_Instance instance, - const PPPDecryptor_Buffer& encrypted_frame, - const std::string& serialized_frame_info) { + PP_DecryptorStreamType decoder_type, + const PPPDecryptor_Buffer& encrypted_buffer, + const std::string& serialized_block_info) { if (ppp_decryptor_impl_) { PP_Resource plugin_resource = - PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, - encrypted_frame.handle, - encrypted_frame.size); - PP_EncryptedVideoFrameInfo frame_info; - if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) + 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_->DecryptAndDecodeFrame, + ppp_decryptor_impl_->DecryptAndDecode, instance, + decoder_type, plugin_resource, - const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); + 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 facec10f..337196b 100644 --- a/ppapi/proxy/ppp_content_decryptor_private_proxy.h +++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.h @@ -52,10 +52,11 @@ class PPP_ContentDecryptor_Private_Proxy : public InterfaceProxy { void OnMsgResetDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id); - void OnMsgDecryptAndDecodeFrame( + void OnMsgDecryptAndDecode( PP_Instance instance, - const PPPDecryptor_Buffer& encrypted_frame, - const std::string& serialized_encrypted_frame_info); + PP_DecryptorStreamType decoder_type, + const PPPDecryptor_Buffer& encrypted_buffer, + const std::string& serialized_encrypted_block_info); const PPP_ContentDecryptor_Private* ppp_decryptor_impl_; |