• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_METADATA_COMMON_UTILS_H
17 #define OHOS_CAMERA_METADATA_COMMON_UTILS_H
18 
19 #include <cstdint>
20 #include "camera_metadata_operator.h"
21 #include "camera_output_capability.h"
22 #include "camera_stream_info_parse.h"
23 #include "output/metadata_output.h"
24 #include "metadata_utils.h"
25 #include "camera_metadata.h"
26 
27 namespace OHOS {
28 namespace CameraStandard {
29 enum RectBoxType {
30     RECT_CAMERA = 0,
31     RECT_MECH
32 };
33 class MetadataCommonUtils {
34 private:
35     explicit MetadataCommonUtils() = default;
36 
37     static void GetMetadataResults(const common_metadata_header_t *metadata,
38         std::vector<camera_metadata_item_t>& metadataResults, std::vector<uint32_t>& metadataTypes);
39 
40     static int32_t ProcessMetaObjects(const int32_t streamId, std::vector<sptr<MetadataObject>>& metaObjects,
41                                             const std::vector<camera_metadata_item_t>& metadataItem,
42                                             const std::vector<uint32_t>& metadataTypes,
43                                             bool isNeedMirror, bool isNeedFlip, RectBoxType rectBoxType);
44 
45     static void GenerateObjects(const camera_metadata_item_t &metadataItem, MetadataObjectType metadataType,
46 								    std::vector<sptr<MetadataObject>> &metaObjects,
47 									bool isNeedMirror, bool isNeedFlip, RectBoxType rectBoxType);
48 
49     static void ProcessBaseInfo(sptr<MetadataObjectFactory> factoryPtr, const camera_metadata_item_t &metadataItem,
50                                         int32_t &index, MetadataObjectType typeFromHal, bool isNeedMirror,
51                                         bool isNeedFlip, RectBoxType rectBoxType);
52 
53     static void ProcessExternInfo(sptr<MetadataObjectFactory> factoryPtr,
54                                         const camera_metadata_item_t &metadataItem, int32_t &index,
55                                         MetadataObjectType typeFromHal, bool isNeedMirror, bool isNeedFlip,
56                                         RectBoxType rectBoxType);
57 
58     static void ProcessHumanFaceDetectInfo(sptr<MetadataObjectFactory> factoryPtr,
59                                                     const camera_metadata_item_t &metadataItem, int32_t &index,
60                                                     bool isNeedMirror, bool isNeedFlip, RectBoxType rectBoxType);
61 
62     static void ProcessCatFaceDetectInfo(sptr<MetadataObjectFactory> factoryPtr,
63                                                 const camera_metadata_item_t &metadataItem, int32_t &index,
64                                                 bool isNeedMirror, bool isNeedFlip, RectBoxType rectBoxType);
65 
66     static void ProcessDogFaceDetectInfo(sptr<MetadataObjectFactory> factoryPtr,
67                                                 const camera_metadata_item_t &metadataItem, int32_t &index,
68                                                 bool isNeedMirror, bool isNeedFlip, RectBoxType rectBoxType);
69 
70     static Rect ProcessRectBox(int32_t offsetTopLeftX, int32_t offsetTopLeftY,
71         int32_t offsetBottomRightX, int32_t offsetBottomRightY, bool isNeedMirror, bool isNeedFlip,
72         RectBoxType rectBoxType);
73 
74     static Rect ProcessCameraRectBox(int32_t offsetTopLeftX, int32_t offsetTopLeftY,
75         int32_t offsetBottomRightX, int32_t offsetBottomRightY, bool isNeedMirror, bool isNeedFlip);
76 
77     static Rect ProcessMechRectBox(int32_t offsetTopLeftX, int32_t offsetTopLeftY,
78         int32_t offsetBottomRightX, int32_t offsetBottomRightY);
79 public:
80     static std::shared_ptr<camera_metadata_item_t> GetCapabilityEntry(
81         const std::shared_ptr<OHOS::Camera::CameraMetadata> metadata, uint32_t metadataTag);
82 
83     static std::shared_ptr<vector<Size>> GetSupportedPreviewSizeRange(const int32_t modeName,
84         camera_format_t targetFormat, const std::shared_ptr<OHOS::Camera::CameraMetadata> metadata);
85 
86     static std::shared_ptr<OHOS::Camera::CameraMetadata> CopyMetadata(
87         const std::shared_ptr<OHOS::Camera::CameraMetadata> srcMetadata);
88 
89     static bool ProcessFocusTrackingModeInfo(const std::shared_ptr<OHOS::Camera::CameraMetadata>& metadata,
90         FocusTrackingMode& mode);
91 
92     static bool ProcessMetaObjects(const int32_t streamId, const std::shared_ptr<OHOS::Camera::CameraMetadata>& result,
93         std::vector<sptr<MetadataObject>> &metaObjects, bool isNeedMirror, bool isNeedFlip, RectBoxType rectBoxType);
94 };
95 
96 std::vector<float> ParsePhysicalApertureRangeByMode(const camera_metadata_item_t &item, const int32_t modeName);
97 
98 } // namespace CameraStandard
99 } // namespace OHOS
100 #endif // OHOS_CAMERA_METADATA_COMMON_UTILS_H