Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: content/renderer/pepper/pepper_video_destination_host.cc

Issue 13771020: Add Pepper VideoReader and VideoWriter plumbing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ImageData management, depends on 14170012 Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "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 #include "ppapi/thunk/enter.h"
15 #include "ppapi/thunk/ppb_image_data_api.h"
16 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
17
18 using ppapi::host::HostMessageContext;
19 using ppapi::host::ReplyMessageContext;
20
21 namespace content {
22
23 PepperVideoDestinationHost::PepperVideoDestinationHost(
24 RendererPpapiHost* host,
25 PP_Instance instance,
26 PP_Resource resource)
27 : ResourceHost(host->GetPpapiHost(), instance, resource),
28 renderer_ppapi_host_(host),
29 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
30 }
31
32 PepperVideoDestinationHost::~PepperVideoDestinationHost() {
33 }
34
35 int32_t PepperVideoDestinationHost::OnResourceMessageReceived(
36 const IPC::Message& msg,
37 HostMessageContext* context) {
38 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
39 return PP_ERROR_FAILED;
40
41 IPC_BEGIN_MESSAGE_MAP(PepperVideoDestinationHost, msg)
42 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Open,
43 OnHostMsgOpen)
44 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame,
45 OnHostMsgPutFrame)
46 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close,
47 OnHostMsgClose)
48 IPC_END_MESSAGE_MAP()
49 return PP_ERROR_FAILED;
50 }
51
52 int32_t PepperVideoDestinationHost::OnHostMsgOpen(HostMessageContext* context) {
53 ReplyMessageContext reply_context = context->MakeReplyMessageContext();
54 reply_context.params.set_result(PP_ERROR_FAILED);
55 host()->SendReply(reply_context,
56 PpapiPluginMsg_VideoDestination_OpenReply());
57 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.
58 }
59
60 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame(
61 HostMessageContext* context,
62 const ppapi::HostResource& image_data,
63 double timestamp) {
64 ReplyMessageContext reply_context = context->MakeReplyMessageContext();
65
66 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter(
67 image_data.host_resource(), true);
68 if (enter.failed())
69 return PP_ERROR_BADRESOURCE;
70 webkit::ppapi::PPB_ImageData_Impl* image_resource =
71 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object());
72
73 if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported(
74 image_resource->format()))
75 return PP_ERROR_BADARGUMENT;
76
77 // TODO() write image data to MediaStream video track.
78
79 reply_context.params.set_result(PP_ERROR_FAILED);
80 return PP_OK_COMPLETIONPENDING;
81 }
82
83 int32_t PepperVideoDestinationHost::OnHostMsgClose(
84 HostMessageContext* context) {
85 // Close the video stream.
86 return PP_OK;
87 }
88
89 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698