3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2006-2010 Nokia Corporation
6 * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program 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
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 AVDTP_SESSION_STATE_DISCONNECTED,
27 AVDTP_SESSION_STATE_CONNECTING,
28 AVDTP_SESSION_STATE_CONNECTED
29 } avdtp_session_state_t;
34 struct avdtp_local_sep;
35 struct avdtp_remote_sep;
44 /* SEP capability categories */
45 #define AVDTP_MEDIA_TRANSPORT 0x01
46 #define AVDTP_REPORTING 0x02
47 #define AVDTP_RECOVERY 0x03
48 #define AVDTP_CONTENT_PROTECTION 0x04
49 #define AVDTP_HEADER_COMPRESSION 0x05
50 #define AVDTP_MULTIPLEXING 0x06
51 #define AVDTP_MEDIA_CODEC 0x07
52 #define AVDTP_DELAY_REPORTING 0x08
53 #define AVDTP_ERRNO 0xff
55 /* AVDTP error definitions */
56 #define AVDTP_BAD_HEADER_FORMAT 0x01
57 #define AVDTP_BAD_LENGTH 0x11
58 #define AVDTP_BAD_ACP_SEID 0x12
59 #define AVDTP_SEP_IN_USE 0x13
60 #define AVDTP_SEP_NOT_IN_USE 0x14
61 #define AVDTP_BAD_SERV_CATEGORY 0x17
62 #define AVDTP_BAD_PAYLOAD_FORMAT 0x18
63 #define AVDTP_NOT_SUPPORTED_COMMAND 0x19
64 #define AVDTP_INVALID_CAPABILITIES 0x1A
65 #define AVDTP_BAD_RECOVERY_TYPE 0x22
66 #define AVDTP_BAD_MEDIA_TRANSPORT_FORMAT 0x23
67 #define AVDTP_BAD_RECOVERY_FORMAT 0x25
68 #define AVDTP_BAD_ROHC_FORMAT 0x26
69 #define AVDTP_BAD_CP_FORMAT 0x27
70 #define AVDTP_BAD_MULTIPLEXING_FORMAT 0x28
71 #define AVDTP_UNSUPPORTED_CONFIGURATION 0x29
72 #define AVDTP_BAD_STATE 0x31
74 /* SEP types definitions */
75 #define AVDTP_SEP_TYPE_SOURCE 0x00
76 #define AVDTP_SEP_TYPE_SINK 0x01
78 /* Media types definitions */
79 #define AVDTP_MEDIA_TYPE_AUDIO 0x00
80 #define AVDTP_MEDIA_TYPE_VIDEO 0x01
81 #define AVDTP_MEDIA_TYPE_MULTIMEDIA 0x02
85 AVDTP_STATE_CONFIGURED,
87 AVDTP_STATE_STREAMING,
92 struct avdtp_service_capability {
96 } __attribute__ ((packed));
98 #if __BYTE_ORDER == __LITTLE_ENDIAN
100 struct avdtp_media_codec_capability {
102 uint8_t media_type:4;
103 uint8_t media_codec_type;
105 } __attribute__ ((packed));
107 #elif __BYTE_ORDER == __BIG_ENDIAN
109 struct avdtp_media_codec_capability {
110 uint8_t media_type:4;
112 uint8_t media_codec_type;
114 } __attribute__ ((packed));
117 #error "Unknown byte order"
120 typedef void (*avdtp_session_state_cb) (struct btd_device *dev,
121 struct avdtp *session,
122 avdtp_session_state_t old_state,
123 avdtp_session_state_t new_state,
126 typedef void (*avdtp_stream_state_cb) (struct avdtp_stream *stream,
127 avdtp_state_t old_state,
128 avdtp_state_t new_state,
129 struct avdtp_error *err,
132 typedef void (*avdtp_set_configuration_cb) (struct avdtp *session,
133 struct avdtp_stream *stream,
134 struct avdtp_error *err);
136 /* Callbacks for when a reply is received to a command that we sent */
137 struct avdtp_sep_cfm {
138 void (*set_configuration) (struct avdtp *session,
139 struct avdtp_local_sep *lsep,
140 struct avdtp_stream *stream,
141 struct avdtp_error *err,
143 void (*get_configuration) (struct avdtp *session,
144 struct avdtp_local_sep *lsep,
145 struct avdtp_stream *stream,
146 struct avdtp_error *err,
148 void (*open) (struct avdtp *session, struct avdtp_local_sep *lsep,
149 struct avdtp_stream *stream, struct avdtp_error *err,
151 void (*start) (struct avdtp *session, struct avdtp_local_sep *lsep,
152 struct avdtp_stream *stream, struct avdtp_error *err,
154 void (*suspend) (struct avdtp *session, struct avdtp_local_sep *lsep,
155 struct avdtp_stream *stream,
156 struct avdtp_error *err, void *user_data);
157 void (*close) (struct avdtp *session, struct avdtp_local_sep *lsep,
158 struct avdtp_stream *stream,
159 struct avdtp_error *err, void *user_data);
160 void (*abort) (struct avdtp *session, struct avdtp_local_sep *lsep,
161 struct avdtp_stream *stream,
162 struct avdtp_error *err, void *user_data);
163 void (*reconfigure) (struct avdtp *session,
164 struct avdtp_local_sep *lsep,
165 struct avdtp_stream *stream,
166 struct avdtp_error *err, void *user_data);
167 void (*delay_report) (struct avdtp *session, struct avdtp_local_sep *lsep,
168 struct avdtp_stream *stream,
169 struct avdtp_error *err, void *user_data);
172 /* Callbacks for indicating when we received a new command. The return value
173 * indicates whether the command should be rejected or accepted */
174 struct avdtp_sep_ind {
175 gboolean (*match_codec) (struct avdtp *session,
176 struct avdtp_media_codec_capability *codec,
178 gboolean (*get_capability) (struct avdtp *session,
179 struct avdtp_local_sep *sep,
181 GSList **caps, uint8_t *err,
183 gboolean (*set_configuration) (struct avdtp *session,
184 struct avdtp_local_sep *lsep,
185 struct avdtp_stream *stream,
187 avdtp_set_configuration_cb cb,
189 gboolean (*get_configuration) (struct avdtp *session,
190 struct avdtp_local_sep *lsep,
191 uint8_t *err, void *user_data);
192 gboolean (*open) (struct avdtp *session, struct avdtp_local_sep *lsep,
193 struct avdtp_stream *stream, uint8_t *err,
195 gboolean (*start) (struct avdtp *session, struct avdtp_local_sep *lsep,
196 struct avdtp_stream *stream, uint8_t *err,
198 gboolean (*suspend) (struct avdtp *session,
199 struct avdtp_local_sep *sep,
200 struct avdtp_stream *stream, uint8_t *err,
202 gboolean (*close) (struct avdtp *session, struct avdtp_local_sep *sep,
203 struct avdtp_stream *stream, uint8_t *err,
205 void (*abort) (struct avdtp *session, struct avdtp_local_sep *sep,
206 struct avdtp_stream *stream, uint8_t *err,
208 gboolean (*reconfigure) (struct avdtp *session,
209 struct avdtp_local_sep *lsep,
210 uint8_t *err, void *user_data);
211 gboolean (*delayreport) (struct avdtp *session,
212 struct avdtp_local_sep *lsep,
213 uint8_t rseid, uint16_t delay,
214 uint8_t *err, void *user_data);
217 typedef void (*avdtp_discover_cb_t) (struct avdtp *session, GSList *seps,
218 struct avdtp_error *err, void *user_data);
220 void avdtp_unref(struct avdtp *session);
221 struct avdtp *avdtp_ref(struct avdtp *session);
223 struct avdtp_service_capability *avdtp_service_cap_new(uint8_t category,
224 void *data, int size);
226 struct avdtp_remote_sep *avdtp_register_remote_sep(struct avdtp *session,
230 bool delay_reporting);
232 uint8_t avdtp_get_seid(struct avdtp_remote_sep *sep);
234 uint8_t avdtp_get_type(struct avdtp_remote_sep *sep);
236 struct avdtp_service_capability *avdtp_get_codec(struct avdtp_remote_sep *sep);
238 bool avdtp_get_delay_reporting(struct avdtp_remote_sep *sep);
240 int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
243 gboolean avdtp_has_stream(struct avdtp *session, struct avdtp_stream *stream);
245 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
246 void finalize_discovery(struct avdtp *session, int err);
249 unsigned int avdtp_stream_add_cb(struct avdtp *session,
250 struct avdtp_stream *stream,
251 avdtp_stream_state_cb cb, void *data);
252 gboolean avdtp_stream_remove_cb(struct avdtp *session,
253 struct avdtp_stream *stream,
256 gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd,
257 size_t imtu, size_t omtu);
258 gboolean avdtp_stream_get_transport(struct avdtp_stream *stream, int *sock,
259 uint16_t *imtu, uint16_t *omtu,
261 struct avdtp_service_capability *avdtp_stream_get_codec(
262 struct avdtp_stream *stream);
263 gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream,
265 struct avdtp_remote_sep *avdtp_stream_get_remote_sep(
266 struct avdtp_stream *stream);
268 unsigned int avdtp_add_state_cb(struct btd_device *dev,
269 avdtp_session_state_cb cb, void *user_data);
271 gboolean avdtp_remove_state_cb(unsigned int id);
273 int avdtp_set_configuration(struct avdtp *session,
274 struct avdtp_remote_sep *rsep,
275 struct avdtp_local_sep *lsep,
277 struct avdtp_stream **stream);
279 int avdtp_get_configuration(struct avdtp *session,
280 struct avdtp_stream *stream);
282 int avdtp_open(struct avdtp *session, struct avdtp_stream *stream);
283 int avdtp_start(struct avdtp *session, struct avdtp_stream *stream);
284 int avdtp_suspend(struct avdtp *session, struct avdtp_stream *stream);
285 int avdtp_close(struct avdtp *session, struct avdtp_stream *stream,
287 int avdtp_abort(struct avdtp *session, struct avdtp_stream *stream);
288 int avdtp_delay_report(struct avdtp *session, struct avdtp_stream *stream,
290 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
291 int delay_report_req(uint16_t delay);
294 struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps, uint8_t type,
297 gboolean delay_reporting,
298 struct avdtp_sep_ind *ind,
299 struct avdtp_sep_cfm *cfm,
302 /* Find a matching pair of local and remote SEP ID's */
303 struct avdtp_remote_sep *avdtp_find_remote_sep(struct avdtp *session,
304 struct avdtp_local_sep *lsep);
306 int avdtp_unregister_sep(struct queue *lseps, struct avdtp_local_sep *sep);
308 avdtp_state_t avdtp_sep_get_state(struct avdtp_local_sep *sep);
309 uint8_t avdtp_sep_get_seid(struct avdtp_local_sep *sep);
311 void avdtp_error_init(struct avdtp_error *err, uint8_t type, int id);
312 const char *avdtp_strerror(struct avdtp_error *err);
313 uint8_t avdtp_error_category(struct avdtp_error *err);
314 int avdtp_error_error_code(struct avdtp_error *err);
315 int avdtp_error_posix_errno(struct avdtp_error *err);
317 struct btd_adapter *avdtp_get_adapter(struct avdtp *session);
318 struct btd_device *avdtp_get_device(struct avdtp *session);
319 struct avdtp_server *avdtp_get_server(struct avdtp_local_sep *lsep);
321 struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
322 struct queue *lseps);
323 uint16_t avdtp_get_version(struct avdtp *session);
325 #if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && defined(TIZEN_FEATURE_BLUEZ_A2DP_MULTISTREAM)
326 void avdtp_set_source_status(struct btd_device *dev, bool pause);