mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-18 05:42:49 +00:00
avdtp: move remote seps to connection
This commit is contained in:
parent
e08eb62a64
commit
44c53bbced
@ -247,8 +247,6 @@ static void stream_endpoint_state_machine(avdtp_connection_t * connection, avdtp
|
|||||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_IDLE;
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_IDLE;
|
||||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE;
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE;
|
||||||
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
|
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
|
||||||
stream_endpoint->remote_seps_num = 0;
|
|
||||||
memset(stream_endpoint->remote_seps, 0, sizeof(avdtp_sep_t)*MAX_NUM_SEPS);
|
|
||||||
stream_endpoint->remote_sep_index = 0;
|
stream_endpoint->remote_sep_index = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -422,6 +422,10 @@ typedef struct {
|
|||||||
uint8_t reject_service_category;
|
uint8_t reject_service_category;
|
||||||
avdtp_signal_identifier_t reject_signal_identifier;
|
avdtp_signal_identifier_t reject_signal_identifier;
|
||||||
uint8_t error_code;
|
uint8_t error_code;
|
||||||
|
|
||||||
|
// store configurations with remote seps
|
||||||
|
avdtp_sep_t remote_seps[MAX_NUM_SEPS];
|
||||||
|
uint8_t remote_seps_num;
|
||||||
} avdtp_connection_t;
|
} avdtp_connection_t;
|
||||||
|
|
||||||
|
|
||||||
@ -440,10 +444,6 @@ typedef struct avdtp_stream_endpoint {
|
|||||||
|
|
||||||
// active connection
|
// active connection
|
||||||
avdtp_connection_t * connection;
|
avdtp_connection_t * connection;
|
||||||
// store configurations with remote seps
|
|
||||||
avdtp_sep_t remote_seps[MAX_NUM_SEPS];
|
|
||||||
uint8_t remote_seps_num;
|
|
||||||
|
|
||||||
// currently active remote seid
|
// currently active remote seid
|
||||||
uint8_t remote_sep_index;
|
uint8_t remote_sep_index;
|
||||||
// register request for media L2cap connection release
|
// register request for media L2cap connection release
|
||||||
|
@ -215,15 +215,15 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
|||||||
// find or add sep
|
// find or add sep
|
||||||
int i;
|
int i;
|
||||||
stream_endpoint->remote_sep_index = 0xFF;
|
stream_endpoint->remote_sep_index = 0xFF;
|
||||||
for (i=0; i < stream_endpoint->remote_seps_num; i++){
|
for (i=0; i < stream_endpoint->connection->remote_seps_num; i++){
|
||||||
if (stream_endpoint->remote_seps[i].seid == sep.seid){
|
if (stream_endpoint->connection->remote_seps[i].seid == sep.seid){
|
||||||
stream_endpoint->remote_sep_index = i;
|
stream_endpoint->remote_sep_index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf(" ACP .. seid %d, index %d\n", sep.seid, stream_endpoint->remote_sep_index);
|
printf(" ACP .. seid %d, index %d\n", sep.seid, stream_endpoint->remote_sep_index);
|
||||||
|
|
||||||
if (stream_endpoint->remote_sep_index != 0xFF){
|
if (stream_endpoint->remote_sep_index != 0xFF){
|
||||||
if (stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].in_use){
|
if (stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].in_use){
|
||||||
// reject if already configured
|
// reject if already configured
|
||||||
connection->error_code = SEP_IN_USE;
|
connection->error_code = SEP_IN_USE;
|
||||||
// find first registered category and fire the error
|
// find first registered category and fire the error
|
||||||
@ -237,16 +237,16 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
|||||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||||
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
||||||
} else {
|
} else {
|
||||||
stream_endpoint->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||||
printf(" ACP: update seid %d, to %p\n", stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
printf(" ACP: update seid %d, to %p\n", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// add new
|
// add new
|
||||||
printf(" ACP: seid %d not found in %p\n", sep.seid, stream_endpoint);
|
printf(" ACP: seid %d not found in %p\n", sep.seid, stream_endpoint);
|
||||||
stream_endpoint->remote_sep_index = stream_endpoint->remote_seps_num;
|
stream_endpoint->remote_sep_index = stream_endpoint->connection->remote_seps_num;
|
||||||
stream_endpoint->remote_seps_num++;
|
stream_endpoint->connection->remote_seps_num++;
|
||||||
stream_endpoint->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||||
printf(" ACP: add seid %d, to %p\n", stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
printf(" ACP: add seid %d, to %p\n", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||||
}
|
}
|
||||||
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){
|
||||||
@ -282,8 +282,8 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
|||||||
// find sep or raise error
|
// find sep or raise error
|
||||||
int i;
|
int i;
|
||||||
stream_endpoint->remote_sep_index = 0xFF;
|
stream_endpoint->remote_sep_index = 0xFF;
|
||||||
for (i = 0; i < stream_endpoint->remote_seps_num; i++){
|
for (i = 0; i < stream_endpoint->connection->remote_seps_num; i++){
|
||||||
if (stream_endpoint->remote_seps[i].seid == sep.seid){
|
if (stream_endpoint->connection->remote_seps[i].seid == sep.seid){
|
||||||
stream_endpoint->remote_sep_index = i;
|
stream_endpoint->remote_sep_index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,8 +295,8 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
|||||||
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stream_endpoint->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||||
printf(" ACP: update seid %d, to %p\n", stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
printf(" ACP: update seid %d, to %p\n", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||||
|
|
||||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||||
switch (sep.capabilities.media_codec.media_codec_type){
|
switch (sep.capabilities.media_codec.media_codec_type){
|
||||||
@ -549,7 +549,7 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION:{
|
case AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION:{
|
||||||
avdtp_sep_t sep = stream_endpoint->remote_seps[stream_endpoint->remote_sep_index];
|
avdtp_sep_t sep = stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index];
|
||||||
avdtp_prepare_capabilities(&connection->signaling_packet, trid, sep.configured_service_categories, sep.configuration, AVDTP_SI_GET_CONFIGURATION);
|
avdtp_prepare_capabilities(&connection->signaling_packet, trid, sep.configured_service_categories, sep.configuration, AVDTP_SI_GET_CONFIGURATION);
|
||||||
l2cap_reserve_packet_buffer();
|
l2cap_reserve_packet_buffer();
|
||||||
out_buffer = l2cap_get_outgoing_buffer();
|
out_buffer = l2cap_get_outgoing_buffer();
|
||||||
|
@ -160,9 +160,9 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
remote_sep_index = avdtp_get_index_of_remote_stream_endpoint_with_seid(stream_endpoint, sep.seid);
|
remote_sep_index = avdtp_get_index_of_remote_stream_endpoint_with_seid(stream_endpoint, sep.seid);
|
||||||
if (remote_sep_index != 0xFF){
|
if (remote_sep_index != 0xFF){
|
||||||
stream_endpoint->remote_sep_index = remote_sep_index;
|
stream_endpoint->remote_sep_index = remote_sep_index;
|
||||||
stream_endpoint->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
||||||
printf(" INT: update seid %d, to %p\n", stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
printf(" INT: update seid %d, to %p\n", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -178,11 +178,11 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
|||||||
if (remote_sep_index != 0xFF){
|
if (remote_sep_index != 0xFF){
|
||||||
stream_endpoint->remote_sep_index = remote_sep_index;
|
stream_endpoint->remote_sep_index = remote_sep_index;
|
||||||
} else {
|
} else {
|
||||||
stream_endpoint->remote_sep_index = stream_endpoint->remote_seps_num;
|
stream_endpoint->remote_sep_index = stream_endpoint->connection->remote_seps_num;
|
||||||
stream_endpoint->remote_seps_num++;
|
stream_endpoint->connection->remote_seps_num++;
|
||||||
}
|
}
|
||||||
stream_endpoint->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
|
||||||
printf(" INT: configured remote seid %d, to %p\n", stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
printf(" INT: configured remote seid %d, to %p\n", stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid, stream_endpoint);
|
||||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,7 @@ void avdtp_initialize_stream_endpoint(avdtp_stream_endpoint_t * stream_endpoint)
|
|||||||
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
|
stream_endpoint->initiator_config_state = AVDTP_INITIATOR_STREAM_CONFIG_IDLE;
|
||||||
stream_endpoint->remote_sep_index = 0;
|
stream_endpoint->remote_sep_index = 0;
|
||||||
stream_endpoint->media_disconnect = 0;
|
stream_endpoint->media_disconnect = 0;
|
||||||
stream_endpoint->remote_seps_num = 0;
|
|
||||||
stream_endpoint->sep.in_use = 0;
|
stream_endpoint->sep.in_use = 0;
|
||||||
memset(stream_endpoint->remote_seps, 0, sizeof(stream_endpoint->remote_seps));
|
|
||||||
stream_endpoint->remote_sep_index = 0;
|
stream_endpoint->remote_sep_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +144,8 @@ avdtp_stream_endpoint_t * avdtp_stream_endpoint_associated_with_acp_seid(uint16_
|
|||||||
while (btstack_linked_list_iterator_has_next(&it)){
|
while (btstack_linked_list_iterator_has_next(&it)){
|
||||||
avdtp_stream_endpoint_t * stream_endpoint = (avdtp_stream_endpoint_t *)btstack_linked_list_iterator_next(&it);
|
avdtp_stream_endpoint_t * stream_endpoint = (avdtp_stream_endpoint_t *)btstack_linked_list_iterator_next(&it);
|
||||||
if (stream_endpoint->remote_sep_index >= 0 && stream_endpoint->remote_sep_index < MAX_NUM_SEPS){
|
if (stream_endpoint->remote_sep_index >= 0 && stream_endpoint->remote_sep_index < MAX_NUM_SEPS){
|
||||||
if (stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].seid == acp_seid){
|
if (!stream_endpoint->connection) continue;
|
||||||
|
if (stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid == acp_seid){
|
||||||
return stream_endpoint;
|
return stream_endpoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -789,12 +788,13 @@ void avdtp_request_can_send_now_self(avdtp_connection_t * connection, uint16_t l
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t avdtp_get_index_of_remote_stream_endpoint_with_seid(avdtp_stream_endpoint_t * stream_endpoint, uint16_t seid){
|
uint8_t avdtp_get_index_of_remote_stream_endpoint_with_seid(avdtp_stream_endpoint_t * stream_endpoint, uint16_t seid){
|
||||||
if (stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].seid == seid){
|
if (!stream_endpoint->connection) return 0xFF;
|
||||||
|
if (stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index].seid == seid){
|
||||||
return stream_endpoint->remote_sep_index;
|
return stream_endpoint->remote_sep_index;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i < stream_endpoint->remote_seps_num; i++){
|
for (i=0; i < stream_endpoint->connection->remote_seps_num; i++){
|
||||||
if (stream_endpoint->remote_seps[i].seid == seid){
|
if (stream_endpoint->connection->remote_seps[i].seid == seid){
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user