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

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

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

Powered by Google App Engine
This is Rietveld 408576698