3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2006-2010 Nokia Corporation
6 * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
7 * Copyright (C) 2011 BMW Car IT GmbH. All rights reserved.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #define A2DP_CODEC_SBC 0x00
27 #define A2DP_CODEC_MPEG12 0x01
28 #define A2DP_CODEC_MPEG24 0x02
29 #define A2DP_CODEC_ATRAC 0x03
31 #define SBC_SAMPLING_FREQ_16000 (1 << 3)
32 #define SBC_SAMPLING_FREQ_32000 (1 << 2)
33 #define SBC_SAMPLING_FREQ_44100 (1 << 1)
34 #define SBC_SAMPLING_FREQ_48000 1
36 #define SBC_CHANNEL_MODE_MONO (1 << 3)
37 #define SBC_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
38 #define SBC_CHANNEL_MODE_STEREO (1 << 1)
39 #define SBC_CHANNEL_MODE_JOINT_STEREO 1
41 #define SBC_BLOCK_LENGTH_4 (1 << 3)
42 #define SBC_BLOCK_LENGTH_8 (1 << 2)
43 #define SBC_BLOCK_LENGTH_12 (1 << 1)
44 #define SBC_BLOCK_LENGTH_16 1
46 #define SBC_SUBBANDS_4 (1 << 1)
47 #define SBC_SUBBANDS_8 1
49 #define SBC_ALLOCATION_SNR (1 << 1)
50 #define SBC_ALLOCATION_LOUDNESS 1
52 #define MPEG_CHANNEL_MODE_MONO (1 << 3)
53 #define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
54 #define MPEG_CHANNEL_MODE_STEREO (1 << 1)
55 #define MPEG_CHANNEL_MODE_JOINT_STEREO 1
57 #define MPEG_LAYER_MP1 (1 << 2)
58 #define MPEG_LAYER_MP2 (1 << 1)
59 #define MPEG_LAYER_MP3 1
61 #define MPEG_SAMPLING_FREQ_16000 (1 << 5)
62 #define MPEG_SAMPLING_FREQ_22050 (1 << 4)
63 #define MPEG_SAMPLING_FREQ_24000 (1 << 3)
64 #define MPEG_SAMPLING_FREQ_32000 (1 << 2)
65 #define MPEG_SAMPLING_FREQ_44100 (1 << 1)
66 #define MPEG_SAMPLING_FREQ_48000 1
68 #define MAX_BITPOOL 64
71 #if __BYTE_ORDER == __LITTLE_ENDIAN
73 struct sbc_codec_cap {
74 struct avdtp_media_codec_capability cap;
75 uint8_t channel_mode:4;
77 uint8_t allocation_method:2;
79 uint8_t block_length:4;
82 } __attribute__ ((packed));
84 struct mpeg_codec_cap {
85 struct avdtp_media_codec_capability cap;
86 uint8_t channel_mode:4;
93 } __attribute__ ((packed));
95 #elif __BYTE_ORDER == __BIG_ENDIAN
97 struct sbc_codec_cap {
98 struct avdtp_media_codec_capability cap;
100 uint8_t channel_mode:4;
101 uint8_t block_length:4;
103 uint8_t allocation_method:2;
106 } __attribute__ ((packed));
108 struct mpeg_codec_cap {
109 struct avdtp_media_codec_capability cap;
112 uint8_t channel_mode:4;
117 } __attribute__ ((packed));
120 #error "Unknown byte order"
126 typedef void (*a2dp_endpoint_select_t) (struct a2dp_setup *setup, void *ret,
128 typedef void (*a2dp_endpoint_config_t) (struct a2dp_setup *setup, gboolean ret);
130 struct a2dp_endpoint {
131 const char *(*get_name) (struct a2dp_sep *sep, void *user_data);
132 size_t (*get_capabilities) (struct a2dp_sep *sep,
133 uint8_t **capabilities,
135 int (*select_configuration) (struct a2dp_sep *sep,
136 uint8_t *capabilities,
138 struct a2dp_setup *setup,
139 a2dp_endpoint_select_t cb,
141 int (*set_configuration) (struct a2dp_sep *sep,
142 struct audio_device *dev,
143 uint8_t *configuration,
145 struct a2dp_setup *setup,
146 a2dp_endpoint_config_t cb,
148 void (*clear_configuration) (struct a2dp_sep *sep, void *user_data);
149 void (*set_delay) (struct a2dp_sep *sep, uint16_t delay,
153 typedef void (*a2dp_select_cb_t) (struct avdtp *session,
154 struct a2dp_sep *sep, GSList *caps,
156 typedef void (*a2dp_config_cb_t) (struct avdtp *session, struct a2dp_sep *sep,
157 struct avdtp_stream *stream,
158 struct avdtp_error *err,
160 typedef void (*a2dp_stream_cb_t) (struct avdtp *session,
161 struct avdtp_error *err,
164 int a2dp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config);
165 void a2dp_unregister(const bdaddr_t *src);
167 struct a2dp_sep *a2dp_add_sep(const bdaddr_t *src, uint8_t type,
168 uint8_t codec, gboolean delay_reporting,
169 struct a2dp_endpoint *endpoint,
170 void *user_data, GDestroyNotify destroy,
172 void a2dp_remove_sep(struct a2dp_sep *sep);
174 struct a2dp_sep *a2dp_get(struct avdtp *session, struct avdtp_remote_sep *sep);
176 unsigned int a2dp_select_capabilities(struct avdtp *session,
177 uint8_t type, const char *sender,
180 unsigned int a2dp_config(struct avdtp *session, struct a2dp_sep *sep,
181 a2dp_config_cb_t cb, GSList *caps,
183 unsigned int a2dp_resume(struct avdtp *session, struct a2dp_sep *sep,
184 a2dp_stream_cb_t cb, void *user_data);
185 unsigned int a2dp_suspend(struct avdtp *session, struct a2dp_sep *sep,
186 a2dp_stream_cb_t cb, void *user_data);
187 gboolean a2dp_cancel(struct audio_device *dev, unsigned int id);
189 gboolean a2dp_sep_lock(struct a2dp_sep *sep, struct avdtp *session);
190 gboolean a2dp_sep_unlock(struct a2dp_sep *sep, struct avdtp *session);
191 gboolean a2dp_sep_get_lock(struct a2dp_sep *sep);
192 struct avdtp_stream *a2dp_sep_get_stream(struct a2dp_sep *sep);
193 struct a2dp_sep *a2dp_get_sep(struct avdtp *session,
194 struct avdtp_stream *stream);