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 * @syscap SystemCapability.Multimedia.Camera.Core 35 * @since 11 36 * @version 1.0 37 */ 38 39 #ifndef NATIVE_INCLUDE_CAMERA_CAMERA_H 40 #define NATIVE_INCLUDE_CAMERA_CAMERA_H 41 42 #include <stdint.h> 43 #include <stdio.h> 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /** 50 * @brief camera manager object. 51 * 52 * A pointer can be created using {@link OH_Camera_GetCameraManager} method. 53 * 54 * @since 11 55 * @version 1.0 56 */ 57 typedef struct Camera_Manager Camera_Manager; 58 59 /** 60 * @brief Enum for camera error code. 61 * 62 * @since 11 63 * @version 1.0 64 */ 65 typedef enum Camera_ErrorCode { 66 /** 67 * Camera result is ok. 68 */ 69 CAMERA_OK = 0, 70 71 /** 72 * Parameter missing or parameter type incorrect. 73 */ 74 CAMERA_INVALID_ARGUMENT = 7400101, 75 76 /** 77 * Operation not allowed. 78 */ 79 CAMERA_OPERATION_NOT_ALLOWED = 7400102, 80 81 /** 82 * Session not config. 83 */ 84 CAMERA_SESSION_NOT_CONFIG = 7400103, 85 86 /** 87 * Session not running. 88 */ 89 CAMERA_SESSION_NOT_RUNNING = 7400104, 90 91 /** 92 * Session config locked. 93 */ 94 CAMERA_SESSION_CONFIG_LOCKED = 7400105, 95 96 /** 97 * Device setting locked. 98 */ 99 CAMERA_DEVICE_SETTING_LOCKED = 7400106, 100 101 /** 102 * Can not use camera cause of conflict. 103 */ 104 CAMERA_CONFLICT_CAMERA = 7400107, 105 106 /** 107 * Camera disabled cause of security reason. 108 */ 109 CAMERA_DEVICE_DISABLED = 7400108, 110 111 /** 112 * Can not use camera cause of preempted. 113 */ 114 CAMERA_DEVICE_PREEMPTED = 7400109, 115 116 /** 117 * Camera service fatal error. 118 */ 119 CAMERA_SERVICE_FATAL_ERROR = 7400201 120 } Camera_ErrorCode; 121 122 /** 123 * @brief Enum for camera status. 124 * 125 * @since 11 126 * @version 1.0 127 */ 128 typedef enum Camera_Status { 129 /** 130 * Appear status. 131 */ 132 CAMERA_STATUS_APPEAR = 0, 133 134 /** 135 * Disappear status. 136 */ 137 CAMERA_STATUS_DISAPPEAR = 1, 138 139 /** 140 * Available status. 141 */ 142 CAMERA_STATUS_AVAILABLE = 2, 143 144 /** 145 * Unavailable status. 146 */ 147 CAMERA_STATUS_UNAVAILABLE = 3 148 } Camera_Status; 149 150 /** 151 * @brief Enum for camera position. 152 * 153 * @since 11 154 * @version 1.0 155 */ 156 typedef enum Camera_Position { 157 /** 158 * Unspecified position. 159 */ 160 CAMERA_POSITION_UNSPECIFIED = 0, 161 162 /** 163 * Back position. 164 */ 165 CAMERA_POSITION_BACK = 1, 166 167 /** 168 * Front position. 169 */ 170 CAMERA_POSITION_FRONT = 2 171 } Camera_Position; 172 173 /** 174 * @brief Enum for camera type. 175 * 176 * @since 11 177 * @version 1.0 178 */ 179 typedef enum Camera_Type { 180 /** 181 * Default camera type. 182 */ 183 CAMERA_TYPE_DEFAULT = 0, 184 185 /** 186 * Wide camera. 187 */ 188 CAMERA_TYPE_WIDE_ANGLE = 1, 189 190 /** 191 * Ultra wide camera. 192 */ 193 CAMERA_TYPE_ULTRA_WIDE = 2, 194 195 /** 196 * Telephoto camera. 197 */ 198 CAMERA_TYPE_TELEPHOTO = 3, 199 200 /** 201 * True depth camera. 202 */ 203 CAMERA_TYPE_TRUE_DEPTH = 4 204 } Camera_Type; 205 206 /** 207 * @brief Enum for camera connection type. 208 * 209 * @since 11 210 * @version 1.0 211 */ 212 typedef enum Camera_Connection { 213 /** 214 * Built-in camera. 215 */ 216 CAMERA_CONNECTION_BUILT_IN = 0, 217 218 /** 219 * Camera connected using USB. 220 */ 221 CAMERA_CONNECTION_USB_PLUGIN = 1, 222 223 /** 224 * Remote camera. 225 */ 226 CAMERA_CONNECTION_REMOTE = 2 227 } Camera_Connection; 228 229 /** 230 * @brief Enum for camera format type. 231 * 232 * @since 11 233 * @version 1.0 234 */ 235 typedef enum Camera_Format { 236 /** 237 * RGBA 8888 Format. 238 */ 239 CAMERA_FORMAT_RGBA_8888 = 3, 240 241 /** 242 * YUV 420 Format. 243 */ 244 CAMERA_FORMAT_YUV_420_SP = 1003, 245 246 /** 247 * JPEG Format. 248 */ 249 CAMERA_FORMAT_JPEG = 2000 250 } Camera_Format; 251 252 /** 253 * @brief Enum for flash mode. 254 * 255 * @since 11 256 * @version 1.0 257 */ 258 typedef enum Camera_FlashMode { 259 /** 260 * Close mode. 261 */ 262 FLASH_MODE_CLOSE = 0, 263 264 /** 265 * Open mode. 266 */ 267 FLASH_MODE_OPEN = 1, 268 269 /** 270 * Auto mode. 271 */ 272 FLASH_MODE_AUTO = 2, 273 274 /** 275 * Always open mode. 276 */ 277 FLASH_MODE_ALWAYS_OPEN = 3 278 } Camera_FlashMode; 279 280 /** 281 * @brief Enum for exposure mode. 282 * 283 * @since 11 284 * @version 1.0 285 */ 286 typedef enum Camera_ExposureMode { 287 /** 288 * Lock exposure mode. 289 */ 290 EXPOSURE_MODE_LOCKED = 0, 291 292 /** 293 * Auto exposure mode. 294 */ 295 EXPOSURE_MODE_AUTO = 1, 296 297 /** 298 * Continuous automatic exposure. 299 */ 300 EXPOSURE_MODE_CONTINUOUS_AUTO = 2 301 } Camera_ExposureMode; 302 303 /** 304 * @brief Enum for focus mode. 305 * 306 * @since 11 307 * @version 1.0 308 */ 309 typedef enum Camera_FocusMode { 310 /** 311 * Manual mode. 312 */ 313 FOCUS_MODE_MANUAL = 0, 314 315 /** 316 * Continuous auto mode. 317 */ 318 FOCUS_MODE_CONTINUOUS_AUTO = 1, 319 320 /** 321 * Auto mode. 322 */ 323 FOCUS_MODE_AUTO = 2, 324 325 /** 326 * Locked mode. 327 */ 328 FOCUS_MODE_LOCKED = 3 329 } Camera_FocusMode; 330 331 /** 332 * @brief Enum for focus state. 333 * 334 * @since 11 335 * @version 1.0 336 */ 337 typedef enum Camera_FocusState { 338 /** 339 * Scan state. 340 */ 341 FOCUS_STATE_SCAN = 0, 342 343 /** 344 * Focused state. 345 */ 346 FOCUS_STATE_FOCUSED = 1, 347 348 /** 349 * Unfocused state. 350 */ 351 FOCUS_STATE_UNFOCUSED = 2 352 } Camera_FocusState; 353 354 /** 355 * @brief Enum for video stabilization mode. 356 * 357 * @since 11 358 * @version 1.0 359 */ 360 typedef enum Camera_VideoStabilizationMode { 361 /** 362 * Turn off video stablization. 363 */ 364 STABILIZATION_MODE_OFF = 0, 365 366 /** 367 * LOW mode provides basic stabilization effect. 368 */ 369 STABILIZATION_MODE_LOW = 1, 370 371 /** 372 * MIDDLE mode means algorithms can achieve better effects than LOW mode. 373 */ 374 STABILIZATION_MODE_MIDDLE = 2, 375 376 /** 377 * HIGH mode means algorithms can achieve better effects than MIDDLE mode. 378 */ 379 STABILIZATION_MODE_HIGH = 3, 380 381 /** 382 * Camera HDF can select mode automatically. 383 */ 384 STABILIZATION_MODE_AUTO = 4 385 } Camera_VideoStabilizationMode; 386 387 /** 388 * @brief Enum for the image rotation angles. 389 * 390 * @since 11 391 * @version 1.0 392 */ 393 typedef enum Camera_ImageRotation { 394 /** 395 * The capture image rotates 0 degrees. 396 */ 397 IAMGE_ROTATION_0 = 0, 398 399 /** 400 * The capture image rotates 90 degrees. 401 */ 402 IAMGE_ROTATION_90 = 90, 403 404 /** 405 * The capture image rotates 180 degrees. 406 */ 407 IAMGE_ROTATION_180 = 180, 408 409 /** 410 * The capture image rotates 270 degrees. 411 */ 412 IAMGE_ROTATION_270 = 270 413 } Camera_ImageRotation; 414 415 /** 416 * @brief Enum for the image quality levels. 417 * 418 * @since 11 419 * @version 1.0 420 */ 421 typedef enum Camera_QualityLevel { 422 /** 423 * High image quality. 424 */ 425 QUALITY_LEVEL_HIGH = 0, 426 427 /** 428 * Medium image quality. 429 */ 430 QUALITY_LEVEL_MEDIUM = 1, 431 432 /** 433 * Low image quality. 434 */ 435 QUALITY_LEVEL_LOW = 2 436 } Camera_QualityLevel; 437 438 /** 439 * @brief Enum for metadata object type. 440 * 441 * @since 11 442 * @version 1.0 443 */ 444 typedef enum Camera_MetadataObjectType { 445 /** 446 * Face detection. 447 */ 448 FACE_DETECTION = 0 449 } Camera_MetadataObjectType; 450 451 /** 452 * @brief Size parameter. 453 * 454 * @since 11 455 * @version 1.0 456 */ 457 typedef struct Camera_Size { 458 /** 459 * Width. 460 */ 461 uint32_t width; 462 463 /** 464 * Height. 465 */ 466 uint32_t height; 467 } Camera_Size; 468 469 /** 470 * @brief Profile for camera streams. 471 * 472 * @since 11 473 * @version 1.0 474 */ 475 typedef struct Camera_Profile { 476 /** 477 * Camera format. 478 */ 479 Camera_Format format; 480 481 /** 482 * Picture size. 483 */ 484 Camera_Size size; 485 } Camera_Profile; 486 487 /** 488 * @brief Frame rate range. 489 * 490 * @since 11 491 * @version 1.0 492 */ 493 typedef struct Camera_FrameRateRange { 494 /** 495 * Min frame rate. 496 */ 497 uint32_t min; 498 499 /** 500 * Max frame rate. 501 */ 502 uint32_t max; 503 } Camera_FrameRateRange; 504 505 /** 506 * @brief Video profile. 507 * 508 * @since 11 509 * @version 1.0 510 */ 511 typedef struct Camera_VideoProfile { 512 /** 513 * Camera format. 514 */ 515 Camera_Format format; 516 517 /** 518 * Picture size. 519 */ 520 Camera_Size size; 521 522 /** 523 * Frame rate in unit fps (frames per second). 524 */ 525 Camera_FrameRateRange range; 526 } Camera_VideoProfile; 527 528 /** 529 * @brief Camera output capability. 530 * 531 * @since 11 532 * @version 1.0 533 */ 534 typedef struct Camera_OutputCapability { 535 /** 536 * Preview profiles list. 537 */ 538 Camera_Profile** previewProfiles; 539 540 /** 541 * Size of preview profiles list. 542 */ 543 uint32_t previewProfilesSize; 544 545 /** 546 * Photo profiles list. 547 */ 548 Camera_Profile** photoProfiles; 549 550 /** 551 * Size of photo profiles list. 552 */ 553 uint32_t photoProfilesSize; 554 555 /** 556 * Video profiles list. 557 */ 558 Camera_VideoProfile** videoProfiles; 559 560 /** 561 * Size of video profiles list. 562 */ 563 uint32_t videoProfilesSize; 564 565 /** 566 * Metadata object types list. 567 */ 568 Camera_MetadataObjectType** supportedMetadataObjectTypes; 569 570 /** 571 * Size of metadata object types list. 572 */ 573 uint32_t metadataProfilesSize; 574 } Camera_OutputCapability; 575 576 /** 577 * @brief Camera device object. 578 * 579 * @since 11 580 * @version 1.0 581 */ 582 typedef struct Camera_Device { 583 /** 584 * Camera id attribute. 585 */ 586 char* cameraId; 587 588 /** 589 * Camera position attribute. 590 */ 591 Camera_Position cameraPosition; 592 593 /** 594 * Camera type attribute. 595 */ 596 Camera_Type cameraType; 597 598 /** 599 * Camera connection type attribute. 600 */ 601 Camera_Connection connectionType; 602 } Camera_Device; 603 604 /** 605 * @brief Camera status info. 606 * 607 * @since 11 608 * @version 1.0 609 */ 610 typedef struct Camera_StatusInfo { 611 /** 612 * Camera instance. 613 */ 614 Camera_Device* camera; 615 616 /** 617 * Current camera status. 618 */ 619 Camera_Status status; 620 } Camera_StatusInfo; 621 622 /** 623 * @brief Point parameter. 624 * 625 * @since 11 626 * @version 1.0 627 */ 628 typedef struct Camera_Point { 629 /** 630 * X co-ordinate. 631 */ 632 double x; 633 634 /** 635 * Y co-ordinate. 636 */ 637 double y; 638 } Camera_Point; 639 640 /** 641 * @brief Photo capture location. 642 * 643 * @since 11 644 * @version 1.0 645 */ 646 typedef struct Camera_Location { 647 /** 648 * Latitude. 649 */ 650 double latitude; 651 652 /** 653 * Longitude. 654 */ 655 double longitude; 656 657 /** 658 * Altitude. 659 */ 660 double altitude; 661 } Camera_Location; 662 663 /** 664 * @brief Photo capture options to set. 665 * 666 * @since 11 667 * @version 1.0 668 */ 669 typedef struct Camera_PhotoCaptureSetting { 670 /** 671 * Photo image quality. 672 */ 673 Camera_QualityLevel quality; 674 675 /** 676 * Photo rotation. 677 */ 678 Camera_ImageRotation rotation; 679 680 /** 681 * Photo location. 682 */ 683 Camera_Location* location; 684 685 /** 686 * Set the mirror photo function switch, default to false. 687 */ 688 bool mirror; 689 } Camera_PhotoCaptureSetting; 690 691 /** 692 * @brief Frame shutter callback info. 693 * 694 * @since 11 695 * @version 1.0 696 */ 697 typedef struct Camera_FrameShutterInfo { 698 /** 699 * Capture id. 700 */ 701 int32_t captureId; 702 703 /** 704 * Timestamp for frame. 705 */ 706 uint64_t timestamp; 707 } Camera_FrameShutterInfo; 708 709 /** 710 * @brief Capture end info. 711 * 712 * @since 11 713 * @version 1.0 714 */ 715 typedef struct Camera_CaptureEndInfo { 716 /** 717 * Capture id. 718 */ 719 int32_t captureId; 720 721 /** 722 * Frame count. 723 */ 724 int64_t frameCount; 725 } Camera_CaptureEndInfo; 726 727 /** 728 * @brief Rectangle definition. 729 * 730 * @since 11 731 * @version 1.0 732 */ 733 typedef struct Camera_Rect { 734 /** 735 * X coordinator of top left point. 736 */ 737 int32_t topLeftX; 738 739 /** 740 * Y coordinator of top left point. 741 */ 742 int32_t topLeftY; 743 744 /** 745 * Width of this rectangle. 746 */ 747 int32_t width; 748 749 /** 750 * Height of this rectangle. 751 */ 752 int32_t height; 753 } Camera_Rect; 754 755 /** 756 * @brief Metadata object basis. 757 * 758 * @since 11 759 * @version 1.0 760 */ 761 typedef struct Camera_MetadataObject { 762 /** 763 * Metadata object type. 764 */ 765 Camera_MetadataObjectType type; 766 767 /** 768 * Metadata object timestamp in milliseconds. 769 */ 770 int64_t timestamp; 771 772 /** 773 * The axis-aligned bounding box of detected metadata object. 774 */ 775 Camera_Rect* boundingBox; 776 } Camera_MetadataObject; 777 778 /** 779 * @brief Creates a CameraManager instance. 780 * 781 * @param cameraManager the output {@link Camera_Manager} cameraManager will be created 782 * if the method call succeeds. 783 * @return {@link #CAMERA_OK} if the method call succeeds. 784 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 785 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 786 * @since 11 787 */ 788 Camera_ErrorCode OH_Camera_GetCameraManager(Camera_Manager** cameraManager); 789 790 /** 791 * @brief Delete the CameraManager instance. 792 * 793 * @param cameraManager the {@link Camera_Manager} cameraManager instance to be deleted. 794 * @return {@link #CAMERA_OK} if the method call succeeds. 795 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 796 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 797 * @since 11 798 */ 799 Camera_ErrorCode OH_Camera_DeleteCameraManager(Camera_Manager* cameraManager); 800 801 802 #ifdef __cplusplus 803 } 804 #endif 805 806 #endif // NATIVE_INCLUDE_CAMERA_CAMERA_H 807 /** @} */