OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_IMAGE_CAPTURE_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_IMAGE_CAPTURE_RESOURCE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ppapi/c/pp_size.h" |
| 11 #include "ppapi/proxy/connection.h" |
| 12 #include "ppapi/proxy/plugin_resource.h" |
| 13 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 14 #include "ppapi/shared_impl/resource.h" |
| 15 #include "ppapi/thunk/ppb_image_capture_api.h" |
| 16 |
| 17 namespace ppapi { |
| 18 namespace proxy { |
| 19 |
| 20 class CameraCapabilitiesResource; |
| 21 class ImageCaptureConfigResource; |
| 22 |
| 23 class PPAPI_PROXY_EXPORT ImageCaptureResource |
| 24 : public PluginResource, |
| 25 public thunk::PPB_ImageCapture_API { |
| 26 public: |
| 27 ImageCaptureResource(Connection connection, PP_Instance instance); |
| 28 |
| 29 virtual ~ImageCaptureResource(); |
| 30 |
| 31 // Resource overrides: |
| 32 virtual thunk::PPB_ImageCapture_API* AsPPB_ImageCapture_API() override { |
| 33 return this; |
| 34 } |
| 35 |
| 36 // PPB_ImageCapture_API overrides: |
| 37 virtual int32_t Open(PP_Var camera_source_id, |
| 38 scoped_refptr<TrackedCallback> callback) override; |
| 39 virtual void Close() override; |
| 40 virtual int32_t SetConfig(PP_Resource config, |
| 41 scoped_refptr<TrackedCallback> callback) override; |
| 42 virtual int32_t GetConfig(PP_Resource* config, |
| 43 scoped_refptr<TrackedCallback> callback) override; |
| 44 virtual int32_t GetCameraCapabilities( |
| 45 PP_Resource* capabilities, |
| 46 scoped_refptr<TrackedCallback> callback) override; |
| 47 virtual int32_t ReuseBuffers() override; |
| 48 virtual int32_t CaptureStillImage( |
| 49 PPB_ImageCapture_Private_ShutterCallback shutter_callback, |
| 50 PPB_ImageCapture_Private_PreviewCallback preview_callback, |
| 51 PPB_ImageCapture_Private_JpegCallback jpeg_callback, |
| 52 PPB_ImageCapture_Private_ErrorCallback error_callback, |
| 53 uint64_t* sequence_id) override; |
| 54 |
| 55 private: |
| 56 enum OpenState { BEFORE_OPEN, OPENED, CLOSED }; |
| 57 |
| 58 // PluginResource overrides. |
| 59 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, |
| 60 const IPC::Message& msg) override; |
| 61 |
| 62 // Host -> plugin messages. |
| 63 void OnPluginMsgGetPreviewSizesReply( |
| 64 const ResourceMessageReplyParams& params, |
| 65 const std::vector<PP_Size>& preview_sizes); |
| 66 |
| 67 // reply to open |
| 68 void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params); |
| 69 |
| 70 // other |
| 71 bool IsOpened() const {return open_state_ == OPENED;} |
| 72 |
| 73 // Holds a reference of the callback so that Close() can cancel it. |
| 74 scoped_refptr<TrackedCallback> open_callback_; |
| 75 OpenState open_state_; |
| 76 |
| 77 PP_Resource* get_capabilities_output_; |
| 78 scoped_refptr<TrackedCallback> get_capabilities_callback_; |
| 79 scoped_refptr<CameraCapabilitiesResource> camera_capabilities_; |
| 80 |
| 81 // scoped_refptr<ImageCaptureConfigResource> config_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(ImageCaptureResource); |
| 84 }; |
| 85 |
| 86 } // namespace proxy |
| 87 } // namespace ppapi |
| 88 |
| 89 #endif // PPAPI_PROXY_IMAGE_CAPTURE_RESOURCE_H_ |
OLD | NEW |