1 /*
2  * Copyright (c) 2023 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  * @addtogroup OH_Camera
18  * @{
19  *
20  * @brief Provide the definition of the C interface for the camera module.
21  *
22  * @syscap SystemCapability.Multimedia.Camera.Core
23  *
24  * @since 11
25  * @version 1.0
26  */
27 
28 /**
29  * @file camera_input.h
30  *
31  * @brief Declare the camera input concepts.
32  *
33  * @library libohcamera.so
34  * @kit CameraKit
35  * @syscap SystemCapability.Multimedia.Camera.Core
36  * @since 11
37  * @version 1.0
38  */
39 
40 #ifndef NATIVE_INCLUDE_CAMERA_CAMERA_INPUT_H
41 #define NATIVE_INCLUDE_CAMERA_CAMERA_INPUT_H
42 
43 #include <stdint.h>
44 #include <stdio.h>
45 #include "camera.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /**
52  * @brief Camera input object.
53  *
54  * A pointer can be created using {@link OH_CameraManager_CreateCameraInput} method.
55  *
56  * @since 11
57  * @version 1.0
58  */
59 typedef struct Camera_Input Camera_Input;
60 
61 /**
62  * @brief Camera input error callback to be called in {@link CameraInput_Callbacks}.
63  *
64  * @param cameraInput the {@link Camera_Input} which deliver the callback.
65  * @param errorCode the {@link Camera_ErrorCode} of the camera input.
66  *
67  * @see CAMERA_CONFLICT_CAMERA
68  * @see CAMERA_DEVICE_DISABLED
69  * @see CAMERA_DEVICE_PREEMPTED
70  * @see CAMERA_SERVICE_FATAL_ERROR
71  * @since 11
72  */
73 typedef void (*OH_CameraInput_OnError)(const Camera_Input* cameraInput, Camera_ErrorCode errorCode);
74 
75 /**
76  * @brief A listener for camera input error events.
77  *
78  * @see OH_CameraInput_RegisterCallback
79  * @since 11
80  * @version 1.0
81  */
82 typedef struct CameraInput_Callbacks {
83     /**
84      * Camera input error event.
85      */
86     OH_CameraInput_OnError onError;
87 } CameraInput_Callbacks;
88 
89 /**
90  * @brief Register camera input change event callback.
91  *
92  * @param cameraInput the {@link Camera_Input} instance.
93  * @param callback the {@link CameraInput_Callbacks} to be registered.
94  * @return {@link #CAMERA_OK} if the method call succeeds.
95  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
96  * @since 11
97  */
98 Camera_ErrorCode OH_CameraInput_RegisterCallback(Camera_Input* cameraInput, CameraInput_Callbacks* callback);
99 
100 /**
101  * @brief Unregister camera input change event callback.
102  *
103  * @param cameraInput the {@link Camera_Input} instance.
104  * @param callback the {@link CameraInput_Callbacks} to be unregistered.
105  * @return {@link #CAMERA_OK} if the method call succeeds.
106  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
107  * @since 11
108  */
109 Camera_ErrorCode OH_CameraInput_UnregisterCallback(Camera_Input* cameraInput, CameraInput_Callbacks* callback);
110 
111 /**
112  * @brief Open camera.
113  *
114  * @param cameraInput the {@link Camera_Input} instance to be opened.
115  * @return {@link #CAMERA_OK} if the method call succeeds.
116  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
117  *         {@link #CAMERA_CONFLICT_CAMERA} if can not use camera cause of conflict.
118  *         {@link #CAMERA_DEVICE_DISABLED} if camera disabled cause of security reason.
119  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
120  * @since 11
121  */
122 Camera_ErrorCode OH_CameraInput_Open(Camera_Input* cameraInput);
123 
124 /**
125  * @brief Open camera.
126  *
127  * @param cameraInput the {@link Camera_Input} instance to be opened.
128  * @param secureSeqId which indicates SequenceId that secure camera is on.
129  * @return {@link #CAMERA_OK} if the method call succeeds.
130  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
131  *         {@link #CAMERA_CONFLICT_CAMERA} if can not use camera cause of conflict.
132  *         {@link #CAMERA_DEVICE_DISABLED} if camera disabled cause of security reason.
133  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
134  * @since 12
135  */
136 Camera_ErrorCode OH_CameraInput_OpenSecureCamera(Camera_Input* cameraInput, uint64_t* secureSeqId);
137 
138 /**
139  * @brief Close camera.
140  *
141  * @param cameraInput the {@link Camera_Input} instance to be closed.
142  * @return {@link #CAMERA_OK} if the method call succeeds.
143  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
144  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
145  * @since 11
146  */
147 Camera_ErrorCode OH_CameraInput_Close(Camera_Input* cameraInput);
148 
149 /**
150  * @brief Release camera input instance.
151  *
152  * @param cameraInput the {@link Camera_Input} instance to be released.
153  * @return {@link #CAMERA_OK} if the method call succeeds.
154  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
155  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
156  * @since 11
157  */
158 Camera_ErrorCode OH_CameraInput_Release(Camera_Input* cameraInput);
159 
160 #ifdef __cplusplus
161 }
162 #endif
163 
164 #endif // NATIVE_INCLUDE_CAMERA_CAMERA_INPUT_H
165 /** @} */