• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #ifndef AUDIO_TONE_PARSER_H
16 #define AUDIO_TONE_PARSER_H
17 
18 #include <map>
19 #include <string>
20 #include <vector>
21 #include <string>
22 #include <sstream>
23 #include <unordered_map>
24 #include "audio_errors.h"
25 #include "audio_info.h"
26 #include "audio_policy_log.h"
27 #include "audio_xml_parser.h"
28 
29 namespace OHOS {
30 namespace AudioStandard {
31 using ToneInfoMap = std::unordered_map<int32_t, std::shared_ptr<ToneInfo>>;
32 class AudioToneParser {
33 public:
34     static constexpr char AUDIO_TONE_CONFIG_FILE[] = "/system/etc/audio/audio_tone_dtmf_config.xml";
35     AudioToneParser();
36     virtual ~AudioToneParser();
37     int32_t LoadConfig(ToneInfoMap &toneDescriptorMap);
38     int32_t LoadNewConfig(const std::string &configPath, ToneInfoMap &toneDescriptorMap,
39         std::unordered_map<std::string, ToneInfoMap> &customToneDescriptorMap);
40 
41 private:
42     void ParseSegment(std::shared_ptr<AudioXmlNode> curNode, int32_t segInx, std::shared_ptr<ToneInfo> ltoneDesc);
43     void ParseToneInfoAttribute(std::shared_ptr<AudioXmlNode>, std::shared_ptr<ToneInfo> ltoneDesc);
44     void ParseToneInfo(std::shared_ptr<AudioXmlNode>, std::vector<ToneInfoMap*> &toneDescriptorMaps);
45     void ParseFrequency(std::string freqList, ToneSegment &ltoneSeg);
46     void ParseCustom(std::shared_ptr<AudioXmlNode>,
47         std::unordered_map<std::string, ToneInfoMap> &customToneDescriptorMap);
48 };
49 } // namespace AudioStandard
50 } // namespace OHOS
51 #endif // AUDIO_TONE_PARSER_H
52