1 /* 2 * Copyright (c) 2023-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 #ifndef OHOS_CAMERA_MANAGER_IMPL_H 17 #define OHOS_CAMERA_MANAGER_IMPL_H 18 19 #include "kits/native/include/camera/camera.h" 20 #include "kits/native/include/camera/camera_manager.h" 21 #include "input/camera_manager.h" 22 #include "capture_session_impl.h" 23 #include "camera_input_impl.h" 24 #include "preview_output_impl.h" 25 #include "video_output_impl.h" 26 #include "photo_output_impl.h" 27 #include "metadata_output_impl.h" 28 29 struct Camera_Manager { 30 public: 31 Camera_Manager(); 32 ~Camera_Manager(); 33 34 Camera_ErrorCode RegisterCallback(CameraManager_Callbacks* callback); 35 36 Camera_ErrorCode UnregisterCallback(CameraManager_Callbacks* callback); 37 38 Camera_ErrorCode RegisterTorchStatusCallback(OH_CameraManager_TorchStatusCallback torchStatusCallback); 39 40 Camera_ErrorCode UnregisterTorchStatusCallback(OH_CameraManager_TorchStatusCallback torchStatusCallback); 41 42 Camera_ErrorCode GetSupportedCameras(Camera_Device** cameras, uint32_t* size); 43 44 Camera_ErrorCode DeleteSupportedCameras(Camera_Device* cameras, uint32_t size); 45 46 Camera_ErrorCode GetSupportedCameraOutputCapability(const Camera_Device* camera, 47 Camera_OutputCapability** cameraOutputCapability); 48 49 Camera_ErrorCode GetSupportedCameraOutputCapabilityWithSceneMode(const Camera_Device* camera, 50 Camera_SceneMode sceneMode, Camera_OutputCapability** cameraOutputCapability); 51 52 Camera_ErrorCode DeleteSupportedCameraOutputCapability(Camera_OutputCapability* cameraOutputCapability); 53 54 Camera_ErrorCode IsCameraMuted(bool* isCameraMuted); 55 56 Camera_ErrorCode CreateCaptureSession(Camera_CaptureSession** captureSession); 57 58 Camera_ErrorCode CreateCameraInput(const Camera_Device* camera, Camera_Input** cameraInput); 59 60 Camera_ErrorCode CreateCameraInputWithPositionAndType(Camera_Position position, Camera_Type type, 61 Camera_Input** cameraInput); 62 63 Camera_ErrorCode CreatePreviewOutput(const Camera_Profile* profile, const char* surfaceId, 64 Camera_PreviewOutput** previewOutput); 65 66 Camera_ErrorCode CreatePreviewOutputUsedInPreconfig(const char* surfaceId, Camera_PreviewOutput** previewOutput); 67 68 Camera_ErrorCode CreatePhotoOutput(const Camera_Profile* profile, const char* surfaceId, 69 Camera_PhotoOutput** photoOutput); 70 71 Camera_ErrorCode CreatePhotoOutputWithoutSurface(const Camera_Profile* profile, 72 Camera_PhotoOutput** photoOutput); 73 74 Camera_ErrorCode CreatePhotoOutputUsedInPreconfig(const char* surfaceId, Camera_PhotoOutput** photoOutput); 75 76 Camera_ErrorCode CreateVideoOutput(const Camera_VideoProfile* profile, const char* surfaceId, 77 Camera_VideoOutput** videoOutput); 78 79 Camera_ErrorCode CreateVideoOutputUsedInPreconfig(const char* surfaceId, Camera_VideoOutput** videoOutput); 80 81 Camera_ErrorCode CreateMetadataOutput(const Camera_MetadataObjectType* type, 82 Camera_MetadataOutput** metadataOutput); 83 84 Camera_ErrorCode IsTorchSupported(bool* isTorchSupported); 85 86 Camera_ErrorCode IsTorchSupportedByTorchMode(Camera_TorchMode torchMode, bool* isTorchSupported); 87 88 Camera_ErrorCode SetTorchMode(Camera_TorchMode torchMode); 89 90 static Camera_ErrorCode GetCameraOrientation(Camera_Device* cameras, uint32_t* orientation); 91 92 static Camera_ErrorCode GetSupportedSceneModes(Camera_Device* camera, 93 Camera_SceneMode** sceneModes, uint32_t* size); 94 95 Camera_ErrorCode DeleteSceneModes(Camera_SceneMode* sceneModes); 96 97 Camera_ErrorCode RegisterFoldStatusCallback(OH_CameraManager_OnFoldStatusInfoChange foldStatusCallback); 98 99 Camera_ErrorCode UnregisterFoldStatusCallback(OH_CameraManager_OnFoldStatusInfoChange foldStatusCallback); 100 101 private: 102 Camera_ErrorCode GetSupportedPreviewProfiles(Camera_OutputCapability* outCapability, 103 std::vector<OHOS::CameraStandard::Profile> &previewProfiles); 104 105 Camera_ErrorCode GetSupportedPhotoProfiles(Camera_OutputCapability* outCapability, 106 std::vector<OHOS::CameraStandard::Profile> &photoProfiles); 107 108 Camera_ErrorCode GetSupportedVideoProfiles(Camera_OutputCapability* outCapability, 109 std::vector<OHOS::CameraStandard::VideoProfile> &videoProfiles); 110 111 Camera_ErrorCode GetSupportedMetadataTypeList(Camera_OutputCapability* outCapability, 112 std::vector<OHOS::CameraStandard::MetadataObjectType> &metadataTypeList); 113 114 OHOS::sptr<OHOS::CameraStandard::CameraManager> cameraManager_; 115 static thread_local OHOS::sptr<OHOS::Surface> photoSurface_; 116 }; 117 #endif // OHOS_CAMERA_CAPTURE_INPUT_H