Chromium Code Reviews| 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/plugin_resource.h" | |
| 11 #include "ppapi/thunk/ppb_video_capture_api.h" | |
| 12 | |
| 13 namespace ppapi { | |
| 14 namespace proxy { | |
| 15 | |
| 16 class VideoCaptureResource | |
| 17 : public PluginResource, | |
| 18 public ::ppapi::thunk::PPB_VideoCapture_API { | |
| 19 public: | |
| 20 VideoCaptureResource(Connection connection, | |
| 21 PP_Instance instance, | |
| 22 PluginDispatcher* dispatcher); | |
| 23 virtual ~VideoCaptureResource(); | |
| 24 | |
| 25 // PluginResource override. | |
| 26 thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE { | |
|
yzshen1
2012/11/10 01:14:40
virtual, please
victorhsieh
2012/11/13 03:10:53
Oops, done.
| |
| 27 return this; | |
| 28 } | |
| 29 | |
| 30 // PPB_VideoCapture_API implementation. | |
| 31 int32_t EnumerateDevices(PP_Resource* devices, | |
| 32 scoped_refptr<TrackedCallback> callback) OVERRIDE; | |
| 33 int32_t Open(const std::string& device_id, | |
| 34 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
| 35 uint32_t buffer_count, | |
| 36 scoped_refptr<TrackedCallback> callback) OVERRIDE; | |
| 37 int32_t StartCapture() OVERRIDE; | |
| 38 int32_t ReuseBuffer(uint32_t buffer) OVERRIDE; | |
| 39 int32_t StopCapture() OVERRIDE; | |
| 40 void Close() OVERRIDE; | |
| 41 const std::vector<DeviceRefData>& GetDeviceRefData() const OVERRIDE; | |
| 42 | |
| 43 private: | |
| 44 enum OpenState { | |
| 45 BEFORE_OPEN, | |
| 46 OPENED, | |
| 47 CLOSED | |
| 48 }; | |
| 49 | |
| 50 // PluginResource overrides. | |
| 51 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, | |
| 52 const IPC::Message& msg) OVERRIDE; | |
| 53 | |
| 54 void OnPluginMsgOnDeviceInfo(const ResourceMessageReplyParams& params, | |
| 55 const struct PP_VideoCaptureDeviceInfo_Dev& info, | |
| 56 const std::vector<HostResource>& buffers, | |
| 57 uint32_t buffer_size); | |
| 58 void OnPluginMsgOnStatus(const ResourceMessageReplyParams& params, | |
| 59 uint32_t status); | |
| 60 void OnPluginMsgOnError(const ResourceMessageReplyParams& params, | |
| 61 uint32_t error); | |
| 62 void OnPluginMsgOnBufferReady(const ResourceMessageReplyParams& params, | |
| 63 uint32_t buffer); | |
| 64 | |
| 65 void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params); | |
| 66 void OnPluginMsgEnumerateDevicesReply( | |
| 67 PP_Resource* devices_output, | |
| 68 scoped_refptr<TrackedCallback> callback, | |
| 69 const ResourceMessageReplyParams& params, | |
| 70 const std::vector<DeviceRefData>& devices); | |
| 71 | |
| 72 void SetBufferInUse(uint32_t buffer_index); | |
| 73 | |
| 74 // Points to the C interface of client implementation. | |
| 75 const PPP_VideoCapture_Dev* ppp_video_capture_impl_; | |
| 76 | |
| 77 // Indicates that the i-th buffer is currently in use. | |
| 78 std::vector<bool> buffer_in_use_; | |
| 79 | |
| 80 // Holds a reference of the callback so that Close() can cancel it. | |
| 81 scoped_refptr<TrackedCallback> open_callback_; | |
| 82 OpenState open_state_; | |
| 83 | |
| 84 // Saves the output of EnumerateDevices(). | |
| 85 std::vector<DeviceRefData> devices_data_; | |
| 86 bool has_pending_enum_devices_callback_; | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(VideoCaptureResource); | |
| 89 }; | |
| 90 | |
| 91 } // namespace proxy | |
| 92 } // namespace ppapi | |
| 93 | |
| 94 #endif // PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_ | |
| OLD | NEW |