1 /* 2 * Copyright (c) 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 AUDIO_POLICY_GLOBAL_PARSER_H 17 #define AUDIO_POLICY_GLOBAL_PARSER_H 18 19 #include <vector> 20 #include <unordered_map> 21 #include <string> 22 #include <sstream> 23 #include <libxml/parser.h> 24 #include <libxml/tree.h> 25 26 #include "audio_info.h" 27 #include "parser.h" 28 29 namespace OHOS { 30 namespace AudioStandard { 31 using namespace std; 32 33 class AudioPolicyGlobalParser : public Parser { 34 public: 35 static constexpr char POLICY_GLOBAL_CONFIG_FILE[] = "/system/etc/audio/audio_policy_global_config.xml"; 36 37 bool LoadConfiguration() final; 38 bool Parse(); 39 void Destroy() final; 40 AudioPolicyGlobalParser()41 AudioPolicyGlobalParser() {} 42 43 int32_t GetConfigByKeyName(std::string keyName, uint32_t &value); 44 ~AudioPolicyGlobalParser()45 virtual ~AudioPolicyGlobalParser() 46 { 47 Destroy(); 48 } 49 50 private: 51 bool ParseInternal(xmlNode *node); 52 void ParserAttribute(xmlNode *node); 53 54 xmlDoc *mDoc_ = nullptr; 55 std::unordered_map<std::string, uint32_t> globalConfigs_; 56 }; 57 } // namespace AudioStandard 58 } // namespace OHOS 59 #endif // AUDIO_DEVICE_AFFINITY_PARSER_H 60