mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-06 12:39:51 +00:00
a2dp: generalize source config function, pass role param
This commit is contained in:
parent
cb9e52f65b
commit
302e9e5200
@ -268,7 +268,7 @@ static void a2dp_discover_seps_with_next_waiting_connection(void){
|
||||
}
|
||||
}
|
||||
|
||||
void a2dp_source_ready_for_sep_discovery(avdtp_connection_t * connection){
|
||||
void a2dp_config_process_ready_for_sep_discovery(avdtp_role_t role, avdtp_connection_t *connection) {
|
||||
// start discover seps now if:
|
||||
// - outgoing active: signaling for outgoing connection
|
||||
// - outgoing not active: incoming connection and no sep discover ongoing
|
||||
@ -317,7 +317,7 @@ static void a2dp_handle_received_configuration(const uint8_t *packet, uint8_t lo
|
||||
}
|
||||
}
|
||||
|
||||
static void a2dp_source_set_config(avdtp_connection_t * connection){
|
||||
void a2dp_config_process_set_config(avdtp_role_t role, avdtp_connection_t *connection) {
|
||||
uint8_t remote_seid = connection->a2dp_source_config_process.local_stream_endpoint->set_config_remote_seid;
|
||||
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_config_process.local_stream_endpoint), remote_seid);
|
||||
@ -336,8 +336,8 @@ static void a2dp_source_handle_media_capability(uint16_t cid, uint8_t a2dp_subev
|
||||
a2dp_replace_subevent_id_and_emit_source(packet, size, a2dp_subevent_id);
|
||||
}
|
||||
|
||||
uint8_t a2dp_source_config_init(avdtp_connection_t *connection, uint8_t local_seid, uint8_t remote_seid,
|
||||
avdtp_media_codec_type_t codec_type) {
|
||||
uint8_t a2dp_config_process_config_init(avdtp_role_t role, avdtp_connection_t *connection, uint8_t local_seid, uint8_t remote_seid,
|
||||
avdtp_media_codec_type_t codec_type) {
|
||||
|
||||
// check state
|
||||
switch (connection->a2dp_source_config_process.state){
|
||||
@ -390,7 +390,7 @@ uint8_t a2dp_source_config_init(avdtp_connection_t *connection, uint8_t local_se
|
||||
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
void a2dp_source_config_process_avdtp_event_handler(uint8_t *packet, uint16_t size) {
|
||||
void a2dp_config_process_avdtp_event_handler(avdtp_role_t role, uint8_t *packet, uint16_t size) {
|
||||
uint16_t cid;
|
||||
avdtp_connection_t * connection;
|
||||
uint8_t signal_identifier;
|
||||
@ -427,7 +427,7 @@ void a2dp_source_config_process_avdtp_event_handler(uint8_t *packet, uint16_t si
|
||||
// a) this is an outgoing source connection
|
||||
// b) this connection wasn't caused by an outgoing sink request
|
||||
if (connection->a2dp_source_config_process.outgoing_active || !connection->a2dp_sink_config_process.outgoing_active){
|
||||
a2dp_source_ready_for_sep_discovery(connection);
|
||||
a2dp_config_process_ready_for_sep_discovery(AVDTP_ROLE_SOURCE, connection);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -683,7 +683,7 @@ void a2dp_source_config_process_avdtp_event_handler(uint8_t *packet, uint16_t si
|
||||
return;
|
||||
|
||||
case A2DP_SET_CONFIGURATION:
|
||||
a2dp_source_set_config(connection);
|
||||
a2dp_config_process_set_config(AVDTP_ROLE_SOURCE, connection);
|
||||
return;
|
||||
|
||||
case A2DP_W2_OPEN_STREAM_WITH_SEID:
|
||||
|
@ -57,7 +57,17 @@ void a2dp_init(void);
|
||||
|
||||
void a2dp_deinit(void);
|
||||
|
||||
void a2dp_create_sdp_record(uint8_t * service, uint32_t service_record_handle, uint16_t service_class_uuid, uint16_t supported_features, const char * service_name, const char * service_provider_name);
|
||||
void a2dp_create_sdp_record(uint8_t * service, uint32_t service_record_handle, uint16_t service_class_uuid,
|
||||
uint16_t supported_features, const char * service_name, const char * service_provider_name);
|
||||
|
||||
// config process
|
||||
void a2dp_config_process_ready_for_sep_discovery(avdtp_role_t role, avdtp_connection_t *connection);
|
||||
|
||||
void a2dp_config_process_avdtp_event_handler(avdtp_role_t role, uint8_t *packet, uint16_t size);
|
||||
|
||||
uint8_t a2dp_config_process_config_init(avdtp_role_t role, avdtp_connection_t *connection, uint8_t local_seid, uint8_t remote_seid,
|
||||
avdtp_media_codec_type_t codec_type);
|
||||
void a2dp_config_process_set_config(avdtp_role_t role, avdtp_connection_t *connection);
|
||||
|
||||
// source
|
||||
void a2dp_register_source_packet_handler(btstack_packet_handler_t callback);
|
||||
@ -72,13 +82,6 @@ void a2dp_emit_source_streaming_connection_failed(avdtp_connection_t *connection
|
||||
|
||||
void a2dp_emit_source_stream_reconfigured(uint16_t cid, uint8_t local_seid, uint8_t status);
|
||||
|
||||
void a2dp_source_ready_for_sep_discovery(avdtp_connection_t * connection);
|
||||
|
||||
uint8_t a2dp_source_config_init(avdtp_connection_t *connection, uint8_t local_seid, uint8_t remote_seid,
|
||||
avdtp_media_codec_type_t codec_type);
|
||||
|
||||
void a2dp_source_config_process_avdtp_event_handler(uint8_t *packet, uint16_t size);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -100,7 +100,7 @@ static void a2dp_source_packet_handler_internal(uint8_t packet_type, uint16_t ch
|
||||
|
||||
default:
|
||||
// forward events to config process
|
||||
a2dp_source_config_process_avdtp_event_handler(packet, size);
|
||||
a2dp_config_process_avdtp_event_handler(AVDTP_ROLE_SOURCE, packet, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -178,7 +178,7 @@ uint8_t a2dp_source_establish_stream(bd_addr_t remote_addr, uint16_t *avdtp_cid)
|
||||
// restart process e.g. if there no suitable stream endpoints or they had been in use
|
||||
connection->a2dp_source_config_process.outgoing_active = true;
|
||||
*avdtp_cid = connection->avdtp_cid;
|
||||
a2dp_source_ready_for_sep_discovery(connection);
|
||||
a2dp_config_process_ready_for_sep_discovery(AVDTP_ROLE_SOURCE, connection);
|
||||
break;
|
||||
default:
|
||||
return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
@ -226,7 +226,8 @@ uint8_t a2dp_source_set_config_sbc(uint16_t a2dp_cid, uint8_t local_seid, uint8_
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
uint8_t status = a2dp_source_config_init(connection, local_seid, remote_seid, AVDTP_CODEC_SBC);
|
||||
uint8_t status = a2dp_config_process_config_init(AVDTP_ROLE_SOURCE, connection, local_seid, remote_seid,
|
||||
AVDTP_CODEC_SBC);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
@ -236,7 +237,7 @@ uint8_t a2dp_source_set_config_sbc(uint16_t a2dp_cid, uint8_t local_seid, uint8_
|
||||
avdtp_config_sbc_store(connection->a2dp_source_config_process.local_stream_endpoint->remote_configuration.media_codec.media_codec_information, configuration);
|
||||
|
||||
#ifdef ENABLE_A2DP_SOURCE_EXPLICIT_CONFIG
|
||||
a2dp_source_set_config(connection);
|
||||
a2dp_config_process_set_config(AVDTP_ROLE_SOURCE, connection);
|
||||
#endif
|
||||
|
||||
return ERROR_CODE_SUCCESS;
|
||||
@ -248,7 +249,8 @@ uint8_t a2dp_source_set_config_mpeg_audio(uint16_t a2dp_cid, uint8_t local_seid,
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
uint8_t status = a2dp_source_config_init(connection, local_seid, remote_seid, AVDTP_CODEC_MPEG_1_2_AUDIO);
|
||||
uint8_t status = a2dp_config_process_config_init(AVDTP_ROLE_SOURCE, connection, local_seid, remote_seid,
|
||||
AVDTP_CODEC_MPEG_1_2_AUDIO);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
@ -259,7 +261,7 @@ uint8_t a2dp_source_set_config_mpeg_audio(uint16_t a2dp_cid, uint8_t local_seid,
|
||||
avdtp_config_mpeg_audio_store(connection->a2dp_source_config_process.local_stream_endpoint->remote_configuration.media_codec.media_codec_information, configuration);
|
||||
|
||||
#ifdef ENABLE_A2DP_SOURCE_EXPLICIT_CONFIG
|
||||
a2dp_source_set_config(connection);
|
||||
a2dp_config_process_set_config(AVDTP_ROLE_SOURCE, connection);
|
||||
#endif
|
||||
|
||||
return ERROR_CODE_SUCCESS;
|
||||
@ -271,7 +273,8 @@ uint8_t a2dp_source_set_config_mpeg_aac(uint16_t a2dp_cid, uint8_t local_seid,
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
uint8_t status = a2dp_source_config_init(connection, local_seid, remote_seid, AVDTP_CODEC_MPEG_2_4_AAC);
|
||||
uint8_t status = a2dp_config_process_config_init(AVDTP_ROLE_SOURCE, connection, local_seid, remote_seid,
|
||||
AVDTP_CODEC_MPEG_2_4_AAC);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
@ -280,7 +283,7 @@ uint8_t a2dp_source_set_config_mpeg_aac(uint16_t a2dp_cid, uint8_t local_seid,
|
||||
avdtp_config_mpeg_aac_store(connection->a2dp_source_config_process.local_stream_endpoint->remote_configuration.media_codec.media_codec_information, configuration);
|
||||
|
||||
#ifdef ENABLE_A2DP_SOURCE_EXPLICIT_CONFIG
|
||||
a2dp_source_set_config(connection);
|
||||
a2dp_config_process_set_config(AVDTP_ROLE_SOURCE, connection);
|
||||
#endif
|
||||
|
||||
return ERROR_CODE_SUCCESS;
|
||||
@ -292,7 +295,8 @@ uint8_t a2dp_source_set_config_atrac(uint16_t a2dp_cid, uint8_t local_seid, uint
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
uint8_t status = a2dp_source_config_init(connection, local_seid, remote_seid, AVDTP_CODEC_ATRAC_FAMILY);
|
||||
uint8_t status = a2dp_config_process_config_init(AVDTP_ROLE_SOURCE, connection, local_seid, remote_seid,
|
||||
AVDTP_CODEC_ATRAC_FAMILY);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
@ -302,7 +306,7 @@ uint8_t a2dp_source_set_config_atrac(uint16_t a2dp_cid, uint8_t local_seid, uint
|
||||
avdtp_config_atrac_store(connection->a2dp_source_config_process.local_stream_endpoint->remote_configuration.media_codec.media_codec_information, configuration);
|
||||
|
||||
#ifdef ENABLE_A2DP_SOURCE_EXPLICIT_CONFIG
|
||||
a2dp_source_set_config(connection);
|
||||
a2dp_config_process_set_config(AVDTP_ROLE_SOURCE, connection);
|
||||
#endif
|
||||
|
||||
return ERROR_CODE_SUCCESS;
|
||||
@ -315,7 +319,8 @@ uint8_t a2dp_source_set_config_other(uint16_t a2dp_cid, uint8_t local_seid, uin
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
uint8_t status = a2dp_source_config_init(connection, local_seid, remote_seid, AVDTP_CODEC_NON_A2DP);
|
||||
uint8_t status = a2dp_config_process_config_init(AVDTP_ROLE_SOURCE, connection, local_seid, remote_seid,
|
||||
AVDTP_CODEC_NON_A2DP);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
@ -324,7 +329,7 @@ uint8_t a2dp_source_set_config_other(uint16_t a2dp_cid, uint8_t local_seid, uin
|
||||
connection->a2dp_source_config_process.local_stream_endpoint->remote_configuration.media_codec.media_codec_information_len = media_codec_information_len;
|
||||
|
||||
#ifdef ENABLE_A2DP_SOURCE_EXPLICIT_CONFIG
|
||||
a2dp_source_set_config(connection);
|
||||
a2dp_config_process_set_config(AVDTP_ROLE_SOURCE, connection);
|
||||
#endif
|
||||
|
||||
return status;
|
||||
|
Loading…
x
Reference in New Issue
Block a user