mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
a2dp: remove checks on seid, and cid
This commit is contained in:
parent
ef5ad9d62b
commit
e91a86a966
@ -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);
|
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){
|
void a2dp_sink_register_packet_handler(btstack_packet_handler_t callback){
|
||||||
// avdtp_sink_register_packet_handler(callback);
|
// avdtp_sink_register_packet_handler(callback);
|
||||||
// return;
|
// 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);
|
a2dp_streaming_emit_connection_established(a2dp_sink_context.a2dp_callback, cid, address, loc_seid, rem_seid, status);
|
||||||
break;
|
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;
|
app_state = A2DP_STREAMING_OPENED;
|
||||||
a2dp_streaming_emit_connection_established(a2dp_sink_context.a2dp_callback, cid, address, loc_seid, rem_seid, 0);
|
a2dp_streaming_emit_connection_established(a2dp_sink_context.a2dp_callback, cid, address, loc_seid, rem_seid, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -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);
|
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){
|
static void a2dp_streaming_emit_can_send_media_packet_now(btstack_packet_handler_t callback, uint16_t cid, uint8_t seid){
|
||||||
if (!callback) return;
|
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 signal_identifier;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
avdtp_sep_t sep;
|
avdtp_sep_t sep;
|
||||||
uint8_t loc_seid;
|
uint8_t local_seid;
|
||||||
uint8_t rem_seid;
|
uint8_t remote_seid;
|
||||||
uint16_t cid;
|
uint16_t cid;
|
||||||
bd_addr_t address;
|
bd_addr_t address;
|
||||||
uint8_t sep_media_type;
|
uint8_t sep_media_type;
|
||||||
@ -253,36 +240,25 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AVDTP_SUBEVENT_STREAMING_CAN_SEND_MEDIA_PACKET_NOW:
|
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;
|
break;
|
||||||
|
|
||||||
case AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED:
|
case AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED:
|
||||||
avdtp_subevent_streaming_connection_established_get_bd_addr(packet, address);
|
avdtp_subevent_streaming_connection_established_get_bd_addr(packet, address);
|
||||||
|
|
||||||
status = avdtp_subevent_streaming_connection_established_get_status(packet);
|
status = avdtp_subevent_streaming_connection_established_get_status(packet);
|
||||||
cid = avdtp_subevent_streaming_connection_established_get_avdtp_cid(packet);
|
cid = avdtp_subevent_streaming_connection_established_get_avdtp_cid(packet);
|
||||||
|
remote_seid = avdtp_subevent_streaming_connection_established_get_remote_seid(packet);
|
||||||
if (cid != a2dp_cid()){
|
local_seid = avdtp_subevent_streaming_connection_established_get_local_seid(packet);
|
||||||
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);
|
|
||||||
if (status != 0){
|
if (status != 0){
|
||||||
log_info("AVDTP_SUBEVENT_STREAMING_CONNECTION could not be established, status %d ---", status);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
app_state = A2DP_STREAMING_OPENED;
|
app_state = A2DP_STREAMING_OPENED;
|
||||||
a2dp_streaming_emit_connection_established(a2dp_source_context.a2dp_callback, a2dp_cid(), address, local_seid(), remote_seid(), 0);
|
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", a2dp_cid(), local_seid(), remote_seid());
|
log_info("AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED --- avdtp_cid 0x%02x, local seid %d, remote seid %d", cid, local_seid, remote_seid);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AVDTP_SUBEVENT_SIGNALING_ACCEPT:
|
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++] = HCI_EVENT_A2DP_META;
|
||||||
event[pos++] = sizeof(event) - 2;
|
event[pos++] = sizeof(event) - 2;
|
||||||
event[pos++] = A2DP_SUBEVENT_STREAM_STARTED;
|
event[pos++] = A2DP_SUBEVENT_STREAM_STARTED;
|
||||||
little_endian_store_16(event, pos, a2dp_cid());
|
little_endian_store_16(event, pos, cid);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
|
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
|
||||||
(*a2dp_source_context.a2dp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
(*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++] = HCI_EVENT_A2DP_META;
|
||||||
event[pos++] = sizeof(event) - 2;
|
event[pos++] = sizeof(event) - 2;
|
||||||
event[pos++] = A2DP_SUBEVENT_STREAM_SUSPENDED;
|
event[pos++] = A2DP_SUBEVENT_STREAM_SUSPENDED;
|
||||||
little_endian_store_16(event, pos, a2dp_cid());
|
little_endian_store_16(event, pos, cid);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
|
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
|
||||||
(*a2dp_source_context.a2dp_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
(*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++] = HCI_EVENT_A2DP_META;
|
||||||
event[pos++] = sizeof(event) - 2;
|
event[pos++] = sizeof(event) - 2;
|
||||||
event[pos++] = A2DP_SUBEVENT_STREAM_RELEASED;
|
event[pos++] = A2DP_SUBEVENT_STREAM_RELEASED;
|
||||||
little_endian_store_16(event, pos, a2dp_cid());
|
little_endian_store_16(event, pos, cid);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
log_info("send A2DP_SUBEVENT_STREAM_RELEASED to app");
|
log_info("send A2DP_SUBEVENT_STREAM_RELEASED to app");
|
||||||
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
|
event[pos++] = avdtp_stream_endpoint_seid(sc.local_stream_endpoint);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user