File indexing completed on 2024-05-12 05:46:53
0001 /* 0002 * 0003 * BlueZ - Bluetooth protocol stack for Linux 0004 * 0005 * Copyright (C) 2006-2010 Nokia Corporation 0006 * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> 0007 * 0008 * 0009 * This library is free software; you can redistribute it and/or 0010 * modify it under the terms of the GNU Lesser General Public 0011 * License as published by the Free Software Foundation; either 0012 * version 2.1 of the License, or (at your option) any later version. 0013 * 0014 * This library is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 * Lesser General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Lesser General Public 0020 * License along with this library; if not, write to the Free Software 0021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 0022 * 0023 */ 0024 0025 #ifndef BLUEZQT_A2DPCODECS_H 0026 #define BLUEZQT_A2DPCODECS_H 0027 0028 #include <stdint.h> 0029 0030 #define A2DP_CODEC_SBC 0x00 0031 #define A2DP_CODEC_MPEG12 0x01 0032 #define A2DP_CODEC_MPEG24 0x02 0033 #define A2DP_CODEC_ATRAC 0x04 0034 #define A2DP_CODEC_VENDOR 0xFF 0035 0036 #define SBC_SAMPLING_FREQ_16000 (1 << 3) 0037 #define SBC_SAMPLING_FREQ_32000 (1 << 2) 0038 #define SBC_SAMPLING_FREQ_44100 (1 << 1) 0039 #define SBC_SAMPLING_FREQ_48000 1 0040 0041 #define SBC_CHANNEL_MODE_MONO (1 << 3) 0042 #define SBC_CHANNEL_MODE_DUAL_CHANNEL (1 << 2) 0043 #define SBC_CHANNEL_MODE_STEREO (1 << 1) 0044 #define SBC_CHANNEL_MODE_JOINT_STEREO 1 0045 0046 #define SBC_BLOCK_LENGTH_4 (1 << 3) 0047 #define SBC_BLOCK_LENGTH_8 (1 << 2) 0048 #define SBC_BLOCK_LENGTH_12 (1 << 1) 0049 #define SBC_BLOCK_LENGTH_16 1 0050 0051 #define SBC_SUBBANDS_4 (1 << 1) 0052 #define SBC_SUBBANDS_8 1 0053 0054 #define SBC_ALLOCATION_SNR (1 << 1) 0055 #define SBC_ALLOCATION_LOUDNESS 1 0056 0057 #define MAX_BITPOOL 64 0058 #define MIN_BITPOOL 2 0059 0060 #define MPEG_CHANNEL_MODE_MONO (1 << 3) 0061 #define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2) 0062 #define MPEG_CHANNEL_MODE_STEREO (1 << 1) 0063 #define MPEG_CHANNEL_MODE_JOINT_STEREO 1 0064 0065 #define MPEG_LAYER_MP1 (1 << 2) 0066 #define MPEG_LAYER_MP2 (1 << 1) 0067 #define MPEG_LAYER_MP3 1 0068 0069 #define MPEG_SAMPLING_FREQ_16000 (1 << 5) 0070 #define MPEG_SAMPLING_FREQ_22050 (1 << 4) 0071 #define MPEG_SAMPLING_FREQ_24000 (1 << 3) 0072 #define MPEG_SAMPLING_FREQ_32000 (1 << 2) 0073 #define MPEG_SAMPLING_FREQ_44100 (1 << 1) 0074 #define MPEG_SAMPLING_FREQ_48000 1 0075 0076 #define MPEG_BIT_RATE_VBR 0x8000 0077 #define MPEG_BIT_RATE_320000 0x4000 0078 #define MPEG_BIT_RATE_256000 0x2000 0079 #define MPEG_BIT_RATE_224000 0x1000 0080 #define MPEG_BIT_RATE_192000 0x0800 0081 #define MPEG_BIT_RATE_160000 0x0400 0082 #define MPEG_BIT_RATE_128000 0x0200 0083 #define MPEG_BIT_RATE_112000 0x0100 0084 #define MPEG_BIT_RATE_96000 0x0080 0085 #define MPEG_BIT_RATE_80000 0x0040 0086 #define MPEG_BIT_RATE_64000 0x0020 0087 #define MPEG_BIT_RATE_56000 0x0010 0088 #define MPEG_BIT_RATE_48000 0x0008 0089 #define MPEG_BIT_RATE_40000 0x0004 0090 #define MPEG_BIT_RATE_32000 0x0002 0091 #define MPEG_BIT_RATE_FREE 0x0001 0092 0093 #define AAC_OBJECT_TYPE_MPEG2_AAC_LC 0x80 0094 #define AAC_OBJECT_TYPE_MPEG4_AAC_LC 0x40 0095 #define AAC_OBJECT_TYPE_MPEG4_AAC_LTP 0x20 0096 #define AAC_OBJECT_TYPE_MPEG4_AAC_SCA 0x10 0097 0098 #define AAC_SAMPLING_FREQ_8000 0x0800 0099 #define AAC_SAMPLING_FREQ_11025 0x0400 0100 #define AAC_SAMPLING_FREQ_12000 0x0200 0101 #define AAC_SAMPLING_FREQ_16000 0x0100 0102 #define AAC_SAMPLING_FREQ_22050 0x0080 0103 #define AAC_SAMPLING_FREQ_24000 0x0040 0104 #define AAC_SAMPLING_FREQ_32000 0x0020 0105 #define AAC_SAMPLING_FREQ_44100 0x0010 0106 #define AAC_SAMPLING_FREQ_48000 0x0008 0107 #define AAC_SAMPLING_FREQ_64000 0x0004 0108 #define AAC_SAMPLING_FREQ_88200 0x0002 0109 #define AAC_SAMPLING_FREQ_96000 0x0001 0110 0111 #define AAC_CHANNELS_1 0x02 0112 #define AAC_CHANNELS_2 0x01 0113 0114 #define AAC_GET_BITRATE(a) ((a).bitrate1 << 16 | \ 0115 (a).bitrate2 << 8 | (a).bitrate3) 0116 #define AAC_GET_FREQUENCY(a) ((a).frequency1 << 4 | (a).frequency2) 0117 0118 #define AAC_SET_BITRATE(a, b) \ 0119 do { \ 0120 (a).bitrate1 = (b >> 16) & 0x7f; \ 0121 (a).bitrate2 = (b >> 8) & 0xff; \ 0122 (a).bitrate3 = b & 0xff; \ 0123 } while (0) 0124 #define AAC_SET_FREQUENCY(a, f) \ 0125 do { \ 0126 (a).frequency1 = (f >> 4) & 0xff; \ 0127 (a).frequency2 = f & 0x0f; \ 0128 } while (0) 0129 0130 #define AAC_INIT_BITRATE(b) \ 0131 .bitrate1 = (b >> 16) & 0x7f, \ 0132 .bitrate2 = (b >> 8) & 0xff, \ 0133 .bitrate3 = b & 0xff, 0134 #define AAC_INIT_FREQUENCY(f) \ 0135 .frequency1 = (f >> 4) & 0xff, \ 0136 .frequency2 = f & 0x0f, 0137 0138 #define APTX_VENDOR_ID 0x0000004f 0139 #define APTX_CODEC_ID 0x0001 0140 0141 #define APTX_CHANNEL_MODE_MONO 0x01 0142 #define APTX_CHANNEL_MODE_STEREO 0x02 0143 0144 #define APTX_SAMPLING_FREQ_16000 0x08 0145 #define APTX_SAMPLING_FREQ_32000 0x04 0146 #define APTX_SAMPLING_FREQ_44100 0x02 0147 #define APTX_SAMPLING_FREQ_48000 0x01 0148 0149 #define LDAC_VENDOR_ID 0x0000012d 0150 #define LDAC_CODEC_ID 0x00aa 0151 0152 typedef struct { 0153 uint32_t vendor_id; 0154 uint16_t codec_id; 0155 } __attribute__ ((packed)) a2dp_vendor_codec_t; 0156 0157 #if __BYTE_ORDER == __LITTLE_ENDIAN 0158 0159 typedef struct { 0160 uint8_t channel_mode:4; 0161 uint8_t frequency:4; 0162 uint8_t allocation_method:2; 0163 uint8_t subbands:2; 0164 uint8_t block_length:4; 0165 uint8_t min_bitpool; 0166 uint8_t max_bitpool; 0167 } __attribute__ ((packed)) a2dp_sbc_t; 0168 0169 typedef struct { 0170 uint8_t channel_mode:4; 0171 uint8_t crc:1; 0172 uint8_t layer:3; 0173 uint8_t frequency:6; 0174 uint8_t mpf:1; 0175 uint8_t rfa:1; 0176 uint16_t bitrate; 0177 } __attribute__ ((packed)) a2dp_mpeg_t; 0178 0179 typedef struct { 0180 uint8_t object_type; 0181 uint8_t frequency1; 0182 uint8_t rfa:2; 0183 uint8_t channels:2; 0184 uint8_t frequency2:4; 0185 uint8_t bitrate1:7; 0186 uint8_t vbr:1; 0187 uint8_t bitrate2; 0188 uint8_t bitrate3; 0189 } __attribute__ ((packed)) a2dp_aac_t; 0190 0191 typedef struct { 0192 a2dp_vendor_codec_t info; 0193 uint8_t channel_mode:4; 0194 uint8_t frequency:4; 0195 } __attribute__ ((packed)) a2dp_aptx_t; 0196 0197 typedef struct { 0198 a2dp_vendor_codec_t info; 0199 uint8_t unknown[2]; 0200 } __attribute__ ((packed)) a2dp_ldac_t; 0201 0202 #elif __BYTE_ORDER == __BIG_ENDIAN 0203 0204 typedef struct { 0205 uint8_t frequency:4; 0206 uint8_t channel_mode:4; 0207 uint8_t block_length:4; 0208 uint8_t subbands:2; 0209 uint8_t allocation_method:2; 0210 uint8_t min_bitpool; 0211 uint8_t max_bitpool; 0212 } __attribute__ ((packed)) a2dp_sbc_t; 0213 0214 typedef struct { 0215 uint8_t layer:3; 0216 uint8_t crc:1; 0217 uint8_t channel_mode:4; 0218 uint8_t rfa:1; 0219 uint8_t mpf:1; 0220 uint8_t frequency:6; 0221 uint16_t bitrate; 0222 } __attribute__ ((packed)) a2dp_mpeg_t; 0223 0224 typedef struct { 0225 uint8_t object_type; 0226 uint8_t frequency1; 0227 uint8_t frequency2:4; 0228 uint8_t channels:2; 0229 uint8_t rfa:2; 0230 uint8_t vbr:1; 0231 uint8_t bitrate1:7; 0232 uint8_t bitrate2; 0233 uint8_t bitrate3; 0234 } __attribute__ ((packed)) a2dp_aac_t; 0235 0236 typedef struct { 0237 a2dp_vendor_codec_t info; 0238 uint8_t frequency:4; 0239 uint8_t channel_mode:4; 0240 } __attribute__ ((packed)) a2dp_aptx_t; 0241 0242 typedef struct { 0243 a2dp_vendor_codec_t info; 0244 uint8_t unknown[2]; 0245 } __attribute__ ((packed)) a2dp_ldac_t; 0246 0247 #else 0248 #error "Unknown byte order" 0249 #endif 0250 0251 #ifdef __cplusplus 0252 extern "C" { 0253 #endif 0254 0255 #include "bluezqt_export.h" 0256 0257 BLUEZQT_EXPORT extern const a2dp_sbc_t sbcCapabilities; 0258 BLUEZQT_EXPORT extern const a2dp_aac_t aacCapabilities; 0259 0260 #ifdef __cplusplus 0261 } 0262 #endif 0263 0264 #endif