1 /* 2 * Copyright (c) 2023-2025 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_ROTATE_STRATEGY_PARSER_H 17 #define CAMERA_ROTATE_STRATEGY_PARSER_H 18 19 #include <unordered_map> 20 #include <string> 21 #include <sstream> 22 23 #include "camera_log.h" 24 #include "parser.h" 25 #include "camera_xml_parser.h" 26 27 namespace OHOS { 28 namespace CameraStandard { 29 using namespace std; 30 struct CameraRotateStrategyInfo { 31 std::string bundleName; 32 float wideValue; 33 int16_t rotateDegree; 34 int16_t fps; 35 }; 36 37 class CameraRotateStrategyParser : public Parser { 38 public: 39 static constexpr char DEVICE_CONFIG_FILE[] = "/sys_prod/etc/camera/camera_rotate_strategy.xml"; 40 41 bool LoadConfiguration() final; 42 void Destroy() final; 43 CameraRotateStrategyParser()44 CameraRotateStrategyParser() 45 { 46 curNode_ = CameraXmlNode::Create(); 47 MEDIA_DEBUG_LOG("CameraRotateStrategyParser ctor"); 48 } 49 ~CameraRotateStrategyParser()50 ~CameraRotateStrategyParser() 51 { 52 MEDIA_DEBUG_LOG("CameraRotateStrategyParser dtor"); 53 Destroy(); 54 curNode_ = nullptr; 55 } 56 GetCameraRotateStrategyInfos()57 inline std::vector<CameraRotateStrategyInfo> GetCameraRotateStrategyInfos() 58 { 59 return cameraRotateStrategyInfos_; 60 } 61 62 private: 63 std::mutex strategyInfosMutex_; 64 bool ParseInternal(std::shared_ptr<CameraXmlNode> curNode); 65 void ParserStrategyInfo(std::shared_ptr<CameraXmlNode> curNode); 66 std::shared_ptr<CameraXmlNode> curNode_ = nullptr; 67 std::vector<CameraRotateStrategyInfo> cameraRotateStrategyInfos_ = {}; 68 }; 69 } // namespace CameraStandard 70 } // namespace OHOS 71 72 #endif // CAMERA_ROTATE_STRATEGY_PARSER_H 73