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
27 struct avdtp_local_sep;
28 struct avdtp_remote_sep;
39 /* SEP capability categories */
40 #define AVDTP_MEDIA_TRANSPORT 0x01
41 #define AVDTP_REPORTING 0x02
42 #define AVDTP_RECOVERY 0x03
43 #define AVDTP_CONTENT_PROTECTION 0x04
44 #define AVDTP_HEADER_COMPRESSION 0x05
45 #define AVDTP_MULTIPLEXING 0x06
46 #define AVDTP_MEDIA_CODEC 0x07
47 #define AVDTP_DELAY_REPORTING 0x08
48 #define AVDTP_ERRNO 0xff
50 /* AVDTP error definitions */
51 #define AVDTP_BAD_HEADER_FORMAT 0x01
52 #define AVDTP_BAD_LENGTH 0x11
53 #define AVDTP_BAD_ACP_SEID 0x12
54 #define AVDTP_SEP_IN_USE 0x13
55 #define AVDTP_SEP_NOT_IN_USE 0x14
56 #define AVDTP_BAD_SERV_CATEGORY 0x17
57 #define AVDTP_BAD_PAYLOAD_FORMAT 0x18
58 #define AVDTP_NOT_SUPPORTED_COMMAND 0x19
59 #define AVDTP_INVALID_CAPABILITIES 0x1A
60 #define AVDTP_BAD_RECOVERY_TYPE 0x22
61 #define AVDTP_BAD_MEDIA_TRANSPORT_FORMAT 0x23
62 #define AVDTP_BAD_RECOVERY_FORMAT 0x25
63 #define AVDTP_BAD_ROHC_FORMAT 0x26
64 #define AVDTP_BAD_CP_FORMAT 0x27
65 #define AVDTP_BAD_MULTIPLEXING_FORMAT 0x28
66 #define AVDTP_UNSUPPORTED_CONFIGURATION 0x29
67 #define AVDTP_BAD_STATE 0x31
69 /* SEP types definitions */
70 #define AVDTP_SEP_TYPE_SOURCE 0x00
71 #define AVDTP_SEP_TYPE_SINK 0x01
73 /* Media types definitions */
74 #define AVDTP_MEDIA_TYPE_AUDIO 0x00
75 #define AVDTP_MEDIA_TYPE_VIDEO 0x01
76 #define AVDTP_MEDIA_TYPE_MULTIMEDIA 0x02
80 AVDTP_STATE_CONFIGURED,
82 AVDTP_STATE_STREAMING,
87 struct avdtp_service_capability {
91 } __attribute__ ((packed));
93 #if __BYTE_ORDER == __LITTLE_ENDIAN
95 struct avdtp_media_codec_capability {
98 uint8_t media_codec_type;
100 } __attribute__ ((packed));
102 #elif __BYTE_ORDER == __BIG_ENDIAN
104 struct avdtp_media_codec_capability {
105 uint8_t media_type:4;
107 uint8_t media_codec_type;
109 } __attribute__ ((packed));
112 #error "Unknown byte order"
115 typedef void (*avdtp_stream_state_cb) (struct avdtp_stream *stream,
116 avdtp_state_t old_state,
117 avdtp_state_t new_state,
118 struct avdtp_error *err,
121 typedef void (*avdtp_set_configuration_cb) (struct avdtp *session,
122 struct avdtp_stream *stream,
123 struct avdtp_error *err);
125 /* Callbacks for when a reply is received to a command that we sent */
126 struct avdtp_sep_cfm {
127 void (*set_configuration) (struct avdtp *session,
128 struct avdtp_local_sep *lsep,
129 struct avdtp_stream *stream,
130 struct avdtp_error *err,
132 void (*get_configuration) (struct avdtp *session,
133 struct avdtp_local_sep *lsep,
134 struct avdtp_stream *stream,
135 struct avdtp_error *err,
137 void (*open) (struct avdtp *session, struct avdtp_local_sep *lsep,
138 struct avdtp_stream *stream, struct avdtp_error *err,
140 void (*start) (struct avdtp *session, struct avdtp_local_sep *lsep,
141 struct avdtp_stream *stream, struct avdtp_error *err,
143 void (*suspend) (struct avdtp *session, struct avdtp_local_sep *lsep,
144 struct avdtp_stream *stream,
145 struct avdtp_error *err, void *user_data);
146 void (*close) (struct avdtp *session, struct avdtp_local_sep *lsep,
147 struct avdtp_stream *stream,
148 struct avdtp_error *err, void *user_data);
149 void (*abort) (struct avdtp *session, struct avdtp_local_sep *lsep,
150 struct avdtp_stream *stream,
151 struct avdtp_error *err, void *user_data);
152 void (*reconfigure) (struct avdtp *session,
153 struct avdtp_local_sep *lsep,
154 struct avdtp_stream *stream,
155 struct avdtp_error *err, void *user_data);
156 void (*delay_report) (struct avdtp *session, struct avdtp_local_sep *lsep,
157 struct avdtp_stream *stream,
158 struct avdtp_error *err, void *user_data);
162 * Callbacks for indicating when we received a new command. The return value
163 * indicates whether the command should be rejected or accepted
165 struct avdtp_sep_ind {
166 gboolean (*get_capability) (struct avdtp *session,
167 struct avdtp_local_sep *sep,
168 GSList **caps, uint8_t *err,
170 gboolean (*set_configuration) (struct avdtp *session,
171 struct avdtp_local_sep *lsep,
172 struct avdtp_stream *stream,
174 avdtp_set_configuration_cb cb,
176 gboolean (*get_configuration) (struct avdtp *session,
177 struct avdtp_local_sep *lsep,
178 uint8_t *err, void *user_data);
179 gboolean (*open) (struct avdtp *session, struct avdtp_local_sep *lsep,
180 struct avdtp_stream *stream, uint8_t *err,
182 gboolean (*start) (struct avdtp *session, struct avdtp_local_sep *lsep,
183 struct avdtp_stream *stream, uint8_t *err,
185 gboolean (*suspend) (struct avdtp *session,
186 struct avdtp_local_sep *sep,
187 struct avdtp_stream *stream, uint8_t *err,
189 gboolean (*close) (struct avdtp *session, struct avdtp_local_sep *sep,
190 struct avdtp_stream *stream, uint8_t *err,
192 void (*abort) (struct avdtp *session, struct avdtp_local_sep *sep,
193 struct avdtp_stream *stream, uint8_t *err,
195 gboolean (*reconfigure) (struct avdtp *session,
196 struct avdtp_local_sep *lsep,
197 uint8_t *err, void *user_data);
198 gboolean (*delayreport) (struct avdtp *session,
199 struct avdtp_local_sep *lsep,
200 uint8_t rseid, uint16_t delay,
201 uint8_t *err, void *user_data);
204 typedef void (*avdtp_discover_cb_t) (struct avdtp *session, GSList *seps,
205 struct avdtp_error *err, void *user_data);
206 typedef void (*avdtp_disconnect_cb_t) (void *user_data);
208 struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version,
209 struct queue *lseps);
211 unsigned int avdtp_add_disconnect_cb(struct avdtp *session,
212 avdtp_disconnect_cb_t cb,
214 gboolean avdtp_remove_disconnect_cb(struct avdtp *session, unsigned int id);
216 void avdtp_shutdown(struct avdtp *session);
218 void avdtp_unref(struct avdtp *session);
219 struct avdtp *avdtp_ref(struct avdtp *session);
221 struct avdtp_service_capability *avdtp_service_cap_new(uint8_t category,
225 struct avdtp_service_capability *avdtp_get_codec(struct avdtp_remote_sep *sep);
227 int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
230 gboolean avdtp_has_stream(struct avdtp *session, struct avdtp_stream *stream);
232 unsigned int avdtp_stream_add_cb(struct avdtp *session,
233 struct avdtp_stream *stream,
234 avdtp_stream_state_cb cb, void *data);
235 gboolean avdtp_stream_remove_cb(struct avdtp *session,
236 struct avdtp_stream *stream,
239 gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd,
240 size_t imtu, size_t omtu);
241 gboolean avdtp_stream_get_transport(struct avdtp_stream *stream, int *sock,
242 uint16_t *imtu, uint16_t *omtu,
244 struct avdtp_service_capability *avdtp_stream_get_codec(
245 struct avdtp_stream *stream);
246 gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream,
248 struct avdtp_remote_sep *avdtp_stream_get_remote_sep(
249 struct avdtp_stream *stream);
251 int avdtp_set_configuration(struct avdtp *session,
252 struct avdtp_remote_sep *rsep,
253 struct avdtp_local_sep *lsep,
255 struct avdtp_stream **stream);
257 int avdtp_get_configuration(struct avdtp *session,
258 struct avdtp_stream *stream);
260 int avdtp_open(struct avdtp *session, struct avdtp_stream *stream);
261 int avdtp_start(struct avdtp *session, struct avdtp_stream *stream);
262 int avdtp_suspend(struct avdtp *session, struct avdtp_stream *stream);
263 int avdtp_close(struct avdtp *session, struct avdtp_stream *stream,
265 int avdtp_abort(struct avdtp *session, struct avdtp_stream *stream);
266 int avdtp_delay_report(struct avdtp *session, struct avdtp_stream *stream,
269 struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps, uint8_t type,
272 gboolean delay_reporting,
273 struct avdtp_sep_ind *ind,
274 struct avdtp_sep_cfm *cfm,
276 void avdtp_sep_set_vendor_codec(struct avdtp_local_sep *sep, uint32_t vendor_id,
279 /* Find a matching pair of local and remote SEP ID's */
280 struct avdtp_remote_sep *avdtp_find_remote_sep(struct avdtp *session,
281 struct avdtp_local_sep *lsep);
283 int avdtp_unregister_sep(struct queue *lseps, struct avdtp_local_sep *sep);
285 avdtp_state_t avdtp_sep_get_state(struct avdtp_local_sep *sep);
287 void avdtp_error_init(struct avdtp_error *err, uint8_t type, int id);
288 const char *avdtp_strerror(struct avdtp_error *err);
289 uint8_t avdtp_error_category(struct avdtp_error *err);
290 int avdtp_error_error_code(struct avdtp_error *err);
291 int avdtp_error_posix_errno(struct avdtp_error *err);