Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ppapi / cpp / private / camera_device_private.h
blobdce1e1b17477a02c7bb4c32773a35b58c89e31c6
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 */
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"
13 /// @file
14 /// Defines the <code>CameraDevice_Private</code> interface. Used for
15 /// manipulating a camera device.
16 namespace pp {
18 class CameraCapabilities_Private;
19 class CompletionCallback;
20 class InstanceHandle;
22 template <typename T>
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 {
32 public:
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>.
38 ///
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>.
44 ///
45 /// @param[in] resource A <code>PPB_CameraDevice_Private</code> resource.
46 explicit CameraDevice_Private(const Resource& resource);
48 /// Constructs a CameraDevice_Private resource.
49 ///
50 /// @param[in] instance A <code>PP_Instance</code> identifying one instance
51 /// of a module.
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.
56 ///
57 /// @param[in] resource A <code>PPB_CameraDevice_Private</code> resource.
58 CameraDevice_Private(PassRef, PP_Resource resource);
60 // Destructor.
61 ~CameraDevice_Private();
63 /// Opens a camera device.
64 ///
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>.
70 ///
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
78 /// effect.
79 void Close();
81 /// Gets the camera capabilities.
82 ///
83 /// The camera capabilities do not change for a given camera source.
84 ///
85 /// @param[in] callback A <code>CompletionCallbackWithOutput</code>
86 /// to be called upon completion.
87 ///
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.
93 ///
94 /// @param[in] resource The <code>Resource</code> to test.
95 ///
96 /// @return true if the given resource is a camera device resource or false
97 /// otherwise.
98 static bool IsCameraDevice(const Resource& resource);
101 } // namespace pp
103 #endif /* PPAPI_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_ */