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

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: address review comments 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));
24 if (!client)
25 return;
26
27 std::vector<Buffer_Dev> buffer_list;
28 buffer_list.reserve(buffer_count);
29 for (uint32_t i = 0; i < buffer_count; ++i)
30 buffer_list.push_back(Buffer_Dev(buffers[i]));
31
32 client->OnDeviceInfo(resource, *info, buffer_list);
33 }
34
35 void OnStatus(PP_Instance instance, PP_Resource resource, uint32_t status) {
36 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
37 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
38 if (client)
39 client->OnStatus(resource, status);
40 }
41
42 void OnError(PP_Instance instance, PP_Resource resource, uint32_t error_code) {
43 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
44 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
45 if (client)
46 client->OnError(resource, error_code);
47 }
48
49 void OnBufferReady(PP_Instance instance,
50 PP_Resource resource,
51 uint32_t buffer) {
52 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
53 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
54 if (client)
55 client->OnBufferReady(resource, buffer);
56 }
57
58 PPP_VideoCapture_Dev ppp_video_capture = {
59 OnDeviceInfo,
60 OnStatus,
61 OnError,
62 OnBufferReady
63 };
64
65 } // namespace
66
67 VideoCaptureClient_Dev::VideoCaptureClient_Dev(Instance* instance)
68 : instance_(instance) {
69 pp::Module::Get()->AddPluginInterface(kPPPVideoCaptureInterface,
70 &ppp_video_capture);
71 instance_->AddPerInstanceObject(kPPPVideoCaptureInterface, this);
72 }
73
74 VideoCaptureClient_Dev::~VideoCaptureClient_Dev() {
75 instance_->RemovePerInstanceObject(kPPPVideoCaptureInterface, this);
76 }
77
78 } // 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