OLD | NEW |
(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 /* From private/ppb_image_capture_private.idl, |
| 7 * modified Thu Aug 7 23:29:35 2014. |
| 8 */ |
| 9 |
| 10 #ifndef PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ |
| 11 #define PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ |
| 12 |
| 13 #include "ppapi/c/pp_bool.h" |
| 14 #include "ppapi/c/pp_completion_callback.h" |
| 15 #include "ppapi/c/pp_instance.h" |
| 16 #include "ppapi/c/pp_macros.h" |
| 17 #include "ppapi/c/pp_resource.h" |
| 18 #include "ppapi/c/pp_stdint.h" |
| 19 #include "ppapi/c/pp_var.h" |
| 20 |
| 21 #define PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1 "PPB_ImageCapture_Private;0.1" |
| 22 #define PPB_IMAGECAPTURE_PRIVATE_INTERFACE \ |
| 23 PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1 |
| 24 |
| 25 /** |
| 26 * @file |
| 27 * Defines the <code>PPB_ImageCapture_Private</code> interface. Used for |
| 28 * acquiring a single still image from a camera source. |
| 29 */ |
| 30 |
| 31 |
| 32 /** |
| 33 * @addtogroup Typedefs |
| 34 * @{ |
| 35 */ |
| 36 /** |
| 37 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage |
| 38 * </code> to indicate the image has been captured from the sensor. This is a |
| 39 * good opportunity to play a shutter sound or give other feedback of camera |
| 40 * operation. This will occur after the image was captured, but before the |
| 41 * actual data is available. |
| 42 * |
| 43 * Parameters: |
| 44 * |image_capture| the PPB_ImageCapture_Private resource. |
| 45 * |sequence_id| The sequence ID of the image capture, same as the one from |
| 46 * CaptureStillImage. |
| 47 */ |
| 48 typedef void (*PPB_ImageCapture_Private_ShutterCallback)( |
| 49 PP_Resource image_capture, |
| 50 int64_t sequence_id); |
| 51 |
| 52 /** |
| 53 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage |
| 54 * </code> to deliver a preview image. The client can use this to show the |
| 55 * captured image. See <code>PPB_ImageCapture_Private.CaptureStillImage |
| 56 * </code> for more information. |
| 57 * |
| 58 * Parameters: |
| 59 * |image_capture| the PPB_ImageCapture_Private resource. |
| 60 * |sequence_id| The sequence ID of the image capture, same as the one from |
| 61 * CaptureStillImage. |
| 62 * |preview| A <code>PP_Resource</code> corresponding to a VideoFrame |
| 63 * resource used to store the preview image. |
| 64 */ |
| 65 typedef void (*PPB_ImageCapture_Private_PreviewCallback)( |
| 66 PP_Resource image_capture, |
| 67 int64_t sequence_id, |
| 68 PP_Resource preview); |
| 69 |
| 70 /** |
| 71 * Callback function for <code>PPB_ImageCapture_Private.CaptureStillImage |
| 72 * </code> to deliver a still JPEG image. See <code> |
| 73 * PPB_ImageCapture_Private.CaptureStillImage</code> for more information. |
| 74 * |
| 75 * Parameters: |
| 76 * |image_capture| the PPB_ImageCapture_Private resource. |
| 77 * |sequence_id| The sequence ID of the image capture, same as the one from |
| 78 * CaptureStillImage. |
| 79 * |jpeg| A <code>PP_Resource</code> corresponding to a VideoFrame |
| 80 * resource used to store the JPEG image. |
| 81 */ |
| 82 typedef void (*PPB_ImageCapture_Private_JpegCallback)(PP_Resource image_capture, |
| 83 int64_t sequence_id, |
| 84 PP_Resource jpeg); |
| 85 /** |
| 86 * @} |
| 87 */ |
| 88 |
| 89 /** |
| 90 * @addtogroup Interfaces |
| 91 * @{ |
| 92 */ |
| 93 /** |
| 94 * To capture a still image with this class, use the following steps. |
| 95 * 1. Get a PPB_ImageCapture_Private object by Create(). |
| 96 * 2. Call GetCameraCapabilities to get the supported preview sizes. |
| 97 * 3. For optimal performance, set one of the supported preview size as the |
| 98 * constraints of getUserMedia. Use the created MediaStreamVideoTrack for |
| 99 * camera previews. |
| 100 * 4. Set the same preview size and other settings by SetConfig. |
| 101 * 5. Call CaptureStillImage to capture a still image. Play the shutter sound in |
| 102 * the shutter callback. The image from the preview callback can be used for |
| 103 * display. JPEG image will be returned to the JPEG callback. |
| 104 */ |
| 105 struct PPB_ImageCapture_Private_0_1 { |
| 106 /** |
| 107 * Creates a PPB_ImageCapture_Private resource. |
| 108 * |
| 109 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
| 110 * of a module. |
| 111 * @param[in] camera_source_id A <code>PP_Var</code> identifying a camera |
| 112 * source. The type is string. The ID can be obtained from |
| 113 * MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a |
| 114 * MediaStreamVideoTrack is associated with the same source and the track |
| 115 * is closed, this PPB_ImageCapture_Private object can still do image capture. |
| 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)(PP_Instance instance, struct PP_Var camera_source_id); |
| 121 /** |
| 122 * Determines if a resource is an image capture resource. |
| 123 * |
| 124 * @param[in] resource The <code>PP_Resource</code> to test. |
| 125 * |
| 126 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given |
| 127 * resource is an image capture resource or <code>PP_FALSE</code> |
| 128 * otherwise. |
| 129 */ |
| 130 PP_Bool (*IsImageCapture)(PP_Resource resource); |
| 131 /** |
| 132 * Disconnects from the camera and cancels all pending capture requests. |
| 133 * After this returns, no callbacks will be called. If <code> |
| 134 * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this |
| 135 * function will be automatically called. Calling this more than once has no |
| 136 * effect. |
| 137 * |
| 138 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an |
| 139 * image capture resource. |
| 140 */ |
| 141 void (*Close)(PP_Resource resource); |
| 142 /** |
| 143 * Sets the configuration of the image capture. |
| 144 * If <code>SetConfig()</code> is not called, default settings will be used. |
| 145 * |
| 146 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an |
| 147 * image capture resource. |
| 148 * @param[in] config A <code>PP_ImageCaptureConfig_Private</code> object. |
| 149 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon |
| 150 * completion of <code>SetConfig()</code>. |
| 151 * |
| 152 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
| 153 * Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of |
| 154 * <code>SetConfig()</code> or <code>CaptureStillImage()</code>. |
| 155 * If an error is returned, the configuration will not be changed. |
| 156 */ |
| 157 int32_t (*SetConfig)(PP_Resource image_capture, |
| 158 PP_Resource config, |
| 159 struct PP_CompletionCallback callback); |
| 160 /** |
| 161 * Gets the configuration of the image capture. |
| 162 * |
| 163 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an |
| 164 * image capture resource. |
| 165 * @param[out] config A <code>PP_ImageCaptureConfig_Private</code> for storing |
| 166 * the current image capture config on success. Otherwise, the values will not |
| 167 * be changed. |
| 168 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon |
| 169 * completion of <code>GetConfig()</code>. |
| 170 * |
| 171 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
| 172 */ |
| 173 int32_t (*GetConfig)(PP_Resource image_capture, |
| 174 PP_Resource* config, |
| 175 struct PP_CompletionCallback callback); |
| 176 /** |
| 177 * Gets the camera capabilities. |
| 178 * |
| 179 * The camera capabilities do not change for a given camera source. |
| 180 * |
| 181 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an |
| 182 * image capture resource. |
| 183 * @param[out] capabilities A <code>PPB_CameraCapabilities_Private</code> for |
| 184 * storing the image capture capabilities on success. Otherwise, the value |
| 185 * will not be changed. |
| 186 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon |
| 187 * completion of <code>GetCapabilities()</code>. |
| 188 * |
| 189 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
| 190 */ |
| 191 int32_t (*GetCameraCapabilities)(PP_Resource image_capture, |
| 192 PP_Resource* capabilities, |
| 193 struct PP_CompletionCallback callback); |
| 194 /** |
| 195 * Captures a still JPEG image from the camera. |
| 196 * |
| 197 * Triggers an asynchronous image capture. The camera will initiate a series |
| 198 * of callbacks to the application as the image capture progresses. The |
| 199 * callbacks will be invoked in the order of shutter callback, preview |
| 200 * callback, and JPEG callback. The shutter callback occurs after the image is |
| 201 * captured. This can be used to trigger a sound to let the user know that |
| 202 * image has been captured. The preview callback occurs when a scaled, fully |
| 203 * processed preview image is available. The JPEG callback occurs when the |
| 204 * compressed image is available. |
| 205 * |
| 206 * The size of the preview image in preview callback is determined by |
| 207 * <code>PPB_ImageCaptureConfig_Private.SetPreviewSize</code>. The format is |
| 208 * decided by the camera and can be got from <code>PPB_VideoFrame.GetFormat |
| 209 * </code>. The size of the JPEG image is determined by <code> |
| 210 * PPB_ImageCaptureConfig_Private.SetJpegSize</code>. |
| 211 * |
| 212 * The camera may need to stop and re-start streaming during image capture. If |
| 213 * some MediaStreamVideoTrack are associated with the camera source, they will |
| 214 * receive mute and unmute events. The mute event will be received before all |
| 215 * the callbacks. The unmute event will be received after all the callbacks. |
| 216 * The preview image will not be sent to the video tracks associated with the |
| 217 * camera. |
| 218 * |
| 219 * @param[in] image_capture A <code>PP_Resource</code> corresponding to an |
| 220 * image capture resource. |
| 221 * @param[in] shutter_callback A <code> |
| 222 * PPB_ImageCapture_Private_ShutterCallback</code> callback to indicate the |
| 223 * image has been taken. |
| 224 * @param[in] preview_callback A <code> |
| 225 * PPB_ImageCapture_Private_PreviewCallback</code> callback to return a |
| 226 * preview of the captured image. |
| 227 * @param[in] jpeg_callback A <code> |
| 228 * PPB_ImageCapture_Private_JpegCallback</code> callback to return captured |
| 229 * JPEG image. |
| 230 * @param[out] sequence_id The sequence ID is a unique monotonically |
| 231 * increasing value starting from 0, incremented every time a new request like |
| 232 * image capture is submitted. |
| 233 * |
| 234 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
| 235 * PP_OK means the callbacks will be triggered. Other values mean the |
| 236 * callbacks will not be triggered. |
| 237 */ |
| 238 int32_t (*CaptureStillImage)( |
| 239 PP_Resource image_capture, |
| 240 PPB_ImageCapture_Private_ShutterCallback shutter_callback, |
| 241 PPB_ImageCapture_Private_PreviewCallback preview_callback, |
| 242 PPB_ImageCapture_Private_JpegCallback jpeg_callback, |
| 243 int64_t* sequence_id); |
| 244 }; |
| 245 |
| 246 typedef struct PPB_ImageCapture_Private_0_1 PPB_ImageCapture_Private; |
| 247 /** |
| 248 * @} |
| 249 */ |
| 250 |
| 251 #endif /* PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ */ |
| 252 |
OLD | NEW |