Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: ppapi/api/private/ppb_image_capture_private.idl

Issue 848863002: PPAPI: implement GetSupportedPreviewSizes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split ImageCapture_Config to 881743005 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /** 6 /**
7 * Defines the <code>PPB_ImageCapture_Private</code> interface. Used for 7 * Defines the <code>PPB_ImageCapture_Private</code> interface. Used for
8 * acquiring a single still image from a camera source. 8 * acquiring a single still image from a camera source.
9 */ 9 */
10 10
11 [generate_thunk] 11 [generate_thunk]
12 12
13 label Chrome { 13 label Chrome {
14 M39 = 0.1 14 M42 = 0.1
15 }; 15 };
16 16
17 /** 17 /**
18 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage 18 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage
19 * </code> to indicate the image has been captured from the sensor. This is a 19 * </code> to indicate the image has been captured from the sensor. This is a
20 * good opportunity to play a shutter sound or give other feedback of camera 20 * good opportunity to play a shutter sound or give other feedback of camera
21 * operation. This will occur after the image was captured, but before the 21 * operation. This will occur after the image was captured, but before the
22 * actual data is available. 22 * actual data is available.
23 * 23 *
24 * Parameters: 24 * Parameters:
25 * |user_data| The same pointer that was passed into <code>
26 * PPB_ImageCapture_Private.Create()</code>.
27 * |sequence_id| The sequence ID of the image capture, same as the one from 25 * |sequence_id| The sequence ID of the image capture, same as the one from
28 * CaptureStillImage. 26 * CaptureStillImage.
29 */ 27 */
30 typedef void PPB_ImageCapture_Private_ShutterCallback( 28 typedef void PPB_ImageCapture_Private_ShutterCallback(
wuchengli 2015/02/02 14:42:33 No need to remove user_data because we're going to
Justin Chuang 2015/02/03 12:32:08 Already removed in later patchset.
31 [inout] mem_t user_data, 29 [in] uint64_t sequence_id);
32 [in] int64_t sequence_id);
33 30
34 /** 31 /**
35 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage 32 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage
36 * </code> to deliver a preview image. The client can use this to show the 33 * </code> to deliver a preview image. The client can use this to show the
37 * captured image. See <code>PPB_ImageCapture_Private.CaptureStillImage 34 * captured image. See <code>PPB_ImageCapture_Private.CaptureStillImage
38 * </code> for more information. 35 * </code> for more information.
39 * 36 *
40 * Parameters: 37 * Parameters:
41 * |user_data| The same pointer that was passed into <code>
42 * PPB_ImageCapture_Private.Create()</code>.
43 * |sequence_id| The sequence ID of the image capture, same as the one from 38 * |sequence_id| The sequence ID of the image capture, same as the one from
44 * CaptureStillImage. 39 * CaptureStillImage.
45 * |preview| A <code>PP_Resource</code> corresponding to a VideoFrame 40 * |preview| A <code>PP_Resource</code> corresponding to a VideoFrame
46 * resource used to store the preview image. 41 * resource used to store the preview image.
47 */ 42 */
48 typedef void PPB_ImageCapture_Private_PreviewCallback( 43 typedef void PPB_ImageCapture_Private_PreviewCallback(
49 [inout] mem_t user_data, 44 [in] uint64_t sequence_id,
50 [in] int64_t sequence_id,
51 [in] PP_Resource preview); 45 [in] PP_Resource preview);
52 46
53 /** 47 /**
54 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage 48 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage
55 * </code> to deliver a still JPEG image. See <code> 49 * </code> to deliver a still JPEG image. See <code>
56 * PPB_ImageCapture_Private.CaptureStillImage</code> for more information. 50 * PPB_ImageCapture_Private.CaptureStillImage</code> for more information.
57 * 51 *
58 * Parameters: 52 * Parameters:
59 * |user_data| The same pointer that was passed into <code>
60 * PPB_ImageCapture_Private.Create()</code>.
61 * |sequence_id| The sequence ID of the image capture, same as the one from 53 * |sequence_id| The sequence ID of the image capture, same as the one from
62 * CaptureStillImage. 54 * CaptureStillImage.
63 * |jpeg| A <code>PP_Resource</code> corresponding to a VideoFrame 55 * |jpeg| A <code>PP_Resource</code> corresponding to a VideoFrame
64 * resource used to store the JPEG image. 56 * resource used to store the JPEG image.
65 */ 57 */
66 typedef void PPB_ImageCapture_Private_JpegCallback( 58 typedef void PPB_ImageCapture_Private_JpegCallback(
67 [inout] mem_t user_data, 59 [in] uint64_t sequence_id,
68 [in] int64_t sequence_id,
69 [in] PP_Resource jpeg); 60 [in] PP_Resource jpeg);
70 61
71 /** 62 /**
72 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage 63 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage
73 * </code> to indicate the image capture has failed. 64 * </code> to indicate the image capture has failed.
74 * 65 *
75 * Parameters: 66 * Parameters:
76 * |user_data| The same pointer that was passed into <code>
77 * PPB_ImageCapture_Private.Create()</code>.
78 * |sequence_id| The sequence ID of the image capture, same as the one from 67 * |sequence_id| The sequence ID of the image capture, same as the one from
79 * CaptureStillImage. 68 * CaptureStillImage.
80 * |int32_t| An error code from <code>pp_errors.h</code>. 69 * |int32_t| An error code from <code>pp_errors.h</code>.
81 */ 70 */
82 typedef void PPB_ImageCapture_Private_ErrorCallback( 71 typedef void PPB_ImageCapture_Private_ErrorCallback(
83 [inout] mem_t user_data, 72 [in] uint64_t sequence_id,
84 [in] int64_t sequence_id,
85 [in] int32_t pp_error); 73 [in] int32_t pp_error);
86 74
87 /** 75 /**
88 * To capture a still image with this class, use the following steps. 76 * To capture a still image with this class, use the following steps.
89 * 1. Get a PPB_ImageCapture_Private object by Create(). 77 * 1. Get a PPB_ImageCapture_Private object by Create().
90 * 2. Call GetCameraCapabilities to get the supported preview sizes. 78 * 2. Open() the device with camera source ID.
91 * 3. For optimal performance, set one of the supported preview size as the 79 * 3. Call GetCameraCapabilities() to get the supported preview sizes.
80 * 4. For optimal performance, set one of the supported preview size as the
92 * constraints of getUserMedia. Use the created MediaStreamVideoTrack for 81 * constraints of getUserMedia. Use the created MediaStreamVideoTrack for
93 * camera previews. 82 * camera previews.
94 * 4. Set the same preview size and other settings by SetConfig. 83 * 5. Set the same preview size and other settings by SetConfig().
95 * 5. Call CaptureStillImage to capture a still image. Play the shutter sound in 84 * 6. Call CaptureStillImage() to capture a still image. Play the shutter sound
96 * the shutter callback. The image from the preview callback can be used for 85 * in the shutter callback. The image from the preview callback can be used
97 * display. JPEG image will be returned to the JPEG callback. 86 * for displaying preview. JPEG image will be returned by the JPEG callback.
98 */ 87 */
99 interface PPB_ImageCapture_Private { 88 interface PPB_ImageCapture_Private {
100 /** 89 /**
101 * Creates a PPB_ImageCapture_Private resource. 90 * Creates a PPB_ImageCapture_Private resource.
102 * 91 *
103 * @param[in] instance A <code>PP_Instance</code> identifying one instance 92 * @param[in] instance A <code>PP_Instance</code> identifying one instance
104 * of a module. 93 * of a module.
105 * @param[in] camera_source_id A <code>PP_Var</code> identifying a camera
106 * source. The type is string. The ID can be obtained from
107 * MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a
108 * MediaStreamVideoTrack is associated with the same source and the track
109 * is closed, this PPB_ImageCapture_Private object can still do image capture.
110 * @param[in] error_callback A <code>PPB_ImageCapture_Private_ErrorCallback
111 * </code> callback to indicate the image capture has failed.
112 * @param[inout] user_data An opaque pointer that will be passed to the
113 * callbacks of PPB_ImageCapture_Private.
114 * 94 *
115 * @return A <code>PP_Resource</code> corresponding to a 95 * @return A <code>PP_Resource</code> corresponding to a
116 * PPB_ImageCapture_Private resource if successful, 0 if failed. 96 * PPB_ImageCapture_Private resource if successful, 0 if failed.
117 */ 97 */
118 PP_Resource Create([in] PP_Instance instance, 98 PP_Resource Create([in] PP_Instance instance);
119 [in] PP_Var camera_source_id,
120 [in] PPB_ImageCapture_Private_ErrorCallback error_callback,
121 [inout] mem_t user_data);
122 99
123 /** 100 /**
124 * Determines if a resource is an image capture resource. 101 * Determines if a resource is an image capture resource.
125 * 102 *
126 * @param[in] resource The <code>PP_Resource</code> to test. 103 * @param[in] resource The <code>PP_Resource</code> to test.
127 * 104 *
128 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given 105 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
129 * resource is an image capture resource or <code>PP_FALSE</code> 106 * resource is an image capture resource or <code>PP_FALSE</code>
130 * otherwise. 107 * otherwise.
131 */ 108 */
132 PP_Bool IsImageCapture([in] PP_Resource resource); 109 PP_Bool IsImageCapture([in] PP_Resource resource);
133 110
134 /** 111 /**
112 * Opens a video capture device.
113 *
114 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
115 * image capture resource.
116 * @param[in] device_id A <code>PP_Var</code> identifying a camera device. The
117 * type is string. The ID can be obtained from MediaStreamTrack.getSources()
118 * or MediaStreamVideoTrack.id. If a MediaStreamVideoTrack is associated with
119 * the same source and the track is closed, this PPB_ImageCapture_Private
120 * object can still do image capture.
121 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
122 * completion of <code>Open()</code>.
123 *
124 * @return An error code from <code>pp_errors.h</code>.
125 */
126 int32_t Open(
127 [in] PP_Resource image_capture,
128 [in] PP_Var device_id,
129 [in] PP_CompletionCallback callback);
130
131 /**
135 * Disconnects from the camera and cancels all pending capture requests. 132 * Disconnects from the camera and cancels all pending capture requests.
136 * After this returns, no callbacks will be called. If <code> 133 * After this returns, no callbacks will be called. If <code>
137 * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this 134 * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this
138 * function will be automatically called. Calling this more than once has no 135 * function will be automatically called. Calling this more than once has no
139 * effect. 136 * effect.
140 * 137 *
141 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an 138 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
142 * image capture resource. 139 * image capture resource.
143 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon
144 * completion of <code>Close()</code>.
145 *
146 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
147 */ 140 */
148 int32_t Close([in] PP_Resource resource, 141 void Close([in] PP_Resource image_capture);
149 [in] PP_CompletionCallback callback);
150 142
151 /** 143 /**
152 * Sets the configuration of the image capture. 144 * Sets the configuration of the image capture.
153 * If <code>SetConfig()</code> is not called, default settings will be used. 145 * If <code>SetConfig()</code> is not called, default settings will be used.
154 * 146 *
155 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an 147 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
156 * image capture resource. 148 * image capture resource.
157 * @param[in] config A <code>PP_ImageCaptureConfig_Private</code> object. 149 * @param[in] config A <code>PP_ImageCaptureConfig_Private</code> object.
158 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon 150 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon
159 * completion of <code>SetConfig()</code>. 151 * completion of <code>SetConfig()</code>. This callback will only run if the
152 * return code is <code>PP_OK_COMPLETIONPENDING</code>.
160 * 153 *
161 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 154 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
162 * Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of 155 * Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of
163 * <code>SetConfig()</code> or <code>CaptureStillImage()</code>. 156 * <code>SetConfig()</code> or <code>CaptureStillImage()</code>.
164 * If an error is returned, the configuration will not be changed. 157 * If an error is returned, the configuration will not be changed.
165 */ 158 */
166 int32_t SetConfig([in] PP_Resource image_capture, 159 int32_t SetConfig([in] PP_Resource image_capture,
167 [in] PP_Resource config, 160 [in] PP_Resource config,
168 [in] PP_CompletionCallback callback); 161 [in] PP_CompletionCallback callback);
169 162
170 /** 163 /**
171 * Gets the configuration of the image capture. 164 * Gets the configuration of the image capture.
172 * 165 *
173 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an 166 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
174 * image capture resource. 167 * image capture resource.
175 * @param[out] config A <code>PP_ImageCaptureConfig_Private</code> for storing 168 * @param[out] config A <code>PP_ImageCaptureConfig_Private</code> for storing
176 * the current image capture config on success. Otherwise, the values will not 169 * the current image capture config on success. Otherwise, the values will not
177 * be changed. 170 * be changed.
178 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon 171 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon
179 * completion of <code>GetConfig()</code>. 172 * completion of <code>GetConfig()</code>. This callback will only run if the
173 * return code is <code>PP_OK_COMPLETIONPENDING</code>.
180 * 174 *
181 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 175 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
182 */ 176 */
183 int32_t GetConfig([in] PP_Resource image_capture, 177 int32_t GetConfig([in] PP_Resource image_capture,
184 [out] PP_Resource config, 178 [out] PP_Resource config,
185 [in] PP_CompletionCallback callback); 179 [in] PP_CompletionCallback callback);
186 180
187 /** 181 /**
188 * Gets the camera capabilities. 182 * Gets the camera capabilities.
189 * 183 *
190 * The camera capabilities do not change for a given camera source. 184 * The camera capabilities do not change for a given camera source.
191 * 185 *
192 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an 186 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
193 * image capture resource. 187 * image capture resource.
194 * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for 188 * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for
195 * storing the image capture capabilities on success. Otherwise, the value 189 * storing the image capture capabilities on success. Otherwise, the value
196 * will not be changed. 190 * will not be changed.
197 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon 191 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon
198 * completion of <code>GetCameraCapabilities()</code>. 192 * completion of <code>GetCameraCapabilities()</code>. This callback will only
193 * run if the return code is <code>PP_OK_COMPLETIONPENDING</code>.
199 * 194 *
200 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 195 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
201 */ 196 */
202 int32_t GetCameraCapabilities([in] PP_Resource image_capture, 197 int32_t GetCameraCapabilities([in] PP_Resource image_capture,
203 [out] PP_Resource capabilities, 198 [out] PP_Resource capabilities,
204 [in] PP_CompletionCallback callback); 199 [in] PP_CompletionCallback callback);
205 200
206 /** 201 /**
202 * Allows the browser to reuse preview buffer and JPEG buffer that was
203 * previously sent by |preview_calback| and |jpeg_callback| registered in
204 * <code>PPB_ImageCapture_Private.CaptureStillImage()</code>.
205 *
206 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
207 */
208 int32_t ReuseBuffers(
wuchengli 2015/02/02 14:42:33 I'd prefer moving this to another CL. This is not
Justin Chuang 2015/02/03 12:32:08 Already removed.
209 [in] PP_Resource image_capture);
210
211 /**
207 * Captures a still JPEG image from the camera. 212 * Captures a still JPEG image from the camera.
208 * 213 *
209 * Triggers an asynchronous image capture. The camera will initiate a series 214 * Triggers an asynchronous image capture. The camera will initiate a series
210 * of callbacks to the application as the image capture progresses. The 215 * of callbacks to the application as the image capture progresses. The
211 * callbacks will be invoked in the order of shutter callback, preview 216 * callbacks will be invoked in the order of shutter callback, preview
212 * callback, and JPEG callback. The shutter callback occurs after the image is 217 * callback, and JPEG callback. The shutter callback occurs after the image is
213 * captured. This can be used to trigger a sound to let the user know that 218 * captured. This can be used to trigger a sound to let the user know that
214 * image has been captured. The preview callback occurs when a scaled, fully 219 * image has been captured. The preview callback occurs when a scaled, fully
215 * processed preview image is available. The JPEG callback occurs when the 220 * processed preview image is available. The JPEG callback occurs when the
216 * compressed image is available. If there is an error after the capture is in 221 * compressed image is available. If there is an error after the capture is in
217 * progress, the error callback passed to <code> 222 * progress, the error callback will be invoked. All the callbacks are invoked
218 * PPB_ImageCapture_Private.Create()</code> will be invoked. All the callbacks 223 * by the thread that calls this function.
219 * are invoked by the thread that calls this function.
220 * 224 *
221 * The size of the preview image in preview callback is determined by 225 * The size of the preview image in preview callback is determined by
222 * <code>PPB_ImageCaptureConfig_Private.SetPreviewSize</code>. The format is 226 * <code>PPB_ImageCaptureConfig_Private.SetPreviewSize</code>. The format is
223 * decided by the camera and can be got from <code>PPB_VideoFrame.GetFormat 227 * decided by the camera and can be got from <code>PPB_VideoFrame.GetFormat
224 * </code>. The size of the JPEG image is determined by <code> 228 * </code>. The size of the JPEG image is determined by <code>
225 * PPB_ImageCaptureConfig_Private.SetJpegSize</code>. 229 * PPB_ImageCaptureConfig_Private.SetJpegSize</code>.
226 * 230 *
227 * The camera may need to stop and re-start streaming during image capture. If 231 * The camera may need to stop and re-start streaming during image capture. If
228 * some MediaStreamVideoTrack are associated with the camera source, they will 232 * some MediaStreamVideoTrack are associated with the camera source, they will
229 * receive mute and unmute events. The mute event will be received before all 233 * receive mute and unmute events. The mute event will be received before all
230 * the callbacks. The unmute event will be received after all the callbacks. 234 * the callbacks. The unmute event will be received after all the callbacks.
231 * The preview image will not be sent to the video tracks associated with the 235 * The preview image will not be sent to the video tracks associated with the
232 * camera. 236 * camera.
233 * 237 *
234 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an 238 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
235 * image capture resource. 239 * image capture resource.
236 * @param[in] shutter_callback A <code> 240 * @param[in] shutter_callback A <code>
237 * PPB_ImageCapture_Private_ShutterCallback</code> callback to indicate the 241 * PPB_ImageCapture_Private_ShutterCallback</code> callback to indicate the
238 * image has been taken. 242 * image has been taken.
239 * @param[in] preview_callback A <code> 243 * @param[in] preview_callback A <code>
240 * PPB_ImageCapture_Private_PreviewCallback</code> callback to return a 244 * PPB_ImageCapture_Private_PreviewCallback</code> callback to return a
241 * preview of the captured image. 245 * preview of the captured image.
242 * @param[in] jpeg_callback A <code> 246 * @param[in] jpeg_callback A <code>
243 * PPB_ImageCapture_Private_JpegCallback</code> callback to return captured 247 * PPB_ImageCapture_Private_JpegCallback</code> callback to return captured
244 * JPEG image. 248 * JPEG image.
249 * @param[in] error_callback A <code>PPB_ImageCapture_Private_ErrorCallback
250 * </code> callback to indicate <code>CaptureStillImage()</code> has failed.
245 * @param[out] sequence_id The sequence ID is a unique monotonically 251 * @param[out] sequence_id The sequence ID is a unique monotonically
246 * increasing value starting from 0, incremented every time a new request like 252 * increasing value starting from 0, incremented every time a new request like
247 * image capture is submitted. 253 * image capture is submitted.
248 * 254 *
249 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 255 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
250 * PP_OK means the callbacks will be triggered. Other values mean the 256 * PP_OK means the callbacks will be triggered. Other values mean the
251 * callbacks will not be triggered. 257 * callbacks will not be triggered.
252 */ 258 */
253 int32_t CaptureStillImage( 259 int32_t CaptureStillImage(
254 [in] PP_Resource image_capture, 260 [in] PP_Resource image_capture,
255 [in] PPB_ImageCapture_Private_ShutterCallback shutter_callback, 261 [in] PPB_ImageCapture_Private_ShutterCallback shutter_callback,
256 [in] PPB_ImageCapture_Private_PreviewCallback preview_callback, 262 [in] PPB_ImageCapture_Private_PreviewCallback preview_callback,
257 [in] PPB_ImageCapture_Private_JpegCallback jpeg_callback, 263 [in] PPB_ImageCapture_Private_JpegCallback jpeg_callback,
258 [out] int64_t sequence_id); 264 [in] PPB_ImageCapture_Private_ErrorCallback error_callback,
wuchengli 2015/02/02 14:42:33 Since we're going to add PPP_ImageCapture, no need
Justin Chuang 2015/02/03 12:32:08 Already removed.
265 [out] uint64_t sequence_id);
259 }; 266 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698