1 // Copyright 2015 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.
5 #ifndef PPAPI_PROXY_CAMERA_DEVICE_RESOURCE_H_
6 #define PPAPI_PROXY_CAMERA_DEVICE_RESOURCE_H_
8 #include "base/basictypes.h"
9 #include "ppapi/c/pp_size.h"
10 #include "ppapi/c/private/pp_video_capture_format.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_camera_device_api.h"
20 class CameraCapabilitiesResource
;
22 class PPAPI_PROXY_EXPORT CameraDeviceResource
23 : public PluginResource
,
24 public thunk::PPB_CameraDevice_API
{
26 CameraDeviceResource(Connection connection
, PP_Instance instance
);
27 ~CameraDeviceResource() override
;
29 // Resource overrides:
30 thunk::PPB_CameraDevice_API
* AsPPB_CameraDevice_API() override
{
34 // PPB_CameraDevice_API implementation.
35 int32_t Open(PP_Var device_id
,
36 const scoped_refptr
<TrackedCallback
>& callback
) override
;
37 void Close() override
;
38 int32_t GetCameraCapabilities(
39 PP_Resource
* capabilities
,
40 const scoped_refptr
<TrackedCallback
>& callback
) override
;
43 enum class OpenState
{ BEFORE_OPEN
, OPENED
, CLOSED
};
45 void OnPluginMsgGetVideoCaptureFormatsReply(
46 PP_Resource
* capabilities_output
,
47 const ResourceMessageReplyParams
& params
,
48 const std::vector
<PP_VideoCaptureFormat
>& formats
);
50 void OnPluginMsgOpenReply(const ResourceMessageReplyParams
& params
);
52 bool is_opened() const { return open_state_
== OpenState::OPENED
; }
54 // Holds a reference of the callback so that Close() can cancel it.
55 scoped_refptr
<TrackedCallback
> open_callback_
;
56 OpenState open_state_
;
58 scoped_refptr
<TrackedCallback
> get_capabilities_callback_
;
59 scoped_refptr
<CameraCapabilitiesResource
> camera_capabilities_
;
61 DISALLOW_COPY_AND_ASSIGN(CameraDeviceResource
);
67 #endif // PPAPI_PROXY_CAMERA_DEVICE_RESOURCE_H_