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

Side by Side Diff: media/capture/video/chromeos/mojo/arc_camera3.mojom

Issue 2837273004: media: add video capture device for ARC++ camera HAL v3 (Closed)
Patch Set: address wuchengli@'s comments Created 3 years, 7 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
OLDNEW
(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 CAMEAR3_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 uint32 num_streams;
89 array<Camera3Stream> streams;
90 Camera3StreamConfigurationMode operation_mode;
91 int32 error; // Used to piggyback error code returned by driver.
92 };
93
94 struct Camera3StreamBuffer {
95 uint64 stream_id;
96 uint64 buffer_id;
97 Camera3BufferStatus status;
98 handle? acquire_fence;
99 handle? release_fence;
100 };
101
102 struct Camera3CaptureRequest {
103 uint32 frame_number;
104 CameraMetadata settings;
105 Camera3StreamBuffer? input_buffer;
106 array<Camera3StreamBuffer> output_buffers;
107 };
108
109 // Camera3DeviceOps is mostly a translation of the camera3_device_ops_t API from
110 // Android camera HAL v3, with the additional RegisterBuffer() function to pass
111 // buffer handles across processes. This is the interface to interact with a
112 // camera device in the camera HAL.
113 //
114 // The work flow of the Camera3DeviceOps is:
115 //
116 // 1. Call Initialize() to register the Camera3CallbackOps interface with the
117 // camera HAL.
118 //
119 // 2. Call ConfigureStreams() to negotiate the set of usable video streams
120 // with the camera HAL.
121 //
122 // 3. After the video streams are successfully configured, call
123 // ConstructDefaultRequestSettings() to get the capture settings for each
124 // stream. The capture settings of a stream will be associated with the
125 // capture requests of the stream.
126 //
127 // 4. Start the capture loop. The capture loop is composed of a series of
128 // capture requests and results.
129 //
130 // For each capture request:
131 // a. Call RegisterBuffer() for each buffer associated with the request
132 // to register the buffers which will later be filled by the camera
133 // HAL with capture result. For example, the client may register one
134 // small buffer for the low-resolution preview stream and one large
135 // buffer for the high-resolution still capture stream.
136 // b. Call ProcessCaptureRequest() to request capturing one frame. A
137 // request may contain multiple streams and the camera HAL would fill
138 // the buffers of each streams per requirements specified in
139 // ConfigureStreams() and RegisterBuffer(). For example, the camera
140 // HAL may fill a frame to a still capture buffer with the native
141 // capture resolution, and down-scale the same frame to a lower
142 // resolution for the preview buffer.
143 // The client may continue with RegisterBuffer() -> ProcessCaptureRequest()
144 // up to the pipe-line depth configured in ConfigureStreams().
145 //
146 // When the camera HAL is done with a capture request, the capture result
147 // is sent back to the client through the callbacks in Camera3CallbackOps.
148 //
149 // For each capture result:
150 // a. The camera HAL notifies the client through Notify() of the shutter
151 // time of the captured frame. If an error happens while capturing a
152 // frame or filling a buffer, the camera HAL notifies the client
153 // through Notify() of the error.
154 // b. The camera HAL returns the capture result with various result
155 // metadata and the filled buffers to the client in
156 // ProcessCaptureResult(). The result metadata may be sent in
157 // partially in multiple stages, and the client must wait until all
158 // the partial metadata are received before handing the capture result
159 // to upper layer.
160 //
161 // 5. Dump() can be used to dump various information of the camera HAL for
162 // debug purpose.
163 //
164 // 6. Flush() tells the camera HAL to finish processing or discard the
165 // current on-going capture requests and return to the state where
166 // ConfigureStreams() can be called again to set up new streams.
167 //
168 // 7. Close() closes the camera device.
169
170 interface Camera3DeviceOps {
171 // Initialize() is called once after the camera device is opened to register
172 // the Camera3CallbackOps handle.
173 Initialize@0(Camera3CallbackOps callback_ops) => (int32 result);
174
175 // ConfigureStreams() is called every time the client needs to set up new set
176 // of streams.
177 ConfigureStreams@1(Camera3StreamConfiguration config) =>
178 (Camera3StreamConfiguration updated_config);
179
180 // ConstructDefaultRequestSettings() is called to get the request settings for
181 // common use cases, e.g. preview, still capture, video recording...etc.
182 ConstructDefaultRequestSettings@2(Camera3RequestTemplate type) =>
183 (CameraMetadata? settings);
184
185 // ProcessCaptureRequest() is the core method and is called for every captured
186 // frame to provide the camera HAL with the capture settings and the
187 // associated buffers to fill.
188 ProcessCaptureRequest@3(Camera3CaptureRequest request) => (int32 result);
189
190 // Dump() is called to gather various states and information about the camera
191 // HAL; it is mainly for debug purpose.
192 Dump@4(handle fd);
193
194 // Flush() is called to clear out any in-progress captures and return the
195 // camera HAL to idle state.
196 Flush@5() => (int32 result);
197
198 // The type of buffers the ARC++ camera service currently supports.
199 // GRALLOC is for the platform-specific gralloc buffer allocated by Android.
200 // SHM is for the shared memory buffer allocated by Chrome.
201 enum BufferType {
202 GRALLOC = 0, // gralloc buffer. Needs to be imported through GBM.
203 SHM = 1, // shared memory buffer. Can be mmapped directly.
204 // Add DMABUF when needed.
205 };
206
207 // RegisterBuffer() is called to register a buffer with the camera HAL. The
208 // registered buffer can then be specified in ProcessCaptureRequest() for the
209 // camera HAL to fill captured frame. RegisterBuffer() is not part of the
210 // Android camera HAL v3 API; it is added for ARC++ camera service to pass
211 // buffer handles across different processes.
212 RegisterBuffer@6(uint64 buffer_id, BufferType type, array<handle> fds,
213 uint32 drm_format, HalPixelFormat hal_pixel_format,
214 uint32 width, uint32 height, array<uint32> strides,
215 array<uint32> offsets) =>
216 (int32 result);
217
218 // Close() is called to close the camera device.
219 Close@7() => (int32 result);
220 };
221
222 struct Camera3CaptureResult {
223 uint32 frame_number;
224 CameraMetadata result;
225 array<Camera3StreamBuffer>? output_buffers;
226 Camera3StreamBuffer? input_buffer;
227 uint32 partial_result;
228 };
229
230 enum Camera3ErrorMsgCode {
231 CAMERA3_MSG_ERROR_DEVICE = 1,
232 CAMERA3_MSG_ERROR_REQUEST = 2,
233 CAMERA3_MSG_ERROR_RESULT = 3,
234 CAMERA3_MSG_ERROR_BUFFER = 4,
235 CAMERA3_MSG_NUM_ERRORS,
236 };
237
238 struct Camera3ErrorMsg {
239 uint32 frame_number;
240 uint64 error_stream_id;
241 Camera3ErrorMsgCode error_code;
242 };
243
244 struct Camera3ShutterMsg {
245 uint32 frame_number;
246 uint64 timestamp;
247 };
248
249 union Camera3NotifyMsgMessage {
250 Camera3ErrorMsg error;
251 Camera3ShutterMsg shutter;
252 array<uint8> generic;
253 };
254
255 struct Camera3NotifyMsg {
256 Camera3MsgType type;
257 Camera3NotifyMsgMessage message;
258 };
259
260 // Camera3CallbackOps is a translation of the camera3_callback_ops_t API
261 // in Android camera HAL v3. For the work flow of the functions in
262 // Camera3CallbackOps, see the comments about Camear3DeviceOps above.
263 interface Camera3CallbackOps {
264 // ProcessCaptureResult() is called by the camera HAL to send result metadata
265 // and filled buffer to the client.
266 ProcessCaptureResult@0(Camera3CaptureResult result);
267
268 // Notify() is called by the camera HAL to notify the client of the start of
269 // each capture, and of errors encountered.
270 Notify@1(Camera3NotifyMsg msg);
271 };
272
273 struct CameraInfo {
274 CameraFacing facing;
275 int32 orientation;
276 uint32 device_version;
277 CameraMetadata static_camera_characteristics;
278 // resource cost is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower.
279 // conflicting_devices is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower.
280 // conflicting_devices_length is not valid in CAMERA_MODULE_API_VERSION_2_3 or
281 // lower.
282 };
283
284 // CameraModule is a translation of the camera_module_t API
285 // (https://goo.gl/8Hf8S8). CameraModule is the interface to interact with a
286 // camera HAL.
287 interface CameraModule {
288 // Opens the camera device specified by |camera_id|. On success, the camera
289 // device is accessible through the |device_ops| returned.
290 OpenDevice@0(int32 camera_id) => (int32 result, Camera3DeviceOps? device_ops);
291
292 // Gets the number of cameras currently present on the system.
293 GetNumberOfCameras@1() => (int32 result);
294
295 // Gets various info about a camera specified by |camera_id|.
296 GetCameraInfo@2(int32 camera_id) => (int32 result, CameraInfo? camera_info);
297
298 // Registers the CameraModuleCallbacks interface with the camera HAL.
299 SetCallbacks@3(CameraModuleCallbacks callbacks) => (int32 result);
300 };
301
302 enum CameraDeviceStatus {
303 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0,
304 CAMERA_DEVICE_STATUS_PRESENT = 1,
305 CAMERA_DEVICE_STATUS_ENUMERATING = 2,
306 };
307
308 // CameraModuleCallbacks is a translation of the camera_module_callbacks_t API
309 // (https://goo.gl/8Hf8S8). CameraModuleCallbacks is used by the camera HAL to
310 // inform the client of the various status change.
311 interface CameraModuleCallbacks {
312 // CameraDeviceStatusChange() is called by the camera HAL to notify the client
313 // of the new status of the camera device specified by |camera_id|.
314 CameraDeviceStatusChange@0(int32 camera_id, CameraDeviceStatus new_status);
315 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698