Chromium Code Reviews| Index: content/renderer/pepper/pepper_video_destination_host.cc |
| diff --git a/content/renderer/pepper/pepper_video_destination_host.cc b/content/renderer/pepper/pepper_video_destination_host.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d6e7f2ab829676b48912e77f9e4badd29021eef9 |
| --- /dev/null |
| +++ b/content/renderer/pepper/pepper_video_destination_host.cc |
| @@ -0,0 +1,89 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/renderer/pepper/pepper_video_destination_host.h" |
| + |
| +#include "base/bind.h" |
| +#include "content/public/renderer/renderer_ppapi_host.h" |
| +#include "ppapi/c/pp_errors.h" |
| +#include "ppapi/host/dispatch_host_message.h" |
| +#include "ppapi/host/host_message_context.h" |
| +#include "ppapi/host/ppapi_host.h" |
| +#include "ppapi/proxy/ppapi_messages.h" |
| +#include "ppapi/thunk/enter.h" |
| +#include "ppapi/thunk/ppb_image_data_api.h" |
| +#include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
| + |
| +using ppapi::host::HostMessageContext; |
| +using ppapi::host::ReplyMessageContext; |
| + |
| +namespace content { |
| + |
| +PepperVideoDestinationHost::PepperVideoDestinationHost( |
| + RendererPpapiHost* host, |
| + PP_Instance instance, |
| + PP_Resource resource) |
| + : ResourceHost(host->GetPpapiHost(), instance, resource), |
| + renderer_ppapi_host_(host), |
| + weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| +} |
| + |
| +PepperVideoDestinationHost::~PepperVideoDestinationHost() { |
| +} |
| + |
| +int32_t PepperVideoDestinationHost::OnResourceMessageReceived( |
| + const IPC::Message& msg, |
| + HostMessageContext* context) { |
| + if (!host()->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) |
|
yzshen1
2013/05/01 23:18:33
If we don't have private permission, this host ins
bbudge
2013/05/02 21:39:06
True. Removed the check. I copied this from other
|
| + return PP_ERROR_FAILED; |
| + |
| + IPC_BEGIN_MESSAGE_MAP(PepperVideoDestinationHost, msg) |
| + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Open, |
| + OnHostMsgOpen) |
| + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame, |
| + OnHostMsgPutFrame) |
| + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close, |
| + OnHostMsgClose) |
| + IPC_END_MESSAGE_MAP() |
| + return PP_ERROR_FAILED; |
| +} |
| + |
| +int32_t PepperVideoDestinationHost::OnHostMsgOpen(HostMessageContext* context) { |
| + ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
| + reply_context.params.set_result(PP_ERROR_FAILED); |
| + host()->SendReply(reply_context, |
| + PpapiPluginMsg_VideoDestination_OpenReply()); |
| + return PP_OK_COMPLETIONPENDING; |
|
yzshen1
2013/05/01 23:18:33
nit, optional: you could set context->reply_msg an
bbudge
2013/05/02 21:39:06
Done.
|
| +} |
| + |
| +int32_t PepperVideoDestinationHost::OnHostMsgPutFrame( |
| + HostMessageContext* context, |
| + const ppapi::HostResource& image_data, |
| + double timestamp) { |
| + ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
| + |
| + ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter( |
| + image_data.host_resource(), true); |
| + if (enter.failed()) |
| + return PP_ERROR_BADRESOURCE; |
| + webkit::ppapi::PPB_ImageData_Impl* image_resource = |
| + static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object()); |
| + |
| + if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported( |
| + image_resource->format())) |
| + return PP_ERROR_BADARGUMENT; |
| + |
| + // TODO() write image data to MediaStream video track. |
| + |
| + reply_context.params.set_result(PP_ERROR_FAILED); |
| + return PP_OK_COMPLETIONPENDING; |
| +} |
| + |
| +int32_t PepperVideoDestinationHost::OnHostMsgClose( |
| + HostMessageContext* context) { |
| + // Close the video stream. |
| + return PP_OK; |
| +} |
| + |
| +} // namespace content |