avdtp: add avdtp_set_preferred_channel_mode

This commit is contained in:
Milanka Ringwald 2020-11-19 13:23:31 +01:00
parent 95f861f5a6
commit 79654d96bb
2 changed files with 27 additions and 3 deletions

View File

@ -1327,11 +1327,31 @@ void avdtp_set_preferred_sampling_frequeny(avdtp_stream_endpoint_t * stream_e
stream_endpoint->preferred_sampling_frequency = sampling_frequency;
}
void avdtp_set_preferred_channel_mode(avdtp_stream_endpoint_t * stream_endpoint, uint8_t channel_mode){
stream_endpoint->preferred_channel_mode = channel_mode;
}
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;
// use preferred channel mode if possible
if (stream_endpoint->preferred_channel_mode == AVDTP_SBC_JOINT_STEREO){
return AVDTP_SBC_JOINT_STEREO;
}
if (stream_endpoint->preferred_channel_mode == AVDTP_SBC_STEREO){
return AVDTP_SBC_STEREO;
}
if (stream_endpoint->preferred_channel_mode == AVDTP_SBC_DUAL_CHANNEL){
return AVDTP_SBC_DUAL_CHANNEL;
}
if (stream_endpoint->preferred_channel_mode == AVDTP_SBC_MONO){
return AVDTP_SBC_MONO;
}
if (channel_mode_bitmap & AVDTP_SBC_JOINT_STEREO){
channel_mode = AVDTP_SBC_JOINT_STEREO;
} else if (channel_mode_bitmap & AVDTP_SBC_STEREO){

View File

@ -518,8 +518,9 @@ typedef struct avdtp_stream_endpoint {
avdtp_media_type_t media_type;
uint8_t media_codec_sbc_info[4];
// preferred sampling frequency
// preferred SBC codec settings
uint32_t preferred_sampling_frequency;
uint8_t preferred_channel_mode;
// register request for media L2cap connection release
uint8_t media_disconnect;
@ -599,9 +600,12 @@ uint8_t avdtp_get_configuration(uint16_t avdtp_cid, uint8_t remote_seid);
uint8_t avdtp_set_configuration(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
uint8_t avdtp_reconfigure(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration);
// frequency will be used by avdtp_choose_sbc_sampling_frequency if supported by both endpoints
// frequency will be used by avdtp_choose_sbc_sampling_frequency (if supported by both endpoints)
void avdtp_set_preferred_sampling_frequeny(avdtp_stream_endpoint_t * stream_endpoint, uint32_t sampling_frequency);
//
// channel_mode will be used by avdtp_choose_sbc_channel_mode (if supported by both endpoints)
void avdtp_set_preferred_channel_mode(avdtp_stream_endpoint_t * stream_endpoint, uint8_t channel_mode);
void avdtp_set_preferred_sbc_channel_mode(avdtp_stream_endpoint_t * stream_endpoint, uint32_t sampling_frequency);
uint8_t avdtp_choose_sbc_channel_mode(avdtp_stream_endpoint_t * stream_endpoint, uint8_t remote_channel_mode_bitmap);