1 /* 2 * Copyright (c) 2024-2024 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_CAMERA_ABILITY_H 17 #define OHOS_CAMERA_CAMERA_ABILITY_H 18 19 #include "refbase.h" 20 #include <map> 21 #include <vector> 22 #include <cstdint> 23 #include "ability/camera_ability_const.h" 24 #include "session/capture_scene_const.h" 25 26 namespace OHOS { 27 namespace CameraStandard { 28 29 class CameraAbility : public RefBase { 30 public: 31 CameraAbility() = default; 32 virtual ~CameraAbility() = default; 33 void DumpCameraAbilityInfo(); 34 35 bool HasFlash(); 36 bool IsFlashModeSupported(FlashMode flashMode); 37 std::vector<FlashMode> GetSupportedFlashModes(); 38 bool IsExposureModeSupported(ExposureMode exposureMode); 39 std::vector<ExposureMode> GetSupportedExposureModes(); 40 std::vector<float> GetExposureBiasRange(); 41 std::vector<FocusMode> GetSupportedFocusModes(); 42 bool IsFocusModeSupported(FocusMode focusMode); 43 bool IsFocusRangeTypeSupported(FocusRangeType focusRangeType); 44 bool IsFocusDrivenTypeSupported(FocusDrivenType focusDrivenType); 45 std::vector<float> GetZoomRatioRange(); 46 std::vector<BeautyType> GetSupportedBeautyTypes(); 47 std::vector<int32_t> GetSupportedBeautyRange(BeautyType type); 48 std::vector<ColorEffect> GetSupportedColorEffects(); 49 std::vector<ColorSpace> GetSupportedColorSpaces(); 50 bool IsMacroSupported(); 51 bool IsDepthFusionSupported(); 52 std::vector<float> GetDepthFusionThreshold(); 53 std::vector<PortraitEffect> GetSupportedPortraitEffects(); 54 std::vector<float> GetSupportedVirtualApertures(); 55 std::vector<std::vector<float>> GetSupportedPhysicalApertures(); 56 std::vector<VideoStabilizationMode> GetSupportedStabilizationMode(); 57 bool IsVideoStabilizationModeSupported(VideoStabilizationMode stabilizationMode); 58 std::vector<uint32_t> GetSupportedExposureRange(); 59 bool IsFeatureSupported(SceneFeature sceneFeature); 60 bool IsLcdFlashSupported(); 61 62 std::vector<FlashMode> supportedFlashModes_; 63 std::vector<ExposureMode> supportedExposureModes_; 64 std::vector<float> exposureBiasRange_; 65 std::vector<FocusMode> supportedFocusModes_; 66 std::vector<FocusRangeType> supportedFocusRangeTypes_ = {}; 67 std::vector<FocusDrivenType> supportedFocusDrivenTypes_ = {}; 68 std::vector<BeautyType> supportedBeautyTypes_; 69 std::map<BeautyType, std::vector<int32_t>> supportedBeautyRangeMap_; 70 std::vector<ColorEffect> supportedColorEffects_; 71 std::vector<ColorSpace> supportedColorSpaces_; 72 std::vector<PortraitEffect> supportedPortraitEffects_; 73 std::vector<float> supportedVirtualApertures_; 74 std::vector<std::vector<float>> supportedPhysicalApertures_; 75 std::vector<VideoStabilizationMode> supportedVideoStabilizationMode_; 76 std::vector<uint32_t> supportedExposureRange_; 77 std::vector<SceneFeature> supportedSceneFeature_; 78 bool isLcdFlashSupported_; 79 80 std::optional<std::vector<float>> zoomRatioRange_; 81 std::optional<bool> isMacroSupported_; 82 std::optional<bool> isDepthFusionSupported_; 83 std::optional<std::vector<float>> getDepthFusionThreshold_; 84 }; 85 86 class CaptureSession; 87 class CameraAbilityContainer : public RefBase { 88 public: 89 ~CameraAbilityContainer(); 90 void PrepareSpecMaximumValue(std::vector<sptr<CameraAbility>>& abilities); 91 92 CameraAbilityContainer(std::vector<sptr<CameraAbility>> abilities, 93 std::vector<sptr<CameraAbility>> conflictAbilities, 94 wptr<CaptureSession> session); 95 void FilterByZoomRatio(float zoomRatio); 96 void FilterByMacro(bool enableMacro); 97 std::vector<float> GetZoomRatioRange(); 98 bool IsMacroSupported(); 99 100 private: 101 102 void OnAbilityChange(); 103 104 private: 105 wptr<CaptureSession> session_; 106 std::vector<sptr<CameraAbility>> conflictAbilities_; 107 108 bool IsMacroSupportedInSpec_ = false; 109 std::vector<float> zoomRatioRangeInSpec_; 110 111 std::optional<std::vector<float>> lastGetZoomRatioRange_; 112 std::optional<bool> lastIsMacroSupported_; 113 114 std::optional<float> zoomRatioSet_; 115 std::optional<bool> enableMacroSet_; 116 }; 117 } // namespace CameraStandard 118 } // namespace OHOS 119 #endif // OHOS_CAMERA_CAMERA_ABILITY_H