OLD | NEW |
---|---|
1 /* Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 #ifndef PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ | 6 #ifndef PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ |
7 #define PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ | 7 #define PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ |
8 | 8 |
9 #include "ppapi/c/private/ppb_image_capture_private.h" | 9 #include "ppapi/c/private/ppb_image_capture_private.h" |
10 #include "ppapi/cpp/completion_callback.h" | |
11 #include "ppapi/cpp/private/camera_capabilities_private.h" | |
12 #include "ppapi/cpp/resource.h" | 10 #include "ppapi/cpp/resource.h" |
13 #include "ppapi/cpp/var.h" | 11 #include "ppapi/cpp/var.h" |
14 | 12 |
15 /// @file | 13 /// @file |
16 /// Defines the <code>ImageCapture_Private</code> interface. Used for | 14 /// Defines the <code>ImageCapture_Private</code> interface. Used for |
17 /// acquiring a single still image from a camera source. | 15 /// acquiring a single still image from a camera source. |
18 namespace pp { | 16 namespace pp { |
19 | 17 |
18 class CameraCapabilities_Private; | |
19 class CompletionCallback; | |
20 class InstanceHandle; | |
21 | |
22 template <typename T> | |
23 class CompletionCallbackWithOutput; | |
24 | |
20 /// To query camera capabilities: | 25 /// To query camera capabilities: |
21 /// 1. Get a PPB_ImageCapture_Private object by Create(). | 26 /// 1. Create an ImageCapture_Private object. |
22 /// 2. Open() camera device with track id of MediaStream video track. | 27 /// 2. Open() camera device with track id of MediaStream video track. |
23 /// 3. Call GetCameraCapabilities() to get a | 28 /// 3. Call GetCameraCapabilities() to get a |
24 /// <code>PPB_CameraCapabilities_Private</code> object, which can be used to | 29 /// <code>CameraCapabilities_Private</code> object, which can be used to |
25 /// query camera capabilities. | 30 /// query camera capabilities. |
26 class ImageCapture_Private { | 31 class ImageCapture_Private : public Resource { |
27 public: | 32 public: |
28 /// Default constructor for creating an is_null() | 33 /// Default constructor for creating an is_null() |
29 /// <code>ImageCapture_Private</code> object. | 34 /// <code>ImageCapture_Private</code> object. |
30 ImageCapture_Private(); | 35 ImageCapture_Private(); |
31 | 36 |
32 /// Creates an ImageCapture_Private resource. | 37 /// The copy constructor for <code>ImageCapture_Private</code>. |
38 /// | |
39 /// @param[in] other A reference to a <code>ImageCapture_Private</code>. | |
40 ImageCapture_Private(const ImageCapture_Private& other); | |
41 | |
42 /// Constructs an <code>ImageCapture_Private</code> from | |
43 /// a <code>Resource</code>. | |
44 /// | |
45 /// @param[in] resource A <code>PPB_ImageCapture_Private</code> resource. | |
46 explicit ImageCapture_Private(const Resource& resource); | |
47 | |
48 /// Constructs an ImageCapture_Private resource. | |
33 /// | 49 /// |
34 /// @param[in] instance A <code>PP_Instance</code> identifying one instance | 50 /// @param[in] instance A <code>PP_Instance</code> identifying one instance |
35 /// of a module. | 51 /// of a module. |
36 /// @param[in] camera_source_id A <code>Var</code> identifying a camera | 52 explicit ImageCapture_Private(const InstanceHandle& instance); |
37 /// source. The type is string. The ID can be obtained from | |
38 /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a | |
39 /// MediaStreamVideoTrack is associated with the same source and the track | |
40 /// is closed, this ImageCapture_Private object can still do image capture. | |
41 /// @param[in] error_callback A <code>ImageCapture_Private_ErrorCallback | |
42 /// </code> callback to indicate the image capture has failed. | |
43 /// @param[inout] user_data An opaque pointer that will be passed to the | |
44 /// callbacks of ImageCapture_Private. | |
45 ImageCapture_Private(const InstanceHandle& instance, | |
46 const Var& camera_source_id, | |
47 void* user_data); | |
48 | |
49 /// Constructs a <code>ImageCapture_Private</code> from a <code> | |
50 /// Resource</code>. | |
51 /// | |
52 /// @param[in] resource A <code>ImageCapture_Private</code> | |
53 /// resource. | |
54 explicit ImageCapture_Private(const Resource& resource); | |
55 | 53 |
56 /// A constructor used when you have received a <code>PP_Resource</code> as a | 54 /// A constructor used when you have received a <code>PP_Resource</code> as a |
57 /// return value that has had 1 ref added for you. | 55 /// return value that has had 1 ref added for you. |
58 /// | 56 /// |
59 /// @param[in] resource A <code>ImageCapture_Private</code> | 57 /// @param[in] resource A <code>PPB_ImageCapture_Private</code> resource. |
60 /// resource. | |
61 ImageCapture_Private(PassRef, PP_Resource resource); | 58 ImageCapture_Private(PassRef, PP_Resource resource); |
62 | 59 |
63 // Destructor. | 60 // Destructor. |
64 ~ImageCapture_Private(); | 61 ~ImageCapture_Private(); |
65 | 62 |
63 /// Opens a video capture 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>PP_CompletionCallback</code> to be called upon | |
dmichael (off chromium)
2015/02/09 22:26:59
nit:
s/PP_CompletionCallback/CompletionCallback
Justin Chuang
2015/02/10 16:01:02
Done.
| |
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); | |
73 | |
66 /// Disconnects from the camera and cancels all pending capture requests. | 74 /// Disconnects from the camera and cancels all pending capture requests. |
67 /// After this returns, no callbacks will be called. If <code> | 75 /// After this returns, no callbacks will be called. If <code> |
68 /// ImageCapture_Private</code> is destroyed and is not closed yet, this | 76 /// ImageCapture_Private</code> is destroyed and is not closed yet, this |
69 /// function will be automatically called. Calling this more than once has no | 77 /// function will be automatically called. Calling this more than once has no |
70 /// effect. | 78 /// effect. |
71 /// | 79 void Close(); |
72 /// @param[in] callback <code>CompletionCallback</code> to be called upon | |
73 /// completion of <code>Close()</code>. | |
74 /// | |
75 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
76 int32_t Close(const CompletionCallback& callback); | |
77 | 80 |
78 /// Gets the camera capabilities. | 81 /// Gets the camera capabilities. |
79 /// | 82 /// |
80 /// The camera capabilities do not change for a given camera source. | 83 /// The camera capabilities do not change for a given camera source. |
81 /// | 84 /// |
82 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> | 85 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> |
83 /// to be called upon completion. | 86 /// to be called upon completion. |
84 /// | 87 /// |
85 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | 88 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. |
86 int32_t GetCameraCapabilities( | 89 int32_t GetCameraCapabilities( |
87 const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback); | 90 const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback); |
88 | 91 |
89 /// Determines if a resource is an image capture resource. | 92 /// Determines if a resource is an image capture resource. |
90 /// | 93 /// |
91 /// @param[in] resource The <code>Resource</code> to test. | 94 /// @param[in] resource The <code>Resource</code> to test. |
92 /// | 95 /// |
93 /// @return true if the given resource is an image capture resource or false | 96 /// @return true if the given resource is an image capture resource or false |
94 /// otherwise. | 97 /// otherwise. |
95 static bool IsImageCapture(const Resource& resource); | 98 static bool IsImageCapture(const Resource& resource); |
96 }; | 99 }; |
97 | 100 |
98 } // namespace pp | 101 } // namespace pp |
99 | 102 |
100 #endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ */ | 103 #endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ */ |
101 | |
OLD | NEW |