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.
5 #include "ppapi/cpp/dev/video_capture_dev.h"
7 #include "ppapi/c/dev/ppb_video_capture_dev.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/instance_handle.h"
10 #include "ppapi/cpp/module_impl.h"
16 template <> const char* interface_name
<PPB_VideoCapture_Dev_0_3
>() {
17 return PPB_VIDEOCAPTURE_DEV_INTERFACE_0_3
;
22 VideoCapture_Dev::VideoCapture_Dev(const InstanceHandle
& instance
) {
23 if (has_interface
<PPB_VideoCapture_Dev_0_3
>()) {
24 PassRefFromConstructor(get_interface
<PPB_VideoCapture_Dev_0_3
>()->Create(
25 instance
.pp_instance()));
29 VideoCapture_Dev::VideoCapture_Dev(PP_Resource resource
)
30 : Resource(resource
) {
33 VideoCapture_Dev::~VideoCapture_Dev() {
37 bool VideoCapture_Dev::IsAvailable() {
38 return has_interface
<PPB_VideoCapture_Dev_0_3
>();
41 int32_t VideoCapture_Dev::EnumerateDevices(
42 const CompletionCallbackWithOutput
<std::vector
<DeviceRef_Dev
> >& callback
) {
43 if (has_interface
<PPB_VideoCapture_Dev_0_3
>()) {
44 return get_interface
<PPB_VideoCapture_Dev_0_3
>()->EnumerateDevices(
45 pp_resource(), callback
.output(), callback
.pp_completion_callback());
48 return callback
.MayForce(PP_ERROR_NOINTERFACE
);
51 int32_t VideoCapture_Dev::MonitorDeviceChange(
52 PP_MonitorDeviceChangeCallback callback
,
54 if (has_interface
<PPB_VideoCapture_Dev_0_3
>()) {
55 return get_interface
<PPB_VideoCapture_Dev_0_3
>()->MonitorDeviceChange(
56 pp_resource(), callback
, user_data
);
59 return PP_ERROR_NOINTERFACE
;
62 int32_t VideoCapture_Dev::Open(
63 const DeviceRef_Dev
& device_ref
,
64 const PP_VideoCaptureDeviceInfo_Dev
& requested_info
,
65 uint32_t buffer_count
,
66 const CompletionCallback
& callback
) {
67 if (has_interface
<PPB_VideoCapture_Dev_0_3
>()) {
68 return get_interface
<PPB_VideoCapture_Dev_0_3
>()->Open(
69 pp_resource(), device_ref
.pp_resource(), &requested_info
, buffer_count
,
70 callback
.pp_completion_callback());
73 return callback
.MayForce(PP_ERROR_NOINTERFACE
);
76 int32_t VideoCapture_Dev::StartCapture() {
77 if (has_interface
<PPB_VideoCapture_Dev_0_3
>()) {
78 return get_interface
<PPB_VideoCapture_Dev_0_3
>()->StartCapture(
82 return PP_ERROR_NOINTERFACE
;
85 int32_t VideoCapture_Dev::ReuseBuffer(uint32_t buffer
) {
86 if (has_interface
<PPB_VideoCapture_Dev_0_3
>()) {
87 return get_interface
<PPB_VideoCapture_Dev_0_3
>()->ReuseBuffer(pp_resource(),
91 return PP_ERROR_NOINTERFACE
;
94 int32_t VideoCapture_Dev::StopCapture() {
95 if (has_interface
<PPB_VideoCapture_Dev_0_3
>()) {
96 return get_interface
<PPB_VideoCapture_Dev_0_3
>()->StopCapture(
100 return PP_ERROR_NOINTERFACE
;
103 void VideoCapture_Dev::Close() {
104 if (has_interface
<PPB_VideoCapture_Dev_0_3
>()) {
105 get_interface
<PPB_VideoCapture_Dev_0_3
>()->Close(pp_resource());