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

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: Address first round of comments. 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_(this) {
30 }
31
32 PepperVideoDestinationHost::~PepperVideoDestinationHost() {
33 }
34
35 int32_t PepperVideoDestinationHost::OnResourceMessageReceived(
36 const IPC::Message& msg,
37 HostMessageContext* context) {
38 IPC_BEGIN_MESSAGE_MAP(PepperVideoDestinationHost, msg)
39 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_Open,
40 OnHostMsgOpen)
41 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame,
42 OnHostMsgPutFrame)
43 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close,
44 OnHostMsgClose)
45 IPC_END_MESSAGE_MAP()
46 return PP_ERROR_FAILED;
47 }
48
49 int32_t PepperVideoDestinationHost::OnHostMsgOpen(
50 HostMessageContext* context,
51 const std::string& stream_url) {
52 GURL gurl(stream_url);
53 if (!gurl.is_valid())
54 return PP_ERROR_BADARGUMENT;
55 // TODO(ronghuawu) Check that gurl is a valid MediaStream video track URL.
56 // TODO(ronghuawu) Open a MediaStream video track.
57 ReplyMessageContext reply_context = context->MakeReplyMessageContext();
58 reply_context.params.set_result(PP_ERROR_FAILED);
59 host()->SendReply(reply_context,
60 PpapiPluginMsg_VideoDestination_OpenReply());
61 return PP_ERROR_FAILED;
yzshen1 2013/05/02 22:03:05 If you return a value other than PP_OK_COMPLETIONP
bbudge 2013/05/02 23:12:19 Let's return PP_OK_COMPLETIONPENDING here for now.
62 }
63
64 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame(
65 HostMessageContext* context,
66 const ppapi::HostResource& image_data,
67 PP_TimeTicks timestamp) {
68 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter(
69 image_data.host_resource(), true);
70 if (enter.failed())
71 return PP_ERROR_BADRESOURCE;
72 webkit::ppapi::PPB_ImageData_Impl* image_resource =
73 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object());
74
75 if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported(
76 image_resource->format()))
77 return PP_ERROR_BADARGUMENT;
78
79 // TODO(ronghuawu) write image data to MediaStream video track.
80 return PP_ERROR_FAILED;
81 }
82
83 int32_t PepperVideoDestinationHost::OnHostMsgClose(
84 HostMessageContext* context) {
85 // TODO(ronghuawu) Close the video stream.
86 return PP_OK;
87 }
88
89 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698