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 CAMERA_ABILITY_CONST_H
17 #define CAMERA_ABILITY_CONST_H
18
19 #include <cstdint>
20 #include <map>
21 #include "camera_metadata_operator.h"
22 #include "camera_types.h"
23 namespace OHOS {
24 namespace HDI {
25 namespace Display {
26 namespace Graphic {
27 namespace Common {
28 namespace V1_0 {
29 enum CM_ColorSpaceType : int32_t;
30 }}}}}}
31
32 namespace OHOS {
33 namespace HDI {
34 namespace Camera {
35 namespace V1_3 {
36 enum OperationMode : int32_t;
37 }}}}
38
39 namespace OHOS {
40 namespace CameraStandard {
41 enum SceneMode : int32_t;
42 enum class MetadataObjectType : int32_t;
43
44 using namespace OHOS::HDI::Display::Graphic::Common::V1_0;
45
46 enum FlashMode {
47 FLASH_MODE_CLOSE = 0,
48 FLASH_MODE_OPEN,
49 FLASH_MODE_AUTO,
50 FLASH_MODE_ALWAYS_OPEN,
51 };
52
53 enum ExposureMode {
54 EXPOSURE_MODE_UNSUPPORTED = -1,
55 EXPOSURE_MODE_LOCKED = 0,
56 EXPOSURE_MODE_AUTO,
57 EXPOSURE_MODE_CONTINUOUS_AUTO
58 };
59
60 enum FocusMode {
61 FOCUS_MODE_MANUAL = 0,
62 FOCUS_MODE_CONTINUOUS_AUTO,
63 FOCUS_MODE_AUTO,
64 FOCUS_MODE_LOCKED,
65 };
66
67 enum QualityPrioritization {
68 HIGH_QUALITY = 0,
69 POWER_BALANCE,
70 };
71
72 enum BeautyType {
73 AUTO_TYPE = 0,
74 SKIN_SMOOTH = 1,
75 FACE_SLENDER = 2,
76 SKIN_TONE = 3,
77 };
78
79 enum ColorEffect {
80 COLOR_EFFECT_NORMAL = 0,
81 COLOR_EFFECT_BRIGHT,
82 COLOR_EFFECT_SOFT,
83 COLOR_EFFECT_BLACK_WHITE,
84 };
85
86 enum PortraitEffect {
87 OFF_EFFECT = 0,
88 CIRCLES = 1,
89 HEART = 2,
90 ROTATED = 3,
91 STUDIO = 4,
92 THEATER = 5,
93 };
94
95 enum VideoStabilizationMode {
96 OFF = 0,
97 LOW,
98 MIDDLE,
99 HIGH,
100 AUTO
101 };
102
103 enum ColorSpace {
104 COLOR_SPACE_UNKNOWN = 0,
105 DISPLAY_P3 = 3, // CM_P3_FULL
106 SRGB = 4, // CM_SRGB_FULL
107 BT709 = 6, // CM_BT709_FULL
108 BT2020_HLG = 9, // CM_BT2020_HLG_FULL
109 BT2020_PQ = 10, // CM_BT2020_PQ_FULL
110 P3_HLG = 11, // CM_P3_HLG_FULL
111 P3_PQ = 12, // CM_P3_PQ_FULL
112 DISPLAY_P3_LIMIT = 14, // CM_P3_LIMIT
113 SRGB_LIMIT = 15, // CM_SRGB_LIMIT
114 BT709_LIMIT = 16, // CM_BT709_LIMIT
115 BT2020_HLG_LIMIT = 19, // CM_BT2020_HLG_LIMIT
116 BT2020_PQ_LIMIT = 20, // CM_BT2020_PQ_LIMIT
117 P3_HLG_LIMIT = 21, // CM_P3_HLG_LIMIT
118 P3_PQ_LIMIT = 22 // CM_P3_PQ_LIMIT
119 };
120
121 enum class PortraitThemeType {
122 NATURAL = 0,
123 DELICATE,
124 STYLISH
125 };
126
127 enum class VideoRotation {
128 ROTATION_0 = 0,
129 ROTATION_90 = 90,
130 ROTATION_180 = 180,
131 ROTATION_270 = 270
132 };
133
134 enum FocusRangeType {
135 FOCUS_RANGE_TYPE_AUTO = 0,
136 FOCUS_RANGE_TYPE_NEAR
137 };
138
139 enum FocusDrivenType {
140 FOCUS_DRIVEN_TYPE_AUTO = 0,
141 FOCUS_DRIVEN_TYPE_FACE
142 };
143
144 enum ColorReservationType {
145 COLOR_RESERVATION_TYPE_NONE = 0,
146 COLOR_RESERVATION_TYPE_PORTRAIT
147 };
148
149 enum FlashStatus {
150 FLASH_STATUS_OFF = 0,
151 FLASH_STATUS_ON,
152 FLASH_STATUS_UNAVAILABLE
153 };
154
155 enum CameraStatus {
156 CAMERA_STATUS_APPEAR = 0,
157 CAMERA_STATUS_DISAPPEAR,
158 CAMERA_STATUS_AVAILABLE,
159 CAMERA_STATUS_UNAVAILABLE,
160 CAMERA_SERVER_UNAVAILABLE
161 };
162
163 extern const std::unordered_map<camera_flash_mode_enum_t, FlashMode> g_metaFlashModeMap_;
164 extern const std::unordered_map<camera_exposure_mode_enum_t, ExposureMode> g_metaExposureModeMap_;
165 extern const std::unordered_map<camera_focus_mode_enum_t, FocusMode> g_metaFocusModeMap_;
166 extern const std::unordered_map<camera_beauty_type_t, BeautyType> g_metaBeautyTypeMap_;
167 extern const std::unordered_map<camera_device_metadata_tag_t, BeautyType> g_metaBeautyAbilityMap_;
168 extern const std::unordered_map<camera_xmage_color_type_t, ColorEffect> g_metaColorEffectMap_;
169 extern const std::unordered_map<CameraVideoStabilizationMode, VideoStabilizationMode> g_metaVideoStabModesMap_;
170 extern const std::unordered_map<camera_portrait_effect_type_t, PortraitEffect> g_metaToFwPortraitEffect_;
171 extern const std::unordered_map<VideoStabilizationMode, CameraVideoStabilizationMode> g_fwkVideoStabModesMap_;
172 extern const std::unordered_map<ExposureMode, camera_exposure_mode_enum_t> g_fwkExposureModeMap_;
173 extern const std::map<CM_ColorSpaceType, ColorSpace> g_metaColorSpaceMap_;
174 extern const std::unordered_map<FocusMode, camera_focus_mode_enum_t> g_fwkFocusModeMap_;
175 extern const std::unordered_map<ColorEffect, camera_xmage_color_type_t> g_fwkColorEffectMap_;
176 extern const std::unordered_map<FlashMode, camera_flash_mode_enum_t> g_fwkFlashModeMap_;
177 extern const std::unordered_map<BeautyType, camera_beauty_type_t> g_fwkBeautyTypeMap_;
178 extern const std::unordered_map<BeautyType, camera_device_metadata_tag_t> g_fwkBeautyAbilityMap_;
179 extern const std::unordered_map<PortraitThemeType, CameraPortraitThemeTypes> g_fwkPortraitThemeTypeMap_;
180 extern const std::unordered_map<CameraPortraitThemeTypes, PortraitThemeType> g_metaPortraitThemeTypeMap_;
181 extern const std::vector<VideoRotation> g_fwkVideoRotationVector_;
182 extern const std::unordered_map<CameraQualityPrioritization, QualityPrioritization> g_metaQualityPrioritizationMap_;
183 extern const std::unordered_map<QualityPrioritization, CameraQualityPrioritization> g_fwkQualityPrioritizationMap_;
184 extern const std::unordered_map<OHOS::HDI::Camera::V1_3::OperationMode, SceneMode> g_metaToFwSupportedMode_;
185 extern const std::unordered_map<SceneMode, OHOS::HDI::Camera::V1_3::OperationMode> g_fwToMetaSupportedMode_;
186 extern const std::unordered_map<StatisticsDetectType, MetadataObjectType> g_metaToFwCameraMetaDetect_;
187 extern const std::unordered_map<camera_focus_range_type_t, FocusRangeType> g_metaFocusRangeTypeMap_;
188 extern const std::unordered_map<FocusRangeType, camera_focus_range_type_t> g_fwkocusRangeTypeMap_;
189 extern const std::unordered_map<camera_focus_driven_type_t, FocusDrivenType> g_metaFocusDrivenTypeMap_;
190 extern const std::unordered_map<FocusDrivenType, camera_focus_driven_type_t> g_fwkFocusDrivenTypeMap_;
191 extern const std::unordered_map<camera_color_reservation_type_t, ColorReservationType> g_metaColorReservationTypeMap_;
192 extern const std::unordered_map<ColorReservationType, camera_color_reservation_type_t> g_fwkColorReservationTypeMap_;
193
194 template <typename S, typename T>
g_transformValidData(const camera_metadata_item_t & item,const std::unordered_map<S,T> & map,std::vector<T> & validModes)195 void g_transformValidData(
196 const camera_metadata_item_t& item, const std::unordered_map<S, T>& map, std::vector<T>& validModes)
197 {
198 for (uint32_t i = 0; i < item.count; i++) {
199 auto it = map.find(static_cast<S>(item.data.u8[i]));
200 if (it != map.end()) {
201 validModes.emplace_back(it->second);
202 }
203 }
204 }
205 } // namespace CameraStandard
206 } // namespace OHOS
207 #endif