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 #ifndef AUDIO_DEFINITION_POLICY_UTILS_H 16 #define AUDIO_DEFINITION_POLICY_UTILS_H 17 18 #include <bitset> 19 #include <list> 20 #include <string> 21 #include <unordered_map> 22 #include <unordered_set> 23 #include <mutex> 24 #include "singleton.h" 25 #include "audio_info.h" 26 #include "audio_utils.h" 27 #include "audio_errors.h" 28 #include "audio_stream_descriptor.h" 29 #include "audio_pipe_info.h" 30 31 namespace OHOS { 32 namespace AudioStandard { 33 class AudioDefinitionPolicyUtils { 34 public: 35 static uint32_t PcmFormatToBytes(AudioSampleFormat format); 36 static AudioChannel ConvertLayoutToAudioChannel(AudioChannelLayout layout); 37 private: AudioDefinitionPolicyUtils()38 AudioDefinitionPolicyUtils() {} ~AudioDefinitionPolicyUtils()39 ~AudioDefinitionPolicyUtils() {} 40 public: 41 static std::unordered_map<std::string, DeviceRole> deviceRoleStrToEnum; 42 static std::unordered_map<std::string, AudioPipeRole> pipeRoleStrToEnum; 43 static std::unordered_map<std::string, DeviceType> deviceTypeStrToEnum; 44 static std::unordered_map<std::string, DeviceType> deviceNameToTypeEnum; 45 static std::unordered_map<std::string, AudioPin> pinStrToEnum; 46 static std::unordered_map<std::string, AudioSampleFormat> formatStrToEnum; 47 static std::unordered_map<AudioSampleFormat, std::string> enumToFormatStr; 48 static std::unordered_map<std::string, AudioChannelLayout> layoutStrToEnum; 49 static std::unordered_map<std::string, AudioFlag> flagStrToEnum; 50 static std::unordered_map<std::string, uint32_t> usageStrToEnum; 51 static std::unordered_map<std::string, AudioPreloadType> preloadStrToEnum; 52 }; 53 54 } // namespace AudioStandard 55 } // namespace OHOS 56 #endif // AUDIO_DEFINITION_POLICY_UTILS_H 57