1 /* 2 * Copyright (c) 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_TONE_PARSER_H 16 #define AUDIO_TONE_PARSER_H 17 18 #include <map> 19 #include <string> 20 #include <libxml/parser.h> 21 #include <libxml/tree.h> 22 #include <vector> 23 #include <string> 24 #include <sstream> 25 #include <unordered_map> 26 #include "audio_errors.h" 27 #include "audio_info.h" 28 #include "audio_policy_log.h" 29 30 namespace OHOS { 31 namespace AudioStandard { 32 static constexpr char AUDIO_TONE_CONFIG_FILE[] = "system/etc/audio/audio_tone_dtmf_config.xml"; 33 34 class AudioToneParser { 35 public: 36 AudioToneParser(); 37 virtual ~AudioToneParser(); 38 int32_t LoadConfig(std::unordered_map<int32_t, std::shared_ptr<ToneInfo>> &toneDescriptorMap); 39 private: 40 void ParseSegment(xmlNode *node, int32_t segInx, std::shared_ptr<ToneInfo> ltoneDesc); 41 void ParseToneInfoAttribute(xmlNode *sNode, std::shared_ptr<ToneInfo> ltoneDesc); 42 void ParseToneInfo(xmlNode *node, std::unordered_map<int32_t, std::shared_ptr<ToneInfo>> &toneDescriptorMap); 43 void ParseFrequency(std::string freqList, ToneSegment <oneSeg); 44 }; 45 } // namespace AudioStandard 46 } // namespace OHOS 47 #endif // AUDIO_TONE_PARSER_H 48