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_destination_host.h" |
| 6 |
| 7 #include "content/public/renderer/renderer_ppapi_host.h" |
| 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/host/dispatch_host_message.h" |
| 10 #include "ppapi/host/host_message_context.h" |
| 11 #include "ppapi/host/ppapi_host.h" |
| 12 #include "ppapi/proxy/ppapi_messages.h" |
| 13 #include "ppapi/thunk/enter.h" |
| 14 #include "ppapi/thunk/ppb_image_data_api.h" |
| 15 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
| 16 |
| 17 using ppapi::host::HostMessageContext; |
| 18 using ppapi::host::ReplyMessageContext; |
| 19 |
| 20 namespace content { |
| 21 |
| 22 PepperVideoDestinationHost::PepperVideoDestinationHost( |
| 23 RendererPpapiHost* host, |
| 24 PP_Instance instance, |
| 25 PP_Resource resource) |
| 26 : ResourceHost(host->GetPpapiHost(), instance, resource), |
| 27 renderer_ppapi_host_(host), |
| 28 weak_factory_(this) { |
| 29 } |
| 30 |
| 31 PepperVideoDestinationHost::~PepperVideoDestinationHost() { |
| 32 } |
| 33 |
| 34 int32_t PepperVideoDestinationHost::OnResourceMessageReceived( |
| 35 const IPC::Message& msg, |
| 36 HostMessageContext* context) { |
| 37 IPC_BEGIN_MESSAGE_MAP(PepperVideoDestinationHost, msg) |
| 38 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_Open, |
| 39 OnHostMsgOpen) |
| 40 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame, |
| 41 OnHostMsgPutFrame) |
| 42 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close, |
| 43 OnHostMsgClose) |
| 44 IPC_END_MESSAGE_MAP() |
| 45 return PP_ERROR_FAILED; |
| 46 } |
| 47 |
| 48 int32_t PepperVideoDestinationHost::OnHostMsgOpen( |
| 49 HostMessageContext* context, |
| 50 const std::string& stream_url) { |
| 51 GURL gurl(stream_url); |
| 52 if (!gurl.is_valid()) |
| 53 return PP_ERROR_BADARGUMENT; |
| 54 // TODO(ronghuawu) Check that gurl is a valid MediaStream video track URL. |
| 55 // TODO(ronghuawu) Open a MediaStream video track. |
| 56 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
| 57 reply_context.params.set_result(PP_OK); |
| 58 host()->SendReply(reply_context, |
| 59 PpapiPluginMsg_VideoDestination_OpenReply()); |
| 60 return PP_OK_COMPLETIONPENDING; |
| 61 } |
| 62 |
| 63 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame( |
| 64 HostMessageContext* context, |
| 65 const ppapi::HostResource& image_data, |
| 66 PP_TimeTicks timestamp) { |
| 67 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter( |
| 68 image_data.host_resource(), true); |
| 69 if (enter.failed()) |
| 70 return PP_ERROR_BADRESOURCE; |
| 71 webkit::ppapi::PPB_ImageData_Impl* image_resource = |
| 72 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object()); |
| 73 |
| 74 if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported( |
| 75 image_resource->format())) |
| 76 return PP_ERROR_BADARGUMENT; |
| 77 |
| 78 // TODO(ronghuawu) write image data to MediaStream video track. |
| 79 return PP_OK; |
| 80 } |
| 81 |
| 82 int32_t PepperVideoDestinationHost::OnHostMsgClose( |
| 83 HostMessageContext* context) { |
| 84 // TODO(ronghuawu) Close the video stream. |
| 85 return PP_OK; |
| 86 } |
| 87 |
| 88 } // namespace content |
OLD | NEW |