diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index 2da2ccd35..1d4e7748d 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -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){ diff --git a/src/classic/avdtp.h b/src/classic/avdtp.h index 0de275995..bc81df10f 100644 --- a/src/classic/avdtp.h +++ b/src/classic/avdtp.h @@ -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);