Chromium Code Reviews| 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 /** | 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 M42 = 0.1 | 14 M42 = 0.1 |
| 15 }; | 15 }; |
| 16 | 16 |
| 17 /** | 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. | 18 * To capture a still image with this class, use the following steps. |
|
dmichael (off chromium)
2015/02/03 19:38:23
We can't capture an image with this API, so that p
Justin Chuang
2015/02/04 09:46:49
Done.
| |
| 89 * 1. Get a PPB_ImageCapture_Private object by Create(). | 19 * 1. Get a PPB_ImageCapture_Private object by Create(). |
| 90 * 2. Call GetCameraCapabilities to get the supported preview sizes. | 20 * 2. Call GetCameraCapabilities to get the supported preview sizes. |
| 91 * 3. For optimal performance, set one of the supported preview size as the | 21 * 3. For optimal performance, set one of the supported preview size as the |
| 92 * constraints of getUserMedia. Use the created MediaStreamVideoTrack for | 22 * constraints of getUserMedia. Use the created MediaStreamVideoTrack for |
| 93 * camera previews. | 23 * 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 */ | 24 */ |
| 99 interface PPB_ImageCapture_Private { | 25 interface PPB_ImageCapture_Private { |
|
dmichael (off chromium)
2015/02/03 19:38:22
Should it be renamed to something like:
PPB_Camera
Justin Chuang
2015/02/04 09:46:49
Yeah... the current PPAPI name looks odd after rem
dmichael (off chromium)
2015/02/04 17:35:39
SGTM, let's do option 1.
| |
| 100 /** | 26 /** |
| 101 * Creates a PPB_ImageCapture_Private resource. | 27 * Creates a PPB_ImageCapture_Private resource. |
| 102 * | 28 * |
| 103 * @param[in] instance A <code>PP_Instance</code> identifying one instance | 29 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
| 104 * of a module. | 30 * of a module. |
| 105 * | 31 * |
| 106 * @return A <code>PP_Resource</code> corresponding to a | 32 * @return A <code>PP_Resource</code> corresponding to a |
| 107 * PPB_ImageCapture_Private resource if successful, 0 if failed. | 33 * PPB_ImageCapture_Private resource if successful, 0 if failed. |
| 108 */ | 34 */ |
| 109 PP_Resource Create([in] PP_Instance instance); | 35 PP_Resource Create([in] PP_Instance instance); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this | 71 * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this |
| 146 * function will be automatically called. Calling this more than once has no | 72 * function will be automatically called. Calling this more than once has no |
| 147 * effect. | 73 * effect. |
| 148 * | 74 * |
| 149 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an | 75 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an |
| 150 * image capture resource. | 76 * image capture resource. |
| 151 */ | 77 */ |
| 152 void Close([in] PP_Resource image_capture); | 78 void Close([in] PP_Resource image_capture); |
| 153 | 79 |
| 154 /** | 80 /** |
| 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. | 81 * Gets the camera capabilities. |
| 192 * | 82 * |
| 193 * The camera capabilities do not change for a given camera source. | 83 * The camera capabilities do not change for a given camera source. |
| 194 * | 84 * |
| 195 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an | 85 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an |
| 196 * image capture resource. | 86 * image capture resource. |
| 197 * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for | 87 * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for |
| 198 * storing the image capture capabilities on success. Otherwise, the value | 88 * storing the image capture capabilities on success. Otherwise, the value |
| 199 * will not be changed. | 89 * will not be changed. |
| 200 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon | 90 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon |
| 201 * completion of <code>GetCameraCapabilities()</code>. | 91 * completion of <code>GetCameraCapabilities()</code>. |
| 202 * | 92 * |
| 203 * @return An int32_t containing a result code from <code>pp_errors.h</code>. | 93 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
| 204 */ | 94 */ |
| 205 int32_t GetCameraCapabilities([in] PP_Resource image_capture, | 95 int32_t GetCameraCapabilities([in] PP_Resource image_capture, |
| 206 [out] PP_Resource capabilities, | 96 [out] PP_Resource capabilities, |
| 207 [in] PP_CompletionCallback callback); | 97 [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 thread that calls this function. | |
| 223 * | |
| 224 * The size of the preview image in preview callback is determined by | |
| 225 * <code>PPB_ImageCaptureConfig_Private.SetPreviewSize</code>. The format is | |
| 226 * decided by the camera and can be got from <code>PPB_VideoFrame.GetFormat | |
| 227 * </code>. The size of the JPEG image is determined by <code> | |
| 228 * PPB_ImageCaptureConfig_Private.SetJpegSize</code>. | |
| 229 * | |
| 230 * The camera may need to stop and re-start streaming during image capture. If | |
| 231 * some MediaStreamVideoTrack are associated with the camera source, they will | |
| 232 * receive mute and unmute events. The mute event will be received before all | |
| 233 * the callbacks. The unmute event will be received after all the callbacks. | |
| 234 * The preview image will not be sent to the video tracks associated with the | |
| 235 * camera. | |
| 236 * | |
| 237 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an | |
| 238 * image capture resource. | |
| 239 * @param[in] shutter_callback A <code> | |
| 240 * PPB_ImageCapture_Private_ShutterCallback</code> callback to indicate the | |
| 241 * image has been taken. | |
| 242 * @param[in] preview_callback A <code> | |
| 243 * PPB_ImageCapture_Private_PreviewCallback</code> callback to return a | |
| 244 * preview of the captured image. | |
| 245 * @param[in] jpeg_callback A <code> | |
| 246 * PPB_ImageCapture_Private_JpegCallback</code> callback to return captured | |
| 247 * JPEG image. | |
| 248 * @param[out] sequence_id The sequence ID is a unique monotonically | |
| 249 * increasing value starting from 0, incremented every time a new request like | |
| 250 * image capture is submitted. | |
| 251 * | |
| 252 * @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 253 * PP_OK means the callbacks will be triggered. Other values mean the | |
| 254 * callbacks will not be triggered. | |
| 255 */ | |
| 256 int32_t CaptureStillImage( | |
| 257 [in] PP_Resource image_capture, | |
| 258 [in] PPB_ImageCapture_Private_ShutterCallback shutter_callback, | |
| 259 [in] PPB_ImageCapture_Private_PreviewCallback preview_callback, | |
| 260 [in] PPB_ImageCapture_Private_JpegCallback jpeg_callback, | |
| 261 [out] int64_t sequence_id); | |
| 262 }; | 98 }; |
| OLD | NEW |