Index: content/renderer/pepper/pepper_video_writer_host.cc |
diff --git a/content/renderer/pepper/pepper_video_writer_host.cc b/content/renderer/pepper/pepper_video_writer_host.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2679817d13ee82f724410d7d367bd84f6d14077c |
--- /dev/null |
+++ b/content/renderer/pepper/pepper_video_writer_host.cc |
@@ -0,0 +1,74 @@ |
+// 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_writer_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" |
+ |
+using ppapi::host::HostMessageContext; |
+using ppapi::host::ReplyMessageContext; |
+ |
+namespace content { |
+ |
+PepperVideoWriterHost::PepperVideoWriterHost( |
+ 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)) { |
+} |
+ |
+PepperVideoWriterHost::~PepperVideoWriterHost() { |
+} |
+ |
+int32_t PepperVideoWriterHost::OnResourceMessageReceived( |
+ const IPC::Message& msg, |
+ HostMessageContext* context) { |
+ if (!host()->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) |
+ return PP_ERROR_FAILED; |
+ |
+ IPC_BEGIN_MESSAGE_MAP(PepperVideoWriterHost, msg) |
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoWriter_Open, |
+ OnHostMsgOpen) |
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoWriter_PutFrame, |
+ OnHostMsgPutFrame) |
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoWriter_Close, |
+ OnHostMsgClose) |
+ IPC_END_MESSAGE_MAP() |
+ return PP_ERROR_FAILED; |
+} |
+ |
+int32_t PepperVideoWriterHost::OnHostMsgOpen(HostMessageContext* context) { |
+ ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
+ // Open a video stream for writing. |
+ std::string stream_id; |
+ reply_context.params.set_result(PP_ERROR_FAILED); |
+ host()->SendReply(reply_context, |
+ PpapiPluginMsg_VideoWriter_OpenReply(stream_id)); |
+ return PP_OK_COMPLETIONPENDING; |
+} |
+ |
+int32_t PepperVideoWriterHost::OnHostMsgPutFrame( |
+ HostMessageContext* context, |
+ const ppapi::HostResource& image_data, |
+ double timestamp) { |
+ ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
+ // Copy the image data to the video stream. |
+ reply_context.params.set_result(PP_ERROR_FAILED); |
+ return PP_OK_COMPLETIONPENDING; |
+} |
+ |
+int32_t PepperVideoWriterHost::OnHostMsgClose(HostMessageContext* context) { |
+ // Close the video stream. |
+ return PP_OK; |
+} |
+ |
+} // namespace content |