Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/pepper/pepper_video_reader_host.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "content/public/renderer/renderer_ppapi_host.h" | |
| 9 #include "ppapi/c/pp_errors.h" | |
| 10 #include "ppapi/host/dispatch_host_message.h" | |
| 11 #include "ppapi/host/host_message_context.h" | |
| 12 #include "ppapi/host/ppapi_host.h" | |
| 13 #include "ppapi/proxy/ppapi_messages.h" | |
| 14 | |
| 15 using ppapi::host::HostMessageContext; | |
| 16 using ppapi::host::ReplyMessageContext; | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 PepperVideoReaderHost::PepperVideoReaderHost( | |
| 21 RendererPpapiHost* host, | |
| 22 PP_Instance instance, | |
| 23 PP_Resource resource) | |
| 24 : ResourceHost(host->GetPpapiHost(), instance, resource), | |
| 25 renderer_ppapi_host_(host), | |
| 26 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | |
| 27 } | |
| 28 | |
| 29 PepperVideoReaderHost::~PepperVideoReaderHost() { | |
| 30 } | |
| 31 | |
| 32 int32_t PepperVideoReaderHost::OnResourceMessageReceived( | |
| 33 const IPC::Message& msg, | |
| 34 HostMessageContext* context) { | |
| 35 if (!host()->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) | |
| 36 return PP_ERROR_FAILED; | |
| 37 | |
| 38 IPC_BEGIN_MESSAGE_MAP(PepperVideoReaderHost, msg) | |
| 39 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoReader_Open, | |
| 40 OnHostMsgOpen) | |
| 41 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoReader_GetFrame, | |
| 42 OnHostMsgGetFrame) | |
| 43 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoReader_Close, | |
| 44 OnHostMsgClose) | |
| 45 IPC_END_MESSAGE_MAP() | |
| 46 return PP_ERROR_FAILED; | |
| 47 } | |
| 48 | |
| 49 int32_t PepperVideoReaderHost::OnHostMsgOpen(HostMessageContext* context, | |
| 50 const std::string& stream_id) { | |
| 51 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); | |
| 52 // Create the video stream here and return error / result code. | |
| 53 reply_context.params.set_result(PP_ERROR_FAILED); | |
| 54 host()->SendReply(reply_context, | |
| 55 PpapiPluginMsg_VideoReader_OpenReply()); | |
| 56 return PP_OK_COMPLETIONPENDING; | |
| 57 } | |
| 58 | |
| 59 int32_t PepperVideoReaderHost::OnHostMsgGetFrame(HostMessageContext* context) { | |
| 60 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); | |
| 61 // Create an image data resource and copy the stream's next frame into it. | |
|
Ronghua Wu (Left Chromium)
2013/04/08 22:34:39
Will the plugin need to call this GetFrame for eve
bbudge
2013/04/08 22:38:01
My understanding of this API is that the plugin 'p
| |
| 62 // Return a timestamp. | |
| 63 ppapi::HostResource image_data; | |
| 64 double timestamp = 0; | |
| 65 reply_context.params.set_result(PP_ERROR_FAILED); | |
| 66 host()->SendReply( | |
| 67 reply_context, | |
| 68 PpapiPluginMsg_VideoReader_GetFrameReply(image_data, timestamp)); | |
| 69 return PP_OK_COMPLETIONPENDING; | |
| 70 } | |
| 71 | |
| 72 int32_t PepperVideoReaderHost::OnHostMsgClose(HostMessageContext* context) { | |
| 73 // Close the video stream. | |
| 74 return PP_OK; | |
| 75 } | |
| 76 | |
| 77 } // namespace content | |
| OLD | NEW |