diff --git a/port/libusb/.gitignore b/port/libusb/.gitignore index 71fe9de5f..c2388f734 100644 --- a/port/libusb/.gitignore +++ b/port/libusb/.gitignore @@ -1,11 +1,10 @@ a2dp_sink_demo +a2dp_source_demo ancs_client_demo ancs_client_demo.h avdtp_sink.sbc avdtp_sink.sbc avdtp_sink.wav -avdtp_sink_demo -avdtp_source_demo ble_central_test ble_peripheral_test bnep_test diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index f40bc7bf6..54b5e9dec 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -212,7 +212,7 @@ void avdtp_handle_can_send_now(avdtp_connection_t * connection, uint16_t l2cap_c if (stream_endpoint->connection == connection){ if (stream_endpoint->state >= AVDTP_STREAM_ENDPOINT_OPENED && stream_endpoint->state != AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_DISCONNECTED){ stream_endpoint->state = AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_DISCONNECTED; - avdtp_request_can_send_now_self(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_self(connection, connection->l2cap_signaling_cid); l2cap_disconnect(stream_endpoint->l2cap_media_cid, 0); return; } @@ -220,7 +220,7 @@ void avdtp_handle_can_send_now(avdtp_connection_t * connection, uint16_t l2cap_c } connection->disconnect = 0; connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_DISCONNECTED; - l2cap_disconnect(connection->tl2cap_signaling_cid, 0); + l2cap_disconnect(connection->l2cap_signaling_cid, 0); return; } } @@ -464,7 +464,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet // log_info("avdtp_packet_handler packet type %02x, event %02x ", packet_type, hci_event_packet_get_type(packet)); switch (packet_type) { case L2CAP_DATA_PACKET: - connection = avdtp_connection_for_tl2cap_signaling_cid(channel, context); + connection = avdtp_connection_for_l2cap_signaling_cid(channel, context); if (connection){ handle_l2cap_data_packet_for_signaling_connection(connection, packet, size, context); break; @@ -477,7 +477,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet break; } - if (channel == stream_endpoint->connection->tl2cap_signaling_cid){ + if (channel == stream_endpoint->connection->l2cap_signaling_cid){ stream_endpoint_state_machine(stream_endpoint->connection, stream_endpoint, L2CAP_DATA_PACKET, 0, packet, size, context); break; } @@ -555,9 +555,9 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet connection = avdtp_connection_for_bd_addr(event_addr, context); if (!connection) break; - if (connection->tl2cap_signaling_cid == 0) { + if (connection->l2cap_signaling_cid == 0) { if (connection->state != AVDTP_SIGNALING_CONNECTION_W4_L2CAP_CONNECTED) break; - connection->tl2cap_signaling_cid = local_cid; + connection->l2cap_signaling_cid = local_cid; connection->local_seid = 0; connection->state = AVDTP_SIGNALING_CONNECTION_OPENED; log_info(" -> AVDTP_SIGNALING_CONNECTION_OPENED, connection %p, avdtp_cid 0x%02x", connection, connection->avdtp_cid); @@ -576,7 +576,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet case L2CAP_EVENT_CHANNEL_CLOSED: // data: event (8), len(8), channel (16) local_cid = l2cap_event_channel_closed_get_local_cid(packet); - connection = avdtp_connection_for_tl2cap_signaling_cid(local_cid, context); + connection = avdtp_connection_for_l2cap_signaling_cid(local_cid, context); log_info(" -> L2CAP_EVENT_CHANNEL_CLOSED signaling cid 0x%0x", local_cid); stream_endpoint = avdtp_stream_endpoint_for_l2cap_cid(local_cid, context); @@ -607,7 +607,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet break; case L2CAP_EVENT_CAN_SEND_NOW: - connection = avdtp_connection_for_tl2cap_signaling_cid(channel, context); + connection = avdtp_connection_for_l2cap_signaling_cid(channel, context); if (!connection) { stream_endpoint = avdtp_stream_endpoint_for_l2cap_cid(channel, context); if (!stream_endpoint->connection) break; @@ -634,7 +634,7 @@ uint8_t avdtp_disconnect(uint16_t avdtp_cid, avdtp_context_t * context){ if (connection->state == AVDTP_SIGNALING_CONNECTION_W4_L2CAP_DISCONNECTED) return AVDTP_CONNECTION_IN_WRONG_STATE; connection->disconnect = 1; - avdtp_request_can_send_now_self(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_self(connection, connection->l2cap_signaling_cid); return ERROR_CODE_SUCCESS; } @@ -664,11 +664,11 @@ uint8_t avdtp_open_stream(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX) return AVDTP_SEID_DOES_NOT_EXIST; connection->initiator_transaction_label++; - connection->acp_seid = remote_seid; + connection->remote_seid = remote_seid; connection->local_seid = local_seid; stream_endpoint->initiator_config_state = AVDTP_INITIATOR_W2_OPEN_STREAM; stream_endpoint->state = AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); return ERROR_CODE_SUCCESS; } @@ -696,7 +696,7 @@ uint8_t avdtp_start_stream(uint16_t avdtp_cid, uint8_t local_seid, avdtp_context stream_endpoint->start_stream = 1; connection->local_seid = local_seid; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); return ERROR_CODE_SUCCESS; } @@ -721,7 +721,7 @@ uint8_t avdtp_stop_stream(uint16_t avdtp_cid, uint8_t local_seid, avdtp_context_ stream_endpoint->stop_stream = 1; connection->local_seid = local_seid; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); return ERROR_CODE_SUCCESS; } @@ -746,7 +746,7 @@ uint8_t avdtp_abort_stream(uint16_t avdtp_cid, uint8_t local_seid, avdtp_context stream_endpoint->abort_stream = 1; connection->local_seid = local_seid; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); return ERROR_CODE_SUCCESS; } @@ -771,7 +771,7 @@ uint8_t avdtp_suspend_stream(uint16_t avdtp_cid, uint8_t local_seid, avdtp_conte stream_endpoint->suspend_stream = 1; connection->local_seid = local_seid; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); return ERROR_CODE_SUCCESS; } @@ -787,7 +787,7 @@ void avdtp_discover_stream_endpoints(uint16_t avdtp_cid, avdtp_context_t * conte case AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE: connection->initiator_transaction_label++; connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); break; default: log_error("avdtp_discover_stream_endpoints: wrong state"); @@ -806,8 +806,8 @@ void avdtp_get_capabilities(uint16_t avdtp_cid, uint8_t remote_seid, avdtp_conte if (connection->initiator_connection_state != AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE) return; connection->initiator_transaction_label++; connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES; - connection->acp_seid = remote_seid; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + connection->remote_seid = remote_seid; + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); } @@ -821,8 +821,8 @@ void avdtp_get_all_capabilities(uint16_t avdtp_cid, uint8_t remote_seid, avdtp_c if (connection->initiator_connection_state != AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE) return; connection->initiator_transaction_label++; connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES; - connection->acp_seid = remote_seid; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + connection->remote_seid = remote_seid; + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); } void avdtp_get_configuration(uint16_t avdtp_cid, uint8_t remote_seid, avdtp_context_t * context){ @@ -835,8 +835,8 @@ void avdtp_get_configuration(uint16_t avdtp_cid, uint8_t remote_seid, avdtp_cont if (connection->initiator_connection_state != AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE) return; connection->initiator_transaction_label++; connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CONFIGURATION; - connection->acp_seid = remote_seid; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + connection->remote_seid = remote_seid; + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); } void avdtp_set_configuration(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context){ @@ -855,12 +855,12 @@ void avdtp_set_configuration(uint16_t avdtp_cid, uint8_t local_seid, uint8_t rem } connection->initiator_transaction_label++; - connection->acp_seid = remote_seid; + connection->remote_seid = remote_seid; connection->local_seid = local_seid; stream_endpoint->remote_capabilities_bitmap = configured_services_bitmap; stream_endpoint->remote_capabilities = configuration; stream_endpoint->initiator_config_state = AVDTP_INITIATOR_W2_SET_CONFIGURATION; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); } void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context){ @@ -885,12 +885,12 @@ void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_se } connection->initiator_transaction_label++; - connection->acp_seid = remote_seid; + connection->remote_seid = remote_seid; connection->local_seid = local_seid; stream_endpoint->remote_capabilities_bitmap = configured_services_bitmap; stream_endpoint->remote_capabilities = configuration; stream_endpoint->initiator_config_state = AVDTP_INITIATOR_W2_RECONFIGURE_STREAM_WITH_SEID; - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); } uint8_t avdtp_remote_seps_num(uint16_t avdtp_cid, avdtp_context_t * context){ diff --git a/src/classic/avdtp.h b/src/classic/avdtp.h index 8f2872b3f..c0cb69fac 100644 --- a/src/classic/avdtp.h +++ b/src/classic/avdtp.h @@ -362,16 +362,16 @@ typedef enum { } avdtp_initiator_connection_state_t; typedef struct { - uint8_t command[200]; + uint8_t command[200]; uint16_t size; uint16_t offset; - avdtp_signal_identifier_t signal_identifier; - avdtp_message_type_t message_type; - avdtp_packet_type_t packet_type; - uint8_t acp_seid; - uint8_t int_seid; + uint8_t acp_seid; + uint8_t int_seid; uint16_t transaction_label; uint16_t num_packets; + avdtp_signal_identifier_t signal_identifier; + avdtp_message_type_t message_type; + avdtp_packet_type_t packet_type; } avdtp_signaling_packet_t; typedef struct { @@ -379,7 +379,7 @@ typedef struct { bd_addr_t remote_addr; uint16_t avdtp_cid; - uint16_t tl2cap_signaling_cid; + uint16_t l2cap_signaling_cid; avdtp_service_mode_t service_mode; avdtp_connection_state_t state; @@ -392,11 +392,11 @@ typedef struct { uint8_t disconnect; + uint8_t local_seid; + uint8_t remote_seid; + uint8_t initiator_transaction_label; uint8_t acceptor_transaction_label; - uint8_t local_seid; - uint8_t acp_seid; - uint8_t wait_to_send_acceptor; uint8_t wait_to_send_initiator; uint8_t wait_to_send_self; diff --git a/src/classic/avdtp_acceptor.c b/src/classic/avdtp_acceptor.c index 0f17b2c1b..02b8001cf 100644 --- a/src/classic/avdtp_acceptor.c +++ b/src/classic/avdtp_acceptor.c @@ -87,7 +87,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t connection->error_code = BAD_LENGTH; connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE; connection->reject_signal_identifier = connection->signaling_packet.signal_identifier; - avdtp_request_can_send_now_acceptor(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid); return; } @@ -96,7 +96,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return; log_info(" ACP: AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS"); connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS; - avdtp_request_can_send_now_acceptor(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid); return; case AVDTP_SI_GET_CAPABILITIES: case AVDTP_SI_GET_ALL_CAPABILITIES: @@ -122,7 +122,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE; } connection->reject_signal_identifier = connection->signaling_packet.signal_identifier; - avdtp_request_can_send_now_acceptor(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid); return; } break; @@ -145,7 +145,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t connection->reject_service_category = connection->local_seid; connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE; connection->reject_signal_identifier = connection->signaling_packet.signal_identifier; - avdtp_request_can_send_now_acceptor(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid); return; } // deal with first susspended seid @@ -158,7 +158,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE; connection->reject_signal_identifier = connection->signaling_packet.signal_identifier; connection->num_suspended_seids = 0; - avdtp_request_can_send_now_acceptor(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid); return; } break; @@ -167,7 +167,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_GENERAL_REJECT_WITH_ERROR_CODE; connection->reject_signal_identifier = connection->signaling_packet.signal_identifier; log_info("AVDTP_CMD_MSG signal %d not implemented, general reject", connection->signaling_packet.signal_identifier); - avdtp_request_can_send_now_acceptor(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid); return; } @@ -402,7 +402,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t if (!request_to_send){ log_info(" ACP: NOT IMPLEMENTED"); } - avdtp_request_can_send_now_acceptor(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid); } static int avdtp_acceptor_send_seps_response(uint16_t cid, uint8_t transaction_label, avdtp_stream_endpoint_t * endpoints){ @@ -460,19 +460,19 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd case AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS: connection->state = AVDTP_SIGNALING_CONNECTION_OPENED; connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE; - avdtp_acceptor_send_seps_response(connection->tl2cap_signaling_cid, connection->acceptor_transaction_label, (avdtp_stream_endpoint_t *) stream_endpoints); + avdtp_acceptor_send_seps_response(connection->l2cap_signaling_cid, connection->acceptor_transaction_label, (avdtp_stream_endpoint_t *) stream_endpoints); break; case AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE: connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE; - avdtp_acceptor_send_response_reject_with_error_code(connection->tl2cap_signaling_cid, connection->reject_signal_identifier, connection->error_code, connection->acceptor_transaction_label); + avdtp_acceptor_send_response_reject_with_error_code(connection->l2cap_signaling_cid, connection->reject_signal_identifier, connection->error_code, connection->acceptor_transaction_label); break; case AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE: connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE; - avdtp_acceptor_send_response_reject_service_category(connection->tl2cap_signaling_cid, connection->reject_signal_identifier, connection->reject_service_category, connection->error_code, connection->acceptor_transaction_label); + avdtp_acceptor_send_response_reject_service_category(connection->l2cap_signaling_cid, connection->reject_signal_identifier, connection->reject_service_category, connection->error_code, connection->acceptor_transaction_label); break; case AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_GENERAL_REJECT_WITH_ERROR_CODE: connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE; - avdtp_acceptor_send_response_general_reject(connection->tl2cap_signaling_cid, connection->reject_signal_identifier, connection->acceptor_transaction_label); + avdtp_acceptor_send_response_general_reject(connection->l2cap_signaling_cid, connection->reject_signal_identifier, connection->acceptor_transaction_label); break; default: sent = 0; @@ -489,7 +489,7 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd uint8_t reject_service_category = connection->reject_service_category; avdtp_signal_identifier_t reject_signal_identifier = connection->reject_signal_identifier; uint8_t error_code = connection->error_code; - uint16_t cid = stream_endpoint->connection ? stream_endpoint->connection->tl2cap_signaling_cid : connection->tl2cap_signaling_cid; + uint16_t cid = stream_endpoint->connection ? stream_endpoint->connection->l2cap_signaling_cid : connection->l2cap_signaling_cid; uint8_t trid = stream_endpoint->connection ? stream_endpoint->connection->acceptor_transaction_label : connection->acceptor_transaction_label; avdtp_acceptor_stream_endpoint_state_t acceptor_config_state = stream_endpoint->acceptor_config_state; @@ -606,6 +606,6 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->signaling_packet.signal_identifier); // check fragmentation if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){ - avdtp_request_can_send_now_acceptor(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid); } } diff --git a/src/classic/avdtp_initiator.c b/src/classic/avdtp_initiator.c index 2b47fb762..14a1b1698 100644 --- a/src/classic/avdtp_initiator.c +++ b/src/classic/avdtp_initiator.c @@ -73,12 +73,12 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_ if (connection->initiator_connection_state == AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER) { connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE; } else { - stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(connection->acp_seid, context); + stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(connection->remote_seid, context); if (!stream_endpoint){ stream_endpoint = avdtp_stream_endpoint_with_seid(connection->local_seid, context); } if (!stream_endpoint) return; - sep.seid = connection->acp_seid; + sep.seid = connection->remote_seid; if (stream_endpoint->initiator_config_state != AVDTP_INITIATOR_W4_ANSWER) return; stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE; @@ -124,15 +124,15 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_ case AVDTP_SI_GET_CAPABILITIES: case AVDTP_SI_GET_ALL_CAPABILITIES: - log_info("AVDTP_SI_GET(_ALL)_CAPABILITIES int %d, acp %d", connection->local_seid, connection->acp_seid); + log_info("AVDTP_SI_GET(_ALL)_CAPABILITIES int %d, acp %d", connection->local_seid, connection->remote_seid); sep.registered_service_categories = avdtp_unpack_service_capabilities(connection, &sep.capabilities, packet+offset, size-offset); if (get_bit16(sep.registered_service_categories, AVDTP_MEDIA_CODEC)){ switch (sep.capabilities.media_codec.media_codec_type){ case AVDTP_CODEC_SBC: - avdtp_signaling_emit_media_codec_sbc_capability(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->acp_seid, sep.capabilities.media_codec); + avdtp_signaling_emit_media_codec_sbc_capability(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid, sep.capabilities.media_codec); break; default: - avdtp_signaling_emit_media_codec_other_capability(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->acp_seid, sep.capabilities.media_codec); + avdtp_signaling_emit_media_codec_other_capability(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid, sep.capabilities.media_codec); break; } } @@ -144,10 +144,10 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_ if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){ switch (sep.configuration.media_codec.media_codec_type){ case AVDTP_CODEC_SBC: - avdtp_signaling_emit_media_codec_sbc_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->acp_seid, sep.configuration.media_codec); + avdtp_signaling_emit_media_codec_sbc_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid, sep.configuration.media_codec); break; default: - avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->acp_seid, sep.configuration.media_codec); + avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->avdtp_cid, connection->local_seid, connection->remote_seid, sep.configuration.media_codec); break; } } @@ -250,22 +250,22 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS: log_info(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS"); connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER; - avdtp_initiator_send_signaling_cmd(connection->tl2cap_signaling_cid, AVDTP_SI_DISCOVER, connection->initiator_transaction_label); + avdtp_initiator_send_signaling_cmd(connection->l2cap_signaling_cid, AVDTP_SI_DISCOVER, connection->initiator_transaction_label); break; case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES: log_info(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CAPABILITIES"); connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER; - avdtp_initiator_send_signaling_cmd_with_seid(connection->tl2cap_signaling_cid, AVDTP_SI_GET_CAPABILITIES, connection->initiator_transaction_label, connection->acp_seid); + avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_CAPABILITIES, connection->initiator_transaction_label, connection->remote_seid); break; case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES: log_info(" INT: AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_ALL_CAPABILITIES"); connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER; - avdtp_initiator_send_signaling_cmd_with_seid(connection->tl2cap_signaling_cid, AVDTP_SI_GET_ALL_CAPABILITIES, connection->initiator_transaction_label, connection->acp_seid); + avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_ALL_CAPABILITIES, connection->initiator_transaction_label, connection->remote_seid); break; case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_GET_CONFIGURATION: log_info(" INT: AVDTP_INITIATOR_W4_GET_CONFIGURATION"); connection->initiator_connection_state = AVDTP_SIGNALING_CONNECTION_INITIATOR_W4_ANSWER; - avdtp_initiator_send_signaling_cmd_with_seid(connection->tl2cap_signaling_cid, AVDTP_SI_GET_CONFIGURATION, connection->initiator_transaction_label, connection->acp_seid); + avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_GET_CONFIGURATION, connection->initiator_transaction_label, connection->remote_seid); break; default: sent = 0; @@ -277,7 +277,7 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av avdtp_stream_endpoint_t * stream_endpoint = NULL; - stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(connection->acp_seid, context); + stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(connection->remote_seid, context); if (!stream_endpoint){ stream_endpoint = avdtp_stream_endpoint_with_seid(connection->local_seid, context); } @@ -290,8 +290,8 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av stream_endpoint->start_stream = 0; if (stream_endpoint->state == AVDTP_STREAM_ENDPOINT_OPENED){ connection->local_seid = stream_endpoint->sep.seid; - connection->acp_seid = connection->remote_seps[stream_endpoint->remote_sep_index].seid; - avdtp_initiator_send_signaling_cmd_with_seid(connection->tl2cap_signaling_cid, AVDTP_SI_START, connection->initiator_transaction_label++, connection->acp_seid); + connection->remote_seid = connection->remote_seps[stream_endpoint->remote_sep_index].seid; + avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_START, connection->initiator_transaction_label++, connection->remote_seid); return; } return; @@ -301,8 +301,8 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av stream_endpoint->stop_stream = 0; if (stream_endpoint->state >= AVDTP_STREAM_ENDPOINT_OPENED){ connection->local_seid = stream_endpoint->sep.seid; - connection->acp_seid = connection->remote_seps[stream_endpoint->remote_sep_index].seid; - avdtp_initiator_send_signaling_cmd_with_seid(connection->tl2cap_signaling_cid, AVDTP_SI_CLOSE, connection->initiator_transaction_label++, connection->acp_seid); + connection->remote_seid = connection->remote_seps[stream_endpoint->remote_sep_index].seid; + avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_CLOSE, connection->initiator_transaction_label++, connection->remote_seid); return; } } @@ -315,9 +315,9 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av case AVDTP_STREAM_ENDPOINT_OPENED: case AVDTP_STREAM_ENDPOINT_STREAMING: connection->local_seid = stream_endpoint->sep.seid; - connection->acp_seid = connection->remote_seps[stream_endpoint->remote_sep_index].seid; + connection->remote_seid = connection->remote_seps[stream_endpoint->remote_sep_index].seid; stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING; - avdtp_initiator_send_signaling_cmd_with_seid(connection->tl2cap_signaling_cid, AVDTP_SI_ABORT, connection->initiator_transaction_label++, connection->acp_seid); + avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_ABORT, connection->initiator_transaction_label++, connection->remote_seid); return; default: break; @@ -328,7 +328,7 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av stream_endpoint->suspend_stream = 0; if (stream_endpoint->state == AVDTP_STREAM_ENDPOINT_STREAMING){ stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING; - avdtp_initiator_send_signaling_cmd_with_seid(connection->tl2cap_signaling_cid, AVDTP_SI_SUSPEND, connection->initiator_transaction_label, connection->acp_seid); + avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_SUSPEND, connection->initiator_transaction_label, connection->remote_seid); return; } } @@ -346,9 +346,9 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av switch (stream_endpoint_state){ case AVDTP_INITIATOR_W2_SET_CONFIGURATION: case AVDTP_INITIATOR_W2_RECONFIGURE_STREAM_WITH_SEID:{ - log_info(" INT: AVDTP_INITIATOR_W2_(RE)CONFIGURATION bitmap, int seid %d, acp seid %d", connection->local_seid, connection->acp_seid); + log_info(" INT: AVDTP_INITIATOR_W2_(RE)CONFIGURATION bitmap, int seid %d, acp seid %d", connection->local_seid, connection->remote_seid); // log_info_hexdump( connection->remote_capabilities.media_codec.media_codec_information, connection->remote_capabilities.media_codec.media_codec_information_len); - connection->signaling_packet.acp_seid = connection->acp_seid; + connection->signaling_packet.acp_seid = connection->remote_seid; connection->signaling_packet.int_seid = connection->local_seid; connection->signaling_packet.signal_identifier = AVDTP_SI_SET_CONFIGURATION; @@ -360,30 +360,30 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av avdtp_prepare_capabilities(&connection->signaling_packet, connection->initiator_transaction_label, stream_endpoint->remote_capabilities_bitmap, stream_endpoint->remote_capabilities, connection->signaling_packet.signal_identifier); l2cap_reserve_packet_buffer(); uint8_t * out_buffer = l2cap_get_outgoing_buffer(); - uint16_t pos = avdtp_signaling_create_fragment(connection->tl2cap_signaling_cid, &connection->signaling_packet, out_buffer); + uint16_t pos = avdtp_signaling_create_fragment(connection->l2cap_signaling_cid, &connection->signaling_packet, out_buffer); if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){ stream_endpoint->initiator_config_state = AVDTP_INITIATOR_FRAGMENTATED_COMMAND; log_info(" INT: fragmented"); } - l2cap_send_prepared(connection->tl2cap_signaling_cid, pos); + l2cap_send_prepared(connection->l2cap_signaling_cid, pos); break; } case AVDTP_INITIATOR_FRAGMENTATED_COMMAND:{ l2cap_reserve_packet_buffer(); uint8_t * out_buffer = l2cap_get_outgoing_buffer(); - uint16_t pos = avdtp_signaling_create_fragment(connection->tl2cap_signaling_cid, &connection->signaling_packet, out_buffer); + uint16_t pos = avdtp_signaling_create_fragment(connection->l2cap_signaling_cid, &connection->signaling_packet, out_buffer); if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){ stream_endpoint->initiator_config_state = AVDTP_INITIATOR_FRAGMENTATED_COMMAND; log_info(" INT: fragmented"); } - l2cap_send_prepared(connection->tl2cap_signaling_cid, pos); + l2cap_send_prepared(connection->l2cap_signaling_cid, pos); break; } case AVDTP_INITIATOR_W2_OPEN_STREAM: switch (stream_endpoint->state){ case AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM: log_info(" INT: AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM"); - avdtp_initiator_send_signaling_cmd_with_seid(connection->tl2cap_signaling_cid, AVDTP_SI_OPEN, connection->initiator_transaction_label, connection->acp_seid); + avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_OPEN, connection->initiator_transaction_label, connection->remote_seid); break; default: sent = 0; @@ -397,6 +397,6 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av // check fragmentation if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){ - avdtp_request_can_send_now_initiator(connection, connection->tl2cap_signaling_cid); + avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid); } } diff --git a/src/classic/avdtp_util.c b/src/classic/avdtp_util.c index 74addf528..2301b8fdc 100644 --- a/src/classic/avdtp_util.c +++ b/src/classic/avdtp_util.c @@ -92,12 +92,12 @@ avdtp_connection_t * avdtp_connection_for_avdtp_cid(uint16_t avdtp_cid, avdtp_co return NULL; } -avdtp_connection_t * avdtp_connection_for_tl2cap_signaling_cid(uint16_t l2cap_cid, avdtp_context_t * context){ +avdtp_connection_t * avdtp_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid, avdtp_context_t * context){ btstack_linked_list_iterator_t it; btstack_linked_list_iterator_init(&it, &context->connections); while (btstack_linked_list_iterator_has_next(&it)){ avdtp_connection_t * connection = (avdtp_connection_t *)btstack_linked_list_iterator_next(&it); - if (connection->tl2cap_signaling_cid != l2cap_cid) continue; + if (connection->l2cap_signaling_cid != l2cap_cid) continue; return connection; } return NULL; diff --git a/src/classic/avdtp_util.h b/src/classic/avdtp_util.h index 25d838418..c07393171 100644 --- a/src/classic/avdtp_util.h +++ b/src/classic/avdtp_util.h @@ -56,7 +56,7 @@ extern "C" { avdtp_connection_t * avdtp_connection_for_bd_addr(bd_addr_t addr, avdtp_context_t * context); avdtp_connection_t * avdtp_connection_for_avdtp_cid(uint16_t l2cap_cid, avdtp_context_t * context); -avdtp_connection_t * avdtp_connection_for_tl2cap_signaling_cid(uint16_t l2cap_cid, avdtp_context_t * context); +avdtp_connection_t * avdtp_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid, avdtp_context_t * context); avdtp_stream_endpoint_t * avdtp_stream_endpoint_for_l2cap_cid(uint16_t l2cap_cid, avdtp_context_t * context); avdtp_stream_endpoint_t * avdtp_stream_endpoint_with_seid(uint8_t seid, avdtp_context_t * context); avdtp_stream_endpoint_t * avdtp_stream_endpoint_associated_with_acp_seid(uint16_t acp_seid, avdtp_context_t * context);