avdtp: add remote seps on discovery

This commit is contained in:
Milanka Ringwald 2017-04-11 18:05:24 +02:00
parent 44c53bbced
commit 85efc5ac63
4 changed files with 22 additions and 17 deletions

View File

@ -213,13 +213,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
break;
}
// find or add sep
int i;
stream_endpoint->remote_sep_index = 0xFF;
for (i=0; i < stream_endpoint->connection->remote_seps_num; i++){
if (stream_endpoint->connection->remote_seps[i].seid == sep.seid){
stream_endpoint->remote_sep_index = i;
}
}
stream_endpoint->remote_sep_index = avdtp_find_remote_sep(stream_endpoint->connection, sep.seid);
printf(" ACP .. seid %d, index %d\n", sep.seid, stream_endpoint->remote_sep_index);
if (stream_endpoint->remote_sep_index != 0xFF){
@ -228,6 +222,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
connection->error_code = SEP_IN_USE;
// find first registered category and fire the error
connection->reject_service_category = 0;
int i;
for (i = 1; i < 9; i++){
if (get_bit16(sep.configured_service_categories, i)){
connection->reject_service_category = i;
@ -280,14 +275,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
}
// find sep or raise error
int i;
stream_endpoint->remote_sep_index = 0xFF;
for (i = 0; i < stream_endpoint->connection->remote_seps_num; i++){
if (stream_endpoint->connection->remote_seps[i].seid == sep.seid){
stream_endpoint->remote_sep_index = i;
}
}
stream_endpoint->remote_sep_index = avdtp_find_remote_sep(stream_endpoint->connection, sep.seid);
if (stream_endpoint->remote_sep_index == 0xFF){
printf(" ACP: REJECT AVDTP_SI_RECONFIGURE, BAD_ACP_SEID\n");
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;

View File

@ -116,6 +116,10 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
sep.in_use = (packet[i] >> 1) & 0x01;
sep.media_type = (avdtp_media_type_t)(packet[i+1] >> 4);
sep.type = (avdtp_sep_type_t)((packet[i+1] >> 3) & 0x01);
if (avdtp_find_remote_sep(stream_endpoint->connection, sep.seid) == 0xFF){
connection->remote_seps[connection->remote_seps_num++] = sep;
}
avdtp_signaling_emit_sep(context->avdtp_callback, connection->con_handle, sep);
}
break;
@ -157,7 +161,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
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
remote_sep_index = avdtp_get_index_of_remote_stream_endpoint_with_seid(stream_endpoint, sep.seid);
remote_sep_index = avdtp_find_remote_sep(stream_endpoint->connection, sep.seid);
if (remote_sep_index != 0xFF){
stream_endpoint->remote_sep_index = remote_sep_index;
stream_endpoint->connection->remote_seps[stream_endpoint->remote_sep_index] = sep;
@ -174,7 +178,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
// TODO check if configuration is supported
// find or add sep
remote_sep_index = avdtp_get_index_of_remote_stream_endpoint_with_seid(stream_endpoint, sep.seid);
remote_sep_index = avdtp_find_remote_sep(stream_endpoint->connection, sep.seid);
if (remote_sep_index != 0xFF){
stream_endpoint->remote_sep_index = remote_sep_index;
} else {

View File

@ -800,3 +800,15 @@ uint8_t avdtp_get_index_of_remote_stream_endpoint_with_seid(avdtp_stream_endpoin
}
return 0xFF;
}
uint8_t avdtp_find_remote_sep(avdtp_connection_t * connection, uint8_t remote_seid){
if (!connection) return 0xFF;
int i;
for (i = 0; i < connection->remote_seps_num; i++){
if (connection->remote_seps[i].seid == remote_seid){
return i;
}
}
return 0xFF;
}

View File

@ -94,6 +94,7 @@ 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 acp_seid);
void avdtp_initialize_stream_endpoint(avdtp_stream_endpoint_t * stream_endpoint);
uint8_t avdtp_find_remote_sep(avdtp_connection_t * connection, uint8_t remote_seid);
#if defined __cplusplus
}