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.
6 #ifndef PPAPI_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_
7 #define PPAPI_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_
9 #include "ppapi/c/private/ppb_camera_device_private.h"
10 #include "ppapi/cpp/resource.h"
11 #include "ppapi/cpp/var.h"
14 /// Defines the <code>CameraDevice_Private</code> interface. Used for
15 /// manipulating a camera device.
18 class CameraCapabilities_Private
;
19 class CompletionCallback
;
23 class CompletionCallbackWithOutput
;
25 /// To query camera capabilities:
26 /// 1. Create a CameraDevice_Private object.
27 /// 2. Open() camera device with track id of MediaStream video track.
28 /// 3. Call GetCameraCapabilities() to get a
29 /// <code>CameraCapabilities_Private</code> object, which can be used to
30 /// query camera capabilities.
31 class CameraDevice_Private
: public Resource
{
33 /// Default constructor for creating an is_null()
34 /// <code>CameraDevice_Private</code> object.
35 CameraDevice_Private();
37 /// The copy constructor for <code>CameraDevice_Private</code>.
39 /// @param[in] other A reference to a <code>CameraDevice_Private</code>.
40 CameraDevice_Private(const CameraDevice_Private
& other
);
42 /// Constructs a <code>CameraDevice_Private</code> from a
43 /// <code>Resource</code>.
45 /// @param[in] resource A <code>PPB_CameraDevice_Private</code> resource.
46 explicit CameraDevice_Private(const Resource
& resource
);
48 /// Constructs a CameraDevice_Private resource.
50 /// @param[in] instance A <code>PP_Instance</code> identifying one instance
52 explicit CameraDevice_Private(const InstanceHandle
& instance
);
54 /// A constructor used when you have received a <code>PP_Resource</code> as a
55 /// return value that has had 1 ref added for you.
57 /// @param[in] resource A <code>PPB_CameraDevice_Private</code> resource.
58 CameraDevice_Private(PassRef
, PP_Resource resource
);
61 ~CameraDevice_Private();
63 /// Opens a camera device.
65 /// @param[in] device_id A <code>Var</code> identifying a camera
66 /// device. The type is string. The ID can be obtained from
67 /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id.
68 /// @param[in] callback A <code>CompletionCallback</code> to be called upon
69 /// completion of <code>Open()</code>.
71 /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
72 int32_t Open(const Var
& device_id
, const CompletionCallback
& callback
);
74 /// Disconnects from the camera and cancels all pending requests.
75 /// After this returns, no callbacks will be called. If <code>
76 /// CameraDevice_Private</code> is destroyed and is not closed yet, this
77 /// function will be automatically called. Calling this more than once has no
81 /// Gets the camera capabilities.
83 /// The camera capabilities do not change for a given camera source.
85 /// @param[in] callback A <code>CompletionCallbackWithOutput</code>
86 /// to be called upon completion.
88 /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
89 int32_t GetCameraCapabilities(
90 const CompletionCallbackWithOutput
<CameraCapabilities_Private
>& callback
);
92 /// Determines if a resource is a camera device resource.
94 /// @param[in] resource The <code>Resource</code> to test.
96 /// @return true if the given resource is a camera device resource or false
98 static bool IsCameraDevice(const Resource
& resource
);
103 #endif /* PPAPI_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_ */