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