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 #ifndef CAMERA_ABILITY_PARSE_UTIL_H 16 #define CAMERA_ABILITY_PARSE_UTIL_H 17 18 #include <queue> 19 #include <vector> 20 #include <iostream> 21 #include <utility> 22 #include <variant> 23 #include <cstdint> 24 #include <memory> 25 #include <cstdint> 26 #include "metadata_utils.h" 27 #include <algorithm> 28 29 namespace OHOS { 30 namespace CameraStandard { 31 32 using namespace std; 33 34 typedef struct ProfileDetailInfo { 35 uint32_t format; 36 uint32_t width; 37 uint32_t height; 38 uint32_t fixedFps; 39 uint32_t minFps; 40 uint32_t maxFps; 41 std::vector<uint32_t> abilityIds; 42 } ProfileDetailInfo; 43 44 typedef struct StreamInfo { 45 int32_t streamType; 46 std::vector<ProfileDetailInfo> detailInfos; 47 } StreamInfo; 48 49 typedef struct SpecInfo { 50 int32_t specId; 51 std::vector<StreamInfo> streamInfos; 52 } SpecInfo; 53 54 typedef struct ProfileLevelInfo { 55 std::vector<SpecInfo> specInfos; 56 } ProfileLevelInfo; 57 58 typedef struct ConflictConfigInfo { 59 int32_t cid; 60 std::vector<std::pair<uint32_t, uint32_t>> tagInfos; 61 } ConflictConfigInfo; 62 63 typedef struct ConflictConfig { 64 std::vector<ConflictConfigInfo> configInfos; 65 } ConflictConfig; 66 67 typedef struct AvailableConfigInfo { 68 int32_t specId; 69 std::vector<uint32_t> tagIds; 70 } AvailableConfigInfo; 71 72 typedef struct AvailableConfig { 73 std::vector<AvailableConfigInfo> configInfos; 74 } AvailableConfig; 75 76 const int32_t MODE_END = -1; 77 const int32_t SPEC_END = -1; 78 const int32_t STREAM_END = -1; 79 const int32_t DETAIL_END = -1; 80 const int32_t INFO_END = -1; 81 const int32_t TAG_END = -1; 82 const int32_t STEP_ONE = 1; 83 const int32_t STEP_TWO = 2; 84 const int32_t STEP_THREE = 3; 85 const int32_t STEP_FOUR = 4; 86 87 class CameraAbilityParseUtil { 88 public: 89 static void GetModeInfo( 90 const int32_t modeName, const camera_metadata_item_t& item, ProfileLevelInfo& modeInfo); 91 static void GetAvailableConfiguration( 92 const int32_t modeName, common_metadata_header_t* metadata, AvailableConfig& availableConfig); 93 static void GetConflictConfiguration( 94 const int32_t modeName, common_metadata_header_t* metadata, ConflictConfig& conflictConfig); 95 static void GetAbilityInfo(const int32_t modeName, common_metadata_header_t* metadata, uint32_t tagId, 96 std::map<int32_t, std::vector<int32_t>>& infoMap); 97 98 private: 99 static void GetInfo( 100 int32_t* originInfo, uint32_t start, uint32_t end, std::map<int32_t, std::vector<int32_t>>& infoMap); 101 static void GetSpecInfo(int32_t* originInfo, uint32_t start, uint32_t end, ProfileLevelInfo& modeInfo); 102 static void GetStreamInfo(int32_t* originInfo, uint32_t start, uint32_t end, SpecInfo& specInfo); 103 static void GetDetailInfo(int32_t* originInfo, uint32_t start, uint32_t end, StreamInfo& streamInfo); 104 static void GetAvailableConfigInfo( 105 int32_t* originInfo, uint32_t start, uint32_t end, AvailableConfig& availableConfig); 106 static void GetConflictConfigInfo( 107 int32_t* originInfo, uint32_t start, uint32_t end, ConflictConfig& conflictConfig); 108 }; 109 } // namespace CameraStandard 110 } // namespace OHOS 111 #endif // CAMERA_ABILITY_PARSE_UTIL_H