mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 19:20:51 +00:00
avdtp: fix compile warning, rename function
This commit is contained in:
parent
91a08b113f
commit
319b19cc14
@ -154,7 +154,7 @@ static void produce_audio(int16_t * pcm_buffer, int num_samples){
|
||||
}
|
||||
}
|
||||
|
||||
static int fill_sbc_audio_buffer(a2dp_media_sending_context_t * context){
|
||||
static int a2dp_demo_fill_sbc_audio_buffer(a2dp_media_sending_context_t * context){
|
||||
// perform sbc encodin
|
||||
int total_num_bytes_read = 0;
|
||||
int num_audio_samples_per_sbc_buffer = btstack_sbc_encoder_num_audio_frames();
|
||||
@ -177,7 +177,7 @@ static int fill_sbc_audio_buffer(a2dp_media_sending_context_t * context){
|
||||
return total_num_bytes_read;
|
||||
}
|
||||
|
||||
static void avdtp_audio_timeout_handler(btstack_timer_source_t * timer){
|
||||
static void a2dp_demo_audio_timeout_handler(btstack_timer_source_t * timer){
|
||||
a2dp_media_sending_context_t * context = (a2dp_media_sending_context_t *) btstack_run_loop_get_timer_context(timer);
|
||||
btstack_run_loop_set_timer(&context->audio_timer, AUDIO_TIMEOUT_MS);
|
||||
btstack_run_loop_add_timer(&context->audio_timer);
|
||||
@ -200,7 +200,7 @@ static void avdtp_audio_timeout_handler(btstack_timer_source_t * timer){
|
||||
|
||||
if (context->sbc_ready_to_send) return;
|
||||
|
||||
fill_sbc_audio_buffer(context);
|
||||
a2dp_demo_fill_sbc_audio_buffer(context);
|
||||
|
||||
if ((context->sbc_storage_count + btstack_sbc_encoder_sbc_buffer_length()) > context->max_media_payload_size){
|
||||
// schedule sending
|
||||
@ -215,7 +215,7 @@ static void a2dp_demo_timer_start(a2dp_media_sending_context_t * context){
|
||||
context->sbc_ready_to_send = 0;
|
||||
context->streaming = 1;
|
||||
btstack_run_loop_remove_timer(&context->audio_timer);
|
||||
btstack_run_loop_set_timer_handler(&context->audio_timer, avdtp_audio_timeout_handler);
|
||||
btstack_run_loop_set_timer_handler(&context->audio_timer, a2dp_demo_audio_timeout_handler);
|
||||
btstack_run_loop_set_timer_context(&context->audio_timer, context);
|
||||
btstack_run_loop_set_timer(&context->audio_timer, AUDIO_TIMEOUT_MS);
|
||||
btstack_run_loop_add_timer(&context->audio_timer);
|
||||
|
@ -461,7 +461,6 @@ static void avdtp_handle_sdp_client_query_result(uint8_t packet_type, uint16_t c
|
||||
|
||||
void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size, avdtp_context_t * context){
|
||||
bd_addr_t event_addr;
|
||||
hci_con_handle_t con_handle;
|
||||
uint16_t psm;
|
||||
uint16_t local_cid;
|
||||
avdtp_stream_endpoint_t * stream_endpoint = NULL;
|
||||
@ -553,10 +552,8 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
return;
|
||||
}
|
||||
|
||||
con_handle = l2cap_event_channel_opened_get_handle(packet);
|
||||
|
||||
// log_info("L2CAP_EVENT_CHANNEL_OPENED: Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x",
|
||||
// bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
||||
// bd_addr_to_str(event_addr), l2cap_event_channel_opened_get_handle(packet), psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
||||
|
||||
if (psm != BLUETOOTH_PROTOCOL_AVDTP) break;
|
||||
|
||||
|
@ -94,7 +94,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
switch (connection->signaling_packet.signal_identifier){
|
||||
case AVDTP_SI_DISCOVER:
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
log_info(" ACP: AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS");
|
||||
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->l2cap_signaling_cid);
|
||||
return;
|
||||
@ -110,7 +110,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
connection->local_seid = packet[offset++] >> 2;
|
||||
stream_endpoint = avdtp_stream_endpoint_with_seid(connection->local_seid, context);
|
||||
if (!stream_endpoint){
|
||||
log_info(" ACP: cmd %d - RESPONSE REJECT", connection->signaling_packet.signal_identifier);
|
||||
log_info("ACP: cmd %d - RESPONSE REJECT", connection->signaling_packet.signal_identifier);
|
||||
connection->error_code = BAD_ACP_SEID;
|
||||
if (connection->signaling_packet.signal_identifier == AVDTP_SI_OPEN){
|
||||
connection->error_code = BAD_STATE;
|
||||
@ -129,7 +129,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
|
||||
case AVDTP_SI_SUSPEND:{
|
||||
int i;
|
||||
log_info(" ACP: AVDTP_SI_SUSPEND seids: ");
|
||||
log_info("ACP: AVDTP_SI_SUSPEND seids: ");
|
||||
connection->num_suspended_seids = 0;
|
||||
|
||||
for (i = offset; i < size; i++){
|
||||
@ -140,7 +140,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
}
|
||||
|
||||
if (connection->num_suspended_seids == 0) {
|
||||
log_info(" ACP: CATEGORY RESPONSE REJECT BAD_ACP_SEID");
|
||||
log_info("ACP: CATEGORY RESPONSE REJECT BAD_ACP_SEID");
|
||||
connection->error_code = BAD_ACP_SEID;
|
||||
connection->reject_service_category = connection->local_seid;
|
||||
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
@ -152,7 +152,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
connection->local_seid = connection->suspended_seids[0];
|
||||
stream_endpoint = avdtp_stream_endpoint_with_seid(connection->local_seid, context);
|
||||
if (!stream_endpoint){
|
||||
log_info(" ACP: stream_endpoint not found, CATEGORY RESPONSE REJECT BAD_ACP_SEID");
|
||||
log_info("ACP: stream_endpoint not found, CATEGORY RESPONSE REJECT BAD_ACP_SEID");
|
||||
connection->error_code = BAD_ACP_SEID;
|
||||
connection->reject_service_category = connection->local_seid;
|
||||
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
@ -185,15 +185,15 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
case AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE:
|
||||
switch (connection->signaling_packet.signal_identifier){
|
||||
case AVDTP_SI_GET_ALL_CAPABILITIES:
|
||||
log_info(" ACP: AVDTP_SI_GET_ALL_CAPABILITIES");
|
||||
log_info("ACP: AVDTP_SI_GET_ALL_CAPABILITIES");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_ALL_CAPABILITIES;
|
||||
break;
|
||||
case AVDTP_SI_GET_CAPABILITIES:
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES");
|
||||
log_info("ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES;
|
||||
break;
|
||||
case AVDTP_SI_SET_CONFIGURATION:{
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION ");
|
||||
log_info("ACP: AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION ");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION;
|
||||
connection->reject_service_category = 0;
|
||||
stream_endpoint->connection = connection;
|
||||
@ -211,13 +211,13 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
// find or add sep
|
||||
|
||||
stream_endpoint->remote_sep_index = avdtp_find_remote_sep(stream_endpoint->connection, sep.seid);
|
||||
log_info(" ACP .. seid %d, index %d", sep.seid, stream_endpoint->remote_sep_index);
|
||||
log_info("ACP .. seid %d, index %d", sep.seid, stream_endpoint->remote_sep_index);
|
||||
|
||||
if (stream_endpoint->remote_sep_index != AVDTP_INVALID_SEP_INDEX){
|
||||
if (stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].in_use){
|
||||
// if (stream_endpoint->state < AVDTP_STREAM_ENDPOINT_OPENED){
|
||||
// stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
// log_info(" ACP: update seid %d, to %p", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
// log_info("ACP: update seid %d, to %p", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
// break;
|
||||
// }
|
||||
// reject if already configured
|
||||
@ -235,15 +235,15 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
} else {
|
||||
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
log_info(" ACP: update seid %d, to %p", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info("ACP: update seid %d, to %p", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
}
|
||||
} else {
|
||||
// add new
|
||||
log_info(" ACP: seid %d not found in %p", sep.seid, stream_endpoint);
|
||||
log_info("ACP: seid %d not found in %p", sep.seid, stream_endpoint);
|
||||
stream_endpoint->remote_sep_index = connection->remote_seps_num;
|
||||
connection->remote_seps_num++;
|
||||
connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
log_info(" ACP: add seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info("ACP: add seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
}
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.configuration.media_codec.media_codec_type){
|
||||
@ -264,7 +264,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
|
||||
avdtp_sep_t sep;
|
||||
sep.seid = connection->local_seid;
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE seid %d", sep.seid);
|
||||
log_info("ACP: AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE seid %d", sep.seid);
|
||||
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, connection->signaling_packet.command+offset, packet_size-offset);
|
||||
if (connection->error_code){
|
||||
// fire configuration parsing errors
|
||||
@ -276,14 +276,14 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
// find sep or raise error
|
||||
stream_endpoint->remote_sep_index = avdtp_find_remote_sep(stream_endpoint->connection, sep.seid);
|
||||
if (stream_endpoint->remote_sep_index == AVDTP_INVALID_SEP_INDEX){
|
||||
log_info(" ACP: REJECT AVDTP_SI_RECONFIGURE, BAD_ACP_SEID");
|
||||
log_info("ACP: REJECT AVDTP_SI_RECONFIGURE, BAD_ACP_SEID");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_ACP_SEID;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
break;
|
||||
}
|
||||
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
log_info(" ACP: update seid %d, to %p", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info("ACP: update seid %d, to %p", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.capabilities.media_codec.media_codec_type){
|
||||
@ -300,43 +300,43 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
}
|
||||
|
||||
case AVDTP_SI_GET_CONFIGURATION:
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION");
|
||||
log_info("ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION;
|
||||
break;
|
||||
case AVDTP_SI_OPEN:
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_CONFIGURED){
|
||||
log_info(" ACP: REJECT AVDTP_SI_OPEN, BAD_STATE");
|
||||
log_info("ACP: REJECT AVDTP_SI_OPEN, BAD_STATE");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
break;
|
||||
}
|
||||
log_info(" ACP: AVDTP_STREAM_ENDPOINT_W2_ANSWER_OPEN_STREAM");
|
||||
log_info("ACP: AVDTP_STREAM_ENDPOINT_W2_ANSWER_OPEN_STREAM");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_OPEN_STREAM;
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_CONNECTED;
|
||||
connection->local_seid = stream_endpoint->sep.seid;
|
||||
break;
|
||||
case AVDTP_SI_START:
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED){
|
||||
log_info(" ACP: REJECT AVDTP_SI_START, BAD_STATE");
|
||||
log_info("ACP: REJECT AVDTP_SI_START, BAD_STATE");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
break;
|
||||
}
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM");
|
||||
log_info("ACP: AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM;
|
||||
break;
|
||||
case AVDTP_SI_CLOSE:
|
||||
switch (stream_endpoint->state){
|
||||
case AVDTP_STREAM_ENDPOINT_OPENED:
|
||||
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM");
|
||||
log_info("ACP: AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM;
|
||||
break;
|
||||
default:
|
||||
log_info(" ACP: AVDTP_SI_CLOSE, bad state %d ", stream_endpoint->state);
|
||||
log_info("ACP: AVDTP_SI_CLOSE, bad state %d ", stream_endpoint->state);
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
@ -349,12 +349,12 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
case AVDTP_STREAM_ENDPOINT_CLOSING:
|
||||
case AVDTP_STREAM_ENDPOINT_OPENED:
|
||||
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM");
|
||||
log_info("ACP: AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM;
|
||||
break;
|
||||
default:
|
||||
log_info(" ACP: AVDTP_SI_ABORT, bad state %d ", stream_endpoint->state);
|
||||
log_info("ACP: AVDTP_SI_ABORT, bad state %d ", stream_endpoint->state);
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
@ -369,12 +369,12 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
||||
connection->num_suspended_seids--;
|
||||
if (connection->num_suspended_seids <= 0){
|
||||
log_info(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM");
|
||||
log_info("ACP: AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log_info(" ACP: AVDTP_SI_SUSPEND, bad state ");
|
||||
log_info("ACP: AVDTP_SI_SUSPEND, bad state ");
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||
connection->error_code = BAD_STATE;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
@ -385,7 +385,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
//stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_SUSPEND_STREAM;
|
||||
break;
|
||||
default:
|
||||
log_info(" ACP: NOT IMPLEMENTED, Reject signal_identifier %02x", connection->signaling_packet.signal_identifier);
|
||||
log_info("ACP: NOT IMPLEMENTED, Reject signal_identifier %02x", connection->signaling_packet.signal_identifier);
|
||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD;
|
||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||
break;
|
||||
@ -396,7 +396,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
}
|
||||
|
||||
if (!request_to_send){
|
||||
log_info(" ACP: NOT IMPLEMENTED");
|
||||
log_info("ACP: NOT IMPLEMENTED");
|
||||
}
|
||||
avdtp_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
||||
}
|
||||
@ -475,7 +475,7 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
break;
|
||||
}
|
||||
if (sent){
|
||||
log_info(" ACP: DONE");
|
||||
log_info("ACP: DONE");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -493,7 +493,6 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
uint8_t * out_buffer;
|
||||
uint16_t pos;
|
||||
|
||||
int status = 0;
|
||||
switch (acceptor_config_state){
|
||||
case AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE:
|
||||
break;
|
||||
@ -504,9 +503,9 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
pos = avdtp_signaling_create_fragment(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->acceptor_config_state = acceptor_config_state;
|
||||
log_info(" ACP: fragmented");
|
||||
log_info("ACP: fragmented");
|
||||
} else {
|
||||
log_info(" ACP:DONE");
|
||||
log_info("ACP:DONE");
|
||||
}
|
||||
l2cap_send_prepared(cid, pos);
|
||||
break;
|
||||
@ -517,14 +516,14 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
pos = avdtp_signaling_create_fragment(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->acceptor_config_state = acceptor_config_state;
|
||||
log_info(" ACP: fragmented");
|
||||
log_info("ACP: fragmented");
|
||||
} else {
|
||||
log_info(" ACP:DONE");
|
||||
log_info("ACP:DONE");
|
||||
}
|
||||
l2cap_send_prepared(cid, pos);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION:
|
||||
log_info(" ACP: DONE");
|
||||
log_info("ACP: DONE");
|
||||
log_info(" -> AVDTP_STREAM_ENDPOINT_CONFIGURED");
|
||||
stream_endpoint->connection = connection;
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
||||
@ -532,7 +531,7 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SET_CONFIGURATION);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE:
|
||||
log_info(" ACP: DONE ");
|
||||
log_info("ACP: DONE ");
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_RECONFIGURE);
|
||||
break;
|
||||
|
||||
@ -544,60 +543,56 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
pos = avdtp_signaling_create_fragment(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->acceptor_config_state = acceptor_config_state;
|
||||
log_info(" ACP: fragmented");
|
||||
log_info("ACP: fragmented");
|
||||
} else {
|
||||
log_info(" ACP:DONE");
|
||||
log_info("ACP:DONE");
|
||||
}
|
||||
l2cap_send_prepared(cid, pos);
|
||||
break;
|
||||
}
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_OPEN_STREAM:
|
||||
log_info(" ACP: DONE");
|
||||
log_info("ACP: DONE");
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_OPEN);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM:
|
||||
log_info(" ACP: DONE ");
|
||||
log_info("ACP: DONE ");
|
||||
log_info(" -> AVDTP_STREAM_ENDPOINT_STREAMING ");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_START);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM:
|
||||
log_info(" ACP: DONE");
|
||||
log_info("ACP: DONE");
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_CLOSE);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM:
|
||||
log_info(" ACP: DONE");
|
||||
log_info("ACP: DONE");
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_ABORT);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM:
|
||||
log_info(" ACP: DONE");
|
||||
log_info("ACP: DONE");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SUSPEND);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD:
|
||||
status = 1;
|
||||
log_info(" ACP: DONE REJECT");
|
||||
log_info("ACP: DONE REJECT");
|
||||
connection->reject_signal_identifier = AVDTP_SI_NONE;
|
||||
avdtp_acceptor_send_response_reject(cid, reject_signal_identifier, trid);
|
||||
break;
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE:
|
||||
status = 1;
|
||||
log_info(" ACP: DONE REJECT CATEGORY");
|
||||
log_info("ACP: DONE REJECT CATEGORY");
|
||||
connection->reject_service_category = 0;
|
||||
avdtp_acceptor_send_response_reject_service_category(cid, reject_signal_identifier, reject_service_category, error_code, trid);
|
||||
break;
|
||||
|
||||
case AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE:
|
||||
status = 1;
|
||||
log_info(" ACP: DONE REJECT");
|
||||
log_info("ACP: DONE REJECT");
|
||||
connection->reject_signal_identifier = AVDTP_SI_NONE;
|
||||
connection->error_code = 0;
|
||||
avdtp_acceptor_send_response_reject_with_error_code(cid, reject_signal_identifier, error_code, trid);
|
||||
break;
|
||||
default:
|
||||
status = 0;
|
||||
log_info(" ACP: NOT IMPLEMENTED");
|
||||
log_info("ACP: NOT IMPLEMENTED");
|
||||
sent = 0;
|
||||
break;
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->signaling_packet.signal_identifier);
|
||||
// check fragmentation
|
||||
|
@ -65,7 +65,7 @@ static int avdtp_initiator_send_signaling_cmd_with_seid(uint16_t cid, avdtp_sign
|
||||
}
|
||||
|
||||
void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_t *packet, uint16_t size, int offset, avdtp_context_t * context){
|
||||
int status = 0;
|
||||
// int status = 0;
|
||||
avdtp_stream_endpoint_t * stream_endpoint = NULL;
|
||||
|
||||
uint8_t remote_sep_index;
|
||||
@ -88,26 +88,24 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
case AVDTP_RESPONSE_ACCEPT_MSG:
|
||||
switch (connection->signaling_packet.signal_identifier){
|
||||
case AVDTP_SI_DISCOVER:{
|
||||
log_info("AVDTP_SI_DISCOVER");
|
||||
if (connection->signaling_packet.transaction_label != connection->initiator_transaction_label){
|
||||
log_info(" unexpected transaction label, got %d, expected %d", connection->signaling_packet.transaction_label, connection->initiator_transaction_label);
|
||||
status = BAD_HEADER_FORMAT;
|
||||
// status = BAD_HEADER_FORMAT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (size == 3){
|
||||
log_info(" ERROR code %02x", packet[offset]);
|
||||
status = packet[offset];
|
||||
break;
|
||||
}
|
||||
|
||||
int i;
|
||||
int i;
|
||||
for (i = offset; i < size; i += 2){
|
||||
sep.seid = packet[i] >> 2;
|
||||
offset++;
|
||||
if (sep.seid < 0x01 || sep.seid > 0x3E){
|
||||
log_info(" invalid sep id");
|
||||
status = BAD_ACP_SEID;
|
||||
// status = BAD_ACP_SEID;
|
||||
break;
|
||||
}
|
||||
sep.in_use = (packet[i] >> 1) & 0x01;
|
||||
@ -124,7 +122,6 @@ 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->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){
|
||||
@ -139,7 +136,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
break;
|
||||
|
||||
case AVDTP_SI_GET_CONFIGURATION:
|
||||
log_info("AVDTP_SI_GET_CONFIGURATION");
|
||||
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, packet+offset, size-offset);
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.configuration.media_codec.media_codec_type){
|
||||
@ -154,7 +150,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
break;
|
||||
|
||||
case AVDTP_SI_RECONFIGURE:
|
||||
log_info("AVDTP_SI_RECONFIGURE");
|
||||
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, connection->signaling_packet.command+4, connection->signaling_packet.size-4);
|
||||
// TODO check if configuration is supported
|
||||
|
||||
@ -163,12 +158,11 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
stream_endpoint->remote_sep_index = remote_sep_index;
|
||||
connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
||||
log_info(" INT: update seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info("INT: update seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
}
|
||||
break;
|
||||
|
||||
case AVDTP_SI_SET_CONFIGURATION:{
|
||||
log_info("AVDTP_SI_SET_CONFIGURATION");
|
||||
sep.configured_service_categories = stream_endpoint->remote_capabilities_bitmap;
|
||||
sep.configuration = stream_endpoint->remote_capabilities;
|
||||
sep.in_use = 1;
|
||||
@ -183,13 +177,12 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
connection->remote_seps_num++;
|
||||
}
|
||||
connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||
log_info(" INT: configured remote seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
log_info("INT: configured remote seid %d, to %p", connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
||||
break;
|
||||
}
|
||||
|
||||
case AVDTP_SI_OPEN:
|
||||
log_info("AVDTP_SI_OPEN");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM) {
|
||||
log_error("AVDTP_SI_OPEN in wrong stream endpoint state");
|
||||
return;
|
||||
@ -199,16 +192,13 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
l2cap_create_channel(context->packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, NULL);
|
||||
return;
|
||||
case AVDTP_SI_START:
|
||||
log_info("AVDTP_SI_START");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED) {
|
||||
log_error("AVDTP_SI_START in wrong stream endpoint state");
|
||||
return;
|
||||
}
|
||||
log_info("AVDTP_STREAM_ENDPOINT_STREAMING");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
|
||||
break;
|
||||
case AVDTP_SI_SUSPEND:
|
||||
log_info("AVDTP_SI_SUSPEND");
|
||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING) {
|
||||
log_error("AVDTP_SI_SUSPEND in wrong stream endpoint state");
|
||||
return;
|
||||
@ -216,15 +206,12 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
||||
break;
|
||||
case AVDTP_SI_CLOSE:
|
||||
log_info("AVDTP_SI_CLOSE");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
||||
break;
|
||||
case AVDTP_SI_ABORT:
|
||||
log_info("AVDTP_SI_ABORT");
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
||||
break;
|
||||
default:
|
||||
status = 1;
|
||||
log_info(" AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented", connection->signaling_packet.signal_identifier);
|
||||
break;
|
||||
}
|
||||
@ -245,25 +232,25 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
}
|
||||
|
||||
void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, avdtp_context_t * context){
|
||||
int sent = 1;
|
||||
int sent = 1;
|
||||
switch (connection->initiator_connection_state){
|
||||
case AVDTP_SIGNALING_CONNECTION_INITIATOR_W2_DISCOVER_SEPS:
|
||||
log_info(" INT: 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->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");
|
||||
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->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");
|
||||
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->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");
|
||||
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->l2cap_signaling_cid, AVDTP_SI_GET_CONFIGURATION, connection->initiator_transaction_label, connection->remote_seid);
|
||||
break;
|
||||
@ -346,7 +333,7 @@ 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->remote_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->remote_seid;
|
||||
connection->signaling_packet.int_seid = connection->local_seid;
|
||||
@ -363,7 +350,7 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
|
||||
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");
|
||||
log_info("INT: fragmented");
|
||||
}
|
||||
l2cap_send_prepared(connection->l2cap_signaling_cid, pos);
|
||||
break;
|
||||
@ -374,7 +361,7 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
|
||||
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");
|
||||
log_info("INT: fragmented");
|
||||
}
|
||||
l2cap_send_prepared(connection->l2cap_signaling_cid, pos);
|
||||
break;
|
||||
@ -382,7 +369,7 @@ void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, av
|
||||
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");
|
||||
log_info("INT: AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM");
|
||||
avdtp_initiator_send_signaling_cmd_with_seid(connection->l2cap_signaling_cid, AVDTP_SI_OPEN, connection->initiator_transaction_label, connection->remote_seid);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user