Roll leveldb from r73 to r75.
[chromium-blink-merge.git] / ppapi / proxy / video_capture_resource.h
blobe533ef095fb2e92655dc4fe45d86ff24ad18a3f9
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 #ifndef PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_
6 #define PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_
8 #include "base/compiler_specific.h"
9 #include "ppapi/c/dev/ppp_video_capture_dev.h"
10 #include "ppapi/proxy/device_enumeration_resource_helper.h"
11 #include "ppapi/proxy/plugin_resource.h"
12 #include "ppapi/thunk/ppb_video_capture_api.h"
14 namespace ppapi {
15 namespace proxy {
17 class VideoCaptureResource
18 : public PluginResource,
19 public ::ppapi::thunk::PPB_VideoCapture_API {
20 public:
21 VideoCaptureResource(Connection connection,
22 PP_Instance instance,
23 PluginDispatcher* dispatcher);
24 virtual ~VideoCaptureResource();
26 // PluginResource override.
27 virtual thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE {
28 return this;
31 // PPB_VideoCapture_API implementation.
32 virtual int32_t EnumerateDevices0_2(
33 PP_Resource* devices,
34 scoped_refptr<TrackedCallback> callback) OVERRIDE;
35 virtual int32_t EnumerateDevices(
36 const PP_ArrayOutput& output,
37 scoped_refptr<TrackedCallback> callback) OVERRIDE;
38 virtual int32_t MonitorDeviceChange(
39 PP_MonitorDeviceChangeCallback callback,
40 void* user_data) OVERRIDE;
41 virtual int32_t Open(const std::string& device_id,
42 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
43 uint32_t buffer_count,
44 scoped_refptr<TrackedCallback> callback) OVERRIDE;
45 virtual int32_t StartCapture() OVERRIDE;
46 virtual int32_t ReuseBuffer(uint32_t buffer) OVERRIDE;
47 virtual int32_t StopCapture() OVERRIDE;
48 virtual void Close() OVERRIDE;
49 virtual int32_t EnumerateDevicesSync(const PP_ArrayOutput& devices) OVERRIDE;
51 protected:
52 // Resource override.
53 virtual void LastPluginRefWasDeleted() OVERRIDE;
55 private:
56 enum OpenState {
57 BEFORE_OPEN,
58 OPENED,
59 CLOSED
62 // PluginResource overrides.
63 virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
64 const IPC::Message& msg) OVERRIDE;
66 void OnPluginMsgOnDeviceInfo(const ResourceMessageReplyParams& params,
67 const struct PP_VideoCaptureDeviceInfo_Dev& info,
68 const std::vector<HostResource>& buffers,
69 uint32_t buffer_size);
70 void OnPluginMsgOnStatus(const ResourceMessageReplyParams& params,
71 uint32_t status);
72 void OnPluginMsgOnError(const ResourceMessageReplyParams& params,
73 uint32_t error);
74 void OnPluginMsgOnBufferReady(const ResourceMessageReplyParams& params,
75 uint32_t buffer);
77 void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params);
79 void SetBufferInUse(uint32_t buffer_index);
81 // Points to the C interface of client implementation.
82 const PPP_VideoCapture_Dev* ppp_video_capture_impl_;
84 // Indicates that the i-th buffer is currently in use.
85 std::vector<bool> buffer_in_use_;
87 // Holds a reference of the callback so that Close() can cancel it.
88 scoped_refptr<TrackedCallback> open_callback_;
89 OpenState open_state_;
91 DeviceEnumerationResourceHelper enumeration_helper_;
93 DISALLOW_COPY_AND_ASSIGN(VideoCaptureResource);
96 } // namespace proxy
97 } // namespace ppapi
99 #endif // PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_