1 /* 2 * Copyright (c) 2021-2024 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 ST_AUDIO_CONFIG_H 17 #define ST_AUDIO_CONFIG_H 18 19 #include <list> 20 #include <optional> 21 #include <set> 22 #include <string> 23 #include <vector> 24 25 #include "audio_info.h" 26 #include "audio_policy_log.h" 27 28 namespace OHOS { 29 namespace AudioStandard { 30 namespace { 31 static const char* PRIMARY_CLASS = "primary"; 32 static const char* A2DP_CLASS = "a2dp"; 33 static const char* HEARING_AID_CLASS = "hearing_aid"; 34 static const char* USB_CLASS = "usb"; 35 static const char* DP_CLASS = "dp"; 36 static const char* ACCESSORY_CLASS = "accessory"; 37 static const char* FILE_CLASS = "file_io"; 38 static const char* REMOTE_CLASS = "remote"; 39 static const char* OFFLOAD_CLASS = "offload"; 40 static const char* MCH_CLASS = "multichannel"; 41 static const char* INVALID_CLASS = "invalid"; 42 static const char* DIRECT_VOIP_CLASS = "primary_direct_voip"; 43 static const char* MMAP_VOIP_CLASS = "primary_mmap_voip"; 44 static const char* BLUETOOTH_SPEAKER = "Bt_Speaker"; 45 static const char* HEARING_AID_SPEAKER = "Hearing_Aid_Speaker"; 46 static const char* BLUETOOTH_MIC = "Bt_Mic"; 47 static const char* PRIMARY_SPEAKER = "Speaker"; 48 static const char* OFFLOAD_PRIMARY_SPEAKER = "Offload_Speaker"; 49 static const char* MCH_PRIMARY_SPEAKER = "MCH_Speaker"; 50 static const char* USB_SPEAKER = "Usb_arm_speaker"; 51 static const char* DP_SINK = "DP_speaker"; 52 static const char* USB_MIC = "Usb_arm_mic"; 53 static const char* PRIMARY_MIC = "Built_in_mic"; 54 static const char* PRIMARY_WAKEUP_MIC = "Built_in_wakeup"; 55 static const char* FILE_SINK = "file_sink"; 56 static const char* FILE_SOURCE = "file_source"; 57 static const char* PIPE_SINK = "fifo_output"; 58 static const char* PIPE_SOURCE = "fifo_input"; 59 static const char* INTERNAL_PORT = "internal"; 60 static const char* ROLE_SOURCE = "source"; 61 static const char* ROLE_SINK = "sink"; 62 static const char* PORT_NONE = "none"; 63 static const char* PRIMARY_DIRECT_VOIP = "direct_voip"; 64 static const char* PRIMARY_MMAP_VOIP = "mmap_voip"; 65 static const char* ACCESSORY_SOURCE = "accessory_mic"; 66 } 67 68 enum NodeName { 69 DEVICE_CLASS, 70 MODULES, 71 MODULE, 72 PORTS, 73 PORT, 74 AUDIO_INTERRUPT_ENABLE, 75 UPDATE_ROUTE_SUPPORT, 76 AUDIO_LATENCY, 77 SINK_LATENCY, 78 VOLUME_GROUP_CONFIG, 79 INTERRUPT_GROUP_CONFIG, 80 UNKNOWN 81 }; 82 83 enum ClassType { 84 TYPE_PRIMARY, 85 TYPE_A2DP, 86 TYPE_USB, 87 TYPE_FILE_IO, 88 TYPE_REMOTE_AUDIO, 89 TYPE_DP, 90 TYPE_ACCESSORY, 91 TYPE_HEARING_AID, 92 TYPE_INVALID 93 }; 94 95 enum AudioPipeRole { 96 PIPE_ROLE_OUTPUT = 0, 97 PIPE_ROLE_INPUT, 98 PIPE_ROLE_NONE, 99 }; 100 101 struct AudioModuleInfo { 102 std::string className; 103 std::string name; 104 std::string adapterName; 105 std::string id; 106 std::string lib; 107 std::string role; 108 109 std::string rate; 110 111 std::set<uint32_t> supportedRate_; 112 std::set<uint64_t> supportedChannelLayout_; 113 114 std::string format; 115 std::string channels; 116 std::string channelLayout; 117 std::string bufferSize; 118 std::string fixedLatency; 119 std::string sinkLatency; 120 std::string renderInIdleState; 121 std::string OpenMicSpeaker; 122 std::string fileName; 123 std::string networkId; 124 std::string deviceType; 125 std::string sceneName; 126 std::string sourceType; 127 std::string offloadEnable; 128 std::string defaultAdapterEnable; 129 130 std::string ecType; 131 std::string ecAdapter; 132 std::string ecSamplingRate; 133 std::string ecFormat; 134 std::string ecChannels; 135 std::string openMicRef; 136 std::string micRefRate; 137 std::string micRefFormat; 138 std::string micRefChannels; 139 140 std::list<AudioModuleInfo> ports; 141 std::string extra; 142 AudioPipeRole pipeRole; 143 /** 144 * split stream, sent a few empty chunk when stream pause or stop 145 */ 146 std::optional<bool> needEmptyChunk; 147 }; 148 149 } // namespace AudioStandard 150 } // namespace OHOS 151 152 #endif // ST_AUDIO_CONFIG_H 153