mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-14 18:40:59 +00:00
move connect/open stream to a2dp
This commit is contained in:
parent
274391e8b2
commit
ba155c2213
@ -1231,26 +1231,29 @@ typedef uint8_t sm_key_t[16];
|
||||
/** AVDTP Subevent */
|
||||
|
||||
/**
|
||||
* @format 1H11
|
||||
* @format 1H111
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param int_seid
|
||||
* @param signal_identifier
|
||||
* @param status 0 == OK
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_ACCEPT 0x01
|
||||
|
||||
/**
|
||||
* @format 1H1
|
||||
* @format 1H11
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param int_seid
|
||||
* @param signal_identifier
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_REJECT 0x02
|
||||
|
||||
/**
|
||||
* @format 1H1
|
||||
* @format 1H11
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param int_seid
|
||||
* @param signal_identifier
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT 0x03
|
||||
@ -1283,9 +1286,11 @@ typedef uint8_t sm_key_t[16];
|
||||
#define AVDTP_SUBEVENT_SIGNALING_SEP_FOUND 0x06
|
||||
|
||||
/**
|
||||
* @format 1H11111111
|
||||
* @format 1H1111111111
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param int_seid
|
||||
* @param acp_seid
|
||||
* @param media_type
|
||||
* @param sampling_frequency_bitmap
|
||||
* @param channel_mode_bitmap
|
||||
@ -1298,9 +1303,11 @@ typedef uint8_t sm_key_t[16];
|
||||
#define AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY 0x07
|
||||
|
||||
/**
|
||||
* @format 1H12LV
|
||||
* @format 1H1112LV
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param int_seid
|
||||
* @param acp_seid
|
||||
* @param media_type
|
||||
* @param media_codec_type
|
||||
* @param media_codec_information_len
|
||||
@ -1309,9 +1316,11 @@ typedef uint8_t sm_key_t[16];
|
||||
#define AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY 0x08
|
||||
|
||||
/**
|
||||
* @format 1H1121111111
|
||||
* @format 1H111121111111
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param int_seid
|
||||
* @param acp_seid
|
||||
* @param reconfigure
|
||||
* @param media_type
|
||||
* @param sampling_frequency
|
||||
@ -1326,9 +1335,11 @@ typedef uint8_t sm_key_t[16];
|
||||
#define AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION 0x09
|
||||
|
||||
/**
|
||||
* @format 1H112LV
|
||||
* @format 1H11112LV
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param int_seid
|
||||
* @param acp_seid
|
||||
* @param reconfigure
|
||||
* @param media_type
|
||||
* @param media_codec_type
|
||||
@ -1356,12 +1367,13 @@ typedef uint8_t sm_key_t[16];
|
||||
* @format 1H12
|
||||
* @param subevent_code
|
||||
* @param avdtp_cid
|
||||
* @param seid
|
||||
* @param int_seid
|
||||
* @param sequence_number
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_STREAMING_CAN_SEND_MEDIA_PACKET_NOW 0x0D
|
||||
|
||||
|
||||
|
||||
/** AVRCP Subevent */
|
||||
|
||||
/**
|
||||
|
@ -3880,6 +3880,15 @@ static inline hci_con_handle_t ancs_subevent_client_disconnected_get_handle(cons
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_accept_get_avdtp_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field int_seid from event AVDTP_SUBEVENT_SIGNALING_ACCEPT
|
||||
* @param event packet
|
||||
* @return int_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_accept_get_int_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field signal_identifier from event AVDTP_SUBEVENT_SIGNALING_ACCEPT
|
||||
* @param event packet
|
||||
@ -3887,7 +3896,7 @@ static inline hci_con_handle_t avdtp_subevent_signaling_accept_get_avdtp_cid(con
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_accept_get_signal_identifier(const uint8_t * event){
|
||||
return event[5];
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field status from event AVDTP_SUBEVENT_SIGNALING_ACCEPT
|
||||
@ -3896,7 +3905,7 @@ static inline uint8_t avdtp_subevent_signaling_accept_get_signal_identifier(cons
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_accept_get_status(const uint8_t * event){
|
||||
return event[6];
|
||||
return event[7];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3908,6 +3917,15 @@ static inline uint8_t avdtp_subevent_signaling_accept_get_status(const uint8_t *
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_reject_get_avdtp_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field int_seid from event AVDTP_SUBEVENT_SIGNALING_REJECT
|
||||
* @param event packet
|
||||
* @return int_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_reject_get_int_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field signal_identifier from event AVDTP_SUBEVENT_SIGNALING_REJECT
|
||||
* @param event packet
|
||||
@ -3915,7 +3933,7 @@ static inline hci_con_handle_t avdtp_subevent_signaling_reject_get_avdtp_cid(con
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_reject_get_signal_identifier(const uint8_t * event){
|
||||
return event[5];
|
||||
return event[6];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3927,6 +3945,15 @@ static inline uint8_t avdtp_subevent_signaling_reject_get_signal_identifier(cons
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_general_reject_get_avdtp_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field int_seid from event AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT
|
||||
* @param event packet
|
||||
* @return int_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_general_reject_get_int_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field signal_identifier from event AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT
|
||||
* @param event packet
|
||||
@ -3934,7 +3961,7 @@ static inline hci_con_handle_t avdtp_subevent_signaling_general_reject_get_avdtp
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_general_reject_get_signal_identifier(const uint8_t * event){
|
||||
return event[5];
|
||||
return event[6];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4030,6 +4057,24 @@ static inline uint8_t avdtp_subevent_signaling_sep_found_get_sep_type(const uint
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_sbc_capability_get_avdtp_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field int_seid from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
* @param event packet
|
||||
* @return int_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_int_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field acp_seid from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
* @param event packet
|
||||
* @return acp_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_acp_seid(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
* @param event packet
|
||||
@ -4037,7 +4082,7 @@ static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_sbc_capabili
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_media_type(const uint8_t * event){
|
||||
return event[5];
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field sampling_frequency_bitmap from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
@ -4046,7 +4091,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_me
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_sampling_frequency_bitmap(const uint8_t * event){
|
||||
return event[6];
|
||||
return event[8];
|
||||
}
|
||||
/**
|
||||
* @brief Get field channel_mode_bitmap from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
@ -4055,7 +4100,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_sa
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_channel_mode_bitmap(const uint8_t * event){
|
||||
return event[7];
|
||||
return event[9];
|
||||
}
|
||||
/**
|
||||
* @brief Get field block_length_bitmap from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
@ -4064,7 +4109,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_ch
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_block_length_bitmap(const uint8_t * event){
|
||||
return event[8];
|
||||
return event[10];
|
||||
}
|
||||
/**
|
||||
* @brief Get field subbands_bitmap from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
@ -4073,7 +4118,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_bl
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_subbands_bitmap(const uint8_t * event){
|
||||
return event[9];
|
||||
return event[11];
|
||||
}
|
||||
/**
|
||||
* @brief Get field allocation_method_bitmap from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
@ -4082,7 +4127,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_su
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_allocation_method_bitmap(const uint8_t * event){
|
||||
return event[10];
|
||||
return event[12];
|
||||
}
|
||||
/**
|
||||
* @brief Get field min_bitpool_value from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
@ -4091,7 +4136,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_al
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_min_bitpool_value(const uint8_t * event){
|
||||
return event[11];
|
||||
return event[13];
|
||||
}
|
||||
/**
|
||||
* @brief Get field max_bitpool_value from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY
|
||||
@ -4100,7 +4145,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_mi
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_max_bitpool_value(const uint8_t * event){
|
||||
return event[12];
|
||||
return event[14];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4112,6 +4157,24 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_capability_get_ma
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_other_capability_get_avdtp_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field int_seid from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY
|
||||
* @param event packet
|
||||
* @return int_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_other_capability_get_int_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field acp_seid from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY
|
||||
* @param event packet
|
||||
* @return acp_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_other_capability_get_acp_seid(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY
|
||||
* @param event packet
|
||||
@ -4119,7 +4182,7 @@ static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_other_capabi
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_other_capability_get_media_type(const uint8_t * event){
|
||||
return event[5];
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_codec_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY
|
||||
@ -4128,7 +4191,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_other_capability_get_
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t avdtp_subevent_signaling_media_codec_other_capability_get_media_codec_type(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
return little_endian_read_16(event, 8);
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_codec_information_len from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY
|
||||
@ -4137,7 +4200,7 @@ static inline uint16_t avdtp_subevent_signaling_media_codec_other_capability_get
|
||||
* @note: btstack_type L
|
||||
*/
|
||||
static inline int avdtp_subevent_signaling_media_codec_other_capability_get_media_codec_information_len(const uint8_t * event){
|
||||
return little_endian_read_16(event, 8);
|
||||
return little_endian_read_16(event, 10);
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_codec_information from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY
|
||||
@ -4146,7 +4209,7 @@ static inline int avdtp_subevent_signaling_media_codec_other_capability_get_medi
|
||||
* @note: btstack_type V
|
||||
*/
|
||||
static inline const uint8_t * avdtp_subevent_signaling_media_codec_other_capability_get_media_codec_information(const uint8_t * event){
|
||||
return &event[10];
|
||||
return &event[12];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4158,6 +4221,24 @@ static inline const uint8_t * avdtp_subevent_signaling_media_codec_other_capabil
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_avdtp_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field int_seid from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
* @param event packet
|
||||
* @return int_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_int_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field acp_seid from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
* @param event packet
|
||||
* @return acp_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_acp_seid(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field reconfigure from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
* @param event packet
|
||||
@ -4165,7 +4246,7 @@ static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_sbc_configur
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_reconfigure(const uint8_t * event){
|
||||
return event[5];
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4174,7 +4255,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_media_type(const uint8_t * event){
|
||||
return event[6];
|
||||
return event[8];
|
||||
}
|
||||
/**
|
||||
* @brief Get field sampling_frequency from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4183,7 +4264,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_sampling_frequency(const uint8_t * event){
|
||||
return little_endian_read_16(event, 7);
|
||||
return little_endian_read_16(event, 9);
|
||||
}
|
||||
/**
|
||||
* @brief Get field channel_mode from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4192,7 +4273,7 @@ static inline uint16_t avdtp_subevent_signaling_media_codec_sbc_configuration_ge
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_channel_mode(const uint8_t * event){
|
||||
return event[9];
|
||||
return event[11];
|
||||
}
|
||||
/**
|
||||
* @brief Get field num_channels from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4201,7 +4282,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_num_channels(const uint8_t * event){
|
||||
return event[10];
|
||||
return event[12];
|
||||
}
|
||||
/**
|
||||
* @brief Get field block_length from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4210,7 +4291,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_block_length(const uint8_t * event){
|
||||
return event[11];
|
||||
return event[13];
|
||||
}
|
||||
/**
|
||||
* @brief Get field subbands from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4219,7 +4300,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_subbands(const uint8_t * event){
|
||||
return event[12];
|
||||
return event[14];
|
||||
}
|
||||
/**
|
||||
* @brief Get field allocation_method from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4228,7 +4309,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_allocation_method(const uint8_t * event){
|
||||
return event[13];
|
||||
return event[15];
|
||||
}
|
||||
/**
|
||||
* @brief Get field min_bitpool_value from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4237,7 +4318,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_min_bitpool_value(const uint8_t * event){
|
||||
return event[14];
|
||||
return event[16];
|
||||
}
|
||||
/**
|
||||
* @brief Get field max_bitpool_value from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION
|
||||
@ -4246,7 +4327,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get_max_bitpool_value(const uint8_t * event){
|
||||
return event[15];
|
||||
return event[17];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4258,6 +4339,24 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_configuration_get
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_other_configuration_get_avdtp_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field int_seid from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION
|
||||
* @param event packet
|
||||
* @return int_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_other_configuration_get_int_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field acp_seid from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION
|
||||
* @param event packet
|
||||
* @return acp_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_other_configuration_get_acp_seid(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field reconfigure from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION
|
||||
* @param event packet
|
||||
@ -4265,7 +4364,7 @@ static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_other_config
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_other_configuration_get_reconfigure(const uint8_t * event){
|
||||
return event[5];
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION
|
||||
@ -4274,7 +4373,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_other_configuration_g
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_other_configuration_get_media_type(const uint8_t * event){
|
||||
return event[6];
|
||||
return event[8];
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_codec_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION
|
||||
@ -4283,7 +4382,7 @@ static inline uint8_t avdtp_subevent_signaling_media_codec_other_configuration_g
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t avdtp_subevent_signaling_media_codec_other_configuration_get_media_codec_type(const uint8_t * event){
|
||||
return little_endian_read_16(event, 7);
|
||||
return little_endian_read_16(event, 9);
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_codec_information_len from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION
|
||||
@ -4292,7 +4391,7 @@ static inline uint16_t avdtp_subevent_signaling_media_codec_other_configuration_
|
||||
* @note: btstack_type L
|
||||
*/
|
||||
static inline int avdtp_subevent_signaling_media_codec_other_configuration_get_media_codec_information_len(const uint8_t * event){
|
||||
return little_endian_read_16(event, 9);
|
||||
return little_endian_read_16(event, 11);
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_codec_information from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION
|
||||
@ -4301,7 +4400,7 @@ static inline int avdtp_subevent_signaling_media_codec_other_configuration_get_m
|
||||
* @note: btstack_type V
|
||||
*/
|
||||
static inline const uint8_t * avdtp_subevent_signaling_media_codec_other_configuration_get_media_codec_information(const uint8_t * event){
|
||||
return &event[11];
|
||||
return &event[13];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4343,12 +4442,12 @@ static inline hci_con_handle_t avdtp_subevent_streaming_can_send_media_packet_no
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field seid from event AVDTP_SUBEVENT_STREAMING_CAN_SEND_MEDIA_PACKET_NOW
|
||||
* @brief Get field int_seid from event AVDTP_SUBEVENT_STREAMING_CAN_SEND_MEDIA_PACKET_NOW
|
||||
* @param event packet
|
||||
* @return seid
|
||||
* @return int_seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_streaming_can_send_media_packet_now_get_seid(const uint8_t * event){
|
||||
static inline uint8_t avdtp_subevent_streaming_can_send_media_packet_now_get_int_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
|
@ -49,12 +49,41 @@
|
||||
#include "avdtp_util.h"
|
||||
#include "avdtp_source.h"
|
||||
#include "a2dp_source.h"
|
||||
#include "sbc_encoder.h"
|
||||
|
||||
static const char * default_a2dp_source_service_name = "BTstack A2DP Source Service";
|
||||
static const char * default_a2dp_source_service_provider_name = "BTstack A2DP Source Service Provider";
|
||||
static avdtp_context_t a2dp_source_context;
|
||||
|
||||
// static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
typedef struct {
|
||||
// to app
|
||||
uint32_t fill_audio_ring_buffer_timeout_ms;
|
||||
uint32_t time_audio_data_sent; // ms
|
||||
uint32_t acc_num_missed_samples;
|
||||
uint32_t samples_ready;
|
||||
btstack_timer_source_t fill_audio_ring_buffer_timer;
|
||||
btstack_ring_buffer_t sbc_ring_buffer;
|
||||
btstack_sbc_encoder_state_t sbc_encoder_state;
|
||||
|
||||
int reconfigure;
|
||||
int num_channels;
|
||||
int sampling_frequency;
|
||||
int channel_mode;
|
||||
int block_length;
|
||||
int subbands;
|
||||
int allocation_method;
|
||||
int min_bitpool_value;
|
||||
int max_bitpool_value;
|
||||
avdtp_stream_endpoint_t * local_stream_endpoint;
|
||||
avdtp_sep_t * active_remote_sep;
|
||||
} avdtp_stream_endpoint_context_t;
|
||||
|
||||
static a2dp_state_t app_state = A2DP_IDLE;
|
||||
static avdtp_stream_endpoint_context_t sc;
|
||||
static uint16_t avdtp_cid = 0;
|
||||
static int next_remote_sep_index_to_query = 0;
|
||||
|
||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
void a2dp_source_create_sdp_record(uint8_t * service, uint32_t service_record_handle, uint16_t supported_features, const char * service_name, const char * service_provider_name){
|
||||
uint8_t* attribute;
|
||||
@ -135,31 +164,235 @@ 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 void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
// UNUSED(channel);
|
||||
// UNUSED(size);
|
||||
// UNUSED(packet_type);
|
||||
// UNUSED(packet);
|
||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
UNUSED(size);
|
||||
|
||||
// }
|
||||
bd_addr_t event_addr;
|
||||
uint8_t signal_identifier;
|
||||
uint8_t status;
|
||||
avdtp_sep_t sep;
|
||||
//
|
||||
|
||||
switch (packet_type) {
|
||||
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (hci_event_packet_get_type(packet)) {
|
||||
case HCI_EVENT_PIN_CODE_REQUEST:
|
||||
// inform about pin code request
|
||||
printf("Pin code request - using '0000'\n");
|
||||
hci_event_pin_code_request_get_bd_addr(packet, event_addr);
|
||||
hci_send_cmd(&hci_pin_code_request_reply, &event_addr, 4, "0000");
|
||||
break;
|
||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||
// connection closed -> quit test app
|
||||
printf("\n --- a2dp source --- HCI_EVENT_DISCONNECTION_COMPLETE ---\n");
|
||||
break;
|
||||
case HCI_EVENT_AVDTP_META:
|
||||
switch (packet[2]){
|
||||
case AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED:
|
||||
avdtp_cid = avdtp_subevent_signaling_connection_established_get_avdtp_cid(packet);
|
||||
status = avdtp_subevent_signaling_connection_established_get_status(packet);
|
||||
if (status != 0){
|
||||
printf(" --- a2dp source --- AVDTP_SUBEVENT_SIGNALING_CONNECTION could not be established, status %d ---\n", status);
|
||||
break;
|
||||
}
|
||||
sc.active_remote_sep = NULL;
|
||||
next_remote_sep_index_to_query = 0;
|
||||
app_state = A2DP_W2_DISCOVER_SEPS;
|
||||
printf(" --- a2dp source --- AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED, avdtp cid 0x%02x ---\n", avdtp_cid);
|
||||
avdtp_source_discover_stream_endpoints(avdtp_cid);
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED:
|
||||
status = avdtp_subevent_streaming_connection_established_get_status(packet);
|
||||
if (status != 0){
|
||||
printf(" --- a2dp source --- AVDTP_SUBEVENT_STREAMING_CONNECTION could not be established, status %d ---\n", status);
|
||||
break;
|
||||
}
|
||||
app_state = A2DP_STREAMING_OPENED;
|
||||
printf(" --- a2dp source --- AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED ---\n");
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_SEP_FOUND:
|
||||
if (app_state != A2DP_W2_DISCOVER_SEPS) return;
|
||||
sep.seid = avdtp_subevent_signaling_sep_found_get_seid(packet);
|
||||
sep.in_use = avdtp_subevent_signaling_sep_found_get_in_use(packet);
|
||||
sep.media_type = avdtp_subevent_signaling_sep_found_get_media_type(packet);
|
||||
sep.type = avdtp_subevent_signaling_sep_found_get_sep_type(packet);
|
||||
printf(" --- a2dp source --- Found sep: seid %u, in_use %d, media type %d, sep type %d (1-SNK)\n", sep.seid, sep.in_use, sep.media_type, sep.type);
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY:{
|
||||
printf(" AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY 0\n");
|
||||
if (!sc.local_stream_endpoint) return;
|
||||
printf(" AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY 1\n");
|
||||
uint8_t sampling_frequency = avdtp_choose_sbc_sampling_frequency(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_sampling_frequency_bitmap(packet));
|
||||
uint8_t channel_mode = avdtp_choose_sbc_channel_mode(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_channel_mode_bitmap(packet));
|
||||
uint8_t block_length = avdtp_choose_sbc_block_length(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_block_length_bitmap(packet));
|
||||
uint8_t subbands = avdtp_choose_sbc_subbands(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_subbands_bitmap(packet));
|
||||
|
||||
uint8_t allocation_method = avdtp_choose_sbc_allocation_method(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_allocation_method_bitmap(packet));
|
||||
uint8_t max_bitpool_value = avdtp_choose_sbc_max_bitpool_value(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_max_bitpool_value(packet));
|
||||
uint8_t min_bitpool_value = avdtp_choose_sbc_min_bitpool_value(sc.local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_min_bitpool_value(packet));
|
||||
|
||||
sc.local_stream_endpoint->remote_configuration.media_codec.media_codec_information[0] = (sampling_frequency << 4) | channel_mode;
|
||||
sc.local_stream_endpoint->remote_configuration.media_codec.media_codec_information[1] = (block_length << 4) | (subbands << 2) | allocation_method;
|
||||
sc.local_stream_endpoint->remote_configuration.media_codec.media_codec_information[2] = min_bitpool_value;
|
||||
sc.local_stream_endpoint->remote_configuration.media_codec.media_codec_information[3] = max_bitpool_value;
|
||||
|
||||
sc.local_stream_endpoint->remote_configuration_bitmap = store_bit16(sc.local_stream_endpoint->remote_configuration_bitmap, AVDTP_MEDIA_CODEC, 1);
|
||||
sc.local_stream_endpoint->remote_configuration.media_codec.media_type = AVDTP_AUDIO;
|
||||
sc.local_stream_endpoint->remote_configuration.media_codec.media_codec_type = AVDTP_CODEC_SBC;
|
||||
|
||||
app_state = A2DP_W2_SET_CONFIGURATION;
|
||||
break;
|
||||
}
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY:
|
||||
printf(" --- a2dp source --- received non SBC codec. not implemented\n");
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION:{
|
||||
sc.sampling_frequency = avdtp_subevent_signaling_media_codec_sbc_configuration_get_sampling_frequency(packet);
|
||||
sc.block_length = avdtp_subevent_signaling_media_codec_sbc_configuration_get_block_length(packet);
|
||||
sc.subbands = avdtp_subevent_signaling_media_codec_sbc_configuration_get_subbands(packet);
|
||||
switch (avdtp_subevent_signaling_media_codec_sbc_configuration_get_allocation_method(packet)){
|
||||
case AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS:
|
||||
sc.allocation_method = SBC_LOUDNESS;
|
||||
break;
|
||||
case AVDTP_SBC_ALLOCATION_METHOD_SNR:
|
||||
sc.allocation_method = SBC_SNR;
|
||||
break;
|
||||
}
|
||||
sc.max_bitpool_value = avdtp_subevent_signaling_media_codec_sbc_configuration_get_max_bitpool_value(packet);
|
||||
// TODO: deal with reconfigure: avdtp_subevent_signaling_media_codec_sbc_configuration_get_reconfigure(packet);
|
||||
break;
|
||||
}
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_ACCEPT:
|
||||
signal_identifier = avdtp_subevent_signaling_accept_get_signal_identifier(packet);
|
||||
status = avdtp_subevent_signaling_accept_get_status(packet);
|
||||
printf(" --- a2dp source --- Accepted %d\n", signal_identifier);
|
||||
|
||||
switch (app_state){
|
||||
case A2DP_W2_DISCOVER_SEPS:
|
||||
app_state = A2DP_W2_GET_ALL_CAPABILITIES;
|
||||
sc.active_remote_sep = avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query++);
|
||||
printf(" --- a2dp source --- Query get caps for seid %d\n", sc.active_remote_sep->seid);
|
||||
avdtp_source_get_capabilities(avdtp_cid, sc.active_remote_sep->seid);
|
||||
break;
|
||||
case A2DP_W2_GET_CAPABILITIES:
|
||||
case A2DP_W2_GET_ALL_CAPABILITIES:
|
||||
if (next_remote_sep_index_to_query < avdtp_source_remote_seps_num(avdtp_cid)){
|
||||
sc.active_remote_sep = avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query++);
|
||||
printf(" --- a2dp source --- Query get caps for seid %d\n", sc.active_remote_sep->seid);
|
||||
avdtp_source_get_capabilities(avdtp_cid, sc.active_remote_sep->seid);
|
||||
} else {
|
||||
printf(" --- a2dp source --- No more remote seps found\n");
|
||||
app_state = A2DP_IDLE;
|
||||
}
|
||||
break;
|
||||
case A2DP_W2_SET_CONFIGURATION:{
|
||||
if (!sc.local_stream_endpoint) return;
|
||||
app_state = A2DP_W2_GET_CONFIGURATION;
|
||||
avdtp_source_set_configuration(avdtp_cid, avdtp_stream_endpoint_seid(sc.local_stream_endpoint), sc.active_remote_sep->seid, sc.local_stream_endpoint->remote_configuration_bitmap, sc.local_stream_endpoint->remote_configuration);
|
||||
break;
|
||||
}
|
||||
case A2DP_W2_GET_CONFIGURATION:
|
||||
app_state = A2DP_W2_OPEN_STREAM_WITH_SEID;
|
||||
avdtp_source_get_configuration(avdtp_cid, sc.active_remote_sep->seid);
|
||||
break;
|
||||
case A2DP_W2_OPEN_STREAM_WITH_SEID:{
|
||||
app_state = A2DP_W4_OPEN_STREAM_WITH_SEID;
|
||||
btstack_sbc_encoder_init(&sc.sbc_encoder_state, SBC_MODE_STANDARD,
|
||||
sc.block_length, sc.subbands,
|
||||
sc.allocation_method, sc.sampling_frequency,
|
||||
sc.max_bitpool_value);
|
||||
avdtp_source_open_stream(avdtp_cid, avdtp_stream_endpoint_seid(sc.local_stream_endpoint), sc.active_remote_sep->seid);
|
||||
break;
|
||||
}
|
||||
case A2DP_STREAMING_OPENED:
|
||||
switch (signal_identifier){
|
||||
case AVDTP_SI_START:
|
||||
break;
|
||||
case AVDTP_SI_CLOSE:
|
||||
break;
|
||||
case AVDTP_SI_SUSPEND:
|
||||
break;
|
||||
case AVDTP_SI_ABORT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
app_state = A2DP_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case AVDTP_SUBEVENT_SIGNALING_REJECT:
|
||||
app_state = A2DP_IDLE;
|
||||
signal_identifier = avdtp_subevent_signaling_reject_get_signal_identifier(packet);
|
||||
printf(" --- a2dp source --- Rejected %d\n", signal_identifier);
|
||||
break;
|
||||
case AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT:
|
||||
app_state = A2DP_IDLE;
|
||||
signal_identifier = avdtp_subevent_signaling_general_reject_get_signal_identifier(packet);
|
||||
printf(" --- a2dp source --- Rejected %d\n", signal_identifier);
|
||||
break;
|
||||
default:
|
||||
app_state = A2DP_IDLE;
|
||||
printf(" --- a2dp source --- not implemented\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// other packet type
|
||||
break;
|
||||
}
|
||||
}
|
||||
void a2dp_source_register_packet_handler(btstack_packet_handler_t callback){
|
||||
if (callback == NULL){
|
||||
log_error("a2dp_source_register_packet_handler called with NULL callback");
|
||||
return;
|
||||
}
|
||||
avdtp_source_register_packet_handler(callback);
|
||||
avdtp_source_register_packet_handler(&packet_handler);
|
||||
a2dp_source_context.a2dp_callback = callback;
|
||||
}
|
||||
|
||||
void a2dp_source_init(void){
|
||||
avdtp_source_init(&a2dp_source_context);
|
||||
// l2cap_register_service(&packet_handler, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, LEVEL_0);
|
||||
l2cap_register_service(&packet_handler, BLUETOOTH_PROTOCOL_AVDTP, 0xffff, LEVEL_0);
|
||||
}
|
||||
|
||||
avdtp_stream_endpoint_t * a2dp_source_create_stream_endpoint(avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, uint8_t * media_codec_info, uint16_t media_codec_info_len){
|
||||
uint8_t a2dp_source_create_stream_endpoint(avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type,
|
||||
uint8_t * codec_capabilities, uint16_t codec_capabilities_len,
|
||||
uint8_t * media_codec_info, uint16_t media_codec_info_len){
|
||||
avdtp_stream_endpoint_t * local_stream_endpoint = avdtp_source_create_stream_endpoint(AVDTP_SOURCE, media_type);
|
||||
avdtp_source_register_media_transport_category(avdtp_stream_endpoint_seid(local_stream_endpoint));
|
||||
avdtp_source_register_media_codec_category(avdtp_stream_endpoint_seid(local_stream_endpoint), media_type, media_codec_type, media_codec_info, media_codec_info_len);
|
||||
return local_stream_endpoint;
|
||||
avdtp_source_register_media_codec_category(avdtp_stream_endpoint_seid(local_stream_endpoint), media_type, media_codec_type,
|
||||
codec_capabilities, codec_capabilities_len);
|
||||
local_stream_endpoint->remote_configuration.media_codec.media_codec_information = media_codec_info;
|
||||
local_stream_endpoint->remote_configuration.media_codec.media_codec_information_len = media_codec_info_len;
|
||||
|
||||
return local_stream_endpoint->sep.seid;
|
||||
}
|
||||
|
||||
void a2dp_source_connect(bd_addr_t bd_addr, uint8_t local_seid){
|
||||
sc.local_stream_endpoint = avdtp_stream_endpoint_for_seid(local_seid, &a2dp_source_context);
|
||||
if (!sc.local_stream_endpoint){
|
||||
printf(" no local_stream_endpoint for seid %d\n", local_seid);
|
||||
}
|
||||
avdtp_source_connect(bd_addr);
|
||||
|
||||
}
|
||||
|
||||
void a2dp_source_disconnect(uint16_t con_handle){
|
||||
avdtp_disconnect(con_handle, &a2dp_source_context);
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,11 @@ void a2dp_source_init(void);
|
||||
|
||||
void a2dp_source_register_packet_handler(btstack_packet_handler_t callback);
|
||||
|
||||
avdtp_stream_endpoint_t * a2dp_source_create_stream_endpoint(avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, uint8_t * media_codec_info, uint16_t media_codec_info_len);
|
||||
uint8_t a2dp_source_create_stream_endpoint(avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type,
|
||||
uint8_t * codec_capabilities, uint16_t codec_capabilities_len,
|
||||
uint8_t * codec_configuration, uint16_t codec_configuration_len);
|
||||
|
||||
void a2dp_source_connect(bd_addr_t bd_addr);
|
||||
void a2dp_source_connect(bd_addr_t bd_addr, uint8_t local_seid);
|
||||
|
||||
/**
|
||||
* @brief Start stream
|
||||
|
@ -613,6 +613,7 @@ void avdtp_discover_stream_endpoints(uint16_t avdtp_cid, avdtp_context_t * conte
|
||||
|
||||
|
||||
void avdtp_get_capabilities(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * context){
|
||||
printf("avdtp_get_capabilities: acp_seid %d\n", acp_seid);
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_get_capabilities: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
@ -628,6 +629,7 @@ void avdtp_get_capabilities(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_
|
||||
|
||||
|
||||
void avdtp_get_all_capabilities(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * context){
|
||||
printf("avdtp_get_all_capabilities: acp_seid %d\n", acp_seid);
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_get_all_capabilities: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
|
@ -416,6 +416,25 @@ typedef struct {
|
||||
uint8_t remote_seps_num;
|
||||
} avdtp_connection_t;
|
||||
|
||||
typedef enum {
|
||||
A2DP_IDLE,
|
||||
A2DP_CONNECTED,
|
||||
A2DP_W2_DISCOVER_SEPS,
|
||||
A2DP_W2_GET_CAPABILITIES,
|
||||
A2DP_W2_GET_ALL_CAPABILITIES,
|
||||
A2DP_W2_SET_CONFIGURATION,
|
||||
A2DP_W4_GET_CONFIGURATION,
|
||||
A2DP_W4_SET_CONFIGURATION,
|
||||
A2DP_W2_SUSPEND_STREAM_WITH_SEID,
|
||||
A2DP_W2_RECONFIGURE_WITH_SEID,
|
||||
A2DP_W2_OPEN_STREAM_WITH_SEID,
|
||||
A2DP_W4_OPEN_STREAM_WITH_SEID,
|
||||
A2DP_W2_START_STREAM_WITH_SEID,
|
||||
A2DP_W2_ABORT_STREAM_WITH_SEID,
|
||||
A2DP_W2_STOP_STREAM_WITH_SEID,
|
||||
A2DP_W2_GET_CONFIGURATION,
|
||||
A2DP_STREAMING_OPENED
|
||||
} a2dp_state_t;
|
||||
|
||||
typedef struct avdtp_stream_endpoint {
|
||||
btstack_linked_item_t item;
|
||||
@ -430,7 +449,7 @@ typedef struct avdtp_stream_endpoint {
|
||||
avdtp_stream_endpoint_state_t state;
|
||||
avdtp_acceptor_stream_endpoint_state_t acceptor_config_state;
|
||||
avdtp_initiator_stream_endpoint_state_t initiator_config_state;
|
||||
|
||||
a2dp_state_t a2dp_state;
|
||||
// active connection
|
||||
avdtp_connection_t * connection;
|
||||
// currently active remote seid
|
||||
|
@ -246,14 +246,14 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.configuration.media_codec.media_codec_type){
|
||||
case AVDTP_CODEC_SBC:
|
||||
avdtp_signaling_emit_media_codec_sbc_configuration(context->avdtp_callback, connection->con_handle, sep.configuration.media_codec);
|
||||
avdtp_signaling_emit_media_codec_sbc_configuration(context->avdtp_callback, connection->con_handle, connection->int_seid, connection->acp_seid, sep.configuration.media_codec);
|
||||
break;
|
||||
default:
|
||||
avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->con_handle, sep.configuration.media_codec);
|
||||
avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->con_handle, connection->int_seid, connection->acp_seid, sep.configuration.media_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->con_handle, connection->signaling_packet.signal_identifier, 0);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->con_handle, connection->int_seid, connection->signaling_packet.signal_identifier, 0);
|
||||
break;
|
||||
}
|
||||
case AVDTP_SI_RECONFIGURE:{
|
||||
@ -289,14 +289,14 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t * connection, uint8_t
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.capabilities.media_codec.media_codec_type){
|
||||
case AVDTP_CODEC_SBC:
|
||||
avdtp_signaling_emit_media_codec_sbc_reconfiguration(context->avdtp_callback, connection->con_handle, sep.capabilities.media_codec);
|
||||
avdtp_signaling_emit_media_codec_sbc_reconfiguration(context->avdtp_callback, connection->con_handle, connection->int_seid, connection->acp_seid, sep.capabilities.media_codec);
|
||||
break;
|
||||
default:
|
||||
avdtp_signaling_emit_media_codec_other_reconfiguration(context->avdtp_callback, connection->con_handle, sep.capabilities.media_codec);
|
||||
avdtp_signaling_emit_media_codec_other_reconfiguration(context->avdtp_callback, connection->con_handle, connection->int_seid, connection->acp_seid, sep.capabilities.media_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->con_handle, connection->signaling_packet.signal_identifier, 0);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->con_handle, connection->int_seid, connection->signaling_packet.signal_identifier, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -599,7 +599,7 @@ void avdtp_acceptor_stream_config_subsm_run(avdtp_connection_t * connection, avd
|
||||
printf(" ACP: NOT IMPLEMENTED\n");
|
||||
sent = 0;
|
||||
}
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->con_handle, connection->signaling_packet.signal_identifier, status);
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->con_handle, connection->int_seid, connection->signaling_packet.signal_identifier, status);
|
||||
|
||||
// check fragmentation
|
||||
if (connection->signaling_packet.packet_type != AVDTP_SINGLE_PACKET && connection->signaling_packet.packet_type != AVDTP_END_PACKET){
|
||||
|
@ -127,15 +127,15 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
|
||||
case AVDTP_SI_GET_CAPABILITIES:
|
||||
case AVDTP_SI_GET_ALL_CAPABILITIES:
|
||||
printf("AVDTP_SI_GET(_ALL)_CAPABILITIES\n");
|
||||
printf("AVDTP_SI_GET(_ALL)_CAPABILITIES int %d, acp %d\n", connection->int_seid, connection->acp_seid);
|
||||
sep.registered_service_categories = avdtp_unpack_service_capabilities(connection, &sep.capabilities, packet+offset, size-offset);
|
||||
if (get_bit16(sep.registered_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.capabilities.media_codec.media_codec_type){
|
||||
case AVDTP_CODEC_SBC:
|
||||
avdtp_signaling_emit_media_codec_sbc_capability(context->avdtp_callback, connection->l2cap_signaling_cid, sep.capabilities.media_codec);
|
||||
avdtp_signaling_emit_media_codec_sbc_capability(context->avdtp_callback, connection->l2cap_signaling_cid, connection->int_seid, connection->acp_seid, sep.capabilities.media_codec);
|
||||
break;
|
||||
default:
|
||||
avdtp_signaling_emit_media_codec_other_capability(context->avdtp_callback, connection->l2cap_signaling_cid, sep.capabilities.media_codec);
|
||||
avdtp_signaling_emit_media_codec_other_capability(context->avdtp_callback, connection->l2cap_signaling_cid, connection->int_seid, connection->acp_seid, sep.capabilities.media_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -147,10 +147,10 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
if (get_bit16(sep.configured_service_categories, AVDTP_MEDIA_CODEC)){
|
||||
switch (sep.configuration.media_codec.media_codec_type){
|
||||
case AVDTP_CODEC_SBC:
|
||||
avdtp_signaling_emit_media_codec_sbc_configuration(context->avdtp_callback, connection->l2cap_signaling_cid, sep.configuration.media_codec);
|
||||
avdtp_signaling_emit_media_codec_sbc_configuration(context->avdtp_callback, connection->l2cap_signaling_cid, connection->int_seid, connection->acp_seid, sep.configuration.media_codec);
|
||||
break;
|
||||
default:
|
||||
avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->l2cap_signaling_cid, sep.configuration.media_codec);
|
||||
avdtp_signaling_emit_media_codec_other_configuration(context->avdtp_callback, connection->l2cap_signaling_cid, connection->int_seid, connection->acp_seid, sep.configuration.media_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -233,20 +233,20 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t * connection, uint8_
|
||||
break;
|
||||
case AVDTP_RESPONSE_REJECT_MSG:
|
||||
printf(" AVDTP_RESPONSE_REJECT_MSG signal %d\n", connection->signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_reject(context->avdtp_callback, connection->l2cap_signaling_cid, connection->signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_reject(context->avdtp_callback, connection->l2cap_signaling_cid, connection->int_seid, connection->signaling_packet.signal_identifier);
|
||||
return;
|
||||
case AVDTP_GENERAL_REJECT_MSG:
|
||||
printf(" AVDTP_GENERAL_REJECT_MSG signal %d\n", connection->signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_general_reject(context->avdtp_callback, connection->l2cap_signaling_cid, connection->signaling_packet.signal_identifier);
|
||||
avdtp_signaling_emit_general_reject(context->avdtp_callback, connection->l2cap_signaling_cid, connection->int_seid, connection->signaling_packet.signal_identifier);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->l2cap_signaling_cid, 0, connection->signaling_packet.signal_identifier, status);
|
||||
connection->initiator_transaction_label++;
|
||||
connection->int_seid = 0;
|
||||
connection->acp_seid = 0;
|
||||
avdtp_signaling_emit_accept(context->avdtp_callback, connection->l2cap_signaling_cid, connection->signaling_packet.signal_identifier, status);
|
||||
// connection->int_seid = 0;
|
||||
// connection->acp_seid = 0;
|
||||
}
|
||||
|
||||
void avdtp_initiator_stream_config_subsm_run(avdtp_connection_t * connection, avdtp_context_t * context){
|
||||
|
@ -557,55 +557,60 @@ void avdtp_signaling_emit_sep(btstack_packet_handler_t callback, uint16_t avdtp_
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avdtp_cid, avdtp_signal_identifier_t identifier, uint8_t status){
|
||||
void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier, uint8_t status){
|
||||
if (!callback) return;
|
||||
uint8_t event[7];
|
||||
uint8_t event[8];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
event[pos++] = AVDTP_SUBEVENT_SIGNALING_ACCEPT;
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = int_seid;
|
||||
event[pos++] = identifier;
|
||||
event[pos++] = status;
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, avdtp_signal_identifier_t identifier){
|
||||
void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier){
|
||||
if (!callback) return;
|
||||
uint8_t event[6];
|
||||
uint8_t event[7];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
event[pos++] = AVDTP_SUBEVENT_SIGNALING_REJECT;
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = int_seid;
|
||||
event[pos++] = identifier;
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, avdtp_signal_identifier_t identifier){
|
||||
void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier){
|
||||
if (!callback) return;
|
||||
uint8_t event[6];
|
||||
uint8_t event[7];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
event[pos++] = AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT;
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = int_seid;
|
||||
event[pos++] = identifier;
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_media_codec_sbc_capability(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec){
|
||||
void avdtp_signaling_emit_media_codec_sbc_capability(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec){
|
||||
if (!callback) return;
|
||||
uint8_t event[13];
|
||||
uint8_t event[15];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
event[pos++] = AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY;
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = int_seid;
|
||||
event[pos++] = acp_seid;
|
||||
event[pos++] = media_codec.media_type;
|
||||
event[pos++] = media_codec.media_codec_information[0] >> 4;
|
||||
event[pos++] = media_codec.media_codec_information[0] & 0x0F;
|
||||
@ -617,15 +622,17 @@ void avdtp_signaling_emit_media_codec_sbc_capability(btstack_packet_handler_t ca
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_media_codec_other_capability(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec){
|
||||
void avdtp_signaling_emit_media_codec_other_capability(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec){
|
||||
if (!callback) return;
|
||||
uint8_t event[109];
|
||||
uint8_t event[111];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
event[pos++] = AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY;
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = int_seid;
|
||||
event[pos++] = acp_seid;
|
||||
event[pos++] = media_codec.media_type;
|
||||
little_endian_store_16(event, pos, media_codec.media_codec_type);
|
||||
pos += 2;
|
||||
@ -639,9 +646,9 @@ void avdtp_signaling_emit_media_codec_other_capability(btstack_packet_handler_t
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
static inline void avdtp_signaling_emit_media_codec_sbc(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec, uint8_t reconfigure){
|
||||
static inline void avdtp_signaling_emit_media_codec_sbc(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec, uint8_t reconfigure){
|
||||
if (!callback) return;
|
||||
uint8_t event[14+2];
|
||||
uint8_t event[16+2];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
@ -649,6 +656,8 @@ static inline void avdtp_signaling_emit_media_codec_sbc(btstack_packet_handler_t
|
||||
event[pos++] = AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION;
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
event[pos++] = int_seid;
|
||||
event[pos++] = acp_seid;
|
||||
event[pos++] = reconfigure;
|
||||
|
||||
uint8_t num_channels = 0;
|
||||
@ -717,25 +726,26 @@ static inline void avdtp_signaling_emit_media_codec_sbc(btstack_packet_handler_t
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_media_codec_sbc_configuration(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec){
|
||||
void avdtp_signaling_emit_media_codec_sbc_configuration(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec){
|
||||
if (!callback) return;
|
||||
avdtp_signaling_emit_media_codec_sbc(callback, avdtp_cid, media_codec, 0);
|
||||
avdtp_signaling_emit_media_codec_sbc(callback, avdtp_cid, int_seid, acp_seid, media_codec, 0);
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_media_codec_sbc_reconfiguration(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec){
|
||||
void avdtp_signaling_emit_media_codec_sbc_reconfiguration(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec){
|
||||
if (!callback) return;
|
||||
avdtp_signaling_emit_media_codec_sbc(callback, avdtp_cid, media_codec, 1);
|
||||
avdtp_signaling_emit_media_codec_sbc(callback, avdtp_cid, int_seid, acp_seid, media_codec, 1);
|
||||
}
|
||||
|
||||
static inline void avdtp_signaling_emit_media_codec_other(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec, uint8_t reconfigure){
|
||||
uint8_t event[110];
|
||||
static inline void avdtp_signaling_emit_media_codec_other(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec, uint8_t reconfigure){
|
||||
uint8_t event[112];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_AVDTP_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
event[pos++] = AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CONFIGURATION;
|
||||
little_endian_store_16(event, pos, avdtp_cid);
|
||||
pos += 2;
|
||||
|
||||
event[pos++] = int_seid;
|
||||
event[pos++] = acp_seid;
|
||||
event[pos++] = reconfigure;
|
||||
|
||||
event[pos++] = media_codec.media_type;
|
||||
@ -752,14 +762,14 @@ static inline void avdtp_signaling_emit_media_codec_other(btstack_packet_handler
|
||||
(*callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_media_codec_other_configuration(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec){
|
||||
void avdtp_signaling_emit_media_codec_other_configuration(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec){
|
||||
if (!callback) return;
|
||||
avdtp_signaling_emit_media_codec_other(callback, avdtp_cid, media_codec, 0);
|
||||
avdtp_signaling_emit_media_codec_other(callback, avdtp_cid, int_seid, acp_seid, media_codec, 0);
|
||||
}
|
||||
|
||||
void avdtp_signaling_emit_media_codec_other_reconfiguration(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec){
|
||||
void avdtp_signaling_emit_media_codec_other_reconfiguration(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec){
|
||||
if (!callback) return;
|
||||
avdtp_signaling_emit_media_codec_other(callback, avdtp_cid, media_codec, 1);
|
||||
avdtp_signaling_emit_media_codec_other(callback, avdtp_cid, int_seid, acp_seid, media_codec, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,17 +74,17 @@ int avdtp_signaling_create_fragment(uint16_t cid, avdtp_signaling_packet_t * sig
|
||||
void avdtp_signaling_emit_connection_established(btstack_packet_handler_t callback, uint16_t avdtp_cid, bd_addr_t addr, uint8_t status);
|
||||
void avdtp_streaming_emit_connection_established(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t status);
|
||||
void avdtp_signaling_emit_sep(btstack_packet_handler_t callback, uint16_t avdtp_cid, avdtp_sep_t sep);
|
||||
void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avdtp_cid, avdtp_signal_identifier_t identifier, uint8_t status);
|
||||
void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, avdtp_signal_identifier_t identifier);
|
||||
void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, avdtp_signal_identifier_t identifier);
|
||||
void avdtp_streaming_emit_can_send_media_packet_now(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t seid, uint16_t sequence_number);
|
||||
void avdtp_signaling_emit_accept(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t seid, avdtp_signal_identifier_t identifier, uint8_t status);
|
||||
void avdtp_signaling_emit_general_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier);
|
||||
void avdtp_signaling_emit_reject(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, avdtp_signal_identifier_t identifier);
|
||||
void avdtp_streaming_emit_can_send_media_packet_now(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint16_t sequence_number);
|
||||
|
||||
void avdtp_signaling_emit_media_codec_sbc_capability(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_other_capability(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_sbc_configuration(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_other_configuration(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_sbc_reconfiguration(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_other_reconfiguration(btstack_packet_handler_t callback, uint16_t avdtp_cid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_sbc_capability(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_other_capability(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_sbc_configuration(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_other_configuration(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_sbc_reconfiguration(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec);
|
||||
void avdtp_signaling_emit_media_codec_other_reconfiguration(btstack_packet_handler_t callback, uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, adtvp_media_codec_capabilities_t media_codec);
|
||||
|
||||
void avdtp_request_can_send_now_acceptor(avdtp_connection_t * connection, uint16_t l2cap_cid);
|
||||
void avdtp_request_can_send_now_initiator(avdtp_connection_t * connection, uint16_t l2cap_cid);
|
||||
|
@ -93,6 +93,10 @@ typedef struct {
|
||||
int min_bitpool_value;
|
||||
int max_bitpool_value;
|
||||
} avdtp_stream_endpoint_context_t;
|
||||
static avdtp_stream_endpoint_context_t sc;
|
||||
|
||||
static uint8_t int_seid;
|
||||
// static uint8_t acp_seid;
|
||||
|
||||
typedef struct {
|
||||
int16_t source[TABLE_SIZE_441HZ];
|
||||
@ -117,13 +121,12 @@ static uint16_t avdtp_cid = 0;
|
||||
static uint8_t sdp_avdtp_source_service_buffer[150];
|
||||
static avdtp_stream_endpoint_t * local_stream_endpoint;
|
||||
|
||||
static int next_remote_sep_index_to_query = -1;
|
||||
static avdtp_sep_t * active_remote_sep = NULL;
|
||||
|
||||
static uint8_t media_sbc_codec_configuration[4];
|
||||
static uint8_t sbc_samples_storage[44100*4];
|
||||
|
||||
static avdtp_stream_endpoint_context_t sc;
|
||||
|
||||
static paTestData sin_data;
|
||||
|
||||
static int hxcmod_initialized = 0;
|
||||
@ -136,27 +139,8 @@ typedef enum {
|
||||
STREAM_MOD
|
||||
} stream_data_source_t;
|
||||
|
||||
typedef enum {
|
||||
AVDTP_APPLICATION_IDLE,
|
||||
AVDTP_APPLICATION_CONNECTED,
|
||||
AVDTP_APPLICATION_W2_DISCOVER_SEPS,
|
||||
AVDTP_APPLICATION_W2_GET_CAPABILITIES,
|
||||
AVDTP_APPLICATION_W2_GET_ALL_CAPABILITIES,
|
||||
AVDTP_APPLICATION_W2_SET_CONFIGURATION,
|
||||
AVDTP_APPLICATION_W4_GET_CONFIGURATION,
|
||||
AVDTP_APPLICATION_W4_SET_CONFIGURATION,
|
||||
AVDTP_APPLICATION_W2_SUSPEND_STREAM_WITH_SEID,
|
||||
AVDTP_APPLICATION_W2_RECONFIGURE_WITH_SEID,
|
||||
AVDTP_APPLICATION_W2_OPEN_STREAM_WITH_SEID,
|
||||
AVDTP_APPLICATION_W4_OPEN_STREAM_WITH_SEID,
|
||||
AVDTP_APPLICATION_W2_START_STREAM_WITH_SEID,
|
||||
AVDTP_APPLICATION_W2_ABORT_STREAM_WITH_SEID,
|
||||
AVDTP_APPLICATION_W2_STOP_STREAM_WITH_SEID,
|
||||
AVDTP_APPLICATION_W2_GET_CONFIGURATION,
|
||||
AVDTP_APPLICATION_STREAMING_OPENED
|
||||
} avdtp_application_state_t;
|
||||
|
||||
avdtp_application_state_t app_state = AVDTP_APPLICATION_IDLE;
|
||||
a2dp_state_t app_state = A2DP_IDLE;
|
||||
stream_data_source_t data_source = STREAM_SINE;
|
||||
|
||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
@ -166,9 +150,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
UNUSED(size);
|
||||
|
||||
bd_addr_t event_addr;
|
||||
uint8_t signal_identifier;
|
||||
uint8_t status;
|
||||
avdtp_sep_t sep;
|
||||
|
||||
switch (packet_type) {
|
||||
|
||||
@ -182,138 +163,10 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
break;
|
||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||
// connection closed -> quit test app
|
||||
printf("\n --- avdtp source --- HCI_EVENT_DISCONNECTION_COMPLETE ---\n");
|
||||
printf("\n --- application --- HCI_EVENT_DISCONNECTION_COMPLETE ---\n");
|
||||
break;
|
||||
case HCI_EVENT_AVDTP_META:
|
||||
switch (packet[2]){
|
||||
case AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED:
|
||||
avdtp_cid = avdtp_subevent_signaling_connection_established_get_avdtp_cid(packet);
|
||||
status = avdtp_subevent_signaling_connection_established_get_status(packet);
|
||||
if (status != 0){
|
||||
printf(" --- avdtp source --- AVDTP_SUBEVENT_SIGNALING_CONNECTION could not be established, status %d ---\n", status);
|
||||
break;
|
||||
}
|
||||
active_remote_sep = NULL;
|
||||
next_remote_sep_index_to_query = -1;
|
||||
app_state = AVDTP_APPLICATION_CONNECTED;
|
||||
printf(" --- avdtp source --- AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED, avdtp cid 0x%02x ---\n", avdtp_cid);
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED:
|
||||
status = avdtp_subevent_streaming_connection_established_get_status(packet);
|
||||
if (status != 0){
|
||||
printf(" --- avdtp source --- AVDTP_SUBEVENT_STREAMING_CONNECTION could not be established, status %d ---\n", status);
|
||||
break;
|
||||
}
|
||||
app_state = AVDTP_APPLICATION_STREAMING_OPENED;
|
||||
printf(" --- avdtp source --- AVDTP_SUBEVENT_STREAMING_CONNECTION_ESTABLISHED ---\n");
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_SEP_FOUND:
|
||||
if (app_state != AVDTP_APPLICATION_W2_DISCOVER_SEPS) return;
|
||||
sep.seid = avdtp_subevent_signaling_sep_found_get_seid(packet);
|
||||
sep.in_use = avdtp_subevent_signaling_sep_found_get_in_use(packet);
|
||||
sep.media_type = avdtp_subevent_signaling_sep_found_get_media_type(packet);
|
||||
sep.type = avdtp_subevent_signaling_sep_found_get_sep_type(packet);
|
||||
printf(" --- avdtp source --- Found sep: seid %u, in_use %d, media type %d, sep type %d (1-SNK)\n", sep.seid, sep.in_use, sep.media_type, sep.type);
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY:{
|
||||
avdtp_initialize_sbc_configuration_storage(local_stream_endpoint, media_sbc_codec_configuration, sizeof(media_sbc_codec_configuration), packet, size);
|
||||
active_remote_sep = avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query);
|
||||
app_state = AVDTP_APPLICATION_W2_SET_CONFIGURATION;
|
||||
break;
|
||||
}
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER_CAPABILITY:
|
||||
printf(" --- avdtp source --- received non SBC codec. not implemented\n");
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CONFIGURATION:{
|
||||
sc.sampling_frequency = avdtp_subevent_signaling_media_codec_sbc_configuration_get_sampling_frequency(packet);
|
||||
sc.block_length = avdtp_subevent_signaling_media_codec_sbc_configuration_get_block_length(packet);
|
||||
sc.subbands = avdtp_subevent_signaling_media_codec_sbc_configuration_get_subbands(packet);
|
||||
switch (avdtp_subevent_signaling_media_codec_sbc_configuration_get_allocation_method(packet)){
|
||||
case AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS:
|
||||
sc.allocation_method = SBC_LOUDNESS;
|
||||
break;
|
||||
case AVDTP_SBC_ALLOCATION_METHOD_SNR:
|
||||
sc.allocation_method = SBC_SNR;
|
||||
break;
|
||||
}
|
||||
sc.max_bitpool_value = avdtp_subevent_signaling_media_codec_sbc_configuration_get_max_bitpool_value(packet);
|
||||
// TODO: deal with reconfigure: avdtp_subevent_signaling_media_codec_sbc_configuration_get_reconfigure(packet);
|
||||
break;
|
||||
}
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_ACCEPT:
|
||||
signal_identifier = avdtp_subevent_signaling_accept_get_signal_identifier(packet);
|
||||
status = avdtp_subevent_signaling_accept_get_status(packet);
|
||||
printf(" --- avdtp source --- Accepted %d\n", signal_identifier);
|
||||
|
||||
switch (app_state){
|
||||
case AVDTP_APPLICATION_W2_DISCOVER_SEPS:
|
||||
app_state = AVDTP_APPLICATION_W2_GET_ALL_CAPABILITIES;
|
||||
next_remote_sep_index_to_query = 0;
|
||||
printf(" --- avdtp source --- Query get caps for seid %d\n", avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query)->seid);
|
||||
avdtp_source_get_capabilities(avdtp_cid, avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query)->seid);
|
||||
break;
|
||||
case AVDTP_APPLICATION_W2_GET_CAPABILITIES:
|
||||
case AVDTP_APPLICATION_W2_GET_ALL_CAPABILITIES:
|
||||
if (next_remote_sep_index_to_query < avdtp_source_remote_seps_num(avdtp_cid) - 1){
|
||||
next_remote_sep_index_to_query++;
|
||||
printf(" --- avdtp source --- Query get caps for seid %d\n", avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query)->seid);
|
||||
avdtp_source_get_capabilities(avdtp_cid, avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query)->seid);
|
||||
} else {
|
||||
printf(" --- avdtp source --- Cannot query get caps, index %d\n", next_remote_sep_index_to_query);
|
||||
app_state = AVDTP_APPLICATION_IDLE;
|
||||
}
|
||||
break;
|
||||
case AVDTP_APPLICATION_W2_SET_CONFIGURATION:
|
||||
app_state = AVDTP_APPLICATION_W2_GET_CONFIGURATION;
|
||||
avdtp_source_set_configuration(avdtp_cid, avdtp_stream_endpoint_seid(local_stream_endpoint), active_remote_sep->seid, local_stream_endpoint->remote_configuration_bitmap, local_stream_endpoint->remote_configuration);
|
||||
break;
|
||||
case AVDTP_APPLICATION_W2_GET_CONFIGURATION:
|
||||
app_state = AVDTP_APPLICATION_W2_OPEN_STREAM_WITH_SEID;
|
||||
avdtp_source_get_configuration(avdtp_cid, active_remote_sep->seid);
|
||||
break;
|
||||
case AVDTP_APPLICATION_W2_OPEN_STREAM_WITH_SEID:
|
||||
app_state = AVDTP_APPLICATION_W4_OPEN_STREAM_WITH_SEID;
|
||||
btstack_sbc_encoder_init(&sc.sbc_encoder_state, SBC_MODE_STANDARD,
|
||||
sc.block_length, sc.subbands,
|
||||
sc.allocation_method, sc.sampling_frequency,
|
||||
sc.max_bitpool_value);
|
||||
avdtp_source_open_stream(avdtp_cid, avdtp_stream_endpoint_seid(local_stream_endpoint), active_remote_sep->seid);
|
||||
break;
|
||||
case AVDTP_APPLICATION_STREAMING_OPENED:
|
||||
switch (signal_identifier){
|
||||
case AVDTP_SI_START:
|
||||
break;
|
||||
case AVDTP_SI_CLOSE:
|
||||
break;
|
||||
case AVDTP_SI_SUSPEND:
|
||||
break;
|
||||
case AVDTP_SI_ABORT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
app_state = AVDTP_APPLICATION_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case AVDTP_SUBEVENT_SIGNALING_REJECT:
|
||||
app_state = AVDTP_APPLICATION_IDLE;
|
||||
signal_identifier = avdtp_subevent_signaling_reject_get_signal_identifier(packet);
|
||||
printf(" --- avdtp source --- Rejected %d\n", signal_identifier);
|
||||
break;
|
||||
case AVDTP_SUBEVENT_SIGNALING_GENERAL_REJECT:
|
||||
app_state = AVDTP_APPLICATION_IDLE;
|
||||
signal_identifier = avdtp_subevent_signaling_general_reject_get_signal_identifier(packet);
|
||||
printf(" --- avdtp source --- Rejected %d\n", signal_identifier);
|
||||
break;
|
||||
case AVDTP_SUBEVENT_STREAMING_CAN_SEND_MEDIA_PACKET_NOW: {
|
||||
avdtp_source_stream_send_media_payload(local_stream_endpoint->l2cap_media_cid, &sc.sbc_ring_buffer, 0);
|
||||
if (btstack_ring_buffer_bytes_available(&sc.sbc_ring_buffer)){
|
||||
@ -322,8 +175,8 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
break;
|
||||
}
|
||||
default:
|
||||
app_state = AVDTP_APPLICATION_IDLE;
|
||||
printf(" --- avdtp source --- not implemented\n");
|
||||
app_state = A2DP_IDLE;
|
||||
printf(" --- application --- not implemented\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -493,68 +346,23 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
switch (cmd){
|
||||
case 'c':
|
||||
printf("Creating L2CAP Connection to %s, PSM_AVDTP\n", bd_addr_to_str(remote));
|
||||
avdtp_source_connect(remote);
|
||||
a2dp_source_connect(remote, int_seid);
|
||||
break;
|
||||
case 'C':
|
||||
printf("Disconnect not implemented\n");
|
||||
avdtp_source_disconnect(avdtp_cid);
|
||||
break;
|
||||
case 'd':
|
||||
app_state = AVDTP_APPLICATION_W2_DISCOVER_SEPS;
|
||||
printf("Discover stream endpoints, cid 0x%02x \n", avdtp_cid);
|
||||
avdtp_source_discover_stream_endpoints(avdtp_cid);
|
||||
break;
|
||||
default:
|
||||
if (!active_remote_sep){
|
||||
show_usage();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!active_remote_sep) return;
|
||||
switch (cmd){
|
||||
case 'f':
|
||||
app_state = AVDTP_APPLICATION_W2_GET_CONFIGURATION;
|
||||
avdtp_source_get_configuration(avdtp_cid, active_remote_sep->seid);
|
||||
break;
|
||||
case 'm':
|
||||
app_state = AVDTP_APPLICATION_W2_START_STREAM_WITH_SEID;
|
||||
avdtp_source_start_stream(avdtp_cid, avdtp_stream_endpoint_seid(local_stream_endpoint), active_remote_sep->seid);
|
||||
break;
|
||||
case 'A':
|
||||
app_state = AVDTP_APPLICATION_W2_ABORT_STREAM_WITH_SEID;
|
||||
avdtp_source_abort_stream(avdtp_cid, avdtp_stream_endpoint_seid(local_stream_endpoint), active_remote_sep->seid);
|
||||
break;
|
||||
case 'S':
|
||||
app_state = AVDTP_APPLICATION_W2_STOP_STREAM_WITH_SEID;
|
||||
avdtp_source_stop_stream(avdtp_cid, avdtp_stream_endpoint_seid(local_stream_endpoint), active_remote_sep->seid);
|
||||
break;
|
||||
case 'P':
|
||||
app_state = AVDTP_APPLICATION_W2_SUSPEND_STREAM_WITH_SEID;
|
||||
avdtp_source_suspend(avdtp_cid, avdtp_stream_endpoint_seid(local_stream_endpoint), active_remote_sep->seid);
|
||||
a2dp_source_disconnect(avdtp_cid);
|
||||
break;
|
||||
case 'x':
|
||||
printf("Start streaming sine.\n");
|
||||
data_source = STREAM_SINE;
|
||||
avdtp_source_stream_data_start();
|
||||
break;
|
||||
case 'z':
|
||||
printf("Start streaming '%s'.\n", mod_name);
|
||||
data_source = STREAM_MOD;
|
||||
// a2dp_source_start_stream(avdtp_cid, int_seid, acp_seid);
|
||||
avdtp_source_stream_data_start();
|
||||
break;
|
||||
case 'X':
|
||||
printf("Stop streaming.\n");
|
||||
// a2dp_source_stop_stream(avdtp_cid, int_seid, acp_seid);
|
||||
avdtp_source_stream_data_stop();
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
case '\r':
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -573,7 +381,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
a2dp_source_register_packet_handler(&packet_handler);
|
||||
|
||||
//#ifndef SMG_BI
|
||||
local_stream_endpoint = a2dp_source_create_stream_endpoint(AVDTP_AUDIO, AVDTP_CODEC_SBC, media_sbc_codec_capabilities, sizeof(media_sbc_codec_capabilities));
|
||||
int_seid = a2dp_source_create_stream_endpoint(AVDTP_AUDIO, AVDTP_CODEC_SBC, media_sbc_codec_capabilities, sizeof(media_sbc_codec_capabilities), media_sbc_codec_configuration, sizeof(media_sbc_codec_configuration));
|
||||
|
||||
// Initialize SDP
|
||||
sdp_init();
|
||||
|
Loading…
x
Reference in New Issue
Block a user