Pepper_47_C++_interfaces
video_capture_dev.cc
Go to the documentation of this file.
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 
6 
7 #include "ppapi/c/dev/ppb_video_capture_dev.h"
8 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/cpp/module_impl.h"
11 
12 namespace pp {
13 
14 namespace {
15 
16 template <> const char* interface_name<PPB_VideoCapture_Dev_0_3>() {
17  return PPB_VIDEOCAPTURE_DEV_INTERFACE_0_3;
18 }
19 
20 } // namespace
21 
23  if (has_interface<PPB_VideoCapture_Dev_0_3>()) {
24  PassRefFromConstructor(get_interface<PPB_VideoCapture_Dev_0_3>()->Create(
25  instance.pp_instance()));
26  }
27 }
28 
30  : Resource(resource) {
31 }
32 
34 }
35 
36 // static
38  return has_interface<PPB_VideoCapture_Dev_0_3>();
39 }
40 
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());
46  }
47 
48  return callback.MayForce(PP_ERROR_NOINTERFACE);
49 }
50 
52  PP_MonitorDeviceChangeCallback callback,
53  void* user_data) {
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);
57  }
58 
59  return PP_ERROR_NOINTERFACE;
60 }
61 
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());
71  }
72 
73  return callback.MayForce(PP_ERROR_NOINTERFACE);
74 }
75 
77  if (has_interface<PPB_VideoCapture_Dev_0_3>()) {
78  return get_interface<PPB_VideoCapture_Dev_0_3>()->StartCapture(
79  pp_resource());
80  }
81 
82  return PP_ERROR_NOINTERFACE;
83 }
84 
86  if (has_interface<PPB_VideoCapture_Dev_0_3>()) {
87  return get_interface<PPB_VideoCapture_Dev_0_3>()->ReuseBuffer(pp_resource(),
88  buffer);
89  }
90 
91  return PP_ERROR_NOINTERFACE;
92 }
93 
95  if (has_interface<PPB_VideoCapture_Dev_0_3>()) {
96  return get_interface<PPB_VideoCapture_Dev_0_3>()->StopCapture(
97  pp_resource());
98  }
99 
100  return PP_ERROR_NOINTERFACE;
101 }
102 
104  if (has_interface<PPB_VideoCapture_Dev_0_3>()) {
105  get_interface<PPB_VideoCapture_Dev_0_3>()->Close(pp_resource());
106  }
107 }
108 
109 } // namespace pp
void PassRefFromConstructor(PP_Resource resource)
Definition: resource.cc:50
int32_t MayForce(int32_t result) const
const PP_CompletionCallback & pp_completion_callback() const
int32_t Open(const DeviceRef_Dev &device_ref, const PP_VideoCaptureDeviceInfo_Dev &requested_info, uint32_t buffer_count, const CompletionCallback &callback)
int32_t ReuseBuffer(uint32_t buffer)
VideoCapture_Dev(const InstanceHandle &instance)
int32_t EnumerateDevices(const CompletionCallbackWithOutput< std::vector< DeviceRef_Dev > > &callback)
PP_Resource pp_resource() const
Definition: resource.h:47
PP_Instance pp_instance() const
A reference counted module resource.
Definition: resource.h:20
int32_t MonitorDeviceChange(PP_MonitorDeviceChangeCallback callback, void *user_data)