Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 module arc.mojom; | |
| 6 | |
| 7 import "arc_camera3_metadata.mojom"; | |
| 8 | |
| 9 [Extensible] | |
| 10 enum HalPixelFormat { | |
| 11 HAL_PIXEL_FORMAT_RGBA_8888 = 0x1, | |
| 12 HAL_PIXEL_FORMAT_RGBX_8888 = 0x2, | |
| 13 HAL_PIXEL_FORMAT_BGRA_8888 = 0x5, | |
| 14 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, | |
| 15 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, | |
| 16 HAL_PIXEL_FORMAT_BLOB = 0x21, | |
| 17 HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, | |
| 18 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, | |
| 19 HAL_PIXEL_FORMAT_YV12 = 0x32315659, | |
| 20 }; | |
| 21 | |
| 22 // The following enums are from Android's camera HAL v3 API header | |
| 23 // (https://goo.gl/jciSjC). | |
| 24 | |
| 25 enum CameraFacing { | |
| 26 CAMERA_FACING_BACK = 0, | |
| 27 CAMERA_FACING_FRONT = 1, | |
| 28 CAMERA_FACING_EXTERNAL = 2, | |
| 29 }; | |
| 30 | |
| 31 enum Camera3StreamType { | |
| 32 CAMERA3_STREAM_OUTPUT = 0, | |
| 33 CAMERA3_STREAM_INPUT = 1, | |
| 34 CAMERA3_STREAM_BIDIRECTIONAL = 2, | |
| 35 CAMERA3_NUM_STREAM_TYPES, | |
| 36 }; | |
| 37 | |
| 38 enum Camera3StreamRotation { | |
| 39 CAMERA3_STREAM_ROTATION_0 = 0, | |
| 40 CAMERA3_STREAM_ROTATION_90 = 1, | |
| 41 CAMERA3_STREAM_ROTATION_180 = 2, | |
| 42 CAMERA3_STREAM_ROTATION_270 = 3, | |
| 43 }; | |
| 44 | |
| 45 [Extensible] | |
| 46 enum Camera3StreamConfigurationMode { | |
| 47 CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0, | |
| 48 CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE =1, | |
| 49 CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000, | |
| 50 }; | |
| 51 | |
| 52 [Extensible] | |
| 53 enum Camera3RequestTemplate { | |
| 54 CAMERA3_TEMPLATE_PREVIEW = 1, | |
| 55 CAMERA3_TEMPLATE_STILL_CAPTURE = 2, | |
| 56 CAMERA3_TEMPLATE_VIDEO_RECORD = 3, | |
| 57 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, | |
| 58 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, | |
| 59 CAMERA3_TEMPLATE_MANUAL = 6, | |
| 60 CAMERA3_TEMPLATE_COUNT, | |
| 61 CAMERA3_VENDOR_TEMPLATE_START = 0x40000000, | |
| 62 }; | |
| 63 | |
| 64 enum Camera3BufferStatus { | |
| 65 CAMERA3_BUFFER_STATUS_OK = 0, | |
| 66 CAMERA3_BUFFER_STATUS_ERROR = 1, | |
| 67 }; | |
| 68 | |
| 69 enum Camera3MsgType { | |
| 70 CAMERA3_MSG_ERROR = 1, | |
| 71 CAMERA3_MSG_SHUTTER = 2, | |
| 72 CAMERA3_NUM_MESSAGES, | |
| 73 }; | |
| 74 | |
| 75 struct Camera3Stream { | |
| 76 uint64 id; | |
| 77 Camera3StreamType stream_type; | |
| 78 uint32 width; | |
| 79 uint32 height; | |
| 80 HalPixelFormat format; | |
| 81 uint32 usage; | |
| 82 uint32 max_buffers; | |
| 83 uint32 data_space; | |
| 84 Camera3StreamRotation rotation; | |
| 85 }; | |
| 86 | |
| 87 struct Camera3StreamConfiguration { | |
| 88 array<Camera3Stream> streams; | |
| 89 Camera3StreamConfigurationMode operation_mode; | |
| 90 }; | |
| 91 | |
| 92 struct Camera3StreamBuffer { | |
| 93 uint64 stream_id; | |
| 94 uint64 buffer_id; | |
| 95 Camera3BufferStatus status; | |
| 96 handle? acquire_fence; | |
| 97 handle? release_fence; | |
| 98 }; | |
| 99 | |
| 100 struct Camera3CaptureRequest { | |
| 101 uint32 frame_number; | |
| 102 CameraMetadata settings; | |
| 103 Camera3StreamBuffer? input_buffer; | |
| 104 array<Camera3StreamBuffer> output_buffers; | |
| 105 }; | |
| 106 | |
| 107 // Camera3DeviceOps is mostly a translation of the camera3_device_ops_t API from | |
| 108 // Android camera HAL v3, with the additional RegisterBuffer() function to pass | |
| 109 // buffer handles across processes. This is the interface to interact with a | |
| 110 // camera device in the camera HAL. | |
| 111 // | |
| 112 // The work flow of the Camera3DeviceOps is: | |
| 113 // | |
| 114 // 1. Call Initialize() to register the Camera3CallbackOps interface with the | |
| 115 // camera HAL. | |
| 116 // | |
| 117 // 2. Call ConfigureStreams() to negotiate the set of usable video streams | |
| 118 // with the camera HAL. | |
| 119 // | |
| 120 // 3. After the video streams are successfully configured, call | |
| 121 // ConstructDefaultRequestSettings() to get the capture settings for each | |
| 122 // stream. The capture settings of a stream will be associated with the | |
| 123 // capture requests of the stream. | |
| 124 // | |
| 125 // 4. Start the capture loop. The capture loop is composed of a series of | |
| 126 // capture requests and results. | |
| 127 // | |
| 128 // For each capture request: | |
| 129 // a. Call RegisterBuffer() for each buffer associated with the request | |
| 130 // to register the buffers which will later be filled by the camera | |
| 131 // HAL with capture result. For example, the client may register one | |
| 132 // small buffer for the low-resolution preview stream and one large | |
| 133 // buffer for the high-resolution still capture stream. | |
| 134 // b. Call ProcessCaptureRequest() to request capturing one frame. A | |
| 135 // request may contain multiple streams and the camera HAL would fill | |
| 136 // the buffers of each streams per requirements specified in | |
| 137 // ConfigureStreams() and RegisterBuffer(). For example, the camera | |
| 138 // HAL may fill a frame to a still capture buffer with the native | |
| 139 // capture resolution, and down-scale the same frame to a lower | |
| 140 // resolution for the preview buffer. | |
| 141 // The client may continue with RegisterBuffer() -> ProcessCaptureRequest() | |
| 142 // up to the pipe-line depth configured in ConfigureStreams(). | |
| 143 // | |
| 144 // When the camera HAL is done with a capture request, the capture result | |
| 145 // is sent back to the client through the callbacks in Camera3CallbackOps. | |
| 146 // | |
| 147 // For each capture result: | |
| 148 // a. The camera HAL notifies the client through Notify() of the shutter | |
| 149 // time of the captured frame. If an error happens while capturing a | |
| 150 // frame or filling a buffer, the camera HAL notifies the client | |
| 151 // through Notify() of the error. | |
| 152 // b. The camera HAL returns the capture result with various result | |
| 153 // metadata and the filled buffers to the client in | |
| 154 // ProcessCaptureResult(). The result metadata may be sent partially | |
| 155 // in multiple stages, and the client must wait until all the partial | |
| 156 // metadata are received before handing the capture result to upper | |
| 157 // layer. | |
| 158 // | |
| 159 // 5. Dump() can be used to dump various information of the camera HAL for | |
| 160 // debug purpose. | |
| 161 // | |
| 162 // 6. Flush() tells the camera HAL to finish processing or discard the | |
| 163 // current on-going capture requests and return to the state where | |
| 164 // ConfigureStreams() can be called again to set up new streams. | |
| 165 // | |
| 166 // 7. Close() closes the camera device. | |
| 167 | |
| 168 interface Camera3DeviceOps { | |
| 169 // Initialize() is called once after the camera device is opened to register | |
| 170 // the Camera3CallbackOps handle. | |
| 171 Initialize@0(Camera3CallbackOps callback_ops) => (int32 result); | |
| 172 | |
| 173 // ConfigureStreams() is called every time the client needs to set up new set | |
| 174 // of streams. | |
| 175 ConfigureStreams@1(Camera3StreamConfiguration config) => | |
| 176 (int32 result, Camera3StreamConfiguration? updated_config); | |
| 177 | |
| 178 // ConstructDefaultRequestSettings() is called to get the request settings for | |
| 179 // common use cases, e.g. preview, still capture, video recording...etc. | |
| 180 ConstructDefaultRequestSettings@2(Camera3RequestTemplate type) => | |
| 181 (CameraMetadata? settings); | |
| 182 | |
| 183 // ProcessCaptureRequest() is the core method and is called for every captured | |
| 184 // frame to provide the camera HAL with the capture settings and the | |
| 185 // associated buffers to fill. | |
| 186 ProcessCaptureRequest@3(Camera3CaptureRequest request) => (int32 result); | |
| 187 | |
| 188 // Dump() is called to gather various states and information about the camera | |
| 189 // HAL; it is mainly for debug purpose. | |
| 190 Dump@4(handle fd); | |
| 191 | |
| 192 // Flush() is called to clear out any in-progress captures and return the | |
| 193 // camera HAL to idle state. | |
| 194 Flush@5() => (int32 result); | |
| 195 | |
| 196 // The type of buffers the ARC++ camera service currently supports. | |
| 197 // GRALLOC is for the platform-specific gralloc buffer allocated by Android. | |
| 198 // SHM is for the shared memory buffer allocated by Chrome. | |
| 199 enum BufferType { | |
| 200 GRALLOC = 0, // gralloc buffer. Needs to be imported through GBM. | |
| 201 SHM = 1, // shared memory buffer. Can be mmapped directly. | |
| 202 // Add DMABUF when needed. | |
| 203 }; | |
| 204 | |
| 205 // RegisterBuffer() is called to register a buffer with the camera HAL. The | |
| 206 // registered buffer can then be specified in ProcessCaptureRequest() for the | |
| 207 // camera HAL to fill captured frame. RegisterBuffer() is not part of the | |
| 208 // Android camera HAL v3 API; it is added for ARC++ camera service to pass | |
| 209 // buffer handles across different processes. | |
| 210 RegisterBuffer@6(uint64 buffer_id, BufferType type, array<handle> fds, | |
| 211 uint32 drm_format, HalPixelFormat hal_pixel_format, | |
| 212 uint32 width, uint32 height, array<uint32> strides, | |
| 213 array<uint32> offsets) => | |
| 214 (int32 result); | |
| 215 | |
| 216 // Close() is called to close the camera device. | |
| 217 Close@7() => (int32 result); | |
| 218 }; | |
| 219 | |
| 220 struct Camera3CaptureResult { | |
| 221 uint32 frame_number; | |
| 222 CameraMetadata result; | |
| 223 array<Camera3StreamBuffer>? output_buffers; | |
| 224 Camera3StreamBuffer? input_buffer; | |
| 225 uint32 partial_result; | |
| 226 }; | |
| 227 | |
| 228 enum Camera3ErrorMsgCode { | |
| 229 CAMERA3_MSG_ERROR_DEVICE = 1, | |
| 230 CAMERA3_MSG_ERROR_REQUEST = 2, | |
| 231 CAMERA3_MSG_ERROR_RESULT = 3, | |
| 232 CAMERA3_MSG_ERROR_BUFFER = 4, | |
| 233 CAMERA3_MSG_NUM_ERRORS, | |
| 234 }; | |
| 235 | |
| 236 struct Camera3ErrorMsg { | |
| 237 uint32 frame_number; | |
| 238 uint64 error_stream_id; | |
| 239 Camera3ErrorMsgCode error_code; | |
| 240 }; | |
| 241 | |
| 242 struct Camera3ShutterMsg { | |
| 243 uint32 frame_number; | |
| 244 uint64 timestamp; | |
| 245 }; | |
| 246 | |
| 247 union Camera3NotifyMsgMessage { | |
| 248 Camera3ErrorMsg error; | |
| 249 Camera3ShutterMsg shutter; | |
| 250 array<uint8> generic; | |
| 251 }; | |
| 252 | |
| 253 struct Camera3NotifyMsg { | |
| 254 Camera3MsgType type; | |
| 255 Camera3NotifyMsgMessage message; | |
| 256 }; | |
| 257 | |
| 258 // Camera3CallbackOps is a translation of the camera3_callback_ops_t API | |
| 259 // in Android camera HAL v3. For the work flow of the functions in | |
| 260 // Camera3CallbackOps, see the comments about Camear3DeviceOps above. | |
|
chfremer
2017/05/26 17:40:58
typo: Camera3DeviceOps
jcliang
2017/05/31 14:58:07
Done.
| |
| 261 interface Camera3CallbackOps { | |
| 262 // ProcessCaptureResult() is called by the camera HAL to send result metadata | |
| 263 // and filled buffer to the client. | |
| 264 ProcessCaptureResult@0(Camera3CaptureResult result); | |
| 265 | |
| 266 // Notify() is called by the camera HAL to notify the client of the start of | |
| 267 // each capture, and of errors encountered. | |
| 268 Notify@1(Camera3NotifyMsg msg); | |
| 269 }; | |
| 270 | |
| 271 struct CameraInfo { | |
| 272 CameraFacing facing; | |
| 273 int32 orientation; | |
| 274 uint32 device_version; | |
| 275 CameraMetadata static_camera_characteristics; | |
| 276 // resource cost is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower. | |
| 277 // conflicting_devices is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower. | |
| 278 // conflicting_devices_length is not valid in CAMERA_MODULE_API_VERSION_2_3 or | |
| 279 // lower. | |
| 280 }; | |
| 281 | |
| 282 // CameraModule is a translation of the camera_module_t API | |
| 283 // (https://goo.gl/8Hf8S8). CameraModule is the interface to interact with a | |
| 284 // camera HAL to query device info and open camera devices. | |
| 285 interface CameraModule { | |
| 286 // Opens the camera device specified by |camera_id|. On success, the camera | |
| 287 // device is accessible through the |device_ops| returned. | |
| 288 OpenDevice@0(int32 camera_id) => (int32 result, Camera3DeviceOps? device_ops); | |
|
chfremer
2017/05/26 17:40:58
When I worked on the video_capture service mojoms,
jcliang
2017/05/31 14:58:07
Done.
| |
| 289 | |
| 290 // Gets the number of cameras currently present on the system. | |
| 291 GetNumberOfCameras@1() => (int32 result); | |
| 292 | |
| 293 // Gets various info about the camera specified by |camera_id|. | |
| 294 GetCameraInfo@2(int32 camera_id) => (int32 result, CameraInfo? camera_info); | |
| 295 | |
| 296 // Registers the CameraModuleCallbacks interface with the camera HAL. | |
| 297 SetCallbacks@3(CameraModuleCallbacks callbacks) => (int32 result); | |
|
chfremer
2017/05/26 17:40:58
Any reason why we wouldn't want to use an enum for
jcliang
2017/05/31 14:58:07
The returned result codes are either 0 or the stan
chfremer
2017/05/31 18:30:41
I assume you are referring to errno.h from the C s
jcliang
2017/06/01 17:11:16
Yes I mean the errno.h from C standard library. I
| |
| 298 }; | |
| 299 | |
| 300 enum CameraDeviceStatus { | |
| 301 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, | |
| 302 CAMERA_DEVICE_STATUS_PRESENT = 1, | |
| 303 CAMERA_DEVICE_STATUS_ENUMERATING = 2, | |
| 304 }; | |
| 305 | |
| 306 // CameraModuleCallbacks is a translation of the camera_module_callbacks_t API | |
| 307 // (https://goo.gl/8Hf8S8). CameraModuleCallbacks is used by the camera HAL to | |
| 308 // inform the client of the various status change of a camera. | |
| 309 interface CameraModuleCallbacks { | |
| 310 // CameraDeviceStatusChange() is called by the camera HAL to notify the client | |
| 311 // of the new status of the camera device specified by |camera_id|. | |
| 312 CameraDeviceStatusChange@0(int32 camera_id, CameraDeviceStatus new_status); | |
| 313 }; | |
| OLD | NEW |