| 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 DeinitializeDecoder(PP_Instance instance, |
| 189 PP_StreamType decoder_type, |
| 190 uint32_t request_id) { |
| 191 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 192 if (!dispatcher) { |
| 193 NOTREACHED(); |
| 194 return; |
| 195 } |
| 196 |
| 197 dispatcher->Send( |
| 198 new PpapiMsg_PPPContentDecryptor_DeinitializeDecoder( |
| 199 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 200 instance, |
| 201 decoder_type, |
| 202 request_id)); |
| 203 } |
| 204 |
| 205 void ResetDecoder(PP_Instance instance, |
| 206 PP_StreamType decoder_type, |
| 207 uint32_t request_id) { |
| 208 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 209 if (!dispatcher) { |
| 210 NOTREACHED(); |
| 211 return; |
| 212 } |
| 213 |
| 214 dispatcher->Send( |
| 215 new PpapiMsg_PPPContentDecryptor_ResetDecoder( |
| 216 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 217 instance, |
| 218 decoder_type, |
| 219 request_id)); |
| 220 } |
| 221 |
| 188 void DecryptAndDecodeFrame( | 222 void DecryptAndDecodeFrame( |
| 189 PP_Instance instance, | 223 PP_Instance instance, |
| 190 PP_Resource encrypted_frame, | 224 PP_Resource encrypted_frame, |
| 191 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { | 225 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { |
| 192 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 226 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 193 if (!dispatcher) { | 227 if (!dispatcher) { |
| 194 NOTREACHED(); | 228 NOTREACHED(); |
| 195 return; | 229 return; |
| 196 } | 230 } |
| 197 | 231 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 228 instance, | 262 instance, |
| 229 buffer, | 263 buffer, |
| 230 serialized_frame_info)); | 264 serialized_frame_info)); |
| 231 } | 265 } |
| 232 | 266 |
| 233 static const PPP_ContentDecryptor_Private content_decryptor_interface = { | 267 static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
| 234 &GenerateKeyRequest, | 268 &GenerateKeyRequest, |
| 235 &AddKey, | 269 &AddKey, |
| 236 &CancelKeyRequest, | 270 &CancelKeyRequest, |
| 237 &Decrypt, | 271 &Decrypt, |
| 272 &DeinitializeDecoder, |
| 273 &ResetDecoder, |
| 238 &DecryptAndDecodeFrame | 274 &DecryptAndDecodeFrame |
| 239 }; | 275 }; |
| 240 | 276 |
| 241 } // namespace | 277 } // namespace |
| 242 | 278 |
| 243 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( | 279 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( |
| 244 Dispatcher* dispatcher) | 280 Dispatcher* dispatcher) |
| 245 : InterfaceProxy(dispatcher), | 281 : InterfaceProxy(dispatcher), |
| 246 ppp_decryptor_impl_(NULL) { | 282 ppp_decryptor_impl_(NULL) { |
| 247 if (dispatcher->IsPlugin()) { | 283 if (dispatcher->IsPlugin()) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 265 bool handled = true; | 301 bool handled = true; |
| 266 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) | 302 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) |
| 267 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, | 303 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, |
| 268 OnMsgGenerateKeyRequest) | 304 OnMsgGenerateKeyRequest) |
| 269 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, | 305 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, |
| 270 OnMsgAddKey) | 306 OnMsgAddKey) |
| 271 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, | 307 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, |
| 272 OnMsgCancelKeyRequest) | 308 OnMsgCancelKeyRequest) |
| 273 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, | 309 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
| 274 OnMsgDecrypt) | 310 OnMsgDecrypt) |
| 311 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, |
| 312 OnMsgDeinitializeDecoder) |
| 313 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, |
| 314 OnMsgResetDecoder) |
| 275 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, | 315 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, |
| 276 OnMsgDecryptAndDecodeFrame) | 316 OnMsgDecryptAndDecodeFrame) |
| 277 IPC_MESSAGE_UNHANDLED(handled = false) | 317 IPC_MESSAGE_UNHANDLED(handled = false) |
| 278 IPC_END_MESSAGE_MAP() | 318 IPC_END_MESSAGE_MAP() |
| 279 DCHECK(handled); | 319 DCHECK(handled); |
| 280 return handled; | 320 return handled; |
| 281 } | 321 } |
| 282 | 322 |
| 283 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( | 323 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( |
| 284 PP_Instance instance, | 324 PP_Instance instance, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 PP_EncryptedBlockInfo block_info; | 368 PP_EncryptedBlockInfo block_info; |
| 329 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) | 369 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) |
| 330 return; | 370 return; |
| 331 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, | 371 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, |
| 332 instance, | 372 instance, |
| 333 plugin_resource, | 373 plugin_resource, |
| 334 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); | 374 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
| 335 } | 375 } |
| 336 } | 376 } |
| 337 | 377 |
| 378 void PPP_ContentDecryptor_Private_Proxy::OnMsgDeinitializeDecoder( |
| 379 PP_Instance instance, |
| 380 PP_StreamType decoder_type, |
| 381 uint32_t request_id) { |
| 382 if (ppp_decryptor_impl_) { |
| 383 CallWhileUnlocked( |
| 384 ppp_decryptor_impl_->DeinitializeDecoder, |
| 385 instance, |
| 386 decoder_type, |
| 387 request_id); |
| 388 } |
| 389 } |
| 390 |
| 391 void PPP_ContentDecryptor_Private_Proxy::OnMsgResetDecoder( |
| 392 PP_Instance instance, |
| 393 PP_StreamType decoder_type, |
| 394 uint32_t request_id) { |
| 395 if (ppp_decryptor_impl_) { |
| 396 CallWhileUnlocked( |
| 397 ppp_decryptor_impl_->ResetDecoder, |
| 398 instance, |
| 399 decoder_type, |
| 400 request_id); |
| 401 } |
| 402 } |
| 403 |
| 338 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( | 404 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( |
| 339 PP_Instance instance, | 405 PP_Instance instance, |
| 340 const PPPDecryptor_Buffer& encrypted_frame, | 406 const PPPDecryptor_Buffer& encrypted_frame, |
| 341 const std::string& serialized_frame_info) { | 407 const std::string& serialized_frame_info) { |
| 342 if (ppp_decryptor_impl_) { | 408 if (ppp_decryptor_impl_) { |
| 343 PP_Resource plugin_resource = | 409 PP_Resource plugin_resource = |
| 344 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, | 410 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, |
| 345 encrypted_frame.handle, | 411 encrypted_frame.handle, |
| 346 encrypted_frame.size); | 412 encrypted_frame.size); |
| 347 PP_EncryptedVideoFrameInfo frame_info; | 413 PP_EncryptedVideoFrameInfo frame_info; |
| 348 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) | 414 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) |
| 349 return; | 415 return; |
| 350 CallWhileUnlocked( | 416 CallWhileUnlocked( |
| 351 ppp_decryptor_impl_->DecryptAndDecodeFrame, | 417 ppp_decryptor_impl_->DecryptAndDecodeFrame, |
| 352 instance, | 418 instance, |
| 353 plugin_resource, | 419 plugin_resource, |
| 354 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); | 420 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); |
| 355 } | 421 } |
| 356 } | 422 } |
| 357 | 423 |
| 358 } // namespace proxy | 424 } // namespace proxy |
| 359 } // namespace ppapi | 425 } // namespace ppapi |
| OLD | NEW |