• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * @syscap SystemCapability.Multimedia.Camera.Core
35  * @since 11
36  * @version 1.0
37  */
38 
39 #ifndef NATIVE_INCLUDE_CAMERA_CAMERA_INPUT_H
40 #define NATIVE_INCLUDE_CAMERA_CAMERA_INPUT_H
41 
42 #include <stdint.h>
43 #include <stdio.h>
44 #include "camera.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /**
51  * @brief Camera input object.
52  *
53  * A pointer can be created using {@link OH_CameraManager_CreateCameraInput} method.
54  *
55  * @since 11
56  * @version 1.0
57  */
58 typedef struct Camera_Input Camera_Input;
59 
60 /**
61  * @brief Camera input error callback to be called in {@link CameraInput_Callbacks}.
62  *
63  * @param cameraInput the {@link Camera_Input} which deliver the callback.
64  * @param errorCode the {@link Camera_ErrorCode} of the camera input.
65  *
66  * @see CAMERA_CONFLICT_CAMERA
67  * @see CAMERA_DEVICE_DISABLED
68  * @see CAMERA_DEVICE_PREEMPTED
69  * @see CAMERA_SERVICE_FATAL_ERROR
70  * @since 11
71  */
72 typedef void (*OH_CameraInput_OnError)(const Camera_Input* cameraInput, Camera_ErrorCode errorCode);
73 
74 /**
75  * @brief A listener for camera input error events.
76  *
77  * @see OH_CameraInput_RegisterCallback
78  * @since 11
79  * @version 1.0
80  */
81 typedef struct CameraInput_Callbacks {
82     /**
83      * Camera input error event.
84      */
85     OH_CameraInput_OnError onError;
86 } CameraInput_Callbacks;
87 
88 /**
89  * @brief Register camera input change event callback.
90  *
91  * @param cameraInput the {@link Camera_Input} instance.
92  * @param callback the {@link CameraInput_Callbacks} to be registered.
93  * @return {@link #CAMERA_OK} if the method call succeeds.
94  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
95  * @since 11
96  */
97 Camera_ErrorCode OH_CameraInput_RegisterCallback(Camera_Input* cameraInput, CameraInput_Callbacks* callback);
98 
99 /**
100  * @brief Unregister camera input change event callback.
101  *
102  * @param cameraInput the {@link Camera_Input} instance.
103  * @param callback the {@link CameraInput_Callbacks} to be unregistered.
104  * @return {@link #CAMERA_OK} if the method call succeeds.
105  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
106  * @since 11
107  */
108 Camera_ErrorCode OH_CameraInput_UnregisterCallback(Camera_Input* cameraInput, CameraInput_Callbacks* callback);
109 
110 /**
111  * @brief Open camera.
112  *
113  * @param cameraInput the {@link Camera_Input} instance to be opened.
114  * @return {@link #CAMERA_OK} if the method call succeeds.
115  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
116  *         {@link #CAMERA_CONFLICT_CAMERA} if can not use camera cause of conflict.
117  *         {@link #CAMERA_DEVICE_DISABLED} if camera disabled cause of security reason.
118  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
119  * @since 11
120  */
121 Camera_ErrorCode OH_CameraInput_Open(Camera_Input* cameraInput);
122 
123 /**
124  * @brief Close camera.
125  *
126  * @param cameraInput the {@link Camera_Input} instance to be closed.
127  * @return {@link #CAMERA_OK} if the method call succeeds.
128  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
129  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
130  * @since 11
131  */
132 Camera_ErrorCode OH_CameraInput_Close(Camera_Input* cameraInput);
133 
134 /**
135  * @brief Release camera input instance.
136  *
137  * @param cameraInput the {@link Camera_Input} instance to be released.
138  * @return {@link #CAMERA_OK} if the method call succeeds.
139  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
140  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
141  * @since 11
142  */
143 Camera_ErrorCode OH_CameraInput_Release(Camera_Input* cameraInput);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif // NATIVE_INCLUDE_CAMERA_CAMERA_INPUT_H
150 /** @} */