Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / ppapi / cpp / dev / video_capture_client_dev.cc
blob439c0afb0dceaf18e4d9d108ee586064ab9a1001
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.
5 #include "ppapi/cpp/dev/video_capture_client_dev.h"
7 #include "ppapi/c/dev/ppp_video_capture_dev.h"
8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/instance_handle.h"
10 #include "ppapi/cpp/module.h"
12 namespace pp {
14 namespace {
16 const char kPPPVideoCaptureInterface[] = PPP_VIDEO_CAPTURE_DEV_INTERFACE;
18 void OnDeviceInfo(PP_Instance instance,
19 PP_Resource resource,
20 const struct PP_VideoCaptureDeviceInfo_Dev* info,
21 uint32_t buffer_count,
22 const PP_Resource buffers[]) {
23 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
24 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
25 if (!client)
26 return;
28 std::vector<Buffer_Dev> buffer_list;
29 buffer_list.reserve(buffer_count);
30 for (uint32_t i = 0; i < buffer_count; ++i)
31 buffer_list.push_back(Buffer_Dev(buffers[i]));
33 client->OnDeviceInfo(resource, *info, buffer_list);
36 void OnStatus(PP_Instance instance, PP_Resource resource, uint32_t status) {
37 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
38 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
39 if (client)
40 client->OnStatus(resource, status);
43 void OnError(PP_Instance instance, PP_Resource resource, uint32_t error_code) {
44 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
45 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
46 if (client)
47 client->OnError(resource, error_code);
50 void OnBufferReady(PP_Instance instance,
51 PP_Resource resource,
52 uint32_t buffer) {
53 VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
54 Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
55 if (client)
56 client->OnBufferReady(resource, buffer);
59 PPP_VideoCapture_Dev ppp_video_capture = {
60 OnDeviceInfo,
61 OnStatus,
62 OnError,
63 OnBufferReady
66 } // namespace
68 VideoCaptureClient_Dev::VideoCaptureClient_Dev(Instance* instance)
69 : instance_(instance) {
70 Module::Get()->AddPluginInterface(kPPPVideoCaptureInterface,
71 &ppp_video_capture);
72 instance->AddPerInstanceObject(kPPPVideoCaptureInterface, this);
75 VideoCaptureClient_Dev::~VideoCaptureClient_Dev() {
76 Instance::RemovePerInstanceObject(instance_,
77 kPPPVideoCaptureInterface, this);
80 } // namespace pp