OLD | NEW |
---|---|
(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_source_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/private/pp_video_frame_private.h" | |
11 #include "ppapi/proxy/ppapi_messages.h" | |
12 #include "ppapi/shared_impl/array_writer.h" | |
yzshen1
2013/05/01 23:18:33
this is not needed.
bbudge
2013/05/02 21:39:06
Done.
| |
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_VideoSource_Private_API; | |
20 | |
21 namespace { | |
yzshen1
2013/05/01 23:18:33
this is not needed.
bbudge
2013/05/02 21:39:06
Done.
| |
22 | |
23 } // namespace | |
24 | |
25 namespace ppapi { | |
26 namespace proxy { | |
27 | |
28 VideoSourceResource::VideoSourceResource( | |
29 Connection connection, | |
30 PP_Instance instance) | |
31 : PluginResource(connection, instance) { | |
32 SendCreate(RENDERER, PpapiHostMsg_VideoSource_Create()); | |
33 } | |
34 | |
35 VideoSourceResource::~VideoSourceResource() { | |
36 } | |
37 | |
38 PPB_VideoSource_Private_API* | |
39 VideoSourceResource::AsPPB_VideoSource_Private_API() { | |
40 return this; | |
41 } | |
42 | |
43 int32_t VideoSourceResource::Open( | |
44 PP_Var stream_url, | |
45 scoped_refptr<TrackedCallback> callback) { | |
46 scoped_refptr<StringVar> stream_url_var = StringVar::FromPPVar(stream_url); | |
47 const uint32_t kMaxStreamIdSizeInBytes = 16384; | |
48 if (!stream_url_var || | |
49 stream_url_var->value().size() > kMaxStreamIdSizeInBytes) | |
50 return PP_ERROR_BADARGUMENT; | |
51 Call<PpapiPluginMsg_VideoSource_OpenReply>(RENDERER, | |
52 PpapiHostMsg_VideoSource_Open(stream_url_var->value()), | |
53 base::Bind(&VideoSourceResource::OnPluginMsgOpenComplete, this, | |
54 callback)); | |
55 return PP_OK_COMPLETIONPENDING; | |
56 } | |
57 | |
58 int32_t VideoSourceResource::GetFrame( | |
59 PP_VideoFrame_Private* frame, | |
60 scoped_refptr<TrackedCallback> callback) { | |
61 Call<PpapiPluginMsg_VideoSource_GetFrameReply>(RENDERER, | |
62 PpapiHostMsg_VideoSource_GetFrame(), | |
63 base::Bind(&VideoSourceResource::OnPluginMsgGetFrameComplete, this, | |
64 callback, frame)); | |
65 return PP_OK_COMPLETIONPENDING; | |
66 } | |
67 | |
68 void VideoSourceResource::Close() { | |
69 Post(RENDERER, PpapiHostMsg_VideoSource_Close()); | |
70 } | |
71 | |
72 void VideoSourceResource::OnPluginMsgOpenComplete( | |
73 scoped_refptr<TrackedCallback> callback, | |
74 const ResourceMessageReplyParams& params) { | |
75 int32_t result = params.result(); | |
76 callback->Run(result); | |
77 } | |
78 | |
79 void VideoSourceResource::OnPluginMsgGetFrameComplete( | |
80 scoped_refptr<TrackedCallback> callback, | |
81 PP_VideoFrame_Private* frame, | |
82 const ResourceMessageReplyParams& params, | |
83 const HostResource& image_data, | |
84 double timestamp) { | |
85 int32_t result = params.result(); | |
yzshen1
2013/05/01 23:18:33
We need to test whether the callback is still pend
bbudge
2013/05/02 21:39:06
Done. I redid the whole callback setup for both re
| |
86 if (result == PP_OK) { | |
87 frame->timestamp = static_cast<PP_TimeTicks>(timestamp); | |
88 frame->image_data = image_data.host_resource(); | |
89 } | |
90 | |
91 callback->Run(result); | |
92 } | |
93 | |
94 } // namespace proxy | |
95 } // namespace ppapi | |
OLD | NEW |