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

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

Issue 11274036: Refactor video capture to new design (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: export Created 8 years, 1 month 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
« no previous file with comments | « ppapi/proxy/ppb_video_capture_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/ppb_video_capture_proxy.h"
6
7 #include "base/compiler_specific.h"
8 #include "base/logging.h"
9 #include "build/build_config.h"
10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/c/pp_resource.h"
12 #include "ppapi/c/ppb_core.h"
13 #include "ppapi/c/dev/ppb_video_capture_dev.h"
14 #include "ppapi/proxy/enter_proxy.h"
15 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/ppapi_messages.h"
18 #include "ppapi/proxy/ppb_buffer_proxy.h"
19 #include "ppapi/shared_impl/ppapi_globals.h"
20 #include "ppapi/shared_impl/ppb_video_capture_shared.h"
21 #include "ppapi/shared_impl/proxy_lock.h"
22 #include "ppapi/shared_impl/resource_tracker.h"
23 #include "ppapi/shared_impl/tracked_callback.h"
24 #include "ppapi/thunk/ppb_buffer_api.h"
25 #include "ppapi/thunk/ppb_buffer_trusted_api.h"
26 #include "ppapi/thunk/ppb_video_capture_api.h"
27 #include "ppapi/thunk/resource_creation_api.h"
28 #include "ppapi/thunk/thunk.h"
29
30 using ppapi::thunk::EnterResourceNoLock;
31 using ppapi::thunk::PPB_Buffer_API;
32 using ppapi::thunk::PPB_BufferTrusted_API;
33 using ppapi::thunk::PPB_VideoCapture_API;
34
35 namespace ppapi {
36 namespace proxy {
37
38 namespace {
39
40 InterfaceProxy* CreatePPPVideoCaptureProxy(Dispatcher* dispatcher) {
41 return new PPP_VideoCapture_Proxy(dispatcher);
42 }
43
44 void OnDeviceInfo(PP_Instance instance,
45 PP_Resource resource,
46 const PP_VideoCaptureDeviceInfo_Dev* info,
47 uint32_t buffer_count,
48 const PP_Resource resources[]) {
49 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
50 if (!dispatcher) {
51 NOTREACHED();
52 return;
53 }
54 HostResource host_resource;
55 host_resource.SetHostResource(instance, resource);
56 std::vector<PPPVideoCapture_Buffer> buffers(buffer_count);
57 const PPB_Core* core = static_cast<const PPB_Core*>(
58 dispatcher->local_get_interface()(PPB_CORE_INTERFACE));
59 DCHECK(core);
60 for (uint32_t i = 0; i < buffer_count; ++i) {
61 // We need to take a ref on the resource now. The browser may drop
62 // references once we return from here, but we're sending an asynchronous
63 // message. The plugin side takes ownership of that reference.
64 core->AddRefResource(resources[i]);
65 buffers[i].resource.SetHostResource(instance, resources[i]);
66 {
67 EnterResourceNoLock<PPB_Buffer_API> enter(resources[i], true);
68 DCHECK(enter.succeeded());
69 PP_Bool result = enter.object()->Describe(&buffers[i].size);
70 DCHECK(result);
71 }
72 {
73 EnterResourceNoLock<PPB_BufferTrusted_API> enter(resources[i], true);
74 DCHECK(enter.succeeded());
75 int handle;
76 int32_t result = enter.object()->GetSharedMemory(&handle);
77 DCHECK(result == PP_OK);
78 // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle,
79 // those casts are ugly.
80 base::PlatformFile platform_file =
81 #if defined(OS_WIN)
82 reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
83 #elif defined(OS_POSIX)
84 handle;
85 #else
86 #error Not implemented.
87 #endif
88 buffers[i].handle =
89 dispatcher->ShareHandleWithRemote(platform_file, false);
90 }
91 }
92 dispatcher->Send(new PpapiMsg_PPPVideoCapture_OnDeviceInfo(
93 API_ID_PPP_VIDEO_CAPTURE_DEV, host_resource, *info, buffers));
94 }
95
96 void OnStatus(PP_Instance instance, PP_Resource resource, uint32_t status) {
97 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
98 if (!dispatcher) {
99 NOTREACHED();
100 return;
101 }
102 HostResource host_resource;
103 host_resource.SetHostResource(instance, resource);
104 dispatcher->Send(new PpapiMsg_PPPVideoCapture_OnStatus(
105 API_ID_PPP_VIDEO_CAPTURE_DEV, host_resource, status));
106 }
107
108 void OnError(PP_Instance instance, PP_Resource resource, uint32_t error_code) {
109 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
110 if (!dispatcher) {
111 NOTREACHED();
112 return;
113 }
114 HostResource host_resource;
115 host_resource.SetHostResource(instance, resource);
116 dispatcher->Send(new PpapiMsg_PPPVideoCapture_OnError(
117 API_ID_PPP_VIDEO_CAPTURE_DEV, host_resource, error_code));
118 }
119
120 void OnBufferReady(PP_Instance instance,
121 PP_Resource resource,
122 uint32_t buffer) {
123 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
124 if (!dispatcher) {
125 NOTREACHED();
126 return;
127 }
128 HostResource host_resource;
129 host_resource.SetHostResource(instance, resource);
130 dispatcher->Send(new PpapiMsg_PPPVideoCapture_OnBufferReady(
131 API_ID_PPP_VIDEO_CAPTURE_DEV, host_resource, buffer));
132 }
133
134 PPP_VideoCapture_Dev ppp_video_capture = {
135 OnDeviceInfo,
136 OnStatus,
137 OnError,
138 OnBufferReady
139 };
140
141 } // namespace
142
143 class VideoCapture : public PPB_VideoCapture_Shared {
144 public:
145 explicit VideoCapture(const HostResource& resource);
146 virtual ~VideoCapture();
147
148 bool OnStatus(PP_VideoCaptureStatus_Dev status);
149
150 void set_status(PP_VideoCaptureStatus_Dev status) {
151 SetStatus(status, true);
152 }
153
154 void SetBufferCount(size_t count) {
155 buffer_in_use_ = std::vector<bool>(count);
156 }
157
158 void SetBufferInUse(uint32_t buffer) {
159 DCHECK(buffer < buffer_in_use_.size());
160 buffer_in_use_[buffer] = true;
161 }
162
163 private:
164 // PPB_VideoCapture_Shared implementation.
165 virtual int32_t InternalEnumerateDevices(
166 PP_Resource* devices,
167 scoped_refptr<TrackedCallback> callback) OVERRIDE;
168 virtual int32_t InternalOpen(
169 const std::string& device_id,
170 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
171 uint32_t buffer_count,
172 scoped_refptr<TrackedCallback> callback) OVERRIDE;
173 virtual int32_t InternalStartCapture() OVERRIDE;
174 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE;
175 virtual int32_t InternalStopCapture() OVERRIDE;
176 virtual void InternalClose() OVERRIDE;
177 virtual int32_t InternalStartCapture0_1(
178 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
179 uint32_t buffer_count) OVERRIDE;
180 virtual const std::vector<DeviceRefData>&
181 InternalGetDeviceRefData() const OVERRIDE;
182
183 PluginDispatcher* GetDispatcher() const {
184 return PluginDispatcher::GetForResource(this);
185 }
186
187 std::vector<bool> buffer_in_use_;
188
189 DISALLOW_COPY_AND_ASSIGN(VideoCapture);
190 };
191
192 VideoCapture::VideoCapture(const HostResource& resource)
193 : PPB_VideoCapture_Shared(resource) {
194 }
195
196 VideoCapture::~VideoCapture() {
197 Close();
198 }
199
200 bool VideoCapture::OnStatus(PP_VideoCaptureStatus_Dev status) {
201 switch (status) {
202 case PP_VIDEO_CAPTURE_STATUS_STARTED:
203 case PP_VIDEO_CAPTURE_STATUS_PAUSED:
204 case PP_VIDEO_CAPTURE_STATUS_STOPPED:
205 return SetStatus(status, false);
206 case PP_VIDEO_CAPTURE_STATUS_STARTING:
207 case PP_VIDEO_CAPTURE_STATUS_STOPPING:
208 // Those states are not sent by the browser.
209 break;
210 }
211
212 NOTREACHED();
213 return false;
214 }
215
216 int32_t VideoCapture::InternalEnumerateDevices(
217 PP_Resource* devices,
218 scoped_refptr<TrackedCallback> callback) {
219 devices_ = devices;
220 enumerate_devices_callback_ = callback;
221 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices(
222 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource()));
223 return PP_OK_COMPLETIONPENDING;
224 }
225
226 int32_t VideoCapture::InternalOpen(
227 const std::string& device_id,
228 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
229 uint32_t buffer_count,
230 scoped_refptr<TrackedCallback> callback) {
231 open_callback_ = callback;
232 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open(
233 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info,
234 buffer_count));
235 return PP_OK_COMPLETIONPENDING;
236 }
237
238 int32_t VideoCapture::InternalStartCapture() {
239 buffer_in_use_.clear();
240 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture(
241 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource()));
242 return PP_OK;
243 }
244
245 int32_t VideoCapture::InternalReuseBuffer(uint32_t buffer) {
246 if (buffer >= buffer_in_use_.size() || !buffer_in_use_[buffer])
247 return PP_ERROR_BADARGUMENT;
248 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_ReuseBuffer(
249 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), buffer));
250 return PP_OK;
251 }
252
253 int32_t VideoCapture::InternalStopCapture() {
254 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StopCapture(
255 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource()));
256 return PP_OK;
257 }
258
259 void VideoCapture::InternalClose() {
260 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Close(
261 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource()));
262 }
263
264 int32_t VideoCapture::InternalStartCapture0_1(
265 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
266 uint32_t buffer_count) {
267 buffer_in_use_.clear();
268 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture0_1(
269 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), requested_info,
270 buffer_count));
271 return PP_OK;
272 }
273
274 const std::vector<DeviceRefData>&
275 VideoCapture::InternalGetDeviceRefData() const {
276 // This should never be called at the plugin side.
277 NOTREACHED();
278 static std::vector<DeviceRefData> result;
279 return result;
280 }
281
282 PPB_VideoCapture_Proxy::PPB_VideoCapture_Proxy(Dispatcher* dispatcher)
283 : InterfaceProxy(dispatcher),
284 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
285 }
286
287 PPB_VideoCapture_Proxy::~PPB_VideoCapture_Proxy() {
288 }
289
290 // static
291 PP_Resource PPB_VideoCapture_Proxy::CreateProxyResource(PP_Instance instance) {
292 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
293 if (!dispatcher)
294 return 0;
295
296 HostResource result;
297 dispatcher->Send(new PpapiHostMsg_PPBVideoCapture_Create(
298 API_ID_PPB_VIDEO_CAPTURE_DEV, instance, &result));
299 if (result.is_null())
300 return 0;
301 return (new VideoCapture(result))->GetReference();
302 }
303
304 bool PPB_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) {
305 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV))
306 return false;
307
308 bool handled = true;
309 IPC_BEGIN_MESSAGE_MAP(PPB_VideoCapture_Proxy, msg)
310 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Create, OnMsgCreate)
311 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_EnumerateDevices,
312 OnMsgEnumerateDevices)
313 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Open, OnMsgOpen)
314 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture,
315 OnMsgStartCapture)
316 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_ReuseBuffer,
317 OnMsgReuseBuffer)
318 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StopCapture,
319 OnMsgStopCapture)
320 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Close, OnMsgClose)
321 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture0_1,
322 OnMsgStartCapture0_1)
323
324 IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoCapture_EnumerateDevicesACK,
325 OnMsgEnumerateDevicesACK)
326 IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoCapture_OpenACK,
327 OnMsgOpenACK)
328 IPC_MESSAGE_UNHANDLED(handled = false)
329 IPC_END_MESSAGE_MAP()
330 // TODO(brettw) handle bad messages!
331 return handled;
332 }
333
334 void PPB_VideoCapture_Proxy::OnMsgCreate(PP_Instance instance,
335 HostResource* result_resource) {
336 thunk::EnterResourceCreation enter(instance);
337 if (enter.succeeded()) {
338 result_resource->SetHostResource(
339 instance,
340 enter.functions()->CreateVideoCapture(instance));
341 }
342 }
343
344 void PPB_VideoCapture_Proxy::OnMsgEnumerateDevices(
345 const HostResource& resource) {
346 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter(
347 resource, callback_factory_,
348 &PPB_VideoCapture_Proxy::EnumerateDevicesACKInHost, resource);
349
350 if (enter.succeeded())
351 enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback()));
352 }
353
354 void PPB_VideoCapture_Proxy::OnMsgOpen(
355 const ppapi::HostResource& resource,
356 const std::string& device_id,
357 const PP_VideoCaptureDeviceInfo_Dev& info,
358 uint32_t buffers) {
359 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter(
360 resource, callback_factory_, &PPB_VideoCapture_Proxy::OpenACKInHost,
361 resource);
362
363 if (enter.succeeded()) {
364 enter.SetResult(enter.object()->Open(device_id, info, buffers,
365 enter.callback()));
366 }
367 }
368
369 void PPB_VideoCapture_Proxy::OnMsgStartCapture(const HostResource& resource) {
370 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource);
371 if (enter.succeeded())
372 enter.object()->StartCapture();
373 }
374
375 void PPB_VideoCapture_Proxy::OnMsgReuseBuffer(const HostResource& resource,
376 uint32_t buffer) {
377 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource);
378 if (enter.succeeded())
379 enter.object()->ReuseBuffer(buffer);
380 }
381
382 void PPB_VideoCapture_Proxy::OnMsgStopCapture(const HostResource& resource) {
383 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource);
384 if (enter.succeeded())
385 enter.object()->StopCapture();
386 }
387
388 void PPB_VideoCapture_Proxy::OnMsgClose(const HostResource& resource) {
389 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource);
390 if (enter.succeeded())
391 enter.object()->Close();
392 }
393
394 void PPB_VideoCapture_Proxy::OnMsgStartCapture0_1(
395 const HostResource& resource,
396 const PP_VideoCaptureDeviceInfo_Dev& info,
397 uint32_t buffers) {
398 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource);
399 if (enter.succeeded())
400 enter.object()->StartCapture0_1(info, buffers);
401 }
402
403 void PPB_VideoCapture_Proxy::OnMsgEnumerateDevicesACK(
404 const HostResource& resource,
405 int32_t result,
406 const std::vector<ppapi::DeviceRefData>& devices) {
407 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(resource);
408 if (enter.succeeded()) {
409 static_cast<VideoCapture*>(enter.object())->OnEnumerateDevicesComplete(
410 result, devices);
411 }
412 }
413
414 void PPB_VideoCapture_Proxy::OnMsgOpenACK(
415 const HostResource& resource,
416 int32_t result) {
417 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(resource);
418 if (enter.succeeded())
419 static_cast<VideoCapture*>(enter.object())->OnOpenComplete(result);
420 }
421
422 void PPB_VideoCapture_Proxy::EnumerateDevicesACKInHost(
423 int32_t result,
424 const HostResource& resource) {
425 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource);
426 dispatcher()->Send(new PpapiMsg_PPBVideoCapture_EnumerateDevicesACK(
427 API_ID_PPB_VIDEO_CAPTURE_DEV, resource, result,
428 enter.succeeded() && result == PP_OK ?
429 enter.object()->GetDeviceRefData() : std::vector<DeviceRefData>()));
430 }
431
432 void PPB_VideoCapture_Proxy::OpenACKInHost(int32_t result,
433 const HostResource& resource) {
434 dispatcher()->Send(new PpapiMsg_PPBVideoCapture_OpenACK(
435 API_ID_PPB_VIDEO_CAPTURE_DEV, resource, result));
436 }
437
438 PPP_VideoCapture_Proxy::PPP_VideoCapture_Proxy(Dispatcher* dispatcher)
439 : InterfaceProxy(dispatcher),
440 ppp_video_capture_impl_(NULL) {
441 if (dispatcher->IsPlugin()) {
442 ppp_video_capture_impl_ = static_cast<const PPP_VideoCapture_Dev*>(
443 dispatcher->local_get_interface()(PPP_VIDEO_CAPTURE_DEV_INTERFACE));
444 }
445 }
446
447 PPP_VideoCapture_Proxy::~PPP_VideoCapture_Proxy() {
448 }
449
450 // static
451 const InterfaceProxy::Info* PPP_VideoCapture_Proxy::GetInfo() {
452 static const Info info = {
453 &ppp_video_capture,
454 PPP_VIDEO_CAPTURE_DEV_INTERFACE,
455 API_ID_PPP_VIDEO_CAPTURE_DEV,
456 false,
457 &CreatePPPVideoCaptureProxy,
458 };
459 return &info;
460 }
461
462 bool PPP_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) {
463 bool handled = true;
464 IPC_BEGIN_MESSAGE_MAP(PPP_VideoCapture_Proxy, msg)
465 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoCapture_OnDeviceInfo,
466 OnMsgOnDeviceInfo)
467 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoCapture_OnStatus, OnMsgOnStatus)
468 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoCapture_OnError, OnMsgOnError)
469 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoCapture_OnBufferReady,
470 OnMsgOnBufferReady)
471 IPC_MESSAGE_UNHANDLED(handled = false)
472 IPC_END_MESSAGE_MAP()
473 // TODO(brettw) handle bad messages!
474 return handled;
475 }
476
477 void PPP_VideoCapture_Proxy::OnMsgOnDeviceInfo(
478 const HostResource& host_resource,
479 const PP_VideoCaptureDeviceInfo_Dev& info,
480 const std::vector<PPPVideoCapture_Buffer>& buffers) {
481 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource);
482 if (enter.failed() || !ppp_video_capture_impl_)
483 return;
484
485 PluginResourceTracker* tracker =
486 PluginGlobals::Get()->plugin_resource_tracker();
487 scoped_array<PP_Resource> resources(new PP_Resource[buffers.size()]);
488 for (size_t i = 0; i < buffers.size(); ++i) {
489 // We assume that the browser created a new set of resources.
490 DCHECK(!tracker->PluginResourceForHostResource(buffers[i].resource));
491 resources[i] = PPB_Buffer_Proxy::AddProxyResource(buffers[i].resource,
492 buffers[i].handle,
493 buffers[i].size);
494 }
495
496 VideoCapture* capture = static_cast<VideoCapture*>(enter.object());
497 capture->SetBufferCount(buffers.size());
498 CallWhileUnlocked(ppp_video_capture_impl_->OnDeviceInfo,
499 host_resource.instance(),
500 capture->pp_resource(),
501 &info,
502 static_cast<uint32_t>(buffers.size()),
503 const_cast<const PP_Resource*>(resources.get()));
504 for (size_t i = 0; i < buffers.size(); ++i)
505 tracker->ReleaseResource(resources[i]);
506 }
507
508 void PPP_VideoCapture_Proxy::OnMsgOnStatus(const HostResource& host_resource,
509 uint32_t status) {
510 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource);
511 if (enter.failed() || !ppp_video_capture_impl_)
512 return;
513
514 VideoCapture* capture = static_cast<VideoCapture*>(enter.object());
515 if (!capture->OnStatus(static_cast<PP_VideoCaptureStatus_Dev>(status)))
516 return;
517 CallWhileUnlocked(ppp_video_capture_impl_->OnStatus,
518 host_resource.instance(), capture->pp_resource(), status);
519 }
520
521 void PPP_VideoCapture_Proxy::OnMsgOnError(const HostResource& host_resource,
522 uint32_t error_code) {
523 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource);
524 if (enter.failed() || !ppp_video_capture_impl_)
525 return;
526
527 VideoCapture* capture = static_cast<VideoCapture*>(enter.object());
528 capture->set_status(PP_VIDEO_CAPTURE_STATUS_STOPPED);
529 CallWhileUnlocked(ppp_video_capture_impl_->OnError,
530 host_resource.instance(), capture->pp_resource(), error_code);
531 }
532
533 void PPP_VideoCapture_Proxy::OnMsgOnBufferReady(
534 const HostResource& host_resource, uint32_t buffer) {
535 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource);
536 if (enter.failed() || !ppp_video_capture_impl_)
537 return;
538
539 VideoCapture* capture = static_cast<VideoCapture*>(enter.object());
540 capture->SetBufferInUse(buffer);
541 CallWhileUnlocked(ppp_video_capture_impl_->OnBufferReady,
542 host_resource.instance(), capture->pp_resource(), buffer);
543 }
544
545 } // namespace proxy
546 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_video_capture_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698