Index: ppapi/proxy/video_capture_resource.h |
diff --git a/ppapi/proxy/video_capture_resource.h b/ppapi/proxy/video_capture_resource.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e724f37a3ec68786a61e0ba090c0d79575eb3c5a |
--- /dev/null |
+++ b/ppapi/proxy/video_capture_resource.h |
@@ -0,0 +1,95 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_ |
+#define PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_ |
+ |
+#include "base/compiler_specific.h" |
+#include "ppapi/c/dev/ppp_video_capture_dev.h" |
+#include "ppapi/proxy/ppapi_proxy_export.h" |
+#include "ppapi/proxy/plugin_resource.h" |
+#include "ppapi/shared_impl/api_id.h" |
+#include "ppapi/thunk/ppb_video_capture_api.h" |
+ |
+namespace ppapi { |
+namespace proxy { |
+ |
+class PPAPI_PROXY_EXPORT VideoCaptureResource |
+ : public PluginResource, |
+ public NON_EXPORTED_BASE(::ppapi::thunk::PPB_VideoCapture_API) { |
+ public: |
+ VideoCaptureResource(Connection connection, PP_Instance instance, |
+ PluginDispatcher* dispatcher); |
+ ~VideoCaptureResource(); |
+ |
+ void OnReplyReceived(const ResourceMessageReplyParams& params, |
+ const IPC::Message& msg) OVERRIDE; |
+ |
+ thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE { |
+ return this; |
+ } |
+ |
+ // PPB_VideoCapture_API |
+ int32_t EnumerateDevices(PP_Resource* devices, |
+ scoped_refptr<TrackedCallback> callback) OVERRIDE; |
+ int32_t Open(const std::string& device_id, |
+ const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
+ uint32_t buffer_count, |
+ scoped_refptr<TrackedCallback> callback) OVERRIDE; |
+ int32_t StartCapture() OVERRIDE; |
+ int32_t ReuseBuffer(uint32_t buffer) OVERRIDE; |
+ int32_t StopCapture() OVERRIDE; |
+ void Close() OVERRIDE; |
+ const std::vector<DeviceRefData>& GetDeviceRefData() const OVERRIDE { |
+ return devices_data_; |
+ } |
+ |
+ private: |
+ enum OpenState { |
+ BEFORE_OPEN, |
+ OPENED, |
+ CLOSED |
+ }; |
+ |
+ void OnDeviceInfo(const ResourceMessageReplyParams& params, |
+ const struct PP_VideoCaptureDeviceInfo_Dev& info, |
+ const std::vector<HostResource>& buffers, |
+ uint32_t buffer_size); |
+ void OnStatus(const ResourceMessageReplyParams& params, |
+ uint32_t status); |
+ void OnError(const ResourceMessageReplyParams& params, |
+ uint32_t error); |
+ void OnBufferReady(const ResourceMessageReplyParams& params, |
+ uint32_t buffer); |
+ |
+ void OnOpenComplete(const ResourceMessageReplyParams& params); |
+ void OnEnumerateDevicesComplete(const ResourceMessageReplyParams& params, |
+ const std::vector<DeviceRefData>& devices); |
+ |
+ void SetBufferInUse(uint32_t buffer_index); |
+ |
+ // Points to the client implementation of pp::VideoCaptureClient_Dev. |
+ const PPP_VideoCapture_Dev* ppp_video_capture_impl_; |
+ |
+ // Indicates that the i-th buffer is currently in use. |
+ std::vector<bool> buffer_in_use_; |
+ |
+ scoped_refptr<TrackedCallback> open_callback_; |
+ |
+ // Saves the output of EnumerateDevices(). |
+ std::vector<DeviceRefData> devices_data_; |
+ |
+ // Output parameter of EnumerateDevices(). It should not be accessed after |
+ // |enumerate_devices_callback_| is run. |
+ PP_Resource* devices_; |
+ |
+ OpenState open_state_; |
+ |
+ scoped_refptr<TrackedCallback> enumerate_devices_callback_; |
+}; |
+ |
+} // namespace proxy |
+} // namespace ppapi |
+ |
+#endif // PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_ |