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