2016-10-19 15:07:28 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 BlueKitchen GmbH
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the copyright holders nor the names of
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
* 4. Any redistribution, use, or modification is done solely for
|
|
|
|
* personal benefit and not for any commercial purpose or for
|
|
|
|
* monetary gain.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
|
|
|
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Please inquire about commercial licensing options at
|
|
|
|
* contact@bluekitchen-gmbh.com
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "btstack.h"
|
|
|
|
#include "avdtp.h"
|
|
|
|
#include "avdtp_util.h"
|
|
|
|
#include "avdtp_acceptor.h"
|
|
|
|
|
2016-11-10 12:33:34 +01:00
|
|
|
|
2016-12-08 16:12:04 +01:00
|
|
|
static int avdtp_acceptor_send_accept_response(uint16_t cid, uint8_t transaction_label, avdtp_signal_identifier_t identifier){
|
2016-10-19 15:07:28 +02:00
|
|
|
uint8_t command[2];
|
|
|
|
command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_RESPONSE_ACCEPT_MSG);
|
|
|
|
command[1] = (uint8_t)identifier;
|
|
|
|
return l2cap_send(cid, command, sizeof(command));
|
|
|
|
}
|
|
|
|
|
2016-12-13 15:20:48 +01:00
|
|
|
static int avdtp_acceptor_process_chunk(avdtp_signaling_packet_t * signaling_packet, uint8_t * packet, uint16_t size){
|
|
|
|
memcpy(signaling_packet->command + signaling_packet->size, packet, size);
|
|
|
|
signaling_packet->size += size;
|
|
|
|
return signaling_packet->packet_type == AVDTP_SINGLE_PACKET || signaling_packet->packet_type == AVDTP_END_PACKET;
|
2016-12-12 13:45:36 +01:00
|
|
|
}
|
|
|
|
|
2017-01-17 13:42:46 +01:00
|
|
|
static avdtp_stream_endpoint_t * get_avdtp_stream_endpoint_for_active_seid(uint8_t seid){
|
|
|
|
btstack_linked_list_iterator_t it;
|
|
|
|
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) &stream_endpoints);
|
|
|
|
while (btstack_linked_list_iterator_has_next(&it)){
|
|
|
|
avdtp_stream_endpoint_t * stream_endpoint = (avdtp_stream_endpoint_t *)btstack_linked_list_iterator_next(&it);
|
|
|
|
if (stream_endpoint->sep.seid == seid){
|
|
|
|
return stream_endpoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int avdtp_acceptor_validate_msg_length(avdtp_signal_identifier_t signal_identifier, uint16_t msg_size){
|
|
|
|
int minimal_msg_lenght = 2;
|
|
|
|
switch (signal_identifier){
|
|
|
|
case AVDTP_SI_GET_CAPABILITIES:
|
|
|
|
case AVDTP_SI_GET_ALL_CAPABILITIES:
|
|
|
|
case AVDTP_SI_SET_CONFIGURATION:
|
|
|
|
case AVDTP_SI_GET_CONFIGURATION:
|
|
|
|
case AVDTP_SI_START:
|
|
|
|
case AVDTP_SI_CLOSE:
|
|
|
|
case AVDTP_SI_ABORT:
|
|
|
|
case AVDTP_SI_RECONFIGURE:
|
|
|
|
case AVDTP_SI_OPEN:
|
|
|
|
minimal_msg_lenght = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return msg_size >= minimal_msg_lenght;
|
|
|
|
}
|
|
|
|
|
2017-01-17 14:42:03 +01:00
|
|
|
void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t * packet, uint16_t size, int offset){
|
|
|
|
avdtp_stream_endpoint_t * stream_endpoint;
|
|
|
|
|
|
|
|
if (!avdtp_acceptor_validate_msg_length(connection->signaling_packet.signal_identifier, size)) {
|
2017-01-17 13:42:46 +01:00
|
|
|
connection->error_code = BAD_LENGTH;
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
2017-01-17 14:42:03 +01:00
|
|
|
avdtp_sink_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
2017-01-17 13:42:46 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-01-17 14:42:03 +01:00
|
|
|
|
2017-01-17 13:42:46 +01:00
|
|
|
switch (connection->signaling_packet.signal_identifier){
|
|
|
|
case AVDTP_SI_DISCOVER:
|
|
|
|
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
2017-01-17 14:42:03 +01:00
|
|
|
printf(" ACP: AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS\n");
|
2017-01-17 13:42:46 +01:00
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS;
|
2017-01-17 14:42:03 +01:00
|
|
|
avdtp_sink_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
2017-01-17 13:42:46 +01:00
|
|
|
return;
|
|
|
|
case AVDTP_SI_GET_CAPABILITIES:
|
|
|
|
case AVDTP_SI_GET_ALL_CAPABILITIES:
|
|
|
|
case AVDTP_SI_SET_CONFIGURATION:
|
|
|
|
case AVDTP_SI_GET_CONFIGURATION:
|
|
|
|
case AVDTP_SI_START:
|
|
|
|
case AVDTP_SI_CLOSE:
|
|
|
|
case AVDTP_SI_ABORT:
|
|
|
|
case AVDTP_SI_OPEN:
|
|
|
|
case AVDTP_SI_RECONFIGURE:
|
|
|
|
connection->query_seid = packet[offset++] >> 2;
|
|
|
|
stream_endpoint = get_avdtp_stream_endpoint_for_active_seid(connection->query_seid);
|
|
|
|
if (!stream_endpoint){
|
|
|
|
printf(" ACP: cmd %d - RESPONSE REJECT\n", 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
|
|
|
if (connection->signaling_packet.signal_identifier == AVDTP_SI_RECONFIGURE){
|
|
|
|
connection->reject_service_category = connection->query_seid;
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
|
|
|
}
|
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
2017-01-17 14:42:03 +01:00
|
|
|
avdtp_sink_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
2017-01-17 13:42:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AVDTP_SI_SUSPEND:{
|
|
|
|
int i;
|
|
|
|
printf(" ACP: AVDTP_SI_SUSPEND seids: ");
|
|
|
|
connection->num_suspended_seids = 0;
|
|
|
|
|
|
|
|
for (i = offset; i < size; i++){
|
|
|
|
connection->suspended_seids[connection->num_suspended_seids] = packet[i] >> 2;
|
|
|
|
offset++;
|
|
|
|
printf("%d, \n", connection->suspended_seids[connection->num_suspended_seids]);
|
|
|
|
connection->num_suspended_seids++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (connection->num_suspended_seids == 0) {
|
|
|
|
printf(" ACP: CATEGORY RESPONSE REJECT BAD_ACP_SEID\n");
|
|
|
|
connection->error_code = BAD_ACP_SEID;
|
|
|
|
connection->reject_service_category = connection->query_seid;
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
2017-01-17 14:42:03 +01:00
|
|
|
avdtp_sink_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
2017-01-17 13:42:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// deal with first susspended seid
|
|
|
|
connection->query_seid = connection->suspended_seids[0];
|
|
|
|
stream_endpoint = get_avdtp_stream_endpoint_for_active_seid(connection->query_seid);
|
|
|
|
if (!stream_endpoint){
|
|
|
|
printf(" ACP: stream_endpoint not found, CATEGORY RESPONSE REJECT BAD_ACP_SEID\n");
|
|
|
|
connection->error_code = BAD_ACP_SEID;
|
|
|
|
connection->reject_service_category = connection->query_seid;
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
|
|
|
connection->num_suspended_seids = 0;
|
2017-01-17 14:42:03 +01:00
|
|
|
avdtp_sink_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
2017-01-17 13:42:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_GENERAL_REJECT_WITH_ERROR_CODE;
|
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
|
|
|
printf("AVDTP_CMD_MSG signal %d not implemented, general reject\n", connection->signaling_packet.signal_identifier);
|
2017-01-17 14:42:03 +01:00
|
|
|
avdtp_sink_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
2017-01-17 13:42:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stream_endpoint) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!avdtp_acceptor_process_chunk(&connection->signaling_packet, packet, size)) return;
|
2017-01-11 15:38:03 +01:00
|
|
|
|
2016-12-13 15:20:48 +01:00
|
|
|
uint16_t packet_size = connection->signaling_packet.size;
|
|
|
|
connection->signaling_packet.size = 0;
|
2017-01-11 15:38:03 +01:00
|
|
|
|
2016-12-12 13:45:36 +01:00
|
|
|
int request_to_send = 1;
|
2016-11-26 10:49:06 +01:00
|
|
|
switch (stream_endpoint->acceptor_config_state){
|
2016-10-19 15:07:28 +02:00
|
|
|
case AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE:
|
2016-12-13 15:20:48 +01:00
|
|
|
switch (connection->signaling_packet.signal_identifier){
|
2016-11-10 12:33:34 +01:00
|
|
|
case AVDTP_SI_GET_ALL_CAPABILITIES:
|
2016-11-26 10:49:06 +01:00
|
|
|
printf(" ACP: AVDTP_SI_GET_ALL_CAPABILITIES\n");
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_ALL_CAPABILITIES;
|
2016-11-10 12:33:34 +01:00
|
|
|
break;
|
2016-10-19 15:07:28 +02:00
|
|
|
case AVDTP_SI_GET_CAPABILITIES:
|
2016-11-26 10:49:06 +01:00
|
|
|
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES\n");
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES;
|
2016-10-19 15:07:28 +02:00
|
|
|
break;
|
2016-11-26 10:49:06 +01:00
|
|
|
case AVDTP_SI_SET_CONFIGURATION:{
|
|
|
|
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION \n");
|
2016-12-08 15:57:14 +01:00
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION;
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->reject_service_category = 0;
|
2017-01-16 14:40:25 +01:00
|
|
|
|
2016-11-26 10:49:06 +01:00
|
|
|
avdtp_sep_t sep;
|
2017-01-11 15:38:03 +01:00
|
|
|
sep.seid = connection->signaling_packet.command[offset++] >> 2;
|
2017-01-16 14:40:25 +01:00
|
|
|
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, connection->signaling_packet.command+offset, packet_size-offset);
|
2016-12-14 12:04:47 +01:00
|
|
|
sep.in_use = 1;
|
|
|
|
|
2016-12-14 11:22:37 +01:00
|
|
|
if (connection->error_code){
|
2017-01-16 14:40:25 +01:00
|
|
|
printf("fire configuration parsing errors \n");
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
2016-12-13 20:43:26 +01:00
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-10-19 15:07:28 +02:00
|
|
|
// find or add sep
|
2016-11-26 10:49:06 +01:00
|
|
|
int i;
|
2017-01-16 14:40:25 +01:00
|
|
|
stream_endpoint->remote_sep_index = 0xFF;
|
2016-11-10 15:20:01 +01:00
|
|
|
for (i=0; i < stream_endpoint->remote_seps_num; i++){
|
|
|
|
if (stream_endpoint->remote_seps[i].seid == sep.seid){
|
|
|
|
stream_endpoint->remote_sep_index = i;
|
2016-10-19 15:07:28 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-16 14:40:25 +01:00
|
|
|
printf(" ACP .. seid %d, index %02x\n", sep.seid, stream_endpoint->remote_sep_index );
|
|
|
|
|
2016-12-14 12:04:47 +01:00
|
|
|
if (stream_endpoint->remote_sep_index != 0xFF){
|
|
|
|
if (stream_endpoint->remote_seps[stream_endpoint->remote_sep_index].in_use){
|
|
|
|
// reject if already configured
|
|
|
|
connection->error_code = SEP_IN_USE;
|
|
|
|
// find first registered category and fire the error
|
|
|
|
connection->reject_service_category = 0;
|
|
|
|
for (i = 1; i < 9; i++){
|
2017-01-16 14:40:25 +01:00
|
|
|
if (get_bit16(sep.configured_service_categories, i)){
|
2016-12-14 12:04:47 +01:00
|
|
|
connection->reject_service_category = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
2017-01-11 15:38:03 +01:00
|
|
|
} else {
|
|
|
|
stream_endpoint->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);
|
2016-12-14 12:04:47 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// add new
|
2016-12-08 15:28:06 +01:00
|
|
|
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_seps_num++;
|
|
|
|
stream_endpoint->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);
|
2016-12-14 12:04:47 +01:00
|
|
|
}
|
2017-01-16 15:16:45 +01:00
|
|
|
|
2017-01-16 14:40:25 +01:00
|
|
|
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
|
|
|
switch (sep.configuration.media_codec.media_codec_type){
|
2017-01-11 15:38:03 +01:00
|
|
|
case AVDTP_CODEC_SBC:
|
2017-01-16 14:40:25 +01:00
|
|
|
avdtp_signaling_emit_media_codec_sbc_configuration(avdtp_sink_callback, connection->con_handle, sep.configuration.media_codec);
|
2017-01-11 15:38:03 +01:00
|
|
|
break;
|
|
|
|
default:
|
2017-01-16 14:40:25 +01:00
|
|
|
avdtp_signaling_emit_media_codec_other_configuration(avdtp_sink_callback, connection->con_handle, sep.configuration.media_codec);
|
2017-01-11 15:38:03 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
avdtp_signaling_emit_done(avdtp_sink_callback, connection->con_handle, 0);
|
|
|
|
break;
|
2016-11-26 10:49:06 +01:00
|
|
|
}
|
2016-12-07 15:49:15 +01:00
|
|
|
case AVDTP_SI_RECONFIGURE:{
|
2016-12-08 15:28:06 +01:00
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE;
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->reject_service_category = 0;
|
2017-01-16 14:40:25 +01:00
|
|
|
|
2016-12-07 15:49:15 +01:00
|
|
|
avdtp_sep_t sep;
|
2017-01-16 14:40:25 +01:00
|
|
|
sep.seid = connection->query_seid;
|
2017-01-11 15:38:03 +01:00
|
|
|
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE seid %d\n", sep.seid);
|
|
|
|
// printf_hexdump(connection->signaling_packet.command, packet_size);
|
|
|
|
|
2017-01-16 14:40:25 +01:00
|
|
|
sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, &sep.configuration, connection->signaling_packet.command+offset, packet_size-offset);
|
2016-12-08 15:28:06 +01:00
|
|
|
|
2016-12-14 16:54:02 +01:00
|
|
|
if (connection->error_code){
|
2017-01-16 14:40:25 +01:00
|
|
|
// fire configuration parsing errors
|
2016-12-14 16:54:02 +01:00
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-12-08 15:57:14 +01:00
|
|
|
// find sep or raise error
|
2016-12-07 15:49:15 +01:00
|
|
|
int i;
|
2017-01-16 14:40:25 +01:00
|
|
|
stream_endpoint->remote_sep_index = 0xFF;
|
2016-12-07 15:49:15 +01:00
|
|
|
for (i = 0; i < stream_endpoint->remote_seps_num; i++){
|
|
|
|
if (stream_endpoint->remote_seps[i].seid == sep.seid){
|
|
|
|
stream_endpoint->remote_sep_index = i;
|
|
|
|
}
|
|
|
|
}
|
2016-12-08 15:28:06 +01:00
|
|
|
|
|
|
|
if (stream_endpoint->remote_sep_index == 0xFF){
|
2016-12-14 16:54:02 +01:00
|
|
|
printf(" ACP: REJECT AVDTP_SI_RECONFIGURE, BAD_ACP_SEID\n");
|
2016-12-13 20:43:26 +01:00
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE;
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->error_code = BAD_ACP_SEID;
|
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
2016-12-08 15:28:06 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-01-16 14:40:25 +01:00
|
|
|
stream_endpoint->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);
|
2017-01-17 13:42:46 +01:00
|
|
|
|
|
|
|
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
2017-01-16 14:40:25 +01:00
|
|
|
switch (sep.capabilities.media_codec.media_codec_type){
|
|
|
|
case AVDTP_CODEC_SBC:
|
|
|
|
avdtp_signaling_emit_media_codec_sbc_reconfiguration(avdtp_sink_callback, connection->con_handle, sep.capabilities.media_codec);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
avdtp_signaling_emit_media_codec_other_reconfiguration(avdtp_sink_callback, connection->con_handle, sep.capabilities.media_codec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
avdtp_signaling_emit_done(avdtp_sink_callback, connection->con_handle, 0);
|
2016-12-07 15:49:15 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-01-16 14:40:25 +01:00
|
|
|
|
2016-12-20 11:17:23 +01:00
|
|
|
case AVDTP_SI_GET_CONFIGURATION:
|
|
|
|
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION\n");
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION;
|
|
|
|
break;
|
2016-11-26 10:49:06 +01:00
|
|
|
case AVDTP_SI_OPEN:
|
2016-12-20 11:17:23 +01:00
|
|
|
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_CONFIGURED){
|
|
|
|
printf(" ACP: REJECT AVDTP_SI_OPEN, BAD_STATE\n");
|
|
|
|
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;
|
|
|
|
}
|
2016-11-26 10:49:06 +01:00
|
|
|
printf(" ACP: AVDTP_STREAM_ENDPOINT_W2_ANSWER_OPEN_STREAM\n");
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_OPEN_STREAM;
|
2016-12-08 15:28:06 +01:00
|
|
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_CONNECTED;
|
2016-11-26 10:49:06 +01:00
|
|
|
break;
|
|
|
|
case AVDTP_SI_START:
|
2016-12-20 11:17:23 +01:00
|
|
|
if (stream_endpoint->state != AVDTP_STREAM_ENDPOINT_OPENED){
|
|
|
|
printf(" ACP: REJECT AVDTP_SI_OPEN, BAD_STATE\n");
|
|
|
|
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;
|
|
|
|
}
|
2016-11-26 10:49:06 +01:00
|
|
|
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM\n");
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM;
|
|
|
|
break;
|
2016-12-08 12:10:11 +01:00
|
|
|
case AVDTP_SI_CLOSE:
|
2016-12-08 15:28:06 +01:00
|
|
|
switch (stream_endpoint->state){
|
|
|
|
case AVDTP_STREAM_ENDPOINT_OPENED:
|
|
|
|
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
|
|
|
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM\n");
|
|
|
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf(" ACP: AVDTP_SI_CLOSE, bad state %d \n", stream_endpoint->state);
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE;
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->error_code = BAD_STATE;
|
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
2016-12-08 15:28:06 +01:00
|
|
|
break;
|
2016-12-08 12:10:11 +01:00
|
|
|
}
|
2016-12-08 15:28:06 +01:00
|
|
|
break;
|
|
|
|
case AVDTP_SI_ABORT:
|
2016-12-21 16:42:32 +01:00
|
|
|
switch (stream_endpoint->state){
|
|
|
|
case AVDTP_STREAM_ENDPOINT_CONFIGURED:
|
|
|
|
case AVDTP_STREAM_ENDPOINT_CLOSING:
|
|
|
|
case AVDTP_STREAM_ENDPOINT_OPENED:
|
|
|
|
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
|
|
|
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM\n");
|
|
|
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf(" ACP: AVDTP_SI_ABORT, bad state %d \n", 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;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AVDTP_SI_SUSPEND:
|
2017-01-17 13:42:46 +01:00
|
|
|
printf(" entering AVDTP_SI_SUSPEND\n");
|
2016-12-21 16:42:32 +01:00
|
|
|
switch (stream_endpoint->state){
|
|
|
|
case AVDTP_STREAM_ENDPOINT_OPENED:
|
|
|
|
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
|
|
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
|
|
|
connection->num_suspended_seids--;
|
|
|
|
if (connection->num_suspended_seids <= 0){
|
|
|
|
printf(" ACP: AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM\n");
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf(" ACP: AVDTP_SI_SUSPEND, bad state \n");
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//stream_endpoint->state = AVDTP_STREAM_ENDPOINT_SUSPENDING;
|
|
|
|
//stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_SUSPEND_STREAM;
|
2016-12-08 12:10:11 +01:00
|
|
|
break;
|
2016-11-26 10:49:06 +01:00
|
|
|
default:
|
2016-12-13 15:20:48 +01:00
|
|
|
printf(" ACP: NOT IMPLEMENTED, Reject signal_identifier %02x\n", connection->signaling_packet.signal_identifier);
|
2016-12-07 15:49:15 +01:00
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD;
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->reject_signal_identifier = connection->signaling_packet.signal_identifier;
|
2016-12-07 15:49:15 +01:00
|
|
|
break;
|
2016-11-26 10:49:06 +01:00
|
|
|
}
|
|
|
|
break;
|
2016-10-19 15:07:28 +02:00
|
|
|
default:
|
2017-01-17 13:42:46 +01:00
|
|
|
return;
|
2016-10-19 15:07:28 +02:00
|
|
|
}
|
2016-12-12 13:45:36 +01:00
|
|
|
|
2016-11-26 10:49:06 +01:00
|
|
|
if (!request_to_send){
|
|
|
|
printf(" ACP: NOT IMPLEMENTED\n");
|
|
|
|
}
|
2017-01-17 13:42:46 +01:00
|
|
|
avdtp_sink_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
2016-10-19 15:07:28 +02:00
|
|
|
}
|
|
|
|
|
2017-01-17 14:42:03 +01:00
|
|
|
static int avdtp_acceptor_send_seps_response(uint16_t cid, uint8_t transaction_label, avdtp_stream_endpoint_t * endpoints){
|
|
|
|
uint8_t command[2+2*MAX_NUM_SEPS];
|
|
|
|
int pos = 0;
|
|
|
|
command[pos++] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_RESPONSE_ACCEPT_MSG);
|
|
|
|
command[pos++] = (uint8_t)AVDTP_SI_DISCOVER;
|
|
|
|
|
|
|
|
btstack_linked_list_iterator_t it;
|
|
|
|
btstack_linked_list_iterator_init(&it, (btstack_linked_list_t *) endpoints);
|
|
|
|
while (btstack_linked_list_iterator_has_next(&it)){
|
|
|
|
avdtp_stream_endpoint_t * stream_endpoint = (avdtp_stream_endpoint_t *)btstack_linked_list_iterator_next(&it);
|
|
|
|
command[pos++] = (stream_endpoint->sep.seid << 2) | (stream_endpoint->sep.in_use<<1);
|
|
|
|
command[pos++] = (stream_endpoint->sep.media_type << 4) | (stream_endpoint->sep.type << 3);
|
|
|
|
}
|
|
|
|
return l2cap_send(cid, command, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int avdtp_acceptor_send_response_reject_service_category(uint16_t cid, avdtp_signal_identifier_t identifier, uint8_t category, uint8_t error_code, uint8_t transaction_label){
|
2016-12-08 15:57:14 +01:00
|
|
|
uint8_t command[4];
|
2016-12-13 20:43:26 +01:00
|
|
|
command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_RESPONSE_REJECT_MSG);
|
2016-12-07 15:49:15 +01:00
|
|
|
command[1] = (uint8_t)identifier;
|
|
|
|
command[2] = category;
|
2016-12-13 20:43:26 +01:00
|
|
|
command[3] = error_code;
|
2016-12-07 15:49:15 +01:00
|
|
|
return l2cap_send(cid, command, sizeof(command));
|
|
|
|
}
|
2016-11-21 23:54:32 +01:00
|
|
|
|
2017-01-17 14:42:03 +01:00
|
|
|
static int avdtp_acceptor_send_response_general_reject(uint16_t cid, avdtp_signal_identifier_t identifier, uint8_t transaction_label){
|
2016-12-21 16:42:32 +01:00
|
|
|
uint8_t command[2];
|
|
|
|
command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_GENERAL_REJECT_MSG);
|
|
|
|
command[1] = (uint8_t)identifier;
|
|
|
|
return l2cap_send(cid, command, sizeof(command));
|
|
|
|
}
|
|
|
|
|
2016-12-12 16:27:39 +01:00
|
|
|
static int avdtp_acceptor_send_response_reject(uint16_t cid, avdtp_signal_identifier_t identifier, uint8_t transaction_label){
|
2016-11-10 12:33:34 +01:00
|
|
|
uint8_t command[2];
|
2016-12-13 20:43:26 +01:00
|
|
|
command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_RESPONSE_REJECT_MSG);
|
2016-11-10 12:33:34 +01:00
|
|
|
command[1] = (uint8_t)identifier;
|
|
|
|
return l2cap_send(cid, command, sizeof(command));
|
|
|
|
}
|
|
|
|
|
2017-01-17 14:42:03 +01:00
|
|
|
static int avdtp_acceptor_send_response_reject_with_error_code(uint16_t cid, avdtp_signal_identifier_t identifier, uint8_t error_code, uint8_t transaction_label){
|
2016-12-08 12:10:11 +01:00
|
|
|
uint8_t command[3];
|
2016-12-13 20:43:26 +01:00
|
|
|
command[0] = avdtp_header(transaction_label, AVDTP_SINGLE_PACKET, AVDTP_RESPONSE_REJECT_MSG);
|
2016-12-08 12:10:11 +01:00
|
|
|
command[1] = (uint8_t)identifier;
|
|
|
|
command[2] = error_code;
|
|
|
|
return l2cap_send(cid, command, sizeof(command));
|
|
|
|
}
|
|
|
|
|
2017-01-17 14:42:03 +01:00
|
|
|
void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection){
|
|
|
|
int sent = 1;
|
|
|
|
printf("avdtp_acceptor_stream_config_subsm_run connection state \n");
|
|
|
|
switch (connection->acceptor_connection_state){
|
|
|
|
case AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_ANSWER_DISCOVER_SEPS:
|
|
|
|
printf(" -> AVDTP_SIGNALING_CONNECTION_OPENED\n");
|
|
|
|
connection->state = AVDTP_SIGNALING_CONNECTION_OPENED;
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE;
|
|
|
|
avdtp_acceptor_send_seps_response(connection->l2cap_signaling_cid, connection->acceptor_transaction_label, (avdtp_stream_endpoint_t *)&stream_endpoints);
|
|
|
|
break;
|
|
|
|
case AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE:
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE;
|
|
|
|
avdtp_acceptor_send_response_reject_with_error_code(connection->l2cap_signaling_cid, connection->reject_signal_identifier, connection->error_code, connection->acceptor_transaction_label);
|
|
|
|
break;
|
|
|
|
case AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE:
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE;
|
|
|
|
avdtp_acceptor_send_response_reject_service_category(connection->l2cap_signaling_cid, connection->reject_signal_identifier, connection->reject_service_category, connection->error_code, connection->acceptor_transaction_label);
|
|
|
|
break;
|
|
|
|
case AVDTP_SIGNALING_CONNECTION_ACCEPTOR_W2_GENERAL_REJECT_WITH_ERROR_CODE:
|
|
|
|
connection->acceptor_connection_state = AVDTP_SIGNALING_CONNECTION_ACCEPTOR_IDLE;
|
|
|
|
avdtp_acceptor_send_response_general_reject(connection->l2cap_signaling_cid, connection->reject_signal_identifier, connection->acceptor_transaction_label);
|
|
|
|
default:
|
|
|
|
sent = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (sent) return;
|
|
|
|
|
|
|
|
avdtp_stream_endpoint_t * stream_endpoint = get_avdtp_stream_endpoint_for_seid(connection->query_seid);
|
|
|
|
if (!stream_endpoint) return;
|
2016-12-13 15:20:48 +01:00
|
|
|
|
2016-12-14 11:22:37 +01:00
|
|
|
uint8_t reject_service_category = connection->reject_service_category;
|
|
|
|
avdtp_signal_identifier_t reject_signal_identifier = connection->reject_signal_identifier;
|
|
|
|
uint8_t error_code = connection->error_code;
|
2016-12-08 16:08:55 +01:00
|
|
|
uint16_t cid = stream_endpoint->connection ? stream_endpoint->connection->l2cap_signaling_cid : connection->l2cap_signaling_cid;
|
|
|
|
uint8_t trid = stream_endpoint->connection ? stream_endpoint->connection->acceptor_transaction_label : connection->acceptor_transaction_label;
|
|
|
|
|
2016-12-08 12:10:11 +01:00
|
|
|
avdtp_acceptor_stream_endpoint_state_t acceptor_config_state = stream_endpoint->acceptor_config_state;
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE;
|
2017-01-04 17:51:40 +01:00
|
|
|
uint8_t * out_buffer;
|
|
|
|
uint16_t pos;
|
|
|
|
|
2017-01-16 14:40:25 +01:00
|
|
|
int status = 0;
|
2016-12-08 12:10:11 +01:00
|
|
|
switch (acceptor_config_state){
|
2016-11-26 10:49:06 +01:00
|
|
|
case AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE:
|
2016-10-19 15:07:28 +02:00
|
|
|
break;
|
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_GET_CAPABILITIES:
|
2017-01-04 17:51:40 +01:00
|
|
|
avdtp_prepare_capabilities(&connection->signaling_packet, trid, stream_endpoint->sep.registered_service_categories, stream_endpoint->sep.capabilities, AVDTP_SI_GET_CAPABILITIES);
|
|
|
|
l2cap_reserve_packet_buffer();
|
|
|
|
out_buffer = l2cap_get_outgoing_buffer();
|
|
|
|
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;
|
|
|
|
printf(" ACP: fragmented\n");
|
|
|
|
}
|
|
|
|
l2cap_send_prepared(cid, pos);
|
2016-11-10 12:33:34 +01:00
|
|
|
break;
|
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_GET_ALL_CAPABILITIES:
|
2017-01-04 17:51:40 +01:00
|
|
|
avdtp_prepare_capabilities(&connection->signaling_packet, trid, stream_endpoint->sep.registered_service_categories, stream_endpoint->sep.capabilities, AVDTP_SI_GET_ALL_CAPABILITIES);
|
|
|
|
l2cap_reserve_packet_buffer();
|
|
|
|
out_buffer = l2cap_get_outgoing_buffer();
|
|
|
|
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;
|
|
|
|
printf(" ACP: fragmented\n");
|
|
|
|
}
|
|
|
|
l2cap_send_prepared(cid, pos);
|
2016-11-10 12:33:34 +01:00
|
|
|
break;
|
2016-10-19 15:07:28 +02:00
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_SET_CONFIGURATION:
|
2016-11-26 10:49:06 +01:00
|
|
|
printf(" ACP: DONE\n");
|
2016-12-08 15:28:06 +01:00
|
|
|
printf(" -> AVDTP_STREAM_ENDPOINT_CONFIGURED\n");
|
2016-11-21 23:54:32 +01:00
|
|
|
stream_endpoint->connection = connection;
|
|
|
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED;
|
2016-12-08 16:12:04 +01:00
|
|
|
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SET_CONFIGURATION);
|
2016-11-15 17:17:19 +01:00
|
|
|
break;
|
2016-12-13 20:43:26 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_RECONFIGURE:
|
|
|
|
printf(" ACP: DONE \n");
|
|
|
|
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_RECONFIGURE);
|
|
|
|
break;
|
|
|
|
|
2017-01-11 15:38:03 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_GET_CONFIGURATION:{
|
|
|
|
avdtp_sep_t sep = stream_endpoint->remote_seps[stream_endpoint->remote_sep_index];
|
2017-01-16 14:40:25 +01:00
|
|
|
avdtp_prepare_capabilities(&connection->signaling_packet, trid, sep.configured_service_categories, sep.configuration, AVDTP_SI_GET_CONFIGURATION);
|
2017-01-04 17:51:40 +01:00
|
|
|
l2cap_reserve_packet_buffer();
|
|
|
|
out_buffer = l2cap_get_outgoing_buffer();
|
|
|
|
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;
|
|
|
|
printf(" ACP: fragmented\n");
|
|
|
|
}
|
|
|
|
l2cap_send_prepared(cid, pos);
|
2016-12-07 13:23:07 +01:00
|
|
|
break;
|
2017-01-11 15:38:03 +01:00
|
|
|
}
|
2016-12-08 15:28:06 +01:00
|
|
|
case AVDTP_ACCEPTOR_W4_L2CAP_FOR_MEDIA_CONNECTED:
|
|
|
|
stream_endpoint->acceptor_config_state = AVDTP_ACCEPTOR_W4_L2CAP_FOR_MEDIA_CONNECTED;
|
2017-01-17 14:42:03 +01:00
|
|
|
break;
|
2016-12-07 15:49:15 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_OPEN_STREAM:
|
2016-12-08 15:28:06 +01:00
|
|
|
printf(" ACP: DONE\n");
|
2016-12-08 16:12:04 +01:00
|
|
|
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_OPEN);
|
2016-10-19 15:07:28 +02:00
|
|
|
break;
|
2016-11-26 10:49:06 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_START_STREAM:
|
2016-12-08 12:17:12 +01:00
|
|
|
printf(" ACP: DONE \n");
|
2016-12-08 15:28:06 +01:00
|
|
|
printf(" -> AVDTP_STREAM_ENDPOINT_STREAMING \n");
|
2016-12-21 16:42:32 +01:00
|
|
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_STREAMING;
|
2016-12-08 16:12:04 +01:00
|
|
|
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_START);
|
2016-11-26 10:49:06 +01:00
|
|
|
break;
|
2016-12-08 12:10:11 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_CLOSE_STREAM:
|
|
|
|
printf(" ACP: DONE\n");
|
2016-12-08 16:12:04 +01:00
|
|
|
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_CLOSE);
|
2016-12-08 12:10:11 +01:00
|
|
|
break;
|
2016-12-08 15:28:06 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_ABORT_STREAM:
|
|
|
|
printf(" ACP: DONE\n");
|
2016-12-08 16:12:04 +01:00
|
|
|
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_ABORT);
|
2016-12-08 15:28:06 +01:00
|
|
|
break;
|
2016-12-21 16:42:32 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_ANSWER_SUSPEND_STREAM:
|
|
|
|
printf(" ACP: DONE\n");
|
|
|
|
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_OPENED;
|
|
|
|
avdtp_acceptor_send_accept_response(cid, trid, AVDTP_SI_SUSPEND);
|
|
|
|
break;
|
2016-12-08 12:10:11 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_REJECT_UNKNOWN_CMD:
|
2017-01-16 14:40:25 +01:00
|
|
|
status = 1;
|
2016-12-20 11:17:23 +01:00
|
|
|
printf(" ACP: DONE REJECT\n");
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->reject_signal_identifier = 0;
|
2016-12-08 16:08:55 +01:00
|
|
|
avdtp_acceptor_send_response_reject(cid, reject_signal_identifier, trid);
|
2016-12-08 12:10:11 +01:00
|
|
|
break;
|
2016-12-13 20:43:26 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_REJECT_CATEGORY_WITH_ERROR_CODE:
|
2017-01-16 14:40:25 +01:00
|
|
|
status = 1;
|
2016-12-20 11:17:23 +01:00
|
|
|
printf(" ACP: DONE REJECT CATEGORY\n");
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->reject_service_category = 0;
|
2016-12-13 20:43:26 +01:00
|
|
|
avdtp_acceptor_send_response_reject_service_category(cid, reject_signal_identifier, reject_service_category, error_code, trid);
|
|
|
|
break;
|
|
|
|
|
2016-12-08 12:10:11 +01:00
|
|
|
case AVDTP_ACCEPTOR_W2_REJECT_WITH_ERROR_CODE:
|
2017-01-16 14:40:25 +01:00
|
|
|
status = 1;
|
2016-12-20 11:17:23 +01:00
|
|
|
printf(" ACP: DONE REJECT\n");
|
2016-12-14 11:22:37 +01:00
|
|
|
connection->reject_signal_identifier = 0;
|
|
|
|
connection->error_code = 0;
|
2016-12-08 16:08:55 +01:00
|
|
|
avdtp_acceptor_send_response_reject_with_error_code(cid, reject_signal_identifier, error_code, trid);
|
2016-12-08 12:10:11 +01:00
|
|
|
break;
|
2016-10-19 15:07:28 +02:00
|
|
|
default:
|
2017-01-16 14:40:25 +01:00
|
|
|
status = 0;
|
2016-11-26 10:49:06 +01:00
|
|
|
printf(" ACP: NOT IMPLEMENTED\n");
|
2017-01-16 14:40:25 +01:00
|
|
|
sent = 0;
|
2016-12-12 16:27:39 +01:00
|
|
|
}
|
2017-01-16 14:40:25 +01:00
|
|
|
avdtp_signaling_emit_done(avdtp_sink_callback, connection->con_handle, status);
|
|
|
|
|
2017-01-17 14:42:03 +01:00
|
|
|
// check fragmentation
|
|
|
|
if (stream_endpoint->acceptor_config_state != AVDTP_ACCEPTOR_STREAM_CONFIG_IDLE){
|
|
|
|
avdtp_sink_request_can_send_now_acceptor(connection, connection->l2cap_signaling_cid);
|
2016-12-12 16:27:39 +01:00
|
|
|
}
|
2017-01-17 14:42:03 +01:00
|
|
|
|
|
|
|
return;
|
2016-10-19 15:07:28 +02:00
|
|
|
}
|