1 /* 2 * Copyright (c) 2021-2022 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 AUDIO_FOCUS_PARSER_H 16 #define AUDIO_FOCUS_PARSER_H 17 18 #include<map> 19 #include<string> 20 #include <libxml/parser.h> 21 #include <libxml/tree.h> 22 #include "audio_errors.h" 23 #include "audio_info.h" 24 #include "audio_log.h" 25 26 namespace OHOS { 27 namespace AudioStandard { 28 static constexpr char AUDIO_FOCUS_CONFIG_FILE[] = "system/etc/audio/audio_interrupt_policy_config.xml"; 29 30 class AudioFocusParser { 31 public: 32 AudioFocusParser(); 33 virtual ~AudioFocusParser(); 34 int32_t LoadConfig(std::map<std::pair<AudioStreamType, AudioStreamType>, AudioFocusEntry> &focusMap); 35 36 private: 37 std::map<std::string, InterruptHint> actionMap; 38 std::map<std::string, AudioStreamType> streamMap; 39 std::map<std::string, ActionTarget> targetMap; 40 std::map<std::string, InterruptForceType> forceMap; 41 42 void LoadDefaultConfig(std::map<std::pair<AudioStreamType, AudioStreamType>, AudioFocusEntry> &focusMap); 43 void ParseFocusMap(xmlNode *node, char *curStream, std::map<std::pair<AudioStreamType, AudioStreamType>, 44 AudioFocusEntry> &focusMap); 45 void ParseStreams(xmlNode *node, std::map<std::pair<AudioStreamType, AudioStreamType>, 46 AudioFocusEntry> &focusMap); 47 void ParseAllowedStreams(xmlNode *node, char *curStream, std::map<std::pair<AudioStreamType, AudioStreamType>, 48 AudioFocusEntry> &focusMap); 49 void ParseRejectedStreams(xmlNode *node, char *curStream, std::map<std::pair<AudioStreamType, AudioStreamType>, 50 AudioFocusEntry> &focusMap); 51 }; 52 } // namespace AudioStandard 53 } // namespace OHOS 54 #endif // AUDIO_FOCUS_PARSER_H 55