• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace OHOS {
23 namespace HDI {
24 namespace Display {
25 namespace Graphic {
26 namespace Common {
27 namespace V1_0 {
28 enum CM_ColorSpaceType : int32_t;
29 }}}}}}
30 
31 namespace OHOS {
32 namespace CameraStandard {
33 
34 using namespace OHOS::HDI::Display::Graphic::Common::V1_0;
35 
36 enum FlashMode {
37     FLASH_MODE_CLOSE = 0,
38     FLASH_MODE_OPEN,
39     FLASH_MODE_AUTO,
40     FLASH_MODE_ALWAYS_OPEN,
41 };
42 
43 enum ExposureMode {
44     EXPOSURE_MODE_UNSUPPORTED = -1,
45     EXPOSURE_MODE_LOCKED = 0,
46     EXPOSURE_MODE_AUTO,
47     EXPOSURE_MODE_CONTINUOUS_AUTO
48 };
49 
50 enum FocusMode {
51     FOCUS_MODE_MANUAL = 0,
52     FOCUS_MODE_CONTINUOUS_AUTO,
53     FOCUS_MODE_AUTO,
54     FOCUS_MODE_LOCKED,
55 };
56 
57 enum BeautyType {
58     AUTO_TYPE = 0,
59     SKIN_SMOOTH = 1,
60     FACE_SLENDER = 2,
61     SKIN_TONE = 3,
62 };
63 
64 enum ColorEffect {
65     COLOR_EFFECT_NORMAL = 0,
66     COLOR_EFFECT_BRIGHT,
67     COLOR_EFFECT_SOFT,
68     COLOR_EFFECT_BLACK_WHITE,
69 };
70 
71 enum PortraitEffect {
72     OFF_EFFECT = 0,
73     CIRCLES = 1,
74     HEART = 2,
75     ROTATED = 3,
76     STUDIO = 4,
77     THEATER = 5,
78 };
79 
80 enum VideoStabilizationMode {
81     OFF = 0,
82     LOW,
83     MIDDLE,
84     HIGH,
85     AUTO
86 };
87 
88 enum ColorSpace {
89     COLOR_SPACE_UNKNOWN = 0,
90     DISPLAY_P3 = 3, // CM_P3_FULL
91     SRGB = 4, // CM_SRGB_FULL
92     BT709 = 6, // CM_BT709_FULL
93     BT2020_HLG = 9, // CM_BT2020_HLG_FULL
94     BT2020_PQ = 10, // CM_BT2020_PQ_FULL
95     P3_HLG = 11, // CM_P3_HLG_FULL
96     P3_PQ = 12, // CM_P3_PQ_FULL
97     DISPLAY_P3_LIMIT = 14, // CM_P3_LIMIT
98     SRGB_LIMIT = 15, // CM_SRGB_LIMIT
99     BT709_LIMIT = 16, // CM_BT709_LIMIT
100     BT2020_HLG_LIMIT = 19, // CM_BT2020_HLG_LIMIT
101     BT2020_PQ_LIMIT = 20, // CM_BT2020_PQ_LIMIT
102     P3_HLG_LIMIT = 21, // CM_P3_HLG_LIMIT
103     P3_PQ_LIMIT = 22 // CM_P3_PQ_LIMIT
104 };
105 
106 extern const std::unordered_map<camera_flash_mode_enum_t, FlashMode> g_metaFlashModeMap_;
107 extern const std::unordered_map<camera_exposure_mode_enum_t, ExposureMode> g_metaExposureModeMap_;
108 extern const std::unordered_map<camera_focus_mode_enum_t, FocusMode> g_metaFocusModeMap_;
109 extern const std::unordered_map<camera_beauty_type_t, BeautyType> g_metaBeautyTypeMap_;
110 extern const std::unordered_map<camera_device_metadata_tag_t, BeautyType> g_metaBeautyAbilityMap_;
111 extern const std::unordered_map<camera_xmage_color_type_t, ColorEffect> g_metaColorEffectMap_;
112 extern const std::unordered_map<CameraVideoStabilizationMode, VideoStabilizationMode> g_metaVideoStabModesMap_;
113 extern const std::unordered_map<camera_portrait_effect_type_t, PortraitEffect> g_metaToFwPortraitEffect_;
114 extern const std::unordered_map<VideoStabilizationMode, CameraVideoStabilizationMode> g_fwkVideoStabModesMap_;
115 extern const std::unordered_map<ExposureMode, camera_exposure_mode_enum_t> g_fwkExposureModeMap_;
116 extern const std::map<CM_ColorSpaceType, ColorSpace> g_metaColorSpaceMap_;
117 extern const std::unordered_map<FocusMode, camera_focus_mode_enum_t> g_fwkFocusModeMap_;
118 extern const std::unordered_map<ColorEffect, camera_xmage_color_type_t> g_fwkColorEffectMap_;
119 extern const std::unordered_map<FlashMode, camera_flash_mode_enum_t> g_fwkFlashModeMap_;
120 extern const std::unordered_map<BeautyType, camera_beauty_type_t> g_fwkBeautyTypeMap_;
121 extern const std::unordered_map<BeautyType, camera_device_metadata_tag_t> g_fwkBeautyAbilityMap_;
122 
123 template <typename S, typename T>
g_transformValidData(const camera_metadata_item_t & item,const std::unordered_map<S,T> & map,std::vector<T> & validModes)124 void g_transformValidData(
125     const camera_metadata_item_t& item, const std::unordered_map<S, T>& map, std::vector<T>& validModes)
126 {
127     for (uint32_t i = 0; i < item.count; i++) {
128         auto it = map.find(static_cast<S>(item.data.u8[i]));
129         if (it != map.end()) {
130             validModes.emplace_back(it->second);
131         }
132     }
133 }
134 } // namespace CameraStandard
135 } // namespace OHOS
136 #endif