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

Side by Side Diff: ppapi/proxy/video_writer_resource.cc

Issue 13771020: Add Pepper VideoReader and VideoWriter plumbing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 "ppapi/proxy/video_writer_resource.h"
6
7 #include "base/bind.h"
8 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/pp_video_frame.h"
11 #include "ppapi/proxy/ppapi_messages.h"
12 #include "ppapi/shared_impl/array_writer.h"
13 #include "ppapi/shared_impl/ppapi_globals.h"
14 #include "ppapi/shared_impl/resource_tracker.h"
15 #include "ppapi/shared_impl/var.h"
16 #include "ppapi/thunk/enter.h"
17
18 using ppapi::thunk::EnterResourceNoLock;
19 using ppapi::thunk::PPB_VideoWriter_API;
20
21 namespace {
22
23 } // namespace
24
25 namespace ppapi {
26 namespace proxy {
27
28 VideoWriterResource::VideoWriterResource(
29 Connection connection,
30 PP_Instance instance)
31 : PluginResource(connection, instance) {
32 SendCreate(RENDERER, PpapiHostMsg_VideoWriter_Create());
33 }
34
35 VideoWriterResource::~VideoWriterResource() {
36 }
37
38 PPB_VideoWriter_API* VideoWriterResource::AsPPB_VideoWriter_API() {
39 return this;
40 }
41
42 int32_t VideoWriterResource::Open(
43 PP_Var* stream_id,
44 scoped_refptr<TrackedCallback> callback) {
45 Call<PpapiPluginMsg_VideoWriter_OpenReply>(RENDERER,
46 PpapiHostMsg_VideoWriter_Open(),
47 base::Bind(&VideoWriterResource::OnPluginMsgOpenComplete, this,
48 stream_id, callback));
49 return PP_OK_COMPLETIONPENDING;
50 }
51
52 int32_t VideoWriterResource::PutFrame(const PP_VideoFrame& frame) {
53 Resource* image_object =
54 PpapiGlobals::Get()->GetResourceTracker()->GetResource(frame.image_data);
55 if (!image_object || pp_instance() != image_object->pp_instance()) {
56 Log(PP_LOGLEVEL_ERROR,
57 "VideoWriterResource.PutFrame: Bad image resource.");
58 return PP_ERROR_BADARGUMENT;
59 }
60 Post(RENDERER,
61 PpapiHostMsg_VideoWriter_PutFrame(image_object->host_resource(),
62 frame.timestamp));
63 return PP_OK;
64 }
65
66 void VideoWriterResource::Close() {
67 Post(RENDERER, PpapiHostMsg_VideoWriter_Close());
68 }
69
70 void VideoWriterResource::OnPluginMsgOpenComplete(
71 PP_Var* pp_stream_id,
72 scoped_refptr<TrackedCallback> callback,
73 const ResourceMessageReplyParams& params,
74 const std::string& stream_id) {
75 int32_t result = params.result();
76 *pp_stream_id = StringVar::StringToPPVar(stream_id);
77 callback->Run(result);
78 }
79
80 } // namespace proxy
81 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698