• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file Types.h
18 *
19 * @brief Declares data types
20 * used by the Hardware Driver Interfaces (HDIs) of this module.
21 *
22 * @since 3.2
23 * @version 1.0
24 */
25
26package ohos.hdi.camera.v1_0;
27sequenceable ohos.hdi.camera.v1_0.BufferProducerSequenceable;
28/**
29 * @brief Enumerates return values of the HDIs.
30 */
31enum CamRetCode {
32    /**
33     * Successful call.
34     */
35    NO_ERROR = 0,
36
37    /**
38     * The camera device is busy.
39     */
40    CAMERA_BUSY = -1,
41
42    /**
43     * Insufficient resources.
44     */
45    INSUFFICIENT_RESOURCES = -2,
46
47    /**
48     * Invalid parameters.
49     */
50    INVALID_ARGUMENT = -3,
51
52    /**
53     * Unsupported function.
54     */
55    METHOD_NOT_SUPPORTED = -4,
56
57    /**
58     * The camera device is closed.
59     */
60    CAMERA_CLOSED = -5,
61
62    /**
63     * A critical error occurs at the driver layer.
64     */
65    DEVICE_ERROR = -6,
66
67    /**
68     * No permission to access the camera device.
69     */
70    NO_PERMISSION = -7
71};
72
73/**
74 * @brief Enumerates metadata reporting modes.
75 */
76enum ResultCallbackMode {
77    /**
78     * Frame-by-frame reporting
79     */
80    PER_FRAME = 0,
81
82    /**
83     * Reporting upon device status change
84     */
85    ON_CHANGED = 1,
86};
87
88/**
89 * @brief Enumerates stream operation modes.
90 */
91enum OperationMode {
92    /**
93     * Normal
94     */
95    NORMAL = 0,
96};
97
98/**
99 * @brief Enumerates stream types.
100 */
101enum StreamIntent {
102    /**
103     * Preview streams, indicating that stream data is used for preview
104     */
105    PREVIEW = 0,
106
107    /**
108     * Video streams, indicating that stream data is used to encode and generate videos
109     */
110    VIDEO = 1,
111
112    /**
113     * Photographing streams, indicating that stream data is used to encode and generate images
114     */
115    STILL_CAPTURE = 2,
116
117    /**
118     * Stream data that is used to store thumbnails
119     */
120    POST_VIEW = 3,
121
122    /**
123     * Stream data that is used for image analysis
124     */
125    ANALYZE = 4,
126
127    /**
128     * Custom type
129     */
130    CUSTOM = 5,
131};
132
133/**
134 * @brief Enumerates encoding types of stream data.
135 */
136enum EncodeType {
137    /**
138     * Unspecified
139     */
140    ENCODE_TYPE_NULL = 0,
141
142    /**
143     * H.264
144     */
145    ENCODE_TYPE_H264 = 1,
146
147    /**
148     * H.265
149     */
150    ENCODE_TYPE_H265 = 2,
151
152    /**
153     * JPEG
154     */
155    ENCODE_TYPE_JPEG = 3,
156};
157
158/**
159 * @brief Enumerates the support types of the stream. For details about the application scenario,
160 * see {@link IsStreamsSupported}.
161 */
162enum StreamSupportType {
163    /**
164     * The stream can be dynamically created, and the corresponding stream parameters take effect directly.
165     */
166    DYNAMIC_SUPPORTED = 0,
167
168    /**
169     * The stream cannot be dynamically created,
170     * and the corresponding parameters take effect only after the existing stream is stopped and reconfigured.
171     */
172    RE_CONFIGURED_REQUIRED = 1,
173
174    /**
175     * The stream cannot be dynamically created.
176     */
177    NOT_SUPPORTED = 2,
178};
179
180/**
181 * @brief Enumerates camera device statuses.
182 */
183enum CameraStatus {
184    /**
185     * The camera device is not in position or is unavailable.
186     */
187    UN_AVAILABLE = 0,
188
189    /**
190     * The camera device is available.
191     */
192    AVAILABLE = 1,
193};
194
195/**
196 * @brief Enumerates flash statuses.
197 */
198enum FlashlightStatus {
199    /**
200     * The flash is off.
201     */
202    FLASHLIGHT_OFF = 0,
203
204    /**
205     * The flash is on.
206     */
207    FLASHLIGHT_ON = 1,
208
209    /**
210     * The flash is unavailable.
211     */
212    FLASHLIGHT_UNAVAILABLE = 2,
213};
214
215/**
216 * @brief Camera event.
217 */
218enum CameraEvent {
219    /**
220     * Camera device add event.
221     */
222    CAMERA_EVENT_DEVICE_ADD = 0,
223
224    /**
225     * Camera device remove event.
226     */
227    CAMERA_EVENT_DEVICE_RMV = 1,
228};
229
230/**
231 * @brief Enumerates camera device error types, which are used by {@link OnError}.
232 */
233enum ErrorType {
234    /**
235     * A critical error occurs. The camera device needs to be closed.
236     */
237    FATAL_ERROR = 0,
238
239    /**
240     * A request timeout occurs. The camera device needs to be closed.
241     */
242    REQUEST_TIMEOUT = 1,
243
244    /**
245     * An error occurred int the driver.
246     */
247    DRIVER_ERROR = 2,
248
249    /**
250     * The device is preempted.
251     */
252    DEVICE_PREEMPT = 3,
253
254    /**
255     * Device disconnected.
256     */
257    DEVICE_DISCONNECT = 4,
258
259    /**
260     * The distributed camera error type starts,
261     * and all subsequent error types are distributed camera-specific.
262     */
263    DCAMERA_ERROR_BEGIN = 1024,
264
265    /**
266     * The distributed camera device is busy.
267     */
268    DCAMERA_ERROR_DEVICE_IN_USE,
269
270    /**
271     * No permission to access the distributed camera device.
272     */
273    DCAMERA_ERROR_NO_PERMISSION,
274};
275
276/**
277 * @brief Enumerates stream error types, which are used by {@link CaptureErrorInfo}.
278 */
279enum StreamError {
280    /**
281     * Unknown error
282     */
283    UNKNOWN_ERROR = 0,
284
285    /**
286     * Packet loss
287     */
288    BUFFER_LOST = 1,
289};
290
291/**
292 * @brief Defines the stream information, which is used to pass configuration parameters during stream creation.
293 */
294struct StreamInfo {
295    /**
296     * Stream ID, which uniquely identifies a stream on a camera device.
297     */
298    int streamId_;
299
300    /**
301     * Image width.
302     */
303    int width_;
304
305    /**
306     * Image height.
307     */
308    int height_;
309
310    /**
311     * Image format.
312     */
313    int format_;
314
315    /**
316     * Image color space.
317     */
318    int dataspace_;
319
320    /**
321     * Stream type.
322     */
323    enum StreamIntent intent_;
324
325    /**
326     * Tunnel mode. The value <b>true</b> means that the tunnel mode is enabled, and <b>false</b> means the opposite.
327     *
328     * After the tunnel mode is enabled,
329     * the hardware abstraction layer (HAL) does not directly interact with the upper layer.
330     * Instead, it uses the producer handle provided by the graphics layer to transfer frame data.
331     * You need to disable the tunnel mode for IoT devices that do not support
332     * or require image data caching and forwarding of preview streams.
333     */
334    boolean tunneledMode_;
335
336    /**
337     * Producer handle provided by the graphics layer.
338     */
339
340    BufferProducerSequenceable bufferQueue_;
341
342    /**
343     * Minimum frame interval.
344     */
345    int minFrameDuration_;
346
347    /**
348     * Encoding type.
349     */
350    enum EncodeType encodeType_;
351};
352
353/**
354 * @brief Defines the stream attributes.
355 */
356struct StreamAttribute {
357    /**
358     * Stream ID, which uniquely identifies a stream on a camera device.
359     */
360    int streamId_;
361
362    /**
363     * Image width.
364     */
365    int width_;
366
367    /**
368     * Image height.
369     */
370    int height_;
371
372    /**
373     * New image format.
374     */
375    int overrideFormat_;
376
377    /**
378     * New image color space.
379     */
380    int overrideDataspace_;
381
382    /**
383     * New procedure usage.
384     */
385    int producerUsage_;
386
387    /**
388     * New number of produce buffers.
389     */
390    int producerBufferCount_;
391
392    /**
393     * Maximum number of frames that can be captured in a continuous capture.
394     */
395    int maxBatchCaptureCount_;
396
397    /**
398     * Maximum number of concurrent capture requests. The default value is <b>1</b>.
399    */
400    int maxCaptureCount_;
401};
402
403/**
404 * @brief Defines the information about a capture request.
405 */
406struct CaptureInfo {
407    /**
408     * IDs of captured streams.
409    */
410    int[] streamIds_;
411
412    /**
413     * Captured configuration information.
414     */
415    unsigned char[] captureSetting_;
416
417    /**
418     * Whether to enable callback for each capture. If enabled, {@link OnFrameShutter} is called upon each capture.
419    */
420    boolean enableShutterCallback_;
421};
422
423/**
424 * @brief Defines the information about the end of packet capture, which is used by {@link OnCaptureEnded}.
425 */
426struct CaptureEndedInfo {
427    /**
428     * ID of a captured stream.
429     */
430    int streamId_;
431
432    /**
433     * Number of frames that have been captured when the capture ends.
434     */
435    int frameCount_;
436};
437
438/**
439 * @brief Defines the stream error information, which is used by {@link OnCaptureError}.
440 */
441struct CaptureErrorInfo {
442    /**
443     * Stream ID
444     */
445    int streamId_;
446
447    /**
448     * Error type
449     */
450    enum StreamError error_;
451};
452