mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +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
|
// perform sbc encodin
|
||||||
int total_num_bytes_read = 0;
|
int total_num_bytes_read = 0;
|
||||||
int num_audio_samples_per_sbc_buffer = btstack_sbc_encoder_num_audio_frames();
|
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;
|
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);
|
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_set_timer(&context->audio_timer, AUDIO_TIMEOUT_MS);
|
||||||
btstack_run_loop_add_timer(&context->audio_timer);
|
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;
|
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){
|
if ((context->sbc_storage_count + btstack_sbc_encoder_sbc_buffer_length()) > context->max_media_payload_size){
|
||||||
// schedule sending
|
// 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->sbc_ready_to_send = 0;
|
||||||
context->streaming = 1;
|
context->streaming = 1;
|
||||||
btstack_run_loop_remove_timer(&context->audio_timer);
|
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(&context->audio_timer, context);
|
||||||
btstack_run_loop_set_timer(&context->audio_timer, AUDIO_TIMEOUT_MS);
|
btstack_run_loop_set_timer(&context->audio_timer, AUDIO_TIMEOUT_MS);
|
||||||
btstack_run_loop_add_timer(&context->audio_timer);
|
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){
|
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;
|
bd_addr_t event_addr;
|
||||||
hci_con_handle_t con_handle;
|
|
||||||
uint16_t psm;
|
uint16_t psm;
|
||||||
uint16_t local_cid;
|
uint16_t local_cid;
|
||||||
avdtp_stream_endpoint_t * stream_endpoint = NULL;
|
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;
|
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",
|
// 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;
|
if (psm != BLUETOOTH_PROTOCOL_AVDTP) break;
|
||||||
|
|
||||||
|
@ -493,7 +493,6 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
|||||||
uint8_t * out_buffer;
|
uint8_t * out_buffer;
|
||||||
uint16_t pos;
|
uint16_t pos;
|
||||||
|
|
||||||
int status = 0;
|
|
||||||
switch (acceptor_config_state){
|
switch (acceptor_config_state){
|
||||||
case AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE:
|
case AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE:
|
||||||
break;
|
break;
|
||||||
@ -575,29 +574,25 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
|||||||
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SUSPEND);
|
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SUSPEND);
|
||||||
break;
|
break;
|
||||||
case AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD:
|
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;
|
connection->reject_signal_identifier = AVDTP_SI_NONE;
|
||||||
avdtp_acceptor_send_response_reject(cid, reject_signal_identifier, trid);
|
avdtp_acceptor_send_response_reject(cid, reject_signal_identifier, trid);
|
||||||
break;
|
break;
|
||||||
case AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE:
|
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;
|
connection->reject_service_category = 0;
|
||||||
avdtp_acceptor_send_response_reject_service_category(cid, reject_signal_identifier, reject_service_category, error_code, trid);
|
avdtp_acceptor_send_response_reject_service_category(cid, reject_signal_identifier, reject_service_category, error_code, trid);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE:
|
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->reject_signal_identifier = AVDTP_SI_NONE;
|
||||||
connection->error_code = 0;
|
connection->error_code = 0;
|
||||||
avdtp_acceptor_send_response_reject_with_error_code(cid, reject_signal_identifier, error_code, trid);
|
avdtp_acceptor_send_response_reject_with_error_code(cid, reject_signal_identifier, error_code, trid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
status = 0;
|
|
||||||
log_info("ACP: NOT IMPLEMENTED");
|
log_info("ACP: NOT IMPLEMENTED");
|
||||||
sent = 0;
|
sent = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->signaling_packet.signal_identifier);
|
avdtp_signaling_emit_accept(context->avdtp_callback, connection->avdtp_cid, avdtp_local_seid(stream_endpoint), connection->signaling_packet.signal_identifier);
|
||||||
// check fragmentation
|
// 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){
|
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;
|
avdtp_stream_endpoint_t * stream_endpoint = NULL;
|
||||||
|
|
||||||
uint8_t remote_sep_index;
|
uint8_t remote_sep_index;
|
||||||
@ -88,16 +88,14 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
case AVDTP_RESPONSE_ACCEPT_MSG:
|
case AVDTP_RESPONSE_ACCEPT_MSG:
|
||||||
switch (connection->signaling_packet.signal_identifier){
|
switch (connection->signaling_packet.signal_identifier){
|
||||||
case AVDTP_SI_DISCOVER:{
|
case AVDTP_SI_DISCOVER:{
|
||||||
log_info("AVDTP_SI_DISCOVER");
|
|
||||||
if (connection->signaling_packet.transaction_label != connection->initiator_transaction_label){
|
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);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == 3){
|
if (size == 3){
|
||||||
log_info(" ERROR code %02x", packet[offset]);
|
log_info(" ERROR code %02x", packet[offset]);
|
||||||
status = packet[offset];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +105,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
offset++;
|
offset++;
|
||||||
if (sep.seid < 0x01 || sep.seid > 0x3E){
|
if (sep.seid < 0x01 || sep.seid > 0x3E){
|
||||||
log_info(" invalid sep id");
|
log_info(" invalid sep id");
|
||||||
status = BAD_ACP_SEID;
|
// status = BAD_ACP_SEID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sep.in_use = (packet[i] >> 1) & 0x01;
|
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_CAPABILITIES:
|
||||||
case AVDTP_SI_GET_ALL_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);
|
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)){
|
if (get_bit16(sep.registered_service_categories, AVDTP_MEDIA_CODEC)){
|
||||||
switch (sep.capabilities.media_codec.media_codec_type){
|
switch (sep.capabilities.media_codec.media_codec_type){
|
||||||
@ -139,7 +136,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AVDTP_SI_GET_CONFIGURATION:
|
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);
|
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)){
|
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||||
switch (sep.configuration.media_codec.media_codec_type){
|
switch (sep.configuration.media_codec.media_codec_type){
|
||||||
@ -154,7 +150,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AVDTP_SI_RECONFIGURE:
|
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);
|
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
|
// TODO check if configuration is supported
|
||||||
|
|
||||||
@ -168,7 +163,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AVDTP_SI_SET_CONFIGURATION:{
|
case AVDTP_SI_SET_CONFIGURATION:{
|
||||||
log_info("AVDTP_SI_SET_CONFIGURATION");
|
|
||||||
sep.configured_service_categories = stream_endpoint->remote_capabilities_bitmap;
|
sep.configured_service_categories = stream_endpoint->remote_capabilities_bitmap;
|
||||||
sep.configuration = stream_endpoint->remote_capabilities;
|
sep.configuration = stream_endpoint->remote_capabilities;
|
||||||
sep.in_use = 1;
|
sep.in_use = 1;
|
||||||
@ -189,7 +183,6 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
}
|
}
|
||||||
|
|
||||||
case AVDTP_SI_OPEN:
|
case AVDTP_SI_OPEN:
|
||||||
log_info("AVDTP_SI_OPEN");
|
|
||||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM) {
|
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_W2_REQUEST_OPEN_STREAM) {
|
||||||
log_error("AVDTP_SI_OPEN in wrong stream endpoint state");
|
log_error("AVDTP_SI_OPEN in wrong stream endpoint state");
|
||||||
return;
|
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);
|
l2cap_create_channel(context->packet_handler, connection->remote_addr, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, NULL);
|
||||||
return;
|
return;
|
||||||
case AVDTP_SI_START:
|
case AVDTP_SI_START:
|
||||||
log_info("AVDTP_SI_START");
|
|
||||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED) {
|
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED) {
|
||||||
log_error("AVDTP_SI_START in wrong stream endpoint state");
|
log_error("AVDTP_SI_START in wrong stream endpoint state");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_info("AVDTP_STREAM_ENDPOINT_STREAMING");
|
|
||||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
|
||||||
break;
|
break;
|
||||||
case AVDTP_SI_SUSPEND:
|
case AVDTP_SI_SUSPEND:
|
||||||
log_info("AVDTP_SI_SUSPEND");
|
|
||||||
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING) {
|
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_STREAMING) {
|
||||||
log_error("AVDTP_SI_SUSPEND in wrong stream endpoint state");
|
log_error("AVDTP_SI_SUSPEND in wrong stream endpoint state");
|
||||||
return;
|
return;
|
||||||
@ -216,15 +206,12 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
||||||
break;
|
break;
|
||||||
case AVDTP_SI_CLOSE:
|
case AVDTP_SI_CLOSE:
|
||||||
log_info("AVDTP_SI_CLOSE");
|
|
||||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
||||||
break;
|
break;
|
||||||
case AVDTP_SI_ABORT:
|
case AVDTP_SI_ABORT:
|
||||||
log_info("AVDTP_SI_ABORT");
|
|
||||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
status = 1;
|
|
||||||
log_info(" AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented", connection->signaling_packet.signal_identifier);
|
log_info(" AVDTP_RESPONSE_ACCEPT_MSG, signal %d not implemented", connection->signaling_packet.signal_identifier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user