Changeset View
Changeset View
Standalone View
Standalone View
src/a2dp-codecs.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * | ||||
3 | * BlueZ - Bluetooth protocol stack for Linux | ||||
4 | * | ||||
5 | * Copyright (C) 2006-2010 Nokia Corporation | ||||
6 | * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> | ||||
7 | * | ||||
8 | * | ||||
9 | * This library is free software; you can redistribute it and/or | ||||
10 | * modify it under the terms of the GNU Lesser General Public | ||||
11 | * License as published by the Free Software Foundation; either | ||||
12 | * version 2.1 of the License, or (at your option) any later version. | ||||
13 | * | ||||
14 | * This library is distributed in the hope that it will be useful, | ||||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
17 | * Lesser General Public License for more details. | ||||
18 | * | ||||
19 | * You should have received a copy of the GNU Lesser General Public | ||||
20 | * License along with this library; if not, write to the Free Software | ||||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||||
22 | * | ||||
23 | */ | ||||
24 | | ||||
25 | #ifndef BLUEZQT_A2DPCODECS_H | ||||
26 | #define BLUEZQT_A2DPCODECS_H | ||||
27 | | ||||
28 | #include <stdint.h> | ||||
29 | | ||||
30 | #define A2DP_CODEC_SBC 0x00 | ||||
31 | #define A2DP_CODEC_MPEG12 0x01 | ||||
32 | #define A2DP_CODEC_MPEG24 0x02 | ||||
33 | #define A2DP_CODEC_ATRAC 0x03 | ||||
34 | #define A2DP_CODEC_VENDOR 0xFF | ||||
35 | | ||||
36 | #define SBC_SAMPLING_FREQ_16000 (1 << 3) | ||||
37 | #define SBC_SAMPLING_FREQ_32000 (1 << 2) | ||||
38 | #define SBC_SAMPLING_FREQ_44100 (1 << 1) | ||||
39 | #define SBC_SAMPLING_FREQ_48000 1 | ||||
40 | | ||||
41 | #define SBC_CHANNEL_MODE_MONO (1 << 3) | ||||
42 | #define SBC_CHANNEL_MODE_DUAL_CHANNEL (1 << 2) | ||||
43 | #define SBC_CHANNEL_MODE_STEREO (1 << 1) | ||||
44 | #define SBC_CHANNEL_MODE_JOINT_STEREO 1 | ||||
45 | | ||||
46 | #define SBC_BLOCK_LENGTH_4 (1 << 3) | ||||
47 | #define SBC_BLOCK_LENGTH_8 (1 << 2) | ||||
48 | #define SBC_BLOCK_LENGTH_12 (1 << 1) | ||||
49 | #define SBC_BLOCK_LENGTH_16 1 | ||||
50 | | ||||
51 | #define SBC_SUBBANDS_4 (1 << 1) | ||||
52 | #define SBC_SUBBANDS_8 1 | ||||
53 | | ||||
54 | #define SBC_ALLOCATION_SNR (1 << 1) | ||||
55 | #define SBC_ALLOCATION_LOUDNESS 1 | ||||
56 | | ||||
57 | #define MAX_BITPOOL 64 | ||||
58 | #define MIN_BITPOOL 2 | ||||
59 | | ||||
60 | #define MPEG_CHANNEL_MODE_MONO (1 << 3) | ||||
61 | #define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2) | ||||
62 | #define MPEG_CHANNEL_MODE_STEREO (1 << 1) | ||||
63 | #define MPEG_CHANNEL_MODE_JOINT_STEREO 1 | ||||
64 | | ||||
65 | #define MPEG_LAYER_MP1 (1 << 2) | ||||
66 | #define MPEG_LAYER_MP2 (1 << 1) | ||||
67 | #define MPEG_LAYER_MP3 1 | ||||
68 | | ||||
69 | #define MPEG_SAMPLING_FREQ_16000 (1 << 5) | ||||
70 | #define MPEG_SAMPLING_FREQ_22050 (1 << 4) | ||||
71 | #define MPEG_SAMPLING_FREQ_24000 (1 << 3) | ||||
72 | #define MPEG_SAMPLING_FREQ_32000 (1 << 2) | ||||
73 | #define MPEG_SAMPLING_FREQ_44100 (1 << 1) | ||||
74 | #define MPEG_SAMPLING_FREQ_48000 1 | ||||
75 | | ||||
76 | #define MPEG_BIT_RATE_VBR 0x8000 | ||||
77 | #define MPEG_BIT_RATE_320000 0x4000 | ||||
78 | #define MPEG_BIT_RATE_256000 0x2000 | ||||
79 | #define MPEG_BIT_RATE_224000 0x1000 | ||||
80 | #define MPEG_BIT_RATE_192000 0x0800 | ||||
81 | #define MPEG_BIT_RATE_160000 0x0400 | ||||
82 | #define MPEG_BIT_RATE_128000 0x0200 | ||||
83 | #define MPEG_BIT_RATE_112000 0x0100 | ||||
84 | #define MPEG_BIT_RATE_96000 0x0080 | ||||
85 | #define MPEG_BIT_RATE_80000 0x0040 | ||||
86 | #define MPEG_BIT_RATE_64000 0x0020 | ||||
87 | #define MPEG_BIT_RATE_56000 0x0010 | ||||
88 | #define MPEG_BIT_RATE_48000 0x0008 | ||||
89 | #define MPEG_BIT_RATE_40000 0x0004 | ||||
90 | #define MPEG_BIT_RATE_32000 0x0002 | ||||
91 | #define MPEG_BIT_RATE_FREE 0x0001 | ||||
92 | | ||||
93 | #define AAC_OBJECT_TYPE_MPEG2_AAC_LC 0x80 | ||||
94 | #define AAC_OBJECT_TYPE_MPEG4_AAC_LC 0x40 | ||||
95 | #define AAC_OBJECT_TYPE_MPEG4_AAC_LTP 0x20 | ||||
96 | #define AAC_OBJECT_TYPE_MPEG4_AAC_SCA 0x10 | ||||
97 | | ||||
98 | #define AAC_SAMPLING_FREQ_8000 0x0800 | ||||
99 | #define AAC_SAMPLING_FREQ_11025 0x0400 | ||||
100 | #define AAC_SAMPLING_FREQ_12000 0x0200 | ||||
101 | #define AAC_SAMPLING_FREQ_16000 0x0100 | ||||
102 | #define AAC_SAMPLING_FREQ_22050 0x0080 | ||||
103 | #define AAC_SAMPLING_FREQ_24000 0x0040 | ||||
104 | #define AAC_SAMPLING_FREQ_32000 0x0020 | ||||
105 | #define AAC_SAMPLING_FREQ_44100 0x0010 | ||||
106 | #define AAC_SAMPLING_FREQ_48000 0x0008 | ||||
107 | #define AAC_SAMPLING_FREQ_64000 0x0004 | ||||
108 | #define AAC_SAMPLING_FREQ_88200 0x0002 | ||||
109 | #define AAC_SAMPLING_FREQ_96000 0x0001 | ||||
110 | | ||||
111 | #define AAC_CHANNELS_1 0x02 | ||||
112 | #define AAC_CHANNELS_2 0x01 | ||||
113 | | ||||
114 | #define AAC_GET_BITRATE(a) ((a).bitrate1 << 16 | \ | ||||
115 | (a).bitrate2 << 8 | (a).bitrate3) | ||||
116 | #define AAC_GET_FREQUENCY(a) ((a).frequency1 << 4 | (a).frequency2) | ||||
117 | | ||||
118 | #define AAC_SET_BITRATE(a, b) \ | ||||
119 | do { \ | ||||
120 | (a).bitrate1 = (b >> 16) & 0x7f; \ | ||||
121 | (a).bitrate2 = (b >> 8) & 0xff; \ | ||||
122 | (a).bitrate3 = b & 0xff; \ | ||||
123 | } while (0) | ||||
124 | #define AAC_SET_FREQUENCY(a, f) \ | ||||
125 | do { \ | ||||
126 | (a).frequency1 = (f >> 4) & 0xff; \ | ||||
127 | (a).frequency2 = f & 0x0f; \ | ||||
128 | } while (0) | ||||
129 | | ||||
130 | #define AAC_INIT_BITRATE(b) \ | ||||
131 | .bitrate1 = (b >> 16) & 0x7f, \ | ||||
132 | .bitrate2 = (b >> 8) & 0xff, \ | ||||
133 | .bitrate3 = b & 0xff, | ||||
134 | #define AAC_INIT_FREQUENCY(f) \ | ||||
135 | .frequency1 = (f >> 4) & 0xff, \ | ||||
136 | .frequency2 = f & 0x0f, | ||||
137 | | ||||
138 | #define APTX_VENDOR_ID 0x0000004f | ||||
139 | #define APTX_CODEC_ID 0x0001 | ||||
140 | | ||||
141 | #define APTX_CHANNEL_MODE_MONO 0x01 | ||||
142 | #define APTX_CHANNEL_MODE_STEREO 0x02 | ||||
143 | | ||||
144 | #define APTX_SAMPLING_FREQ_16000 0x08 | ||||
145 | #define APTX_SAMPLING_FREQ_32000 0x04 | ||||
146 | #define APTX_SAMPLING_FREQ_44100 0x02 | ||||
147 | #define APTX_SAMPLING_FREQ_48000 0x01 | ||||
148 | | ||||
149 | #define LDAC_VENDOR_ID 0x0000012d | ||||
150 | #define LDAC_CODEC_ID 0x00aa | ||||
151 | | ||||
152 | typedef struct { | ||||
153 | uint32_t vendor_id; | ||||
154 | uint16_t codec_id; | ||||
155 | } __attribute__ ((packed)) a2dp_vendor_codec_t; | ||||
156 | | ||||
157 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||||
158 | | ||||
159 | typedef struct { | ||||
160 | uint8_t channel_mode:4; | ||||
161 | uint8_t frequency:4; | ||||
162 | uint8_t allocation_method:2; | ||||
163 | uint8_t subbands:2; | ||||
164 | uint8_t block_length:4; | ||||
165 | uint8_t min_bitpool; | ||||
166 | uint8_t max_bitpool; | ||||
167 | } __attribute__ ((packed)) a2dp_sbc_t; | ||||
168 | | ||||
169 | typedef struct { | ||||
170 | uint8_t channel_mode:4; | ||||
171 | uint8_t crc:1; | ||||
172 | uint8_t layer:3; | ||||
173 | uint8_t frequency:6; | ||||
174 | uint8_t mpf:1; | ||||
175 | uint8_t rfa:1; | ||||
176 | uint16_t bitrate; | ||||
177 | } __attribute__ ((packed)) a2dp_mpeg_t; | ||||
178 | | ||||
179 | typedef struct { | ||||
180 | uint8_t object_type; | ||||
181 | uint8_t frequency1; | ||||
182 | uint8_t rfa:2; | ||||
183 | uint8_t channels:2; | ||||
184 | uint8_t frequency2:4; | ||||
185 | uint8_t bitrate1:7; | ||||
186 | uint8_t vbr:1; | ||||
187 | uint8_t bitrate2; | ||||
188 | uint8_t bitrate3; | ||||
189 | } __attribute__ ((packed)) a2dp_aac_t; | ||||
190 | | ||||
191 | typedef struct { | ||||
192 | a2dp_vendor_codec_t info; | ||||
193 | uint8_t channel_mode:4; | ||||
194 | uint8_t frequency:4; | ||||
195 | } __attribute__ ((packed)) a2dp_aptx_t; | ||||
196 | | ||||
197 | typedef struct { | ||||
198 | a2dp_vendor_codec_t info; | ||||
199 | uint8_t unknown[2]; | ||||
200 | } __attribute__ ((packed)) a2dp_ldac_t; | ||||
201 | | ||||
202 | #elif __BYTE_ORDER == __BIG_ENDIAN | ||||
203 | | ||||
204 | typedef struct { | ||||
205 | uint8_t frequency:4; | ||||
206 | uint8_t channel_mode:4; | ||||
207 | uint8_t block_length:4; | ||||
208 | uint8_t subbands:2; | ||||
209 | uint8_t allocation_method:2; | ||||
210 | uint8_t min_bitpool; | ||||
211 | uint8_t max_bitpool; | ||||
212 | } __attribute__ ((packed)) a2dp_sbc_t; | ||||
213 | | ||||
214 | typedef struct { | ||||
215 | uint8_t layer:3; | ||||
216 | uint8_t crc:1; | ||||
217 | uint8_t channel_mode:4; | ||||
218 | uint8_t rfa:1; | ||||
219 | uint8_t mpf:1; | ||||
220 | uint8_t frequency:6; | ||||
221 | uint16_t bitrate; | ||||
222 | } __attribute__ ((packed)) a2dp_mpeg_t; | ||||
223 | | ||||
224 | typedef struct { | ||||
225 | uint8_t object_type; | ||||
226 | uint8_t frequency1; | ||||
227 | uint8_t frequency2:4; | ||||
228 | uint8_t channels:2; | ||||
229 | uint8_t rfa:2; | ||||
230 | uint8_t vbr:1; | ||||
231 | uint8_t bitrate1:7; | ||||
232 | uint8_t bitrate2; | ||||
233 | uint8_t bitrate3; | ||||
234 | } __attribute__ ((packed)) a2dp_aac_t; | ||||
235 | | ||||
236 | typedef struct { | ||||
237 | a2dp_vendor_codec_t info; | ||||
238 | uint8_t frequency:4; | ||||
239 | uint8_t channel_mode:4; | ||||
240 | } __attribute__ ((packed)) a2dp_aptx_t; | ||||
241 | | ||||
242 | typedef struct { | ||||
243 | a2dp_vendor_codec_t info; | ||||
244 | uint8_t unknown[2]; | ||||
245 | } __attribute__ ((packed)) a2dp_ldac_t; | ||||
246 | | ||||
247 | #else | ||||
248 | #error "Unknown byte order" | ||||
249 | #endif | ||||
250 | | ||||
251 | #ifdef __cplusplus | ||||
252 | extern "C" { | ||||
253 | #endif | ||||
254 | | ||||
255 | #include "bluezqt_export.h" | ||||
256 | | ||||
257 | BLUEZQT_EXPORT extern const a2dp_sbc_t sbcCapabilities; | ||||
258 | BLUEZQT_EXPORT extern const a2dp_aac_t aacCapabilities; | ||||
259 | | ||||
260 | #ifdef __cplusplus | ||||
261 | } | ||||
262 | #endif | ||||
263 | | ||||
264 | #endif |