a2dp_source.c (7982528c775720ae89c8c1b991cab7a4486242fb) a2dp_source.c (525037839fe4cb208cf1f3b2bff8664f2b86bbb6)
1
2/*
3 * Copyright (C) 2016 BlueKitchen GmbH
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

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

262 } else {
263 // post-pone sep discovery
264 connection->a2dp_source_discover_seps = true;
265 }
266}
267
268static void a2dp_handle_received_configuration(const uint8_t *packet, uint8_t local_seid) {
269 uint16_t cid = avdtp_subevent_signaling_media_codec_sbc_configuration_get_avdtp_cid(packet);
1
2/*
3 * Copyright (C) 2016 BlueKitchen GmbH
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

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

262 } else {
263 // post-pone sep discovery
264 connection->a2dp_source_discover_seps = true;
265 }
266}
267
268static void a2dp_handle_received_configuration(const uint8_t *packet, uint8_t local_seid) {
269 uint16_t cid = avdtp_subevent_signaling_media_codec_sbc_configuration_get_avdtp_cid(packet);
270 avdtp_connection_t * avdtp_connection = avdtp_get_connection_for_avdtp_cid(cid);
270 avdtp_connection_t *avdtp_connection = avdtp_get_connection_for_avdtp_cid(cid);
271 btstack_assert(avdtp_connection != NULL);
272 avdtp_connection->a2dp_source_local_stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid);
273 // bail out if local seid invalid
274 if (!avdtp_connection->a2dp_source_local_stream_endpoint) return;
275
276 // stop timer
277 if (sep_discovery_cid == cid) {
278 a2dp_source_set_config_timer_stop();
279 sep_discovery_cid = 0;
280 }
281
282 avdtp_connection->a2dp_source_stream_endpoint_configured = true;
283
271 btstack_assert(avdtp_connection != NULL);
272 avdtp_connection->a2dp_source_local_stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid);
273 // bail out if local seid invalid
274 if (!avdtp_connection->a2dp_source_local_stream_endpoint) return;
275
276 // stop timer
277 if (sep_discovery_cid == cid) {
278 a2dp_source_set_config_timer_stop();
279 sep_discovery_cid = 0;
280 }
281
282 avdtp_connection->a2dp_source_stream_endpoint_configured = true;
283
284 // outgoing active?
285 if (avdtp_connection->a2dp_source_state == A2DP_W4_SET_CONFIGURATION){
286 // outgoing: discovery and config of remote sink sep successful, trigger stream open
287 avdtp_connection->a2dp_source_state = A2DP_W2_OPEN_STREAM_WITH_SEID;
288 } else {
289 // incoming: wait for stream open
290 avdtp_connection->a2dp_source_state = A2DP_W4_OPEN_STREAM_WITH_SEID;
284 switch (avdtp_connection->a2dp_source_state) {
285 case A2DP_W4_SET_CONFIGURATION:
286 // outgoing: discovery and config of remote sink sep successful, trigger stream open
287 avdtp_connection->a2dp_source_state = A2DP_W2_OPEN_STREAM_WITH_SEID;
288 break;
289 case A2DP_W4_GET_CONFIGURATION:
290 // incoming: wait for stream open
291 avdtp_connection->a2dp_source_state = A2DP_W4_OPEN_STREAM_WITH_SEID;
292 break;
293 default:
294 // wait for configuration after sending reconfigure - keep state
295 break;
291 }
292}
293
294static void a2dp_source_set_config(avdtp_connection_t * connection){
295 uint8_t remote_seid = connection->a2dp_source_local_stream_endpoint->set_config_remote_seid;
296 log_info("A2DP initiate set configuration locally and wait for response ... local seid 0x%02x, remote seid 0x%02x", avdtp_stream_endpoint_seid(connection->a2dp_source_local_stream_endpoint), remote_seid);
297 connection->a2dp_source_state = A2DP_W4_SET_CONFIGURATION;
298 avdtp_source_set_configuration(connection->avdtp_cid, avdtp_stream_endpoint_seid(connection->a2dp_source_local_stream_endpoint), remote_seid, connection->a2dp_source_local_stream_endpoint->remote_configuration_bitmap, connection->a2dp_source_local_stream_endpoint->remote_configuration);

--- 743 unchanged lines hidden ---
296 }
297}
298
299static void a2dp_source_set_config(avdtp_connection_t * connection){
300 uint8_t remote_seid = connection->a2dp_source_local_stream_endpoint->set_config_remote_seid;
301 log_info("A2DP initiate set configuration locally and wait for response ... local seid 0x%02x, remote seid 0x%02x", avdtp_stream_endpoint_seid(connection->a2dp_source_local_stream_endpoint), remote_seid);
302 connection->a2dp_source_state = A2DP_W4_SET_CONFIGURATION;
303 avdtp_source_set_configuration(connection->avdtp_cid, avdtp_stream_endpoint_seid(connection->a2dp_source_local_stream_endpoint), remote_seid, connection->a2dp_source_local_stream_endpoint->remote_configuration_bitmap, connection->a2dp_source_local_stream_endpoint->remote_configuration);

--- 743 unchanged lines hidden ---