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_manager.h
30  *
31  * @brief Declare the camera manager 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_MANAGER_H
41 #define NATIVE_INCLUDE_CAMERA_CAMERA_MANAGER_H
42 
43 #include <stdint.h>
44 #include <stdio.h>
45 #include "camera.h"
46 #include "camera_input.h"
47 #include "capture_session.h"
48 #include "preview_output.h"
49 #include "video_output.h"
50 #include "photo_output.h"
51 #include "metadata_output.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /**
58  * @brief Camera manager status callback to be called in {@link CameraManager_Callbacks}.
59  *
60  * @param cameraManager the {@link Camera_Manager} which deliver the callback.
61  * @param status the {@link Camera_StatusInfo} of each camera device.
62  * @since 11
63  */
64 typedef void (*OH_CameraManager_StatusCallback)(Camera_Manager* cameraManager, Camera_StatusInfo* status);
65 
66 /**
67  * @brief Camera manager torch status callback.
68  *
69  * @param cameraManager the {@link Camera_Manager} which deliver the callback.
70  * @param status the {@link Camera_TorchStatusInfo} of the torch.
71  * @since 12
72  */
73 typedef void (*OH_CameraManager_TorchStatusCallback)(Camera_Manager* cameraManager, Camera_TorchStatusInfo* status);
74 
75 /**
76  * @brief Camera manager fold status info callback.
77  *
78  * @param cameraManager the {@link Camera_Manager} which deliver the callback.
79  * @param foldStatusInfo the {@link Camera_FoldStatusInfo} of the device.
80  * @since 13
81  */
82 typedef void (*OH_CameraManager_OnFoldStatusInfoChange)(Camera_Manager* cameraManager,
83     Camera_FoldStatusInfo* foldStatusInfo);
84 
85 /**
86  * @brief A listener for camera devices status.
87  *
88  * @see OH_CameraManager_RegisterCallback
89  * @since 11
90  * @version 1.0
91  */
92 typedef struct CameraManager_Callbacks {
93     /**
94      * Camera status change event.
95      */
96     OH_CameraManager_StatusCallback onCameraStatus;
97 } CameraManager_Callbacks;
98 
99 /**
100  * @brief Register camera status change event callback.
101  *
102  * @param cameraManager the {@link Camera_Manager} instance.
103  * @param callback the {@link CameraManager_Callbacks} to be registered.
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_CameraManager_RegisterCallback(Camera_Manager* cameraManager, CameraManager_Callbacks* callback);
109 
110 /**
111  * @brief Unregister camera status change event callback.
112  *
113  * @param cameraManager the {@link Camera_Manager} instance.
114  * @param callback the {@link CameraManager_Callbacks} to be unregistered.
115  * @return {@link #CAMERA_OK} if the method call succeeds.
116  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
117  * @since 11
118  */
119 Camera_ErrorCode OH_CameraManager_UnregisterCallback(Camera_Manager* cameraManager, CameraManager_Callbacks* callback);
120 
121 /**
122  * @brief Register torch status change event callback.
123  *
124  * @param cameraManager the {@link Camera_Manager} instance.
125  * @param torchStatusCallback the {@link OH_CameraManager_TorchStatusCallback} to be registered.
126  * @return {@link #CAMERA_OK} if the method call succeeds.
127  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
128  * @since 12
129  */
130 Camera_ErrorCode OH_CameraManager_RegisterTorchStatusCallback(Camera_Manager* cameraManager,
131     OH_CameraManager_TorchStatusCallback torchStatusCallback);
132 
133 /**
134  * @brief Unregister torch status change event callback.
135  *
136  * @param cameraManager the {@link Camera_Manager} instance.
137  * @param torchStatusCallback the {@link OH_CameraManager_TorchStatusCallback} to be unregistered.
138  * @return {@link #CAMERA_OK} if the method call succeeds.
139  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
140  * @since 12
141  */
142 Camera_ErrorCode OH_CameraManager_UnregisterTorchStatusCallback(Camera_Manager* cameraManager,
143     OH_CameraManager_TorchStatusCallback torchStatusCallback);
144 
145 /**
146  * @brief Register fold status info change event callback.
147  *
148  * @param cameraManager the {@link Camera_Manager} instance.
149  * @param foldStatusInfoCallback the {@link OH_CameraManager_OnFoldStatusInfoChange} to be registered.
150  * @return {@link #CAMERA_OK} if the method call succeeds.
151  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
152  * @since 13
153  */
154 Camera_ErrorCode OH_CameraManager_RegisterFoldStatusInfoCallback(Camera_Manager* cameraManager,
155     OH_CameraManager_OnFoldStatusInfoChange foldStatusInfoCallback);
156 
157 /**
158  * @brief Unregister fold status info change event callback.
159  *
160  * @param cameraManager the {@link Camera_Manager} instance.
161  * @param foldStatusInfoCallback the {@link OH_CameraManager_OnFoldStatusInfoChange} to be unregistered.
162  * @return {@link #CAMERA_OK} if the method call succeeds.
163  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
164  * @since 13
165  */
166 Camera_ErrorCode OH_CameraManager_UnregisterFoldStatusInfoCallback(Camera_Manager* cameraManager,
167     OH_CameraManager_OnFoldStatusInfoChange foldStatusInfoCallback);
168 
169 /**
170  * @brief Gets supported camera descriptions.
171  *
172  * @param cameraManager the {@link Camera_Manager} instance.
173  * @param cameras the supported {@link Camera_Device} list will be filled
174  *        if the method call succeeds.
175  * @param size the size of supported {@link Camera_Device} list will be filled
176  *        if the method call succeeds.
177  * @return {@link #CAMERA_OK} if the method call succeeds.
178  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
179  * @since 11
180  */
181 Camera_ErrorCode OH_CameraManager_GetSupportedCameras(Camera_Manager* cameraManager,
182     Camera_Device** cameras, uint32_t* size);
183 
184 /**
185  * @brief Delete supported camera.
186  *
187  * @param cameraManager the {@link Camera_Manager} instance.
188  * @param cameras the {@link Camera_Device} list to be deleted.
189  * @return {@link #CAMERA_OK} if the method call succeeds.
190  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
191  * @since 11
192  */
193 Camera_ErrorCode OH_CameraManager_DeleteSupportedCameras(Camera_Manager* cameraManager,
194     Camera_Device* cameras, uint32_t size);
195 
196 /**
197  * @brief Gets the supported output capability for the specific camera and specific mode.
198  *
199  * @param cameraManager the {@link Camera_Manager} instance.
200  * @param cameras the {@link Camera_Device} to be queryed.
201  * @param cameraOutputCapability the supported {@link Camera_OutputCapability} will be filled
202  *        if the method call succeeds.
203  * @return {@link #CAMERA_OK} if the method call succeeds.
204  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
205  * @since 11
206  */
207 Camera_ErrorCode OH_CameraManager_GetSupportedCameraOutputCapability(Camera_Manager* cameraManager,
208     const Camera_Device* camera, Camera_OutputCapability** cameraOutputCapability);
209 
210 /**
211  * @brief Gets supported output capability for specific camera and specific sceneMode.
212  *
213  * @param cameraManager the {@link Camera_Manager} instance.
214  * @param camera the {@link Camera_Device} to be queryed.
215  * @param sceneMode the {@link Camera_SceneMode} to be queryed.
216  * @param cameraOutputCapability the supported {@link Camera_OutputCapability} will be filled
217  *        if the method call succeeds.
218  * @return {@link #CAMERA_OK} if the method call succeeds.
219  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
220  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
221  * @since 12
222  */
223 Camera_ErrorCode OH_CameraManager_GetSupportedCameraOutputCapabilityWithSceneMode(Camera_Manager* cameraManager,
224     const Camera_Device* camera, Camera_SceneMode sceneMode, Camera_OutputCapability** cameraOutputCapability);
225 
226 /**
227  * @brief Delete the supported output capability.
228  *
229  * @param cameraManager the {@link Camera_Manager} instance.
230  * @param cameraOutputCapability the {@link Camera_OutputCapability} to be deleted.
231  * @return {@link #CAMERA_OK} if the method call succeeds.
232  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
233  * @since 11
234  */
235 Camera_ErrorCode OH_CameraManager_DeleteSupportedCameraOutputCapability(Camera_Manager* cameraManager,
236     Camera_OutputCapability* cameraOutputCapability);
237 
238 /**
239  * @brief Determine whether camera is muted.
240  *
241  * @param cameraManager the {@link Camera_Manager} instance.
242  * @param isCameraMuted whether camera is muted will be filled if the method call succeeds.
243  * @return {@link #CAMERA_OK} if the method call succeeds.
244  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
245  * @since 11
246  */
247 Camera_ErrorCode OH_CameraManager_IsCameraMuted(Camera_Manager* cameraManager, bool* isCameraMuted);
248 
249 /**
250  * @brief Create a capture session instance.The default session mode is photo session.
251  *
252  * @param cameraManager the {@link Camera_Manager} instance.
253  * @param captureSession the {@link Camera_CaptureSession} will be created
254  *        if the method call succeeds.
255  * @return {@link #CAMERA_OK} if the method call succeeds.
256  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
257  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
258  * @since 11
259  */
260 Camera_ErrorCode OH_CameraManager_CreateCaptureSession(Camera_Manager* cameraManager,
261     Camera_CaptureSession** captureSession);
262 
263 /**
264  * @brief Create a camera input instance.
265  *
266  * @param cameraManager the {@link Camera_Manager} instance.
267  * @param camera the {@link Camera_Device} which use to create {@link Camera_Input}.
268  * @param cameraInput the {@link Camera_Input} will be created if the method call succeeds.
269  * @return {@link #CAMERA_OK} if the method call succeeds.
270  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
271  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
272  * @permission ohos.permission.CAMERA
273  * @since 11
274  */
275 Camera_ErrorCode OH_CameraManager_CreateCameraInput(Camera_Manager* cameraManager,
276     const Camera_Device* camera, Camera_Input** cameraInput);
277 
278 /**
279  * @brief Create a camera input instance.
280  *
281  * @param cameraManager the {@link Camera_Manager} instance.
282  * @param position the {@link Camera_Position} which use to create {@link Camera_Input}.
283  * @param type the {@link Camera_Type} which use to create {@link Camera_Input}.
284  * @param cameraInput the {@link Camera_Input} will be created if the method call succeeds.
285  * @return {@link #CAMERA_OK} if the method call succeeds.
286  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
287  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
288  * @permission ohos.permission.CAMERA
289  * @since 11
290  */
291 Camera_ErrorCode OH_CameraManager_CreateCameraInput_WithPositionAndType(Camera_Manager* cameraManager,
292     Camera_Position position, Camera_Type type, Camera_Input** cameraInput);
293 
294 /**
295  * @brief Create a preview output instance.
296  *
297  * @param cameraManager the {@link Camera_Manager} instance.
298  * @param profile the {@link Camera_Profile} to create {@link Camera_PreviewOutput}.
299  * @param surfaceId the which use to create {@link Camera_PreviewOutput}.
300  * @param previewOutput the {@link Camera_PreviewOutput} will be created if the method call succeeds.
301  * @return {@link #CAMERA_OK} if the method call succeeds.
302  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
303  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
304  * @since 11
305  */
306 Camera_ErrorCode OH_CameraManager_CreatePreviewOutput(Camera_Manager* cameraManager, const Camera_Profile* profile,
307     const char* surfaceId, Camera_PreviewOutput** previewOutput);
308 
309 /**
310  * @brief Create a preview output instance used in preconfig.
311  *
312  * @param cameraManager the {@link Camera_Manager} instance.
313  * @param surfaceId the which use to create {@link Camera_PreviewOutput}.
314  * @param previewOutput the {@link Camera_PreviewOutput} will be created if the method call succeeds.
315  * @return {@link #CAMERA_OK} if the method call succeeds.
316  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
317  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
318  * @since 12
319  */
320 Camera_ErrorCode OH_CameraManager_CreatePreviewOutputUsedInPreconfig(Camera_Manager* cameraManager,
321     const char* surfaceId, Camera_PreviewOutput** previewOutput);
322 
323 /**
324  * @brief Create a photo output instance.
325  *
326  * @param cameraManager the {@link Camera_Manager} instance.
327  * @param profile the {@link Camera_Profile} to create {@link Camera_PhotoOutput}.
328  * @param surfaceId the which use to create {@link Camera_PhotoOutput}.
329  * @param photoOutput the {@link Camera_PhotoOutput} will be created if the method call succeeds.
330  * @return {@link #CAMERA_OK} if the method call succeeds.
331  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
332  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
333  * @since 11
334  */
335 Camera_ErrorCode OH_CameraManager_CreatePhotoOutput(Camera_Manager* cameraManager, const Camera_Profile* profile,
336     const char* surfaceId, Camera_PhotoOutput** photoOutput);
337 
338 /**
339  * @brief Create a photo output instance used in preconfig.
340  *
341  * @param cameraManager the {@link Camera_Manager} instance.
342  * @param surfaceId the which use to create {@link Camera_PhotoOutput}.
343  * @param photoOutput the {@link Camera_PhotoOutput} will be created if the method call succeeds.
344  * @return {@link #CAMERA_OK} if the method call succeeds.
345  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
346  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
347  * @since 12
348  */
349 Camera_ErrorCode OH_CameraManager_CreatePhotoOutputUsedInPreconfig(Camera_Manager* cameraManager,
350     const char* surfaceId, Camera_PhotoOutput** photoOutput);
351 
352 /**
353  * @brief Create a photo output instance without surfaceId.
354  *
355  * @param cameraManager the {@link Camera_Manager} instance.
356  * @param profile the {@link Camera_Profile} to create {@link Camera_PhotoOutput}.
357  * @param photoOutput the {@link Camera_PhotoOutput} will be created if the method call succeeds.
358  * @return {@link #CAMERA_OK} if the method call succeeds.
359  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
360  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
361  * @since 12
362  */
363 Camera_ErrorCode OH_CameraManager_CreatePhotoOutputWithoutSurface(Camera_Manager *cameraManager,
364     const Camera_Profile *profile, Camera_PhotoOutput **photoOutput);
365 
366 /**
367  * @brief Create a video output instance.
368  *
369  * @param cameraManager the {@link Camera_Manager} instance.
370  * @param profile the {@link Camera_VideoProfile} to create {@link Camera_VideoOutput}.
371  * @param surfaceId the which use to create {@link Camera_VideoOutput}.
372  * @param videoOutput the {@link Camera_VideoOutput} will be created if the method call succeeds.
373  * @return {@link #CAMERA_OK} if the method call succeeds.
374  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
375  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
376  * @since 11
377  */
378 Camera_ErrorCode OH_CameraManager_CreateVideoOutput(Camera_Manager* cameraManager, const Camera_VideoProfile* profile,
379     const char* surfaceId, Camera_VideoOutput** videoOutput);
380 
381 /**
382  * @brief Create a video output instance used in preconfig.
383  *
384  * @param cameraManager the {@link Camera_Manager} instance.
385  * @param surfaceId the which use to create {@link Camera_VideoOutput}.
386  * @param videoOutput the {@link Camera_VideoOutput} will be created if the method call succeeds.
387  * @return {@link #CAMERA_OK} if the method call succeeds.
388  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
389  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
390  * @since 12
391  */
392 Camera_ErrorCode OH_CameraManager_CreateVideoOutputUsedInPreconfig(Camera_Manager* cameraManager,
393     const char* surfaceId, Camera_VideoOutput** videoOutput);
394 
395 /**
396  * @brief Create a metadata output instance.
397  *
398  * @param cameraManager the {@link Camera_Manager} instance.
399  * @param profile the {@link Camera_MetadataObjectType} to create {@link Camera_MetadataOutput}.
400  * @param metadataOutput the {@link Camera_MetadataOutput} will be created if the method call succeeds.
401  * @return {@link #CAMERA_OK} if the method call succeeds.
402  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
403  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
404  * @since 11
405  */
406 Camera_ErrorCode OH_CameraManager_CreateMetadataOutput(Camera_Manager* cameraManager,
407     const Camera_MetadataObjectType* profile, Camera_MetadataOutput** metadataOutput);
408 
409 /**
410  * @brief Gets supported scene mode for specific camera.
411  *
412  * @param camera the {@link Camera_Device} to be queryed.
413  * @param sceneModes the supported {@link Camera_SceneMode} will be filled if the method call succeeds.
414  * @param size the size of supported {@link Camera_SceneMode} list will be filled if the method call succeeds.
415  * @return {@link #CAMERA_OK} if the method call succeeds.
416  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
417  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
418  * @since 12
419  */
420 Camera_ErrorCode OH_CameraManager_GetSupportedSceneModes(Camera_Device* camera,
421     Camera_SceneMode** sceneModes, uint32_t* size);
422 
423 /**
424  * @brief Delete the scene mode.
425  *
426  * @param cameraManager the {@link Camera_Manager} instance.
427  * @param sceneModes the {@link Camera_SceneMode} to be deleted.
428  * @return {@link #CAMERA_OK} if the method call succeeds.
429  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
430  * @since 12
431  */
432 Camera_ErrorCode OH_CameraManager_DeleteSceneModes(Camera_Manager* cameraManager, Camera_SceneMode* sceneModes);
433 
434 /**
435  * @brief Check if the device supports torch.
436  *
437  * @param cameraManager the {@link Camera_Manager} instance.
438  * @param isTorchSupported whether the device supports torch.
439  * @return {@link #CAMERA_OK} if the method call succeeds.
440  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
441  * @since 12
442  */
443 Camera_ErrorCode OH_CameraManager_IsTorchSupported(Camera_Manager* cameraManager,
444     bool* isTorchSupported);
445 
446 /**
447  * @brief Check whether the device supports the torch with the specified torch mode.
448  *
449  * @param cameraManager the {@link Camera_Manager} instance.
450  * @param torchMode the {@link Camera_TorchMode} to be checked.
451  * @param isTorchSupported whether device supports the torch mode.
452  * @return {@link #CAMERA_OK} if the method call succeeds.
453  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
454  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
455  * @since 12
456  */
457 Camera_ErrorCode OH_CameraManager_IsTorchSupportedByTorchMode(Camera_Manager* cameraManager,
458     Camera_TorchMode torchMode, bool* isTorchSupported);
459 
460 /**
461  * @brief Set camera torch mode.
462  *
463  * @param cameraManager the {@link Camera_Manager} instance.
464  * @param torchMode the {@link Camera_TorchMode} to be set.
465  * @return {@link #CAMERA_OK} if the method call succeeds.
466  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
467  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
468  * @since 12
469  */
470 Camera_ErrorCode OH_CameraManager_SetTorchMode(Camera_Manager* cameraManager,
471     Camera_TorchMode torchMode);
472 
473 #ifdef __cplusplus
474 }
475 #endif
476 
477 #endif // NATIVE_INCLUDE_CAMERA_CAMERA_MANAGER_H
478 /** @} */