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

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 review 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 * |image_capture| the PPB_ImageCapture_Private resource.
26 * |sequence_id| The sequence ID of the image capture, same as the one from
27 * CaptureStillImage.
28 */
29 typedef void PPB_ImageCapture_Private_ShutterCallback(
30 [in] PP_Resource image_capture,
31 [in] int64_t sequence_id);
32
33 /**
34 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage
35 * </code> to deliver a preview image. The client can use this to show the
36 * captured image. See <code>PPB_ImageCapture_Private.CaptureStillImage
37 * </code> for more information.
38 *
39 * Parameters:
40 * |image_capture| the PPB_ImageCapture_Private resource.
41 * |sequence_id| The sequence ID of the image capture, same as the one from
42 * CaptureStillImage.
43 * |preview| A <code>PP_Resource</code> corresponding to a VideoFrame
44 * resource used to store the preview image.
45 */
46 typedef void PPB_ImageCapture_Private_PreviewCallback(
47 [in] PP_Resource image_capture,
48 [in] int64_t sequence_id,
49 [in] PP_Resource preview);
50
51 /**
52 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage
53 * </code> to deliver a still JPEG image. See <code>
54 * PPB_ImageCapture_Private.CaptureStillImage</code> for more information.
55 *
56 * Parameters:
57 * |image_capture| the PPB_ImageCapture_Private resource.
58 * |sequence_id| The sequence ID of the image capture, same as the one from
59 * CaptureStillImage.
60 * |jpeg| A <code>PP_Resource</code> corresponding to a VideoFrame
61 * resource used to store the JPEG image.
62 */
63 typedef void PPB_ImageCapture_Private_JpegCallback(
64 [in] PP_Resource image_capture,
65 [in] int64_t sequence_id,
66 [in] PP_Resource jpeg);
67
Justin Chuang 2014/08/11 08:32:35 We do not have *_ErrorCallback when HW is broken o
wuchengli 2014/08/12 07:27:02 I added an error callback to Create for image capt
68 /**
69 * To capture a still image with this class, use the following steps.
70 * 1. Get a PPB_ImageCapture_Private object by Create().
71 * 2. Call GetCameraCapabilities to get the supported preview sizes.
72 * 3. For optimal performance, set one of the supported preview size as the
73 * constraints of getUserMedia. Use the created MediaStreamVideoTrack for
74 * camera previews.
75 * 4. Set the same preview size and other settings by SetConfig.
76 * 5. Call CaptureStillImage to capture a still image. Play the shutter sound in
77 * the shutter callback. The image from the preview callback can be used for
78 * display. JPEG image will be returned to the JPEG callback.
79 */
80 interface PPB_ImageCapture_Private {
81 /**
82 * Creates a PPB_ImageCapture_Private resource.
83 *
84 * @param[in] instance A <code>PP_Instance</code> identifying one instance
85 * of a module.
86 * @param[in] camera_source_id A <code>PP_Var</code> identifying a camera
87 * source. The type is string. The ID can be obtained from
88 * MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a
89 * MediaStreamVideoTrack is associated with the same source and the track
90 * is closed, this PPB_ImageCapture_Private object can still do image capture.
91 *
92 * @return A <code>PP_Resource</code> corresponding to a
93 * PPB_ImageCapture_Private resource if successful, 0 if failed.
94 */
95 PP_Resource Create([in] PP_Instance instance,
96 [in] PP_Var camera_source_id);
97
98 /**
99 * Determines if a resource is an image capture resource.
100 *
101 * @param[in] resource The <code>PP_Resource</code> to test.
102 *
103 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
104 * resource is an image capture resource or <code>PP_FALSE</code>
105 * otherwise.
106 */
107 PP_Bool IsImageCapture([in] PP_Resource resource);
108
109 /**
110 * Disconnects from the camera and cancels all pending capture requests.
111 * After this returns, no callbacks will be called. If <code>
112 * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this
113 * function will be automatically called. Calling this more than once has no
114 * effect.
115 *
116 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
117 * image capture resource.
118 */
119 void Close([in] PP_Resource resource);
120
121 /**
122 * Sets the configuration of the image capture.
123 * If <code>SetConfig()</code> is not called, default settings will be used.
124 *
125 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
126 * image capture resource.
127 * @param[in] config A <code>PP_ImageCaptureConfig_Private</code> object.
128 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon
129 * completion of <code>SetConfig()</code>.
130 *
131 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
132 * Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of
133 * <code>SetConfig()</code> or <code>CaptureStillImage()</code>.
134 * If an error is returned, the configuration will not be changed.
135 */
136 int32_t SetConfig([in] PP_Resource image_capture,
137 [in] PP_Resource config,
138 [in] PP_CompletionCallback callback);
139
140 /**
141 * Gets the configuration of the image capture.
142 *
143 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
144 * image capture resource.
145 * @param[out] config A <code>PP_ImageCaptureConfig_Private</code> for storing
146 * the current image capture config on success. Otherwise, the values will not
147 * be changed.
148 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon
149 * completion of <code>GetConfig()</code>.
150 *
151 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
152 */
153 int32_t GetConfig([in] PP_Resource image_capture,
154 [out] PP_Resource config,
155 [in] PP_CompletionCallback callback);
156
157 /**
158 * Gets the camera capabilities.
159 *
160 * The camera capabilities do not change for a given camera source.
161 *
162 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
163 * image capture resource.
164 * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for
165 * storing the image capture capabilities on success. Otherwise, the value
166 * will not be changed.
167 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon
168 * completion of <code>GetCapabilities()</code>.
169 *
170 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
171 */
172 int32_t GetCameraCapabilities([in] PP_Resource image_capture,
173 [out] PP_Resource capabilities,
174 [in] PP_CompletionCallback callback);
175
176 /**
177 * Captures a still JPEG image from the camera.
178 *
179 * Triggers an asynchronous image capture. The camera will initiate a series
180 * of callbacks to the application as the image capture progresses. The
181 * callbacks will be invoked in the order of shutter callback, preview
182 * callback, and JPEG callback. The shutter callback occurs after the image is
183 * captured. This can be used to trigger a sound to let the user know that
184 * image has been captured. The preview callback occurs when a scaled, fully
185 * processed preview image is available. The JPEG callback occurs when the
186 * compressed image is available.
187 *
188 * The size of the preview image in preview callback is determined by
189 * <code>PPB_ImageCaptureConfig_Private.SetPreviewSize</code>. The format is
190 * decided by the camera and can be got from <code>PPB_VideoFrame.GetFormat
191 * </code>. The size of the JPEG image is determined by <code>
192 * PPB_ImageCaptureConfig_Private.SetJpegSize</code>.
193 *
194 * The camera may need to stop and re-start streaming during image capture. If
195 * some MediaStreamVideoTrack are associated with the camera source, they will
196 * receive mute and unmute events. The mute event will be received before all
197 * the callbacks. The unmute event will be received after all the callbacks.
198 * The preview image will not be sent to the video tracks associated with the
199 * camera.
200 *
201 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an
202 * image capture resource.
203 * @param[in] shutter_callback A <code>
204 * PPB_ImageCapture_Private_ShutterCallback</code> callback to indicate the
205 * image has been taken.
206 * @param[in] preview_callback A <code>
207 * PPB_ImageCapture_Private_PreviewCallback</code> callback to return a
208 * preview of the captured image.
209 * @param[in] jpeg_callback A <code>
210 * PPB_ImageCapture_Private_JpegCallback</code> callback to return captured
211 * JPEG image.
212 * @param[out] sequence_id The sequence ID is a unique monotonically
213 * increasing value starting from 0, incremented every time a new request like
214 * image capture is submitted.
215 *
216 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
217 * PP_OK means the callbacks will be triggered. Other values mean the
218 * callbacks will not be triggered.
219 */
220 int32_t CaptureStillImage(
221 [in] PP_Resource image_capture,
222 [in] PPB_ImageCapture_Private_ShutterCallback shutter_callback,
223 [in] PPB_ImageCapture_Private_PreviewCallback preview_callback,
224 [in] PPB_ImageCapture_Private_JpegCallback jpeg_callback,
dmichael (off chromium) 2014/08/08 21:13:05 You might want to consider modeling this after PPB
wuchengli 2014/08/12 07:27:02 Do you mean something like my patchset #3? https:/
225 [out] int64_t sequence_id);
226 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698