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

Side by Side Diff: ppapi/cpp/dev/video_capture_client_dev.cc

Issue 7528006: C++ wrappers for PPB_VideoCapture_Dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
« no previous file with comments | « ppapi/cpp/dev/video_capture_client_dev.h ('k') | ppapi/cpp/dev/video_capture_dev.h » ('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) 2011 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/cpp/dev/video_capture_client_dev.h"
6
7 #include "ppapi/c/dev/ppp_video_capture_dev.h"
8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/module.h"
10
11 namespace pp {
12
13 namespace {
14
15 const char kPPPVideoCaptureInterface[] = PPP_VIDEO_CAPTURE_DEV_INTERFACE;
16
17 void OnDeviceInfo(PP_Instance instance,
18 PP_Resource resource,
19 const struct PP_VideoCaptureDeviceInfo_Dev* info,
20 uint32_t buffer_count,
21 const PP_Resource* buffers) {
22 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
23 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
brettw 2011/08/08 22:46:31 I'd normally expect client to be checked right aft
piman 2011/08/09 02:44:36 Done.
24
25 std::vector<Buffer_Dev> buffer_list;
26 buffer_list.reserve(buffer_count);
27 for (uint32_t i = 0; i<buffer_count; ++i)
brettw 2011/08/08 22:46:31 Style nit: spaces around <
piman 2011/08/09 02:44:36 Done.
28 buffer_list.push_back(Buffer_Dev(buffers[i]));
29
30 if (client)
31 client->OnDeviceInfo(resource, *info, buffer_list);
32 }
33
34 void OnStatus(PP_Instance instance, PP_Resource resource, uint32_t status) {
35 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
36 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
37 if (client)
38 client->OnStatus(resource, status);
39 }
40
41 void OnError(PP_Instance instance, PP_Resource resource, uint32_t error_code) {
42 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
43 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
44 if (client)
45 client->OnError(resource, error_code);
46 }
47
48 void OnBufferReady(PP_Instance instance,
49 PP_Resource resource,
50 uint32_t buffer) {
51 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
52 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
53 if (client)
54 client->OnBufferReady(resource, buffer);
55 }
56
57 PPP_VideoCapture_Dev ppp_video_capture = {
58 OnDeviceInfo,
59 OnStatus,
60 OnError,
61 OnBufferReady
62 };
63
64 } // namespace
65
66 VideoCaptureClient_Dev::VideoCaptureClient_Dev(Instance* instance)
67 : instance_(instance) {
68 pp::Module::Get()->AddPluginInterface(kPPPVideoCaptureInterface,
69 &ppp_video_capture);
70 instance_->AddPerInstanceObject(kPPPVideoCaptureInterface, this);
71 }
72
73 VideoCaptureClient_Dev::~VideoCaptureClient_Dev() {
74 instance_->RemovePerInstanceObject(kPPPVideoCaptureInterface, this);
75 }
76
77 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/dev/video_capture_client_dev.h ('k') | ppapi/cpp/dev/video_capture_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698