a2dp: remove checks on seid, and cid

This commit is contained in:
Milanka Ringwald 2017-08-11 11:56:36 +02:00
parent ef5ad9d62b
commit e91a86a966
2 changed files with 12 additions and 57 deletions

View File

@ -137,17 +137,6 @@ void a2dp_sink_create_sdp_record(uint8_t * service, uint32_t service_record_han
de_add_number(service, DE_UINT, DE_SIZE_16, supported_features);
}
static inline uint16_t a2dp_cid(void){
if (!sc.local_stream_endpoint) return 0;
if (!sc.local_stream_endpoint->connection) return 0;
return sc.local_stream_endpoint->connection->avdtp_cid;
}
static inline uint8_t local_seid(void){
if (!sc.local_stream_endpoint) return 0;
return sc.local_stream_endpoint->sep.seid;
}
void a2dp_sink_register_packet_handler(btstack_packet_handler_t callback){
// avdtp_sink_register_packet_handler(callback);
// return;
@ -291,16 +280,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
a2dp_streaming_emit_connection_established(a2dp_sink_context.a2dp_callback, cid, address, loc_seid, rem_seid, status);
break;
}
if (cid != a2dp_cid()){
a2dp_streaming_emit_connection_established(a2dp_sink_context.a2dp_callback, cid, address, loc_seid, rem_seid, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER);
break;
}
if (loc_seid != local_seid()){
a2dp_streaming_emit_connection_established(a2dp_sink_context.a2dp_callback, cid, address, loc_seid, rem_seid, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER);
break;
}
app_state = A2DP_STREAMING_OPENED;
a2dp_streaming_emit_connection_established(a2dp_sink_context.a2dp_callback, cid, address, loc_seid, rem_seid, 0);
break;

View File

@ -140,19 +140,6 @@ void a2dp_source_create_sdp_record(uint8_t * service, uint32_t service_record_ha
de_add_number(service, DE_UINT, DE_SIZE_16, supported_features);
}
static inline uint16_t a2dp_cid(void){
if (!sc.local_stream_endpoint) return 0;
if (!sc.local_stream_endpoint->connection) return 0;
return sc.local_stream_endpoint->connection->avdtp_cid;
}
static inline uint8_t local_seid(void){
return avdtp_local_seid(sc.local_stream_endpoint);
}
static inline uint8_t remote_seid(void){
return avdtp_remote_seid(sc.local_stream_endpoint);
}
static void a2dp_streaming_emit_can_send_media_packet_now(btstack_packet_handler_t callback, uint16_t cid, uint8_t seid){
if (!callback) return;
@ -174,8 +161,8 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
uint8_t signal_identifier;
uint8_t status;
avdtp_sep_t sep;
uint8_t loc_seid;
uint8_t rem_seid;
uint8_t local_seid;
uint8_t remote_seid;
uint16_t cid;
bd_addr_t address;
uint8_t sep_media_type;
@ -253,36 +240,25 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
break;
}
case AVDTP_SUBEVENT_STREAMING_CAN_SEND_MEDIA_PACKET_NOW:
a2dp_streaming_emit_can_send_media_packet_now(a2dp_source_context.a2dp_callback, a2dp_cid(), 0);
cid = avdtp_subevent_streaming_can_send_media_packet_now_get_avdtp_cid(packet);
a2dp_streaming_emit_can_send_media_packet_now(a2dp_source_context.a2dp_callback, cid, 0);
break;
case AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED:
avdtp_subevent_streaming_connection_established_get_bd_addr(packet, address);
status = avdtp_subevent_streaming_connection_established_get_status(packet);
cid = avdtp_subevent_streaming_connection_established_get_avdtp_cid(packet);
if (cid != a2dp_cid()){
a2dp_streaming_emit_connection_established(a2dp_source_context.a2dp_callback, a2dp_cid(), address, local_seid(), remote_seid(), ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER);
break;
}
loc_seid = avdtp_subevent_streaming_connection_established_get_local_seid(packet);
if (loc_seid != local_seid()){
a2dp_streaming_emit_connection_established(a2dp_source_context.a2dp_callback, a2dp_cid(), address, local_seid(), remote_seid(), ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER);
break;
}
rem_seid = avdtp_subevent_streaming_connection_established_get_remote_seid(packet);
remote_seid = avdtp_subevent_streaming_connection_established_get_remote_seid(packet);
local_seid = avdtp_subevent_streaming_connection_established_get_local_seid(packet);
if (status != 0){
log_info("AVDTP_SUBEVENT_STREAMING_CONNECTION could not be established, status %d ---", status);
a2dp_streaming_emit_connection_established(a2dp_source_context.a2dp_callback, a2dp_cid(), address, local_seid(), rem_seid, status);
a2dp_streaming_emit_connection_established(a2dp_source_context.a2dp_callback, cid, address, local_seid, remote_seid, status);
break;
}
app_state = A2DP_STREAMING_OPENED;
a2dp_streaming_emit_connection_established(a2dp_source_context.a2dp_callback, a2dp_cid(), address, local_seid(), remote_seid(), 0);
log_info("AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED --- avdtp_cid 0x%02x, local seid %d, remote seid %d", a2dp_cid(), local_seid(), remote_seid());
a2dp_streaming_emit_connection_established(a2dp_source_context.a2dp_callback, cid, address, local_seid, remote_seid, 0);
log_info("AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED --- avdtp_cid 0x%02x, local seid %d, remote seid %d", cid, local_seid, remote_seid);
break;
case AVDTP_SUBEVENT_SIGNALING_ACCEPT:
@ -345,7 +321,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
event[pos++] = HCI_EVENT_A2DP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = A2DP_SUBEVENT_STREAM_STARTED;
little_endian_store_16(event, pos, a2dp_cid());
little_endian_store_16(event, pos, cid);
pos += 2;
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
(*a2dp_source_context.a2dp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
@ -357,7 +333,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
event[pos++] = HCI_EVENT_A2DP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = A2DP_SUBEVENT_STREAM_SUSPENDED;
little_endian_store_16(event, pos, a2dp_cid());
little_endian_store_16(event, pos, cid);
pos += 2;
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
(*a2dp_source_context.a2dp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
@ -370,7 +346,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
event[pos++] = HCI_EVENT_A2DP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = A2DP_SUBEVENT_STREAM_RELEASED;
little_endian_store_16(event, pos, a2dp_cid());
little_endian_store_16(event, pos, cid);
pos += 2;
log_info("send A2DP_SUBEVENT_STREAM_RELEASED to app");
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);