| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/cpp/private/content_decryptor_private.h" | 5 #include "ppapi/cpp/private/content_decryptor_private.h" |
| 6 | 6 |
| 7 #include <cstring> // memcpy | 7 #include <cstring> // memcpy |
| 8 | 8 |
| 9 #include "ppapi/c/ppb_var.h" | 9 #include "ppapi/c/ppb_var.h" |
| 10 #include "ppapi/c/private/ppb_content_decryptor_private.h" | 10 #include "ppapi/c/private/ppb_content_decryptor_private.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (!object) | 98 if (!object) |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 pp::Buffer_Dev encrypted_block(pp::PassRef(), encrypted_resource); | 101 pp::Buffer_Dev encrypted_block(pp::PassRef(), encrypted_resource); |
| 102 | 102 |
| 103 static_cast<ContentDecryptor_Private*>(object)->Decrypt( | 103 static_cast<ContentDecryptor_Private*>(object)->Decrypt( |
| 104 encrypted_block, | 104 encrypted_block, |
| 105 *encrypted_block_info); | 105 *encrypted_block_info); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void ResetVideoDecoder(PP_Instance instance, uint32_t request_id) { |
| 109 void* object = |
| 110 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 111 if (!object) |
| 112 return; |
| 113 static_cast<ContentDecryptor_Private*>(object)->ResetVideoDecoder( |
| 114 request_id); |
| 115 } |
| 116 |
| 117 void StopVideoDecoder(PP_Instance instance, uint32_t request_id) { |
| 118 void* object = |
| 119 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 120 if (!object) |
| 121 return; |
| 122 static_cast<ContentDecryptor_Private*>(object)->StopVideoDecoder(request_id); |
| 123 } |
| 124 |
| 108 void DecryptAndDecodeFrame( | 125 void DecryptAndDecodeFrame( |
| 109 PP_Instance instance, | 126 PP_Instance instance, |
| 110 PP_Resource encrypted_resource, | 127 PP_Resource encrypted_resource, |
| 111 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { | 128 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { |
| 112 void* object = | 129 void* object = |
| 113 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 130 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 114 if (!object) | 131 if (!object) |
| 115 return; | 132 return; |
| 116 | 133 |
| 117 pp::Buffer_Dev encrypted_frame(pp::PassRef(), encrypted_resource); | 134 pp::Buffer_Dev encrypted_frame(pp::PassRef(), encrypted_resource); |
| 118 | 135 |
| 119 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecodeFrame( | 136 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecodeFrame( |
| 120 encrypted_frame, | 137 encrypted_frame, |
| 121 *encrypted_video_frame_info); | 138 *encrypted_video_frame_info); |
| 122 } | 139 } |
| 123 | 140 |
| 124 const PPP_ContentDecryptor_Private ppp_content_decryptor = { | 141 const PPP_ContentDecryptor_Private ppp_content_decryptor = { |
| 125 &GenerateKeyRequest, | 142 &GenerateKeyRequest, |
| 126 &AddKey, | 143 &AddKey, |
| 127 &CancelKeyRequest, | 144 &CancelKeyRequest, |
| 128 &Decrypt, | 145 &Decrypt, |
| 146 &ResetVideoDecoder, |
| 147 &StopVideoDecoder, |
| 129 &DecryptAndDecodeFrame | 148 &DecryptAndDecodeFrame |
| 130 }; | 149 }; |
| 131 | 150 |
| 132 template <> const char* interface_name<PPB_ContentDecryptor_Private>() { | 151 template <> const char* interface_name<PPB_ContentDecryptor_Private>() { |
| 133 return PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE; | 152 return PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE; |
| 134 } | 153 } |
| 135 | 154 |
| 136 } // namespace | 155 } // namespace |
| 137 | 156 |
| 138 ContentDecryptor_Private::ContentDecryptor_Private(Instance* instance) | 157 ContentDecryptor_Private::ContentDecryptor_Private(Instance* instance) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 pp::Buffer_Dev decrypted_block, | 232 pp::Buffer_Dev decrypted_block, |
| 214 const PP_DecryptedBlockInfo& decrypted_block_info) { | 233 const PP_DecryptedBlockInfo& decrypted_block_info) { |
| 215 if (has_interface<PPB_ContentDecryptor_Private>()) { | 234 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 216 get_interface<PPB_ContentDecryptor_Private>()->DeliverBlock( | 235 get_interface<PPB_ContentDecryptor_Private>()->DeliverBlock( |
| 217 associated_instance_.pp_instance(), | 236 associated_instance_.pp_instance(), |
| 218 decrypted_block.pp_resource(), | 237 decrypted_block.pp_resource(), |
| 219 &decrypted_block_info); | 238 &decrypted_block_info); |
| 220 } | 239 } |
| 221 } | 240 } |
| 222 | 241 |
| 242 void ContentDecryptor_Private::DecoderReset(uint32_t request_id) { |
| 243 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 244 get_interface<PPB_ContentDecryptor_Private>()->DecoderReset( |
| 245 associated_instance_.pp_instance(), |
| 246 request_id); |
| 247 } |
| 248 } |
| 249 |
| 250 void ContentDecryptor_Private::DecoderStopped(uint32_t request_id) { |
| 251 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 252 get_interface<PPB_ContentDecryptor_Private>()->DecoderStopped( |
| 253 associated_instance_.pp_instance(), |
| 254 request_id); |
| 255 } |
| 256 } |
| 257 |
| 223 void ContentDecryptor_Private::DeliverFrame( | 258 void ContentDecryptor_Private::DeliverFrame( |
| 224 pp::Buffer_Dev decrypted_frame, | 259 pp::Buffer_Dev decrypted_frame, |
| 225 const PP_DecryptedFrameInfo& decrypted_frame_info) { | 260 const PP_DecryptedFrameInfo& decrypted_frame_info) { |
| 226 if (has_interface<PPB_ContentDecryptor_Private>()) { | 261 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 227 get_interface<PPB_ContentDecryptor_Private>()->DeliverFrame( | 262 get_interface<PPB_ContentDecryptor_Private>()->DeliverFrame( |
| 228 associated_instance_.pp_instance(), | 263 associated_instance_.pp_instance(), |
| 229 decrypted_frame.pp_resource(), | 264 decrypted_frame.pp_resource(), |
| 230 &decrypted_frame_info); | 265 &decrypted_frame_info); |
| 231 } | 266 } |
| 232 } | 267 } |
| 233 | 268 |
| 234 void ContentDecryptor_Private::DeliverSamples( | 269 void ContentDecryptor_Private::DeliverSamples( |
| 235 pp::Buffer_Dev decrypted_samples, | 270 pp::Buffer_Dev decrypted_samples, |
| 236 const PP_DecryptedBlockInfo& decrypted_block_info) { | 271 const PP_DecryptedBlockInfo& decrypted_block_info) { |
| 237 if (has_interface<PPB_ContentDecryptor_Private>()) { | 272 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 238 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( | 273 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( |
| 239 associated_instance_.pp_instance(), | 274 associated_instance_.pp_instance(), |
| 240 decrypted_samples.pp_resource(), | 275 decrypted_samples.pp_resource(), |
| 241 &decrypted_block_info); | 276 &decrypted_block_info); |
| 242 } | 277 } |
| 243 } | 278 } |
| 244 | 279 |
| 245 } // namespace pp | 280 } // namespace pp |
| OLD | NEW |