OLD | NEW |
(Empty) | |
| 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 |
| 5 #ifndef PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "ppapi/c/dev/ppp_video_capture_dev.h" |
| 10 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 11 #include "ppapi/proxy/plugin_resource.h" |
| 12 #include "ppapi/shared_impl/api_id.h" |
| 13 #include "ppapi/thunk/ppb_video_capture_api.h" |
| 14 |
| 15 namespace ppapi { |
| 16 namespace proxy { |
| 17 |
| 18 class PPAPI_PROXY_EXPORT VideoCaptureResource |
| 19 : public PluginResource, |
| 20 public NON_EXPORTED_BASE(::ppapi::thunk::PPB_VideoCapture_API) { |
| 21 public: |
| 22 VideoCaptureResource(Connection connection, PP_Instance instance, |
| 23 PluginDispatcher* dispatcher); |
| 24 ~VideoCaptureResource(); |
| 25 |
| 26 void OnReplyReceived(const ResourceMessageReplyParams& params, |
| 27 const IPC::Message& msg) OVERRIDE; |
| 28 |
| 29 thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE { |
| 30 return this; |
| 31 } |
| 32 |
| 33 // PPB_VideoCapture_API |
| 34 int32_t EnumerateDevices(PP_Resource* devices, |
| 35 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 36 int32_t Open(const std::string& device_id, |
| 37 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 38 uint32_t buffer_count, |
| 39 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 40 int32_t StartCapture() OVERRIDE; |
| 41 int32_t ReuseBuffer(uint32_t buffer) OVERRIDE; |
| 42 int32_t StopCapture() OVERRIDE; |
| 43 void Close() OVERRIDE; |
| 44 const std::vector<DeviceRefData>& GetDeviceRefData() const OVERRIDE { |
| 45 return devices_data_; |
| 46 } |
| 47 |
| 48 private: |
| 49 enum OpenState { |
| 50 BEFORE_OPEN, |
| 51 OPENED, |
| 52 CLOSED |
| 53 }; |
| 54 |
| 55 void OnDeviceInfo(const ResourceMessageReplyParams& params, |
| 56 const struct PP_VideoCaptureDeviceInfo_Dev& info, |
| 57 const std::vector<HostResource>& buffers, |
| 58 uint32_t buffer_size); |
| 59 void OnStatus(const ResourceMessageReplyParams& params, |
| 60 uint32_t status); |
| 61 void OnError(const ResourceMessageReplyParams& params, |
| 62 uint32_t error); |
| 63 void OnBufferReady(const ResourceMessageReplyParams& params, |
| 64 uint32_t buffer); |
| 65 |
| 66 void OnOpenComplete(const ResourceMessageReplyParams& params); |
| 67 void OnEnumerateDevicesComplete(const ResourceMessageReplyParams& params, |
| 68 const std::vector<DeviceRefData>& devices); |
| 69 |
| 70 void SetBufferInUse(uint32_t buffer_index); |
| 71 |
| 72 // Points to the client implementation of pp::VideoCaptureClient_Dev. |
| 73 const PPP_VideoCapture_Dev* ppp_video_capture_impl_; |
| 74 |
| 75 // Indicates that the i-th buffer is currently in use. |
| 76 std::vector<bool> buffer_in_use_; |
| 77 |
| 78 scoped_refptr<TrackedCallback> open_callback_; |
| 79 |
| 80 // Saves the output of EnumerateDevices(). |
| 81 std::vector<DeviceRefData> devices_data_; |
| 82 |
| 83 // Output parameter of EnumerateDevices(). It should not be accessed after |
| 84 // |enumerate_devices_callback_| is run. |
| 85 PP_Resource* devices_; |
| 86 |
| 87 OpenState open_state_; |
| 88 |
| 89 scoped_refptr<TrackedCallback> enumerate_devices_callback_; |
| 90 }; |
| 91 |
| 92 } // namespace proxy |
| 93 } // namespace ppapi |
| 94 |
| 95 #endif // PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_ |
OLD | NEW |