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.h
30 *
31 * @brief Declare the camera base 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_H
41#define NATIVE_INCLUDE_CAMERA_CAMERA_H
42
43#include <stdint.h>
44#include <stdio.h>
45#include <stdbool.h>
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/**
52 * @brief camera manager object.
53 *
54 * A pointer can be created using {@link OH_Camera_GetCameraManager} method.
55 *
56 * @since 11
57 * @version 1.0
58 */
59typedef struct Camera_Manager Camera_Manager;
60
61/**
62 * @brief Enum for camera error code.
63 *
64 * @since 11
65 * @version 1.0
66 */
67typedef enum Camera_ErrorCode {
68    /**
69     * Camera result is ok.
70     */
71    CAMERA_OK = 0,
72
73    /**
74     * Parameter missing or parameter type incorrect.
75     */
76    CAMERA_INVALID_ARGUMENT = 7400101,
77
78    /**
79     * Operation not allowed.
80     */
81    CAMERA_OPERATION_NOT_ALLOWED = 7400102,
82
83    /**
84     * Session not config.
85     */
86    CAMERA_SESSION_NOT_CONFIG = 7400103,
87
88    /**
89     * Session not running.
90     */
91    CAMERA_SESSION_NOT_RUNNING = 7400104,
92
93    /**
94     * Session config locked.
95     */
96    CAMERA_SESSION_CONFIG_LOCKED = 7400105,
97
98    /**
99     * Device setting locked.
100     */
101    CAMERA_DEVICE_SETTING_LOCKED = 7400106,
102
103    /**
104     * Can not use camera cause of conflict.
105     */
106    CAMERA_CONFLICT_CAMERA = 7400107,
107
108    /**
109     * Camera disabled cause of security reason.
110     */
111    CAMERA_DEVICE_DISABLED = 7400108,
112
113    /**
114     * Can not use camera cause of preempted.
115     */
116    CAMERA_DEVICE_PREEMPTED = 7400109,
117
118    /**
119     * Unresolved conflicts with current configurations.
120     * @since 12
121     */
122    CAMERA_UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS = 7400110,
123
124    /**
125     * Camera service fatal error.
126     */
127    CAMERA_SERVICE_FATAL_ERROR = 7400201
128} Camera_ErrorCode;
129
130/**
131 * @brief Enum for camera status.
132 *
133 * @since 11
134 * @version 1.0
135 */
136typedef enum Camera_Status {
137    /**
138     * Appear status.
139     */
140    CAMERA_STATUS_APPEAR = 0,
141
142    /**
143     * Disappear status.
144     */
145    CAMERA_STATUS_DISAPPEAR = 1,
146
147    /**
148     * Available status.
149     */
150    CAMERA_STATUS_AVAILABLE = 2,
151
152    /**
153     * Unavailable status.
154     */
155    CAMERA_STATUS_UNAVAILABLE = 3
156} Camera_Status;
157
158/**
159 * @brief Enum for scence mode.
160 *
161 * @since 12
162 * @version 1.0
163 */
164typedef enum Camera_SceneMode {
165    /**
166     * Normal photo mode.
167     */
168    NORMAL_PHOTO = 1,
169
170    /**
171     * Normal video mode.
172     */
173    NORMAL_VIDEO = 2,
174
175    /**
176     * Secure photo mode.
177     */
178    SECURE_PHOTO = 12
179} Camera_SceneMode;
180
181/**
182 * @brief Enum for camera position.
183 *
184 * @since 11
185 * @version 1.0
186 */
187typedef enum Camera_Position {
188    /**
189     * Unspecified position.
190     */
191    CAMERA_POSITION_UNSPECIFIED = 0,
192
193    /**
194     * Back position.
195     */
196    CAMERA_POSITION_BACK = 1,
197
198    /**
199     * Front position.
200     */
201    CAMERA_POSITION_FRONT = 2
202} Camera_Position;
203
204/**
205 * @brief Enum for camera type.
206 *
207 * @since 11
208 * @version 1.0
209 */
210typedef enum Camera_Type {
211    /**
212     * Default camera type.
213     */
214    CAMERA_TYPE_DEFAULT = 0,
215
216    /**
217     * Wide camera.
218     */
219    CAMERA_TYPE_WIDE_ANGLE = 1,
220
221    /**
222     * Ultra wide camera.
223     */
224    CAMERA_TYPE_ULTRA_WIDE = 2,
225
226    /**
227     * Telephoto camera.
228     */
229    CAMERA_TYPE_TELEPHOTO = 3,
230
231    /**
232     * True depth camera.
233     */
234    CAMERA_TYPE_TRUE_DEPTH = 4
235} Camera_Type;
236
237/**
238 * @brief Enum for camera connection type.
239 *
240 * @since 11
241 * @version 1.0
242 */
243typedef enum Camera_Connection {
244    /**
245     * Built-in camera.
246     */
247    CAMERA_CONNECTION_BUILT_IN = 0,
248
249    /**
250     * Camera connected using USB.
251     */
252    CAMERA_CONNECTION_USB_PLUGIN = 1,
253
254    /**
255     * Remote camera.
256     */
257    CAMERA_CONNECTION_REMOTE = 2
258} Camera_Connection;
259
260/**
261 * @brief Enum for camera format type.
262 *
263 * @since 11
264 * @version 1.0
265 */
266typedef enum Camera_Format {
267    /**
268     * RGBA 8888 Format.
269     */
270    CAMERA_FORMAT_RGBA_8888 = 3,
271
272    /**
273     * YUV 420 Format.
274     */
275    CAMERA_FORMAT_YUV_420_SP = 1003,
276
277    /**
278     * JPEG Format.
279     */
280    CAMERA_FORMAT_JPEG = 2000,
281
282    /**
283     * YCBCR P010 Format.
284     * @since 12
285     */
286    CAMERA_FORMAT_YCBCR_P010 = 2001,
287
288    /**
289     * YCRCB P010 Format.
290     * @since 12
291     */
292    CAMERA_FORMAT_YCRCB_P010 = 2002
293} Camera_Format;
294
295/**
296 * @brief Enum for flash mode.
297 *
298 * @since 11
299 * @version 1.0
300 */
301typedef enum Camera_FlashMode {
302    /**
303     * Close mode.
304     */
305    FLASH_MODE_CLOSE = 0,
306
307    /**
308     * Open mode.
309     */
310    FLASH_MODE_OPEN = 1,
311
312    /**
313     * Auto mode.
314     */
315    FLASH_MODE_AUTO = 2,
316
317    /**
318     * Always open mode.
319     */
320    FLASH_MODE_ALWAYS_OPEN = 3
321} Camera_FlashMode;
322
323/**
324 * @brief Enum for exposure mode.
325 *
326 * @since 11
327 * @version 1.0
328 */
329typedef enum Camera_ExposureMode {
330    /**
331     * Lock exposure mode.
332     */
333    EXPOSURE_MODE_LOCKED = 0,
334
335    /**
336     * Auto exposure mode.
337     */
338    EXPOSURE_MODE_AUTO = 1,
339
340    /**
341     * Continuous automatic exposure.
342     */
343    EXPOSURE_MODE_CONTINUOUS_AUTO = 2
344} Camera_ExposureMode;
345
346/**
347 * @brief Enum for focus mode.
348 *
349 * @since 11
350 * @version 1.0
351 */
352typedef enum Camera_FocusMode {
353    /**
354     * Manual mode.
355     */
356    FOCUS_MODE_MANUAL = 0,
357
358    /**
359     * Continuous auto mode.
360     */
361    FOCUS_MODE_CONTINUOUS_AUTO = 1,
362
363    /**
364     * Auto mode.
365     */
366    FOCUS_MODE_AUTO = 2,
367
368    /**
369     * Locked mode.
370     */
371    FOCUS_MODE_LOCKED = 3
372} Camera_FocusMode;
373
374/**
375 * @brief Enum for focus state.
376 *
377 * @since 11
378 * @version 1.0
379 */
380typedef enum Camera_FocusState {
381    /**
382     * Scan state.
383     */
384    FOCUS_STATE_SCAN = 0,
385
386    /**
387     * Focused state.
388     */
389    FOCUS_STATE_FOCUSED = 1,
390
391    /**
392     * Unfocused state.
393     */
394    FOCUS_STATE_UNFOCUSED = 2
395} Camera_FocusState;
396
397/**
398 * @brief Enum for video stabilization mode.
399 *
400 * @since 11
401 * @version 1.0
402 */
403typedef enum Camera_VideoStabilizationMode {
404    /**
405     * Turn off video stablization.
406     */
407    STABILIZATION_MODE_OFF = 0,
408
409    /**
410     * LOW mode provides basic stabilization effect.
411     */
412    STABILIZATION_MODE_LOW = 1,
413
414    /**
415     * MIDDLE mode means algorithms can achieve better effects than LOW mode.
416     */
417    STABILIZATION_MODE_MIDDLE = 2,
418
419    /**
420     * HIGH mode means algorithms can achieve better effects than MIDDLE mode.
421     */
422    STABILIZATION_MODE_HIGH = 3,
423
424    /**
425     * Camera HDF can select mode automatically.
426     */
427    STABILIZATION_MODE_AUTO = 4
428} Camera_VideoStabilizationMode;
429
430/**
431 * @brief Enum for the image rotation angles.
432 *
433 * @since 11
434 * @version 1.0
435 */
436typedef enum Camera_ImageRotation {
437    /**
438     * The capture image rotates 0 degrees.
439     */
440    IAMGE_ROTATION_0 = 0,
441
442    /**
443     * The capture image rotates 90 degrees.
444     */
445    IAMGE_ROTATION_90 = 90,
446
447    /**
448     * The capture image rotates 180 degrees.
449     */
450    IAMGE_ROTATION_180 = 180,
451
452    /**
453     * The capture image rotates 270 degrees.
454     */
455    IAMGE_ROTATION_270 = 270
456} Camera_ImageRotation;
457
458/**
459 * @brief Enum for the image quality levels.
460 *
461 * @since 11
462 * @version 1.0
463 */
464typedef enum Camera_QualityLevel {
465    /**
466     * High image quality.
467     */
468    QUALITY_LEVEL_HIGH = 0,
469
470    /**
471     * Medium image quality.
472     */
473    QUALITY_LEVEL_MEDIUM = 1,
474
475    /**
476     * Low image quality.
477     */
478    QUALITY_LEVEL_LOW = 2
479} Camera_QualityLevel;
480
481/**
482 * @brief Enum for metadata object type.
483 *
484 * @since 11
485 * @version 1.0
486 */
487typedef enum Camera_MetadataObjectType {
488    /**
489     * Face detection.
490     */
491    FACE_DETECTION = 0
492} Camera_MetadataObjectType;
493
494/**
495 * @brief Enum for torch mode.
496 *
497 * @since 12
498 * @version 1.0
499 */
500typedef enum Camera_TorchMode {
501    /**
502     * The device torch is always off.
503     */
504    OFF = 0,
505
506    /**
507     * The device torch is always on.
508     */
509    ON = 1,
510
511    /**
512     * The device continuously monitors light levels and
513     * uses the torch when necessary.
514     */
515    AUTO = 2
516} Camera_TorchMode;
517
518/**
519 * @brief Enum for smooth zoom mode.
520 *
521 * @since 12
522 * @version 1.0
523 */
524typedef enum Camera_SmoothZoomMode {
525    /**
526     * Normal zoom mode.
527     */
528    NORMAL = 0
529} Camera_SmoothZoomMode;
530
531/**
532 * @brief Enum for preconfig type.
533 *
534 * @since 12
535 * @version 1.0
536 */
537typedef enum Camera_PreconfigType {
538    /**
539     * The preconfig type is 720P.
540     */
541    PRECONFIG_720P = 0,
542
543    /**
544     * The preconfig type is 1080P.
545     */
546    PRECONFIG_1080P = 1,
547
548    /**
549     * The preconfig type is 4K.
550     */
551    PRECONFIG_4K = 2,
552
553    /**
554     * The preconfig type is high quality.
555     */
556    PRECONFIG_HIGH_QUALITY = 3
557} Camera_PreconfigType;
558
559/**
560 * @brief Enum for preconfig ratio.
561 *
562 * @since 12
563 * @version 1.0
564 */
565typedef enum Camera_PreconfigRatio {
566    /**
567     * The preconfig ratio is 1:1.
568     */
569    PRECONFIG_RATIO_1_1 = 0,
570
571    /**
572     * The preconfig ratio 4:3.
573     */
574    PRECONFIG_RATIO_4_3 = 1,
575
576    /**
577     * The preconfig ratio 16:9.
578     */
579    PRECONFIG_RATIO_16_9 = 2
580} Camera_PreconfigRatio;
581
582/**
583 * @brief Size parameter.
584 *
585 * @since 11
586 * @version 1.0
587 */
588typedef struct Camera_Size {
589    /**
590     * Width.
591     */
592    uint32_t width;
593
594    /**
595     * Height.
596     */
597    uint32_t height;
598} Camera_Size;
599
600/**
601 * @brief Profile for camera streams.
602 *
603 * @since 11
604 * @version 1.0
605 */
606typedef struct Camera_Profile {
607    /**
608     * Camera format.
609     */
610    Camera_Format format;
611
612    /**
613     * Picture size.
614     */
615    Camera_Size size;
616} Camera_Profile;
617
618/**
619 * @brief Frame rate range.
620 *
621 * @since 11
622 * @version 1.0
623 */
624typedef struct Camera_FrameRateRange {
625    /**
626     * Min frame rate.
627     */
628    uint32_t min;
629
630    /**
631     * Max frame rate.
632     */
633    uint32_t max;
634} Camera_FrameRateRange;
635
636/**
637 * @brief Video profile.
638 *
639 * @since 11
640 * @version 1.0
641 */
642typedef struct Camera_VideoProfile {
643    /**
644     * Camera format.
645     */
646    Camera_Format format;
647
648    /**
649     * Picture size.
650     */
651    Camera_Size size;
652
653    /**
654     * Frame rate in unit fps (frames per second).
655     */
656    Camera_FrameRateRange range;
657} Camera_VideoProfile;
658
659/**
660 * @brief Camera output capability.
661 *
662 * @since 11
663 * @version 1.0
664 */
665typedef struct Camera_OutputCapability {
666    /**
667     * Preview profiles list.
668     */
669    Camera_Profile** previewProfiles;
670
671    /**
672     * Size of preview profiles list.
673     */
674    uint32_t previewProfilesSize;
675
676    /**
677     * Photo profiles list.
678     */
679    Camera_Profile** photoProfiles;
680
681    /**
682     * Size of photo profiles list.
683     */
684    uint32_t photoProfilesSize;
685
686    /**
687     * Video profiles list.
688     */
689    Camera_VideoProfile** videoProfiles;
690
691    /**
692     * Size of video profiles list.
693     */
694    uint32_t videoProfilesSize;
695
696    /**
697     * Metadata object types list.
698     */
699    Camera_MetadataObjectType** supportedMetadataObjectTypes;
700
701    /**
702     * Size of metadata object types list.
703     */
704    uint32_t metadataProfilesSize;
705} Camera_OutputCapability;
706
707/**
708 * @brief Camera device object.
709 *
710 * @since 11
711 * @version 1.0
712 */
713typedef struct Camera_Device {
714    /**
715     * Camera id attribute.
716     */
717    char* cameraId;
718
719    /**
720     * Camera position attribute.
721     */
722    Camera_Position cameraPosition;
723
724    /**
725     * Camera type attribute.
726     */
727    Camera_Type cameraType;
728
729    /**
730     * Camera connection type attribute.
731     */
732    Camera_Connection connectionType;
733} Camera_Device;
734
735/**
736 * @brief Camera status info.
737 *
738 * @since 11
739 * @version 1.0
740 */
741typedef struct Camera_StatusInfo {
742    /**
743     * Camera instance.
744     */
745    Camera_Device* camera;
746
747    /**
748     * Current camera status.
749     */
750    Camera_Status status;
751} Camera_StatusInfo;
752
753/**
754 * @brief Point parameter.
755 *
756 * @since 11
757 * @version 1.0
758 */
759typedef struct Camera_Point {
760    /**
761     * X co-ordinate.
762     */
763    double x;
764
765    /**
766     * Y co-ordinate.
767     */
768    double y;
769} Camera_Point;
770
771/**
772 * @brief Photo capture location.
773 *
774 * @since 11
775 * @version 1.0
776 */
777typedef struct Camera_Location {
778    /**
779     * Latitude.
780     */
781    double latitude;
782
783    /**
784     * Longitude.
785     */
786    double longitude;
787
788    /**
789     * Altitude.
790     */
791    double altitude;
792} Camera_Location;
793
794/**
795 * @brief Photo capture options to set.
796 *
797 * @since 11
798 * @version 1.0
799 */
800typedef struct Camera_PhotoCaptureSetting {
801    /**
802     * Photo image quality.
803     */
804    Camera_QualityLevel quality;
805
806    /**
807     * Photo rotation.
808     */
809    Camera_ImageRotation rotation;
810
811    /**
812     * Photo location.
813     */
814    Camera_Location* location;
815
816    /**
817     * Set the mirror photo function switch, default to false.
818     */
819    bool mirror;
820} Camera_PhotoCaptureSetting;
821
822/**
823 * @brief Frame shutter callback info.
824 *
825 * @since 11
826 * @version 1.0
827 */
828typedef struct Camera_FrameShutterInfo {
829    /**
830     * Capture id.
831     */
832    int32_t captureId;
833
834    /**
835     * Timestamp for frame.
836     */
837    uint64_t timestamp;
838} Camera_FrameShutterInfo;
839
840/**
841 * @brief Capture end info.
842 *
843 * @since 11
844 * @version 1.0
845 */
846typedef struct Camera_CaptureEndInfo {
847    /**
848     * Capture id.
849     */
850    int32_t captureId;
851
852    /**
853     * Frame count.
854     */
855    int64_t frameCount;
856} Camera_CaptureEndInfo;
857
858/**
859 * @brief Rectangle definition.
860 *
861 * @since 11
862 * @version 1.0
863 */
864typedef struct Camera_Rect {
865    /**
866     * X coordinator of top left point.
867     */
868    int32_t topLeftX;
869
870    /**
871     * Y coordinator of top left point.
872     */
873    int32_t topLeftY;
874
875    /**
876     * Width of this rectangle.
877     */
878    int32_t width;
879
880    /**
881     * Height of this rectangle.
882     */
883    int32_t height;
884} Camera_Rect;
885
886/**
887 * @brief Metadata object basis.
888 *
889 * @since 11
890 * @version 1.0
891 */
892typedef struct Camera_MetadataObject {
893    /**
894     * Metadata object type.
895     */
896    Camera_MetadataObjectType type;
897
898    /**
899     * Metadata object timestamp in milliseconds.
900     */
901    int64_t timestamp;
902
903    /**
904     * The axis-aligned bounding box of detected metadata object.
905     */
906    Camera_Rect* boundingBox;
907} Camera_MetadataObject;
908
909/**
910 * @brief Torch Status Info.
911 *
912 * @since 12
913 * @version 1.0
914 */
915typedef struct Camera_TorchStatusInfo {
916    /**
917     * is torch available.
918     */
919    bool isTorchAvailable;
920
921    /**
922     * is torch active.
923     */
924    bool isTorchActive;
925
926    /**
927     * the current torch brightness level.
928     */
929    float torchLevel;
930} Camera_TorchStatusInfo;
931
932/**
933 * @brief SmoothZoomInfo object.
934 *
935 * @since 12
936 * @version 1.0
937 */
938typedef struct Camera_SmoothZoomInfo {
939    /**
940     * The duration of smooth zoom.
941     */
942    int32_t duration;
943} Camera_SmoothZoomInfo;
944
945/**
946 * @brief Capture start info.
947 *
948 * @since 12
949 * @version 1.0
950 */
951typedef struct Camera_CaptureStartInfo {
952    /**
953     * Capture id.
954     */
955    int32_t captureId;
956
957    /**
958     * Time(in milliseconds) is the shutter time for the photo.
959     */
960    int64_t time;
961} Camera_CaptureStartInfo;
962
963/**
964 * @brief Frame shutter end callback info.
965 *
966 * @since 12
967 * @version 1.0
968 */
969typedef struct Camera_FrameShutterEndInfo {
970    /**
971     * Capture id.
972     */
973    int32_t captureId;
974} Camera_FrameShutterEndInfo;
975
976/**
977* @brief Enum for fold status.
978*
979* @since 13
980* @version 1.0
981*/
982typedef enum Camera_FoldStatus {
983    /**
984     * Non_foldable status.
985     */
986    NON_FOLDABLE = 0,
987
988    /**
989     * Expanded status.
990     */
991    EXPANDED = 1,
992
993    /**
994     * Folded status.
995     */
996    FOLDED = 2
997} Camera_FoldStatus;
998
999/**
1000 * @brief Fold status info.
1001 *
1002 * @since 13
1003 * @version 1.0
1004 */
1005typedef struct Camera_FoldStatusInfo {
1006    /**
1007     * Camera instance list.
1008     */
1009    Camera_Device** supportedCameras;
1010
1011    /**
1012     * Size of camera list.
1013     */
1014    uint32_t cameraSize;
1015
1016    /**
1017     * Current fold status.
1018     */
1019    Camera_FoldStatus foldStatus;
1020} Camera_FoldStatusInfo;
1021
1022/**
1023 * @brief Creates a CameraManager instance.
1024 *
1025 * @param cameraManager the output {@link Camera_Manager} cameraManager will be created
1026 *        if the method call succeeds.
1027 * @return {@link #CAMERA_OK} if the method call succeeds.
1028 *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
1029 *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
1030 * @since 11
1031 */
1032Camera_ErrorCode OH_Camera_GetCameraManager(Camera_Manager** cameraManager);
1033
1034/**
1035 * @brief Delete the CameraManager instance.
1036 *
1037 * @param cameraManager the {@link Camera_Manager} cameraManager instance to be deleted.
1038 * @return {@link #CAMERA_OK} if the method call succeeds.
1039 *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
1040 *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
1041 * @since 11
1042 */
1043Camera_ErrorCode OH_Camera_DeleteCameraManager(Camera_Manager* cameraManager);
1044
1045#ifdef __cplusplus
1046}
1047#endif
1048
1049#endif // NATIVE_INCLUDE_CAMERA_CAMERA_H
1050/** @} */