1 /* 2 * Copyright (C) 2021 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 A2DP_PARCEL_CODEC_H 17 #define A2DP_PARCEL_CODEC_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace bluetooth { 24 /** 25 * @brief A2dp codec type enum. 26 * 27 * @since 6.0 28 */ 29 enum A2dpIpcCodecType : uint8_t { 30 A2DP_CODEC_TYPE_SBC_IPC = 0, 31 A2DP_CODEC_TYPE_MPEG1_IPC = 0x01, 32 A2DP_CODEC_TYPE_AAC_IPC = 0x01 << 1, 33 A2DP_CODEC_TYPE_ATRAC_IPC = 0x01 << 2, 34 A2DP_CODEC_TYPE_NONA2DP_IPC = 0xFF 35 }; 36 37 /** 38 * @brief A2dp codec priority enum. 39 * 40 * @since 6.0 41 */ 42 enum A2dpIpcCodecPriority : uint8_t { 43 A2DP_CODEC_PRIORITY_DISABLED_IPC = 0, 44 A2DP_CODEC_PRIORITY_DEFAULT_IPC, 45 A2DP_CODEC_PRIORITY_HIGHEST_IPC = 255, 46 }; 47 48 /** 49 * @brief A2dp codec sample rate enum. 50 * 51 * @since 6.0 52 */ 53 enum A2dpIpcCodecSampleRate : uint32_t { 54 A2DP_SAMPLE_RATE_NONE_IPC = 0x0, 55 A2DP_SBC_SAMPLE_RATE_48000_IPC = 0x1 << 4, /* octet0 b4 */ 56 A2DP_SBC_SAMPLE_RATE_44100_IPC = 0x1 << 5, /* octet0 b5 */ 57 A2DP_SBC_SAMPLE_RATE_32000_IPC = 0x1 << 6, /* octet0 b6 */ 58 A2DP_SBC_SAMPLE_RATE_16000_IPC = 0x1 << 7, /* octet0 b7 */ 59 A2DP_SBC_SAMPLE_RATE_MSK_IPC = 0xF0, 60 A2DP_AAC_SAMPLE_RATE_OCTET1_44100_IPC = 0x01, 61 A2DP_AAC_SAMPLE_RATE_OCTET1_32000_IPC = 0x01 << 1, 62 A2DP_AAC_SAMPLE_RATE_OCTET1_24000_IPC = 0x01 << 2, 63 A2DP_AAC_SAMPLE_RATE_OCTET1_22050_IPC = 0x01 << 3, 64 A2DP_AAC_SAMPLE_RATE_OCTET1_16000_IPC = 0x01 << 4, 65 A2DP_AAC_SAMPLE_RATE_OCTET1_12000_IPC = 0x01 << 5, 66 A2DP_AAC_SAMPLE_RATE_OCTET1_11025_IPC = 0x01 << 6, 67 A2DP_AAC_SAMPLE_RATE_OCTET1_8000_IPC = 0x01 << 7, 68 A2DP_AAC_SAMPLE_RATE_OCTET1_MSK_IPC = 0xFF, 69 A2DP_AAC_SAMPLE_RATE_OCTET2_96000_IPC = 0x01 << 4, 70 A2DP_AAC_SAMPLE_RATE_OCTET2_88200_IPC = 0x01 << 5, 71 A2DP_AAC_SAMPLE_RATE_OCTET2_64000_IPC = 0x01 << 6, 72 A2DP_AAC_SAMPLE_RATE_OCTET2_48000_IPC = 0x01 << 7, 73 A2DP_AAC_SAMPLE_RATE_OCTET2_MSK_IPC = 0xF0, 74 }; 75 76 /** 77 * @brief A2dp codec channel mode enum. 78 * 79 * @since 6.0 80 */ 81 enum A2dpIpcCodecChannelMode : uint8_t { 82 A2DP_CHANNEL_MODE_NONE_IPC = 0x0, 83 A2DP_SBC_CHANNEL_MODE_JOINT_STEREO_IPC = 0x1, /* octet0 b0 */ 84 A2DP_SBC_CHANNEL_MODE_STEREO_IPC = 0x1 << 1, /* octet0 b1 */ 85 A2DP_SBC_CHANNEL_MODE_DUAL_IPC = 0x1 << 2, /* octet0 b2 */ 86 A2DP_SBC_CHANNEL_MODE_MONO_IPC = 0x1 << 3, /* octet0 b3 */ 87 A2DP_SBC_CHANNEL_MODE_MSK_IPC = 0x0F, 88 A2DP_AAC_CHANNEL_MODE_OCTET2_DOUBLE_IPC = 0x01 << 2, /* octet2 b2 */ 89 A2DP_AAC_CHANNEL_MODE_OCTET2_SINGLE_IPC = 0x01 << 3, /* octet2 b3 */ 90 A2DP_AAC_CHANNEL_MODE_OCTET2_MSK_IPC = 0x0C, 91 }; 92 93 /** 94 * @brief A2dp codec bits per sample enum. 95 * 96 * @since 6.0 97 */ 98 enum A2dpIpcCodecBitsPerSample : uint8_t { 99 A2DP_SAMPLE_BITS_NONE_IPC = 0x0, 100 A2DP_SAMPLE_BITS_16_IPC = 0x1 << 0, 101 A2DP_SAMPLE_BITS_24_IPC = 0x1 << 1, 102 A2DP_SAMPLE_BITS_32_IPC = 0x1 << 2, 103 A2DP_SAMPLE_BITS_MSK_IPC = 0x06, 104 }; 105 106 /** 107 * @brief A2dp codec configuration information of a2dp source 108 * 109 * @since 6.0 110 */ 111 struct CodecInfo { 112 // Codec priority 113 uint8_t codecPriority; 114 115 // Codec type 116 uint8_t codecType; 117 118 // Codec sample 119 uint32_t sampleRate; 120 121 // Codec bits per sample 122 uint8_t bitsPerSample; 123 124 // Codec channel mode 125 uint8_t channelMode; 126 127 // Codec specific value1 128 uint64_t codecSpecific1; 129 130 // Codec specific value2 131 uint64_t codecSpecific2; 132 133 // Codec specific value3 134 uint64_t codecSpecific3; 135 136 // Codec specific value4 137 uint64_t codecSpecific4; 138 }; 139 140 /** 141 * @brief The codec configuration and capability information of a2dp source 142 * 143 * @since 6.0 144 */ 145 struct CodecStatus { 146 // current codec information 147 CodecInfo codecInfo; 148 149 // local codec information 150 std::vector<CodecInfo> codecInfoLocalCap; 151 152 // Local device and peer confirmed codec information 153 std::vector<CodecInfo> codecInfoConfirmCap; 154 }; 155 156 struct OffloadCodecInfo { 157 uint16_t mediaPacketHeader; 158 uint8_t mPt; 159 uint32_t ssrc; 160 uint8_t boundaryFlag; 161 uint8_t broadcastFlag; 162 uint32_t codecType; 163 uint16_t maxLatency; 164 uint16_t scmsTEnable; 165 uint32_t sampleRate; 166 uint32_t encodedAudioBitrate; 167 uint8_t bitsPerSample; 168 uint8_t chMode; 169 uint16_t aclHdl; 170 uint16_t l2cRcid; 171 uint16_t mtu; 172 uint8_t codecSpecific0; 173 uint8_t codecSpecific1; 174 uint8_t codecSpecific2; 175 uint8_t codecSpecific3; 176 uint8_t codecSpecific4; 177 uint8_t codecSpecific5; 178 uint8_t codecSpecific6; 179 uint8_t codecSpecific7; 180 }; 181 182 struct OffloadCodecStatus { 183 OffloadCodecInfo offloadInfo; 184 }; 185 186 /** 187 * @brief The details of a2dp audio stream info. 188 * 189 * @since 6.0 190 */ 191 struct BluetoothA2dpStreamInfo { 192 int32_t sessionId; 193 int32_t streamType; 194 int32_t sampleRate; 195 int32_t isSpatialAudio; 196 }; 197 } // namespace bluetooth 198 } // namespace OHOS 199 200 #endif // A2DP_PARCEL_CODEC_H