mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-25 18:35:17 +00:00
move choose config to avdtp
This commit is contained in:
parent
f9bca1f39e
commit
78d08d098e
@ -116,7 +116,7 @@ void avdtp_register_header_compression_category(avdtp_stream_endpoint_t * stream
|
||||
stream_endpoint->sep.capabilities.header_compression.recovery = recovery;
|
||||
}
|
||||
|
||||
void avdtp_register_media_codec_category(avdtp_stream_endpoint_t * stream_endpoint, avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, const uint8_t * media_codec_info, uint16_t media_codec_info_len){
|
||||
void avdtp_register_media_codec_category(avdtp_stream_endpoint_t * 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){
|
||||
if (!stream_endpoint){
|
||||
log_error("avdtp_register_media_transport_category: stream endpoint with given seid is not registered");
|
||||
return;
|
||||
@ -680,7 +680,7 @@ void avdtp_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_s
|
||||
avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid);
|
||||
}
|
||||
|
||||
void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context){
|
||||
void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_reconfigure: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
@ -689,10 +689,18 @@ void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t acp_seid, uint16_t configured
|
||||
//TODO: if opened only app capabilities, enable reconfigure for not opened
|
||||
if (connection->state < AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
if (connection->initiator_connection_state != AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE) return;
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(acp_seid, context);
|
||||
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
log_error("avdtp_reconfigure: no initiator stream endpoint for seid %d\n", int_seid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stream_endpoint->remote_sep_index == 0xFF){
|
||||
log_error("avdtp_reconfigure: no associated remote sep\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stream_endpoint) return;
|
||||
if (stream_endpoint->remote_sep_index == 0xFF) return;
|
||||
connection->initiator_transaction_label++;
|
||||
connection->acp_seid = acp_seid;
|
||||
connection->int_seid = stream_endpoint->sep.seid;
|
||||
@ -702,7 +710,7 @@ void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t acp_seid, uint16_t configured
|
||||
avdtp_request_can_send_now_initiator(connection, connection->l2cap_signaling_cid);
|
||||
}
|
||||
|
||||
void avdtp_suspend(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * context){
|
||||
void avdtp_suspend(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, avdtp_context_t * context){
|
||||
avdtp_connection_t * connection = avdtp_connection_for_l2cap_signaling_cid(avdtp_cid, context);
|
||||
if (!connection){
|
||||
printf("avdtp_suspend: no connection for signaling cid 0x%02x found\n", avdtp_cid);
|
||||
@ -710,9 +718,16 @@ void avdtp_suspend(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * conte
|
||||
}
|
||||
if (connection->state != AVDTP_SIGNALING_CONNECTION_OPENED) return;
|
||||
if (connection->initiator_connection_state != AVDTP_SIGNALING_CONNECTION_INITIATOR_IDLE) return;
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_associated_with_acp_seid(acp_seid, context);
|
||||
if (!stream_endpoint) return;
|
||||
if (stream_endpoint->remote_sep_index == 0xFF) return;
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(int_seid, context);
|
||||
if (!stream_endpoint) {
|
||||
log_error("avdtp_reconfigure: no initiator stream endpoint for seid %d\n", int_seid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stream_endpoint->remote_sep_index == 0xFF){
|
||||
log_error("avdtp_reconfigure: no associated remote sep\n");
|
||||
return;
|
||||
}
|
||||
connection->initiator_transaction_label++;
|
||||
connection->acp_seid = acp_seid;
|
||||
connection->int_seid = stream_endpoint->sep.seid;
|
||||
@ -736,4 +751,102 @@ avdtp_sep_t * avdtp_remote_sep(uint16_t avdtp_cid, uint8_t index, avdtp_context_
|
||||
return NULL;
|
||||
}
|
||||
return &connection->remote_seps[index];
|
||||
}
|
||||
|
||||
void avdtp_store_sbc_configuration(uint8_t * config_storage, uint16_t size, uint8_t sampling_frequency, uint8_t channel_mode, uint8_t block_length, uint8_t subbands, uint8_t allocation_method, uint8_t max_bitpool_value, uint8_t min_bitpool_value){
|
||||
if (size < 4) {
|
||||
printf("storage must have 4 bytes\n");
|
||||
return;
|
||||
}
|
||||
config_storage[0] = (sampling_frequency << 4) | channel_mode;
|
||||
config_storage[1] = (block_length << 4) | (subbands << 2) | allocation_method;
|
||||
config_storage[2] = min_bitpool_value;
|
||||
config_storage[3] = max_bitpool_value;
|
||||
}
|
||||
|
||||
uint8_t avdtp_choose_sbc_channel_mode(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_channel_mode_bitmap){
|
||||
uint8_t * media_codec = stream_endpoint->sep.capabilities.media_codec.media_codec_information;
|
||||
uint8_t channel_mode_bitmap = (media_codec[0] & 0x0F) & remote_channel_mode_bitmap;
|
||||
|
||||
uint8_t channel_mode = AVDTP_SBC_STEREO;
|
||||
if (channel_mode_bitmap & AVDTP_SBC_JOINT_STEREO){
|
||||
channel_mode = AVDTP_SBC_JOINT_STEREO;
|
||||
} else if (channel_mode_bitmap & AVDTP_SBC_STEREO){
|
||||
channel_mode = AVDTP_SBC_STEREO;
|
||||
} else if (channel_mode_bitmap & AVDTP_SBC_DUAL_CHANNEL){
|
||||
channel_mode = AVDTP_SBC_DUAL_CHANNEL;
|
||||
} else if (channel_mode_bitmap & AVDTP_SBC_MONO){
|
||||
channel_mode = AVDTP_SBC_MONO;
|
||||
}
|
||||
return channel_mode;
|
||||
}
|
||||
|
||||
uint8_t avdtp_choose_sbc_allocation_method(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_allocation_method_bitmap){
|
||||
uint8_t * media_codec = stream_endpoint->sep.capabilities.media_codec.media_codec_information;
|
||||
uint8_t allocation_method_bitmap = (media_codec[1] & 0x03) & remote_allocation_method_bitmap;
|
||||
|
||||
uint8_t allocation_method = AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS;
|
||||
if (allocation_method_bitmap & AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS){
|
||||
allocation_method = AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS;
|
||||
} else if (allocation_method_bitmap & AVDTP_SBC_ALLOCATION_METHOD_SNR){
|
||||
allocation_method = AVDTP_SBC_ALLOCATION_METHOD_SNR;
|
||||
}
|
||||
return allocation_method;
|
||||
}
|
||||
|
||||
uint8_t avdtp_choose_sbc_subbands(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_subbands_bitmap){
|
||||
uint8_t * media_codec = stream_endpoint->sep.capabilities.media_codec.media_codec_information;
|
||||
uint8_t subbands_bitmap = ((media_codec[1] >> 2) & 0x03) & remote_subbands_bitmap;
|
||||
|
||||
uint8_t subbands = AVDTP_SBC_SUBBANDS_8;
|
||||
if (subbands_bitmap & AVDTP_SBC_SUBBANDS_8){
|
||||
subbands = AVDTP_SBC_SUBBANDS_8;
|
||||
} else if (subbands_bitmap & AVDTP_SBC_SUBBANDS_4){
|
||||
subbands = AVDTP_SBC_SUBBANDS_4;
|
||||
}
|
||||
return subbands;
|
||||
}
|
||||
|
||||
uint8_t avdtp_choose_sbc_block_length(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_block_length_bitmap){
|
||||
uint8_t * media_codec = stream_endpoint->sep.capabilities.media_codec.media_codec_information;
|
||||
uint8_t block_length_bitmap = (media_codec[1] >> 4) & remote_block_length_bitmap;
|
||||
|
||||
uint8_t block_length = AVDTP_SBC_BLOCK_LENGTH_16;
|
||||
if (block_length_bitmap & AVDTP_SBC_BLOCK_LENGTH_16){
|
||||
block_length = AVDTP_SBC_BLOCK_LENGTH_16;
|
||||
} else if (block_length_bitmap & AVDTP_SBC_BLOCK_LENGTH_12){
|
||||
block_length = AVDTP_SBC_BLOCK_LENGTH_12;
|
||||
} else if (block_length_bitmap & AVDTP_SBC_BLOCK_LENGTH_8){
|
||||
block_length = AVDTP_SBC_BLOCK_LENGTH_8;
|
||||
} else if (block_length_bitmap & AVDTP_SBC_BLOCK_LENGTH_4){
|
||||
block_length = AVDTP_SBC_BLOCK_LENGTH_4;
|
||||
}
|
||||
return block_length;
|
||||
}
|
||||
|
||||
uint8_t avdtp_choose_sbc_sampling_frequency(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_sampling_frequency_bitmap){
|
||||
uint8_t * media_codec = stream_endpoint->sep.capabilities.media_codec.media_codec_information;
|
||||
uint8_t sampling_frequency_bitmap = (media_codec[0] >> 4) & remote_sampling_frequency_bitmap;
|
||||
|
||||
uint8_t sampling_frequency = AVDTP_SBC_44100;
|
||||
if (sampling_frequency_bitmap & AVDTP_SBC_48000){
|
||||
sampling_frequency = AVDTP_SBC_48000;
|
||||
} else if (sampling_frequency_bitmap & AVDTP_SBC_44100){
|
||||
sampling_frequency = AVDTP_SBC_44100;
|
||||
} else if (sampling_frequency_bitmap & AVDTP_SBC_32000){
|
||||
sampling_frequency = AVDTP_SBC_32000;
|
||||
} else if (sampling_frequency_bitmap & AVDTP_SBC_16000){
|
||||
sampling_frequency = AVDTP_SBC_16000;
|
||||
}
|
||||
return sampling_frequency;
|
||||
}
|
||||
|
||||
uint8_t avdtp_choose_sbc_max_bitpool_value(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_max_bitpool_value){
|
||||
uint8_t * media_codec = stream_endpoint->sep.capabilities.media_codec.media_codec_information;
|
||||
return btstack_min(media_codec[3], remote_max_bitpool_value);
|
||||
}
|
||||
|
||||
uint8_t avdtp_choose_sbc_min_bitpool_value(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_min_bitpool_value){
|
||||
uint8_t * media_codec = stream_endpoint->sep.capabilities.media_codec.media_codec_information;
|
||||
return btstack_max(media_codec[2], remote_min_bitpool_value);
|
||||
}
|
@ -185,7 +185,7 @@ typedef struct {
|
||||
avdtp_media_type_t media_type;
|
||||
avdtp_media_codec_type_t media_codec_type;
|
||||
uint16_t media_codec_information_len;
|
||||
const uint8_t * media_codec_information;
|
||||
uint8_t * media_codec_information;
|
||||
} adtvp_media_codec_capabilities_t;
|
||||
|
||||
|
||||
@ -469,7 +469,7 @@ void avdtp_register_delay_reporting_category(avdtp_stream_endpoint_t * stream_en
|
||||
void avdtp_register_recovery_category(avdtp_stream_endpoint_t * stream_endpoint, uint8_t maximum_recovery_window_size, uint8_t maximum_number_media_packets);
|
||||
void avdtp_register_content_protection_category(avdtp_stream_endpoint_t * stream_endpoint, uint16_t cp_type, const uint8_t * cp_type_value, uint8_t cp_type_value_len);
|
||||
void avdtp_register_header_compression_category(avdtp_stream_endpoint_t * stream_endpoint, uint8_t back_ch, uint8_t media, uint8_t recovery);
|
||||
void avdtp_register_media_codec_category(avdtp_stream_endpoint_t * stream_endpoint, avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, const uint8_t * media_codec_info, uint16_t media_codec_info_len);
|
||||
void avdtp_register_media_codec_category(avdtp_stream_endpoint_t * 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);
|
||||
void avdtp_register_multiplexing_category(avdtp_stream_endpoint_t * stream_endpoint, uint8_t fragmentation);
|
||||
void avdtp_handle_can_send_now(avdtp_connection_t * connection, uint16_t l2cap_cid, avdtp_context_t * context);
|
||||
|
||||
@ -488,11 +488,21 @@ 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);
|
||||
void avdtp_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * context);
|
||||
void avdtp_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context);
|
||||
void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context);
|
||||
void avdtp_suspend(uint16_t avdtp_cid, uint8_t acp_seid, avdtp_context_t * context);
|
||||
void avdtp_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context);
|
||||
void avdtp_suspend(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, avdtp_context_t * context);
|
||||
uint8_t avdtp_remote_seps_num(uint16_t avdtp_cid, avdtp_context_t * context);
|
||||
avdtp_sep_t * avdtp_remote_sep(uint16_t avdtp_cid, uint8_t index, avdtp_context_t * context);
|
||||
|
||||
void avdtp_store_sbc_configuration(uint8_t * config_storage, uint16_t size, uint8_t sampling_frequency, uint8_t channel_mode, uint8_t block_length, uint8_t subbands, uint8_t allocation_method, uint8_t max_bitpool_value, uint8_t min_bitpool_value);
|
||||
uint8_t avdtp_choose_sbc_channel_mode(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_channel_mode_bitmap);
|
||||
uint8_t avdtp_choose_sbc_allocation_method(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_allocation_method_bitmap);
|
||||
|
||||
uint8_t avdtp_choose_sbc_subbands(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_subbands_bitmap);
|
||||
uint8_t avdtp_choose_sbc_block_length(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_block_length_bitmap);
|
||||
uint8_t avdtp_choose_sbc_sampling_frequency(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_sampling_frequency_bitmap);
|
||||
uint8_t avdtp_choose_sbc_max_bitpool_value(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_max_bitpool_value);
|
||||
uint8_t avdtp_choose_sbc_min_bitpool_value(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_min_bitpool_value);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -170,7 +170,7 @@ void avdtp_sink_register_header_compression_category(uint8_t seid, uint8_t back_
|
||||
avdtp_register_header_compression_category(stream_endpoint, back_ch, media, recovery);
|
||||
}
|
||||
|
||||
void avdtp_sink_register_media_codec_category(uint8_t seid, avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, const uint8_t * media_codec_info, uint16_t media_codec_info_len){
|
||||
void avdtp_sink_register_media_codec_category(uint8_t seid, 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){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(seid, &avdtp_sink_context);
|
||||
avdtp_register_media_codec_category(stream_endpoint, media_type, media_codec_type, media_codec_info, media_codec_info_len);
|
||||
}
|
||||
@ -273,10 +273,10 @@ void avdtp_sink_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t
|
||||
avdtp_set_configuration(avdtp_cid, int_seid, acp_seid, configured_services_bitmap, configuration, &avdtp_sink_context);
|
||||
}
|
||||
|
||||
void avdtp_sink_reconfigure(uint16_t avdtp_cid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration){
|
||||
avdtp_reconfigure(avdtp_cid, acp_seid, configured_services_bitmap, configuration, &avdtp_sink_context);
|
||||
void avdtp_sink_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration){
|
||||
avdtp_reconfigure(avdtp_cid, int_seid, acp_seid, configured_services_bitmap, configuration, &avdtp_sink_context);
|
||||
}
|
||||
|
||||
void avdtp_sink_suspend(uint16_t avdtp_cid, uint8_t acp_seid){
|
||||
avdtp_suspend(avdtp_cid, acp_seid, &avdtp_sink_context);
|
||||
void avdtp_sink_suspend(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid){
|
||||
avdtp_suspend(avdtp_cid, int_seid, acp_seid, &avdtp_sink_context);
|
||||
}
|
@ -80,7 +80,7 @@ void avdtp_sink_register_recovery_category(uint8_t seid, uint8_t maximum_recover
|
||||
void avdtp_sink_register_header_compression_category(uint8_t seid, uint8_t back_ch, uint8_t media, uint8_t recovery);
|
||||
void avdtp_sink_register_multiplexing_category(uint8_t seid, uint8_t fragmentation);
|
||||
|
||||
void avdtp_sink_register_media_codec_category(uint8_t seid, avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, const uint8_t * media_codec_info, uint16_t media_codec_info_len);
|
||||
void avdtp_sink_register_media_codec_category(uint8_t seid, 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);
|
||||
void avdtp_sink_register_content_protection_category(uint8_t seid, uint16_t cp_type, const uint8_t * cp_type_value, uint8_t cp_type_value_len);
|
||||
|
||||
/**
|
||||
@ -131,7 +131,7 @@ void avdtp_sink_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_t
|
||||
* @param avdtp_cid
|
||||
* @param seid
|
||||
*/
|
||||
void avdtp_sink_reconfigure(uint16_t avdtp_cid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
|
||||
void avdtp_sink_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
|
||||
|
||||
/**
|
||||
* @brief Get configuration
|
||||
@ -144,7 +144,7 @@ void avdtp_sink_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid);
|
||||
* @param avdtp_cid
|
||||
* @param seid
|
||||
*/
|
||||
void avdtp_sink_suspend(uint16_t avdtp_cid, uint8_t acp_seid);
|
||||
void avdtp_sink_suspend(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -170,7 +170,7 @@ void avdtp_source_register_header_compression_category(uint8_t seid, uint8_t bac
|
||||
avdtp_register_header_compression_category(stream_endpoint, back_ch, media, recovery);
|
||||
}
|
||||
|
||||
void avdtp_source_register_media_codec_category(uint8_t seid, avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, const uint8_t * media_codec_info, uint16_t media_codec_info_len){
|
||||
void avdtp_source_register_media_codec_category(uint8_t seid, 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){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = avdtp_stream_endpoint_for_seid(seid, &avdtp_source_context);
|
||||
avdtp_register_media_codec_category(stream_endpoint, media_type, media_codec_type, media_codec_info, media_codec_info_len);
|
||||
}
|
||||
@ -242,12 +242,12 @@ void avdtp_source_set_configuration(uint16_t con_handle, uint8_t int_seid, uint8
|
||||
avdtp_set_configuration(con_handle, int_seid, acp_seid, configured_services_bitmap, configuration, &avdtp_source_context);
|
||||
}
|
||||
|
||||
void avdtp_source_reconfigure(uint16_t con_handle, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration){
|
||||
avdtp_reconfigure(con_handle, acp_seid, configured_services_bitmap, configuration, &avdtp_source_context);
|
||||
void avdtp_source_reconfigure(uint16_t con_handle, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration){
|
||||
avdtp_reconfigure(con_handle, int_seid, acp_seid, configured_services_bitmap, configuration, &avdtp_source_context);
|
||||
}
|
||||
|
||||
void avdtp_source_suspend(uint16_t con_handle, uint8_t acp_seid){
|
||||
avdtp_suspend(con_handle, acp_seid, &avdtp_source_context);
|
||||
void avdtp_source_suspend(uint16_t con_handle, uint8_t int_seid, uint8_t acp_seid){
|
||||
avdtp_suspend(con_handle, int_seid, acp_seid, &avdtp_source_context);
|
||||
}
|
||||
|
||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
|
@ -70,7 +70,7 @@ void avdtp_source_register_delay_reporting_category(uint8_t seid);
|
||||
void avdtp_source_register_recovery_category(uint8_t seid, uint8_t maximum_recovery_window_size, uint8_t maximum_number_media_packets);
|
||||
void avdtp_source_register_content_protection_category(uint8_t seid, uint16_t cp_type, const uint8_t * cp_type_value, uint8_t cp_type_value_len);
|
||||
void avdtp_source_register_header_compression_category(uint8_t seid, uint8_t back_ch, uint8_t media, uint8_t recovery);
|
||||
void avdtp_source_register_media_codec_category(uint8_t seid, avdtp_media_type_t media_type, avdtp_media_codec_type_t media_codec_type, const uint8_t * media_codec_info, uint16_t media_codec_info_len);
|
||||
void avdtp_source_register_media_codec_category(uint8_t seid, 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);
|
||||
void avdtp_source_register_multiplexing_category(uint8_t seid, uint8_t fragmentation);
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ void avdtp_source_set_configuration(uint16_t avdtp_cid, uint8_t int_seid, uint8_
|
||||
* @param avdtp_cid
|
||||
* @param seid
|
||||
*/
|
||||
void avdtp_source_reconfigure(uint16_t avdtp_cid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
|
||||
void avdtp_source_reconfigure(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
|
||||
|
||||
/**
|
||||
* @brief Get configuration
|
||||
@ -132,7 +132,7 @@ void avdtp_source_get_configuration(uint16_t avdtp_cid, uint8_t acp_seid);
|
||||
* @param avdtp_cid
|
||||
* @param seid
|
||||
*/
|
||||
void avdtp_source_suspend(uint16_t avdtp_cid, uint8_t acp_seid);
|
||||
void avdtp_source_suspend(uint16_t avdtp_cid, uint8_t int_seid, uint8_t acp_seid);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -530,19 +530,19 @@ static void show_usage(void){
|
||||
printf("---\n");
|
||||
}
|
||||
|
||||
static const uint8_t media_sbc_codec_capabilities[] = {
|
||||
static uint8_t media_sbc_codec_capabilities[] = {
|
||||
0xFF,//(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
|
||||
0xFF,//(AVDTP_SBC_BLOCK_LENGTH_16 << 4) | (AVDTP_SBC_SUBBANDS_8 << 2) | AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS,
|
||||
2, 53
|
||||
};
|
||||
|
||||
static const uint8_t media_sbc_codec_configuration[] = {
|
||||
static uint8_t media_sbc_codec_configuration[] = {
|
||||
(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
|
||||
(AVDTP_SBC_BLOCK_LENGTH_16 << 4) | (AVDTP_SBC_SUBBANDS_8 << 2) | AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS,
|
||||
2, 53
|
||||
};
|
||||
|
||||
static const uint8_t media_sbc_codec_reconfiguration[] = {
|
||||
static uint8_t media_sbc_codec_reconfiguration[] = {
|
||||
(AVDTP_SBC_44100 << 4) | AVDTP_SBC_STEREO,
|
||||
(AVDTP_SBC_BLOCK_LENGTH_16 << 4) | (AVDTP_SBC_SUBBANDS_8 << 2) | AVDTP_SBC_ALLOCATION_METHOD_SNR,
|
||||
2, 53
|
||||
@ -596,7 +596,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
remote_configuration.media_codec.media_codec_type = AVDTP_CODEC_SBC;
|
||||
remote_configuration.media_codec.media_codec_information_len = sizeof(media_sbc_codec_reconfiguration);
|
||||
remote_configuration.media_codec.media_codec_information = media_sbc_codec_reconfiguration;
|
||||
avdtp_sink_reconfigure(avdtp_cid, sep.seid, remote_configuration_bitmap, remote_configuration);
|
||||
avdtp_sink_reconfigure(avdtp_cid, local_stream_endpoint->sep.seid, sep.seid, remote_configuration_bitmap, remote_configuration);
|
||||
break;
|
||||
case 'o':
|
||||
app_state = AVDTP_APPLICATION_W2_OPEN_STREAM_WITH_SEID;
|
||||
@ -616,7 +616,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
break;
|
||||
case 'P':
|
||||
app_state = AVDTP_APPLICATION_W2_SUSPEND_STREAM_WITH_SEID;
|
||||
avdtp_sink_suspend(avdtp_cid, sep.seid);
|
||||
avdtp_sink_suspend(avdtp_cid, local_stream_endpoint->sep.seid, sep.seid);
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
|
@ -130,7 +130,6 @@ static uint16_t avdtp_cid = 0;
|
||||
|
||||
static uint8_t sdp_avdtp_source_service_buffer[150];
|
||||
|
||||
static adtvp_media_codec_information_sbc_t sbc_capability;
|
||||
static avdtp_media_codec_configuration_sbc_t sbc_configuration;
|
||||
static avdtp_stream_endpoint_t * local_stream_endpoint;
|
||||
|
||||
@ -204,63 +203,6 @@ static const char * avdtp_si2str(uint16_t index){
|
||||
return avdtp_si_name[index];
|
||||
}
|
||||
|
||||
static void dump_sbc_capability(adtvp_media_codec_information_sbc_t media_codec_sbc){
|
||||
printf(" --- avdtp source --- Received media codec capability:\n");
|
||||
printf(" - sampling_frequency: 0x%02x\n", media_codec_sbc.sampling_frequency_bitmap);
|
||||
printf(" - channel_mode: 0x%02x\n", media_codec_sbc.channel_mode_bitmap);
|
||||
printf(" - block_length: 0x%02x\n", media_codec_sbc.block_length_bitmap);
|
||||
printf(" - subbands: 0x%02x\n", media_codec_sbc.subbands_bitmap);
|
||||
printf(" - allocation_method: 0x%02x\n", media_codec_sbc.allocation_method_bitmap);
|
||||
printf(" - bitpool_value [%d, %d] \n", media_codec_sbc.min_bitpool_value, media_codec_sbc.max_bitpool_value);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void avdtp_choose_sbc_configuration_from_sbc_codec_information(adtvp_media_codec_information_sbc_t * media_codec_information, uint8_t * configuration){
|
||||
uint8_t sampling_frequency = AVDTP_SBC_44100;
|
||||
uint8_t channel_mode = AVDTP_SBC_STEREO;
|
||||
uint8_t block_length = AVDTP_SBC_BLOCK_LENGTH_16;
|
||||
uint8_t subbands = AVDTP_SBC_SUBBANDS_8;
|
||||
uint8_t allocation_method = AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS;
|
||||
|
||||
if (media_codec_information->channel_mode_bitmap & AVDTP_SBC_JOINT_STEREO){
|
||||
channel_mode = AVDTP_SBC_JOINT_STEREO;
|
||||
} else if (media_codec_information->channel_mode_bitmap & AVDTP_SBC_STEREO){
|
||||
channel_mode = AVDTP_SBC_STEREO;
|
||||
} else if (media_codec_information->channel_mode_bitmap & AVDTP_SBC_DUAL_CHANNEL){
|
||||
channel_mode = AVDTP_SBC_DUAL_CHANNEL;
|
||||
} else if (media_codec_information->channel_mode_bitmap & AVDTP_SBC_MONO){
|
||||
channel_mode = AVDTP_SBC_MONO;
|
||||
}
|
||||
|
||||
if (media_codec_information->block_length_bitmap & AVDTP_SBC_BLOCK_LENGTH_16){
|
||||
block_length = AVDTP_SBC_BLOCK_LENGTH_16;
|
||||
} else if (media_codec_information->block_length_bitmap & AVDTP_SBC_BLOCK_LENGTH_12){
|
||||
block_length = AVDTP_SBC_BLOCK_LENGTH_12;
|
||||
} else if (media_codec_information->block_length_bitmap & AVDTP_SBC_BLOCK_LENGTH_8){
|
||||
block_length = AVDTP_SBC_BLOCK_LENGTH_8;
|
||||
} else if (media_codec_information->block_length_bitmap & AVDTP_SBC_BLOCK_LENGTH_4){
|
||||
block_length = AVDTP_SBC_BLOCK_LENGTH_4;
|
||||
}
|
||||
|
||||
if (media_codec_information->subbands_bitmap & AVDTP_SBC_SUBBANDS_8){
|
||||
subbands = AVDTP_SBC_SUBBANDS_8;
|
||||
} else if (media_codec_information->subbands_bitmap & AVDTP_SBC_SUBBANDS_4){
|
||||
subbands = AVDTP_SBC_SUBBANDS_4;
|
||||
}
|
||||
|
||||
if (media_codec_information->allocation_method_bitmap & AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS){
|
||||
allocation_method = AVDTP_SBC_ALLOCATION_METHOD_LOUDNESS;
|
||||
} else if (media_codec_information->allocation_method_bitmap & AVDTP_SBC_ALLOCATION_METHOD_SNR){
|
||||
allocation_method = AVDTP_SBC_ALLOCATION_METHOD_SNR;
|
||||
}
|
||||
|
||||
configuration[0] = (sampling_frequency << 4) | channel_mode;
|
||||
configuration[1] = (block_length << 4) | (subbands << 2) | allocation_method;
|
||||
configuration[2] = media_codec_information->min_bitpool_value;
|
||||
configuration[3] = media_codec_information->max_bitpool_value;
|
||||
printf(" --- avdtp source --- SBC settings: frequency %d, channel_mode %d, block_length %d, subbands %d, allocation_method %d, bitpool [%d,%d] \n", sampling_frequency, channel_mode, block_length,
|
||||
subbands, allocation_method, media_codec_information->min_bitpool_value, media_codec_information->max_bitpool_value);
|
||||
}
|
||||
|
||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(channel);
|
||||
@ -320,25 +262,19 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
break;
|
||||
|
||||
case AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC_CAPABILITY:{
|
||||
sbc_capability.sampling_frequency_bitmap = avdtp_subevent_signaling_media_codec_sbc_capability_get_sampling_frequency_bitmap(packet);
|
||||
sbc_capability.channel_mode_bitmap = avdtp_subevent_signaling_media_codec_sbc_capability_get_channel_mode_bitmap(packet);
|
||||
sbc_capability.block_length_bitmap = avdtp_subevent_signaling_media_codec_sbc_capability_get_block_length_bitmap(packet);
|
||||
sbc_capability.subbands_bitmap = avdtp_subevent_signaling_media_codec_sbc_capability_get_subbands_bitmap(packet);
|
||||
sbc_capability.allocation_method_bitmap = avdtp_subevent_signaling_media_codec_sbc_capability_get_allocation_method_bitmap(packet);
|
||||
sbc_capability.min_bitpool_value = avdtp_subevent_signaling_media_codec_sbc_capability_get_min_bitpool_value(packet);
|
||||
sbc_capability.max_bitpool_value = avdtp_subevent_signaling_media_codec_sbc_capability_get_max_bitpool_value(packet);
|
||||
uint8_t sampling_frequency = avdtp_choose_sbc_sampling_frequency(local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_sampling_frequency_bitmap(packet));
|
||||
uint8_t channel_mode = avdtp_choose_sbc_channel_mode(local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_channel_mode_bitmap(packet));
|
||||
uint8_t block_length = avdtp_choose_sbc_block_length(local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_block_length_bitmap(packet));
|
||||
uint8_t subbands = avdtp_choose_sbc_subbands(local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_subbands_bitmap(packet));
|
||||
|
||||
dump_sbc_capability(sbc_capability);
|
||||
|
||||
if (!sbc_capability.sampling_frequency_bitmap) break;
|
||||
if (!sbc_capability.channel_mode_bitmap) break;
|
||||
if (!sbc_capability.block_length_bitmap) break;
|
||||
if (!sbc_capability.allocation_method_bitmap) break;
|
||||
if (!sbc_capability.subbands_bitmap) break;
|
||||
|
||||
if (!(sbc_capability.sampling_frequency_bitmap & AVDTP_SBC_44100)) break;
|
||||
uint8_t allocation_method = avdtp_choose_sbc_allocation_method(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(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(local_stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_min_bitpool_value(packet));
|
||||
|
||||
avdtp_store_sbc_configuration(media_sbc_codec_configuration, sizeof(media_sbc_codec_configuration),
|
||||
sampling_frequency, channel_mode, block_length, subbands,
|
||||
allocation_method, max_bitpool_value, min_bitpool_value);
|
||||
|
||||
avdtp_choose_sbc_configuration_from_sbc_codec_information(&sbc_capability, media_sbc_codec_configuration);
|
||||
app_state = AVDTP_APPLICATION_W2_SET_CONFIGURATION;
|
||||
|
||||
active_remote_sep = avdtp_source_remote_sep(avdtp_cid, next_remote_sep_index_to_query);
|
||||
@ -657,7 +593,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
|
||||
break;
|
||||
case 'P':
|
||||
app_state = AVDTP_APPLICATION_W2_SUSPEND_STREAM_WITH_SEID;
|
||||
avdtp_source_suspend(avdtp_cid, active_remote_sep->seid);
|
||||
avdtp_source_suspend(avdtp_cid, local_stream_endpoint->sep.seid, active_remote_sep->seid);
|
||||
break;
|
||||
case 'x':
|
||||
printf("Start streaming sine.\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user