| 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/proxy/ppp_content_decryptor_private_proxy.h" | 5 #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h" |
| 6 | 6 |
| 7 #include "base/platform_file.h" | 7 #include "base/platform_file.h" |
| 8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/ppb_core.h" | 9 #include "ppapi/c/ppb_core.h" |
| 10 #include "ppapi/proxy/content_decryptor_private_serializer.h" | 10 #include "ppapi/proxy/content_decryptor_private_serializer.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 | 136 |
| 137 dispatcher->Send( | 137 dispatcher->Send( |
| 138 new PpapiMsg_PPPContentDecryptor_CancelKeyRequest( | 138 new PpapiMsg_PPPContentDecryptor_CancelKeyRequest( |
| 139 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 139 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 140 instance, | 140 instance, |
| 141 SerializedVarSendInput(dispatcher, session_id))); | 141 SerializedVarSendInput(dispatcher, session_id))); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void Decrypt(PP_Instance instance, | 144 void Decrypt(PP_Instance instance, |
| 145 PP_Resource encrypted_block, | 145 PP_Resource encrypted_block, |
| 146 const PP_EncryptedBlockInfo* encrypted_block_info) { | 146 const PP_EncryptedBlockInfo* encrypted_block_info) { |
| 147 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 147 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 148 if (!dispatcher) { | 148 if (!dispatcher) { |
| 149 NOTREACHED(); | 149 NOTREACHED(); |
| 150 return; | 150 return; |
| 151 } | 151 } |
| 152 | 152 |
| 153 if (!AddRefResourceForPlugin(dispatcher, encrypted_block)) { | 153 if (!AddRefResourceForPlugin(dispatcher, encrypted_block)) { |
| 154 NOTREACHED(); | 154 NOTREACHED(); |
| 155 return; | 155 return; |
| 156 } | 156 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 dispatcher->Send( | 180 dispatcher->Send( |
| 181 new PpapiMsg_PPPContentDecryptor_Decrypt( | 181 new PpapiMsg_PPPContentDecryptor_Decrypt( |
| 182 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 182 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 183 instance, | 183 instance, |
| 184 buffer, | 184 buffer, |
| 185 serialized_block_info)); | 185 serialized_block_info)); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void DecryptAndDecodeFrame( | 188 void DecryptAndDecode(PP_Instance instance, |
| 189 PP_Instance instance, | 189 PP_StreamType decoder_type, |
| 190 PP_Resource encrypted_frame, | 190 PP_Resource encrypted_buffer, |
| 191 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { | 191 const PP_EncryptedBlockInfo* encrypted_block_info) { |
| 192 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 192 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 193 if (!dispatcher) { | 193 if (!dispatcher) { |
| 194 NOTREACHED(); | 194 NOTREACHED(); |
| 195 return; | 195 return; |
| 196 } | 196 } |
| 197 | 197 |
| 198 if (!AddRefResourceForPlugin(dispatcher, encrypted_frame)) { | 198 if (!AddRefResourceForPlugin(dispatcher, encrypted_buffer)) { |
| 199 NOTREACHED(); | 199 NOTREACHED(); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 | 202 |
| 203 HostResource host_resource; | 203 HostResource host_resource; |
| 204 host_resource.SetHostResource(instance, encrypted_frame); | 204 host_resource.SetHostResource(instance, encrypted_buffer); |
| 205 | 205 |
| 206 uint32_t size = 0; | 206 uint32_t size = 0; |
| 207 if (DescribeHostBufferResource(encrypted_frame, &size) == PP_FALSE) | 207 if (DescribeHostBufferResource(encrypted_buffer, &size) == PP_FALSE) |
| 208 return; | 208 return; |
| 209 | 209 |
| 210 base::SharedMemoryHandle handle; | 210 base::SharedMemoryHandle handle; |
| 211 if (ShareHostBufferResourceToPlugin(dispatcher, | 211 if (ShareHostBufferResourceToPlugin(dispatcher, |
| 212 encrypted_frame, | 212 encrypted_buffer, |
| 213 &handle) == PP_FALSE) | 213 &handle) == PP_FALSE) |
| 214 return; | 214 return; |
| 215 | 215 |
| 216 PPPDecryptor_Buffer buffer; | 216 PPPDecryptor_Buffer buffer; |
| 217 buffer.resource = host_resource; | 217 buffer.resource = host_resource; |
| 218 buffer.handle = handle; | 218 buffer.handle = handle; |
| 219 buffer.size = size; | 219 buffer.size = size; |
| 220 | 220 |
| 221 std::string serialized_frame_info; | 221 std::string serialized_block_info; |
| 222 if (!SerializeBlockInfo(*encrypted_video_frame_info, &serialized_frame_info)) | 222 if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) |
| 223 return; | 223 return; |
| 224 | 224 |
| 225 dispatcher->Send( | 225 dispatcher->Send( |
| 226 new PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame( | 226 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( |
| 227 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 227 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 228 instance, | 228 instance, |
| 229 decoder_type, |
| 229 buffer, | 230 buffer, |
| 230 serialized_frame_info)); | 231 serialized_block_info)); |
| 231 } | 232 } |
| 232 | 233 |
| 233 static const PPP_ContentDecryptor_Private content_decryptor_interface = { | 234 static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
| 234 &GenerateKeyRequest, | 235 &GenerateKeyRequest, |
| 235 &AddKey, | 236 &AddKey, |
| 236 &CancelKeyRequest, | 237 &CancelKeyRequest, |
| 237 &Decrypt, | 238 &Decrypt, |
| 238 &DecryptAndDecodeFrame | 239 &DecryptAndDecode |
| 239 }; | 240 }; |
| 240 | 241 |
| 241 } // namespace | 242 } // namespace |
| 242 | 243 |
| 243 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( | 244 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( |
| 244 Dispatcher* dispatcher) | 245 Dispatcher* dispatcher) |
| 245 : InterfaceProxy(dispatcher), | 246 : InterfaceProxy(dispatcher), |
| 246 ppp_decryptor_impl_(NULL) { | 247 ppp_decryptor_impl_(NULL) { |
| 247 if (dispatcher->IsPlugin()) { | 248 if (dispatcher->IsPlugin()) { |
| 248 ppp_decryptor_impl_ = static_cast<const PPP_ContentDecryptor_Private*>( | 249 ppp_decryptor_impl_ = static_cast<const PPP_ContentDecryptor_Private*>( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 265 bool handled = true; | 266 bool handled = true; |
| 266 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) | 267 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) |
| 267 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, | 268 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, |
| 268 OnMsgGenerateKeyRequest) | 269 OnMsgGenerateKeyRequest) |
| 269 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, | 270 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, |
| 270 OnMsgAddKey) | 271 OnMsgAddKey) |
| 271 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, | 272 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, |
| 272 OnMsgCancelKeyRequest) | 273 OnMsgCancelKeyRequest) |
| 273 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, | 274 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
| 274 OnMsgDecrypt) | 275 OnMsgDecrypt) |
| 275 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, | 276 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, |
| 276 OnMsgDecryptAndDecodeFrame) | 277 OnMsgDecryptAndDecode) |
| 277 IPC_MESSAGE_UNHANDLED(handled = false) | 278 IPC_MESSAGE_UNHANDLED(handled = false) |
| 278 IPC_END_MESSAGE_MAP() | 279 IPC_END_MESSAGE_MAP() |
| 279 DCHECK(handled); | 280 DCHECK(handled); |
| 280 return handled; | 281 return handled; |
| 281 } | 282 } |
| 282 | 283 |
| 283 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( | 284 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( |
| 284 PP_Instance instance, | 285 PP_Instance instance, |
| 285 SerializedVarReceiveInput key_system, | 286 SerializedVarReceiveInput key_system, |
| 286 SerializedVarReceiveInput init_data) { | 287 SerializedVarReceiveInput init_data) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 PP_EncryptedBlockInfo block_info; | 329 PP_EncryptedBlockInfo block_info; |
| 329 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) | 330 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) |
| 330 return; | 331 return; |
| 331 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, | 332 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, |
| 332 instance, | 333 instance, |
| 333 plugin_resource, | 334 plugin_resource, |
| 334 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); | 335 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
| 335 } | 336 } |
| 336 } | 337 } |
| 337 | 338 |
| 338 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( | 339 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecode( |
| 339 PP_Instance instance, | 340 PP_Instance instance, |
| 340 const PPPDecryptor_Buffer& encrypted_frame, | 341 PP_StreamType decoder_type, |
| 341 const std::string& serialized_frame_info) { | 342 const PPPDecryptor_Buffer& encrypted_buffer, |
| 343 const std::string& serialized_block_info) { |
| 342 if (ppp_decryptor_impl_) { | 344 if (ppp_decryptor_impl_) { |
| 343 PP_Resource plugin_resource = | 345 PP_Resource plugin_resource = |
| 344 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, | 346 PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, |
| 345 encrypted_frame.handle, | 347 encrypted_buffer.handle, |
| 346 encrypted_frame.size); | 348 encrypted_buffer.size); |
| 347 PP_EncryptedVideoFrameInfo frame_info; | 349 PP_EncryptedBlockInfo block_info; |
| 348 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) | 350 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) |
| 349 return; | 351 return; |
| 350 CallWhileUnlocked( | 352 CallWhileUnlocked( |
| 351 ppp_decryptor_impl_->DecryptAndDecodeFrame, | 353 ppp_decryptor_impl_->DecryptAndDecode, |
| 352 instance, | 354 instance, |
| 355 decoder_type, |
| 353 plugin_resource, | 356 plugin_resource, |
| 354 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); | 357 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
| 355 } | 358 } |
| 356 } | 359 } |
| 357 | 360 |
| 358 } // namespace proxy | 361 } // namespace proxy |
| 359 } // namespace ppapi | 362 } // namespace ppapi |
| OLD | NEW |