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/private/image_capture_config_private.h" | |
13 #include "ppapi/cpp/resource.h" | 10 #include "ppapi/cpp/resource.h" |
14 #include "ppapi/cpp/var.h" | 11 #include "ppapi/cpp/var.h" |
15 | 12 |
16 /// @file | 13 /// @file |
17 /// Defines the <code>ImageCapture_Private</code> interface. Used for | 14 /// Defines the <code>ImageCapture_Private</code> interface. Used for |
18 /// acquiring a single still image from a camera source. | 15 /// acquiring a single still image from a camera source. |
19 namespace pp { | 16 namespace pp { |
20 | 17 |
18 class CameraCapabilities_Private; | |
19 class CompletionCallback; | |
20 class ImageCaptureConfig_Private; | |
21 class InstanceHandle; | |
22 | |
23 template <typename T> | |
24 class CompletionCallbackWithOutput; | |
25 | |
21 /// To capture a still image with this class, use the following steps. | 26 /// To capture a still image with this class, use the following steps. |
22 /// 1. Create an ImageCapture_Private object by the constructor. | 27 /// 1. Create an ImageCapture_Private object by the constructor. |
23 /// 2. Call GetCameraCapabilities to get the supported preview sizes. | 28 /// 2. Call GetCameraCapabilities to get the supported preview sizes. |
24 /// 3. For optimal performance, set one of the supported preview size as the | 29 /// 3. For optimal performance, set one of the supported preview size as the |
25 /// constraints of getUserMedia. Use the created MediaStreamVideoTrack for | 30 /// constraints of getUserMedia. Use the created MediaStreamVideoTrack for |
26 /// camera previews. | 31 /// camera previews. |
27 /// 4. Set the same preview size and other settings by SetConfig. | 32 /// 4. Set the same preview size and other settings by SetConfig. |
28 /// 5. Call CaptureStillImage to capture a still image. Play the shutter sound | 33 /// 5. Call CaptureStillImage to capture a still image. Play the shutter sound |
29 /// in the shutter callback. The image from the preview callback can be used | 34 /// in the shutter callback. The image from the preview callback can be used |
30 /// for display. JPEG image will be returned to the JPEG callback. | 35 /// for display. JPEG image will be returned to the JPEG callback. |
31 class ImageCapture_Private { | 36 class ImageCapture_Private : public Resource { |
32 public: | 37 public: |
33 /// Default constructor for creating an is_null() | 38 /// Default constructor for creating an is_null() |
34 /// <code>ImageCapture_Private</code> object. | 39 /// <code>ImageCapture_Private</code> object. |
35 ImageCapture_Private(); | 40 ImageCapture_Private(); |
36 | 41 |
37 /// Creates an ImageCapture_Private resource. | 42 /// The copy constructor for <code>ImageCapture_Private</code>. |
43 /// | |
44 /// @param[in] other A reference to a <code>ImageCapture_Private</code>. | |
45 ImageCapture_Private(const ImageCapture_Private& other); | |
46 | |
47 /// Constructs an <code>ImageCapture_Private</code> from | |
48 /// a <code>Resource</code>. | |
49 /// | |
50 /// @param[in] resource A <code>PPB_ImageCapture_Private</code> resource. | |
51 explicit ImageCapture_Private(const Resource& resource); | |
52 | |
53 /// Constructs an ImageCapture_Private resource. | |
38 /// | 54 /// |
39 /// @param[in] instance A <code>PP_Instance</code> identifying one instance | 55 /// @param[in] instance A <code>PP_Instance</code> identifying one instance |
40 /// of a module. | 56 /// of a module. |
57 ImageCapture_Private(const InstanceHandle& instance); | |
58 | |
59 /// A constructor used when you have received a <code>PP_Resource</code> as a | |
60 /// return value that has had 1 ref added for you. | |
61 /// | |
62 /// @param[in] resource A <code>PPB_ImageCapture_Private</code> resource. | |
63 ImageCapture_Private(PassRef, PP_Resource resource); | |
64 | |
65 // Destructor. | |
66 ~ImageCapture_Private(); | |
67 | |
68 /// Opens a video capture device. | |
69 /// | |
41 /// @param[in] camera_source_id A <code>Var</code> identifying a camera | 70 /// @param[in] camera_source_id A <code>Var</code> identifying a camera |
42 /// source. The type is string. The ID can be obtained from | 71 /// source. The type is string. The ID can be obtained from |
43 /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a | 72 /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a |
44 /// MediaStreamVideoTrack is associated with the same source and the track | 73 /// MediaStreamVideoTrack is associated with the same source and the track |
45 /// is closed, this ImageCapture_Private object can still do image capture. | 74 /// is closed, this ImageCapture_Private object can still do image capture. |
46 /// @param[in] error_callback A <code>ImageCapture_Private_ErrorCallback | 75 /// @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
47 /// </code> callback to indicate the image capture has failed. | 76 /// completion of <code>Open()</code>. |
48 /// @param[inout] user_data An opaque pointer that will be passed to the | |
49 /// callbacks of ImageCapture_Private. | |
50 ImageCapture_Private(const InstanceHandle& instance, | |
51 const Var& camera_source_id, | |
52 PPB_ImageCapture_Private_ErrorCallback error_callback, | |
53 void* user_data); | |
54 | |
55 /// Constructs a <code>ImageCapture_Private</code> from a <code> | |
56 /// Resource</code>. | |
57 /// | 77 /// |
58 /// @param[in] resource A <code>ImageCapture_Private</code> | 78 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. |
59 /// resource. | 79 int32_t Open(const Var& camera_source_id, const CompletionCallback& callback); |
60 explicit ImageCapture_Private(const Resource& resource); | |
61 | |
62 /// A constructor used when you have received a <code>PP_Resource</code> as a | |
63 /// return value that has had 1 ref added for you. | |
64 /// | |
65 /// @param[in] resource A <code>ImageCapture_Private</code> | |
66 /// resource. | |
67 ImageCapture_Private(PassRef, PP_Resource resource); | |
68 | |
69 // Destructor. | |
70 ~ImageCapture_Private(); | |
71 | 80 |
72 /// Disconnects from the camera and cancels all pending capture requests. | 81 /// Disconnects from the camera and cancels all pending capture requests. |
73 /// After this returns, no callbacks will be called. If <code> | 82 /// After this returns, no callbacks will be called. If <code> |
74 /// ImageCapture_Private</code> is destroyed and is not closed yet, this | 83 /// ImageCapture_Private</code> is destroyed and is not closed yet, this |
75 /// function will be automatically called. Calling this more than once has no | 84 /// function will be automatically called. Calling this more than once has no |
76 /// effect. | 85 /// effect. |
77 /// | 86 void Close(); |
78 /// @param[in] callback <code>CompletionCallback</code> to be called upon | |
79 /// completion of <code>Close()</code>. | |
80 /// | |
81 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
82 int32_t Close(const CompletionCallback& callback); | |
83 | 87 |
84 /// Sets the configuration of the image capture. | 88 /// Sets the configuration of the image capture. |
85 /// If <code>SetConfig()</code> is not called, default settings will be used. | 89 /// If <code>SetConfig()</code> is not called, default settings will be used. |
86 /// | 90 /// |
87 /// @param[in] config A <code>ImageCaptureConfig_Private</code> object. | 91 /// @param[in] config A <code>ImageCaptureConfig_Private</code> object. |
88 /// @param[in] callback <code>CompletionCallback</code> to be called upon | 92 /// @param[in] callback <code>CompletionCallback</code> to be called upon |
89 /// completion of <code>SetConfig()</code>. | 93 /// completion of <code>SetConfig()</code>. |
90 /// | 94 /// |
91 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | 95 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. |
92 /// Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of | 96 /// Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of |
(...skipping 15 matching lines...) Expand all Loading... | |
108 /// | 112 /// |
109 /// The camera capabilities do not change for a given camera source. | 113 /// The camera capabilities do not change for a given camera source. |
110 /// | 114 /// |
111 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> | 115 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> |
112 /// to be called upon completion. | 116 /// to be called upon completion. |
113 /// | 117 /// |
114 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | 118 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. |
115 int32_t GetCameraCapabilities( | 119 int32_t GetCameraCapabilities( |
116 const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback); | 120 const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback); |
117 | 121 |
122 /// Allows the browser to reuse preview buffer and JPEG buffer that was | |
123 /// previously sent by |preview_calback| and |jpeg_callback| registered in | |
124 /// <code>PPB_ImageCapture_Private.CaptureStillImage()</code>. | |
125 /// | |
126 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
127 int32_t ReuseBuffers(); | |
wuchengli
2015/02/02 14:50:08
Forgot to remove.
Justin Chuang
2015/02/03 12:32:08
Done. Thanks
| |
128 | |
118 /// Captures a still JPEG image from the camera. | 129 /// Captures a still JPEG image from the camera. |
119 /// | 130 /// |
120 /// Triggers an asynchronous image capture. The camera will initiate a series | 131 /// Triggers an asynchronous image capture. The camera will initiate a series |
121 /// of callbacks to the application as the image capture progresses. The | 132 /// of callbacks to the application as the image capture progresses. The |
122 /// callbacks will be invoked in the order of shutter callback, preview | 133 /// callbacks will be invoked in the order of shutter callback, preview |
123 /// callback, and JPEG callback. The shutter callback occurs after the image | 134 /// callback, and JPEG callback. The shutter callback occurs after the image |
124 /// is captured. This can be used to trigger a sound to let the user know that | 135 /// is captured. This can be used to trigger a sound to let the user know that |
125 /// image has been captured. The preview callback occurs when a scaled, fully | 136 /// image has been captured. The preview callback occurs when a scaled, fully |
126 /// processed preview image is available. The JPEG callback occurs when the | 137 /// processed preview image is available. The JPEG callback occurs when the |
127 /// compressed image is available. If there is an error after the capture is | 138 /// compressed image is available. If there is an error after the capture is |
(...skipping 16 matching lines...) Expand all Loading... | |
144 /// | 155 /// |
145 /// @param[in] shutter_callback A <code> | 156 /// @param[in] shutter_callback A <code> |
146 /// ImageCapture_Private_ShutterCallback</code> callback to indicate the | 157 /// ImageCapture_Private_ShutterCallback</code> callback to indicate the |
147 /// image has been taken. | 158 /// image has been taken. |
148 /// @param[in] preview_callback A <code> | 159 /// @param[in] preview_callback A <code> |
149 /// ImageCapture_Private_PreviewCallback</code> callback to return a | 160 /// ImageCapture_Private_PreviewCallback</code> callback to return a |
150 /// preview of the captured image. | 161 /// preview of the captured image. |
151 /// @param[in] jpeg_callback A <code> | 162 /// @param[in] jpeg_callback A <code> |
152 /// ImageCapture_Private_JpegCallback</code> callback to return captured | 163 /// ImageCapture_Private_JpegCallback</code> callback to return captured |
153 /// JPEG image. | 164 /// JPEG image. |
165 /// @param[in] error_callback A <code>PPB_ImageCapture_Private_ErrorCallback | |
166 /// </code> callback to indicate <code>CaptureStillImage()</code> has failed. | |
154 /// @param[out] sequence_id The sequence ID is a unique monotonically | 167 /// @param[out] sequence_id The sequence ID is a unique monotonically |
155 /// increasing value starting from 0, incremented every time a new request | 168 /// increasing value starting from 0, incremented every time a new request |
156 /// like image capture is submitted. | 169 /// like image capture is submitted. |
157 /// | 170 /// |
158 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | 171 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. |
159 /// PP_OK means the callbacks will be triggered. Other values mean the | 172 /// PP_OK means the callbacks will be triggered. Other values mean the |
160 /// callbacks will not be triggered. | 173 /// callbacks will not be triggered. |
161 int32_t CaptureStillImage( | 174 int32_t CaptureStillImage( |
162 PPB_ImageCapture_Private_ShutterCallback shutter_callback, | 175 PPB_ImageCapture_Private_ShutterCallback shutter_callback, |
163 PPB_ImageCapture_Private_PreviewCallback preview_callback, | 176 PPB_ImageCapture_Private_PreviewCallback preview_callback, |
164 PPB_ImageCapture_Private_JpegCallback jpeg_callback, | 177 PPB_ImageCapture_Private_JpegCallback jpeg_callback, |
165 int64_t* sequence_id); | 178 int64_t* sequence_id); |
166 | 179 |
167 /// Determines if a resource is an image capture resource. | 180 /// Determines if a resource is an image capture resource. |
168 /// | 181 /// |
169 /// @param[in] resource The <code>Resource</code> to test. | 182 /// @param[in] resource The <code>Resource</code> to test. |
170 /// | 183 /// |
171 /// @return true if the given resource is an image capture resource or false | 184 /// @return true if the given resource is an image capture resource or false |
172 /// otherwise. | 185 /// otherwise. |
173 static bool IsImageCapture(const Resource& resource); | 186 static bool IsImageCapture(const Resource& resource); |
174 }; | 187 }; |
175 | 188 |
176 } // namespace pp | 189 } // namespace pp |
177 | 190 |
178 #endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ */ | 191 #endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ */ |
179 | |
OLD | NEW |