avdtp.c (e71e31fe9f74e2560d9fc912e33482be0aa4575b) avdtp.c (371399398143f203d62dc4ad577955d8fc33c4d5)
1/*
2 * Copyright (C) 2016 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 254 unchanged lines hidden (view full) ---

263 avdtp_stream_endpoints_id_counter++;
264 }
265 return avdtp_stream_endpoints_id_counter;
266}
267
268static void avdtp_handle_start_sdp_client_query(void * context){
269 UNUSED(context);
270
1/*
2 * Copyright (C) 2016 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 254 unchanged lines hidden (view full) ---

263 avdtp_stream_endpoints_id_counter++;
264 }
265 return avdtp_stream_endpoints_id_counter;
266}
267
268static void avdtp_handle_start_sdp_client_query(void * context){
269 UNUSED(context);
270
271 uint16_t uuid;
271 btstack_linked_list_iterator_t it;
272 btstack_linked_list_iterator_init(&it, &avdtp_connections);
273 while (btstack_linked_list_iterator_has_next(&it)){
274 avdtp_connection_t * connection = (avdtp_connection_t *)btstack_linked_list_iterator_next(&it);
275
276 switch (connection->state){
277 case AVDTP_SIGNALING_W2_SEND_SDP_QUERY_FOR_REMOTE_SOURCE:
272 btstack_linked_list_iterator_t it;
273 btstack_linked_list_iterator_init(&it, &avdtp_connections);
274 while (btstack_linked_list_iterator_has_next(&it)){
275 avdtp_connection_t * connection = (avdtp_connection_t *)btstack_linked_list_iterator_next(&it);
276
277 switch (connection->state){
278 case AVDTP_SIGNALING_W2_SEND_SDP_QUERY_FOR_REMOTE_SOURCE:
279 uuid = BLUETOOTH_SERVICE_CLASS_AUDIO_SOURCE;
278 connection->state = AVDTP_SIGNALING_W4_SDP_QUERY_FOR_REMOTE_SOURCE_COMPLETE;
279 break;
280 case AVDTP_SIGNALING_W2_SEND_SDP_QUERY_FOR_REMOTE_SINK:
280 connection->state = AVDTP_SIGNALING_W4_SDP_QUERY_FOR_REMOTE_SOURCE_COMPLETE;
281 break;
282 case AVDTP_SIGNALING_W2_SEND_SDP_QUERY_FOR_REMOTE_SINK:
283 uuid = BLUETOOTH_SERVICE_CLASS_AUDIO_SINK;
281 connection->state = AVDTP_SIGNALING_W4_SDP_QUERY_FOR_REMOTE_SINK_COMPLETE;
282 break;
283 case AVDTP_SIGNALING_CONNECTION_OPENED:
284 switch (connection->initiator_connection_state ){
284 connection->state = AVDTP_SIGNALING_W4_SDP_QUERY_FOR_REMOTE_SINK_COMPLETE;
285 break;
286 case AVDTP_SIGNALING_CONNECTION_OPENED:
287 switch (connection->initiator_connection_state ){
285 case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_SEND_SDP_QUERY_THEN_GET_ALL_CAPABILITIES_FROM_REMOTE_SINK:
286 case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_SEND_SDP_QUERY_THEN_GET_ALL_CAPABILITIES_FROM_REMOTE_SOURCE:
288 case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_SEND_SDP_QUERY_THEN_GET_ALL_CAPABILITIES_FROM_REMOTE_SOURCE:
289 uuid = BLUETOOTH_SERVICE_CLASS_AUDIO_SOURCE;
287 connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_SDP_QUERY_COMPLETE_THEN_GET_ALL_CAPABILITIES;
288 break;
290 connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_SDP_QUERY_COMPLETE_THEN_GET_ALL_CAPABILITIES;
291 break;
292 case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_SEND_SDP_QUERY_THEN_GET_ALL_CAPABILITIES_FROM_REMOTE_SINK:
293 uuid = BLUETOOTH_SERVICE_CLASS_AUDIO_SINK;
294 connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_SDP_QUERY_COMPLETE_THEN_GET_ALL_CAPABILITIES;
295 break;
289 default:
290 continue;
291 }
292 break;
293 default:
294 continue;
295 }
296 avdtp_sdp_query_context_avdtp_cid = connection->avdtp_cid;
297 avdtp_record_id = -1;
296 default:
297 continue;
298 }
299 break;
300 default:
301 continue;
302 }
303 avdtp_sdp_query_context_avdtp_cid = connection->avdtp_cid;
304 avdtp_record_id = -1;
298 sdp_client_query_uuid16(&avdtp_handle_sdp_client_query_result, (uint8_t *) connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP);
305 sdp_client_query_uuid16(&avdtp_handle_sdp_client_query_result, (uint8_t *) connection->remote_addr, uuid);
299 return;
300 }
301}
302
303uint8_t avdtp_connect(bd_addr_t remote, avdtp_role_t role, uint16_t * avdtp_cid){
304 avdtp_connection_t * connection = avdtp_get_connection_for_bd_addr(remote);
305 if (connection){
306 return ERROR_CODE_COMMAND_DISALLOWED;

--- 1322 unchanged lines hidden ---
306 return;
307 }
308}
309
310uint8_t avdtp_connect(bd_addr_t remote, avdtp_role_t role, uint16_t * avdtp_cid){
311 avdtp_connection_t * connection = avdtp_get_connection_for_bd_addr(remote);
312 if (connection){
313 return ERROR_CODE_COMMAND_DISALLOWED;

--- 1322 unchanged lines hidden ---