bluez5: add codec check_caps + check vendor codec id for ldac & aptx

This commit is contained in:
Pauli Virtanen 2021-01-24 21:54:43 +02:00 committed by Wim Taymans
parent ce335b6d88
commit 0908588d0c
4 changed files with 28 additions and 2 deletions

View file

@ -86,6 +86,10 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags,
memcpy(&conf, caps, sizeof(conf));
if (codec->vendor.vendor_id != conf.info.vendor_id ||
codec->vendor.codec_id != conf.info.codec_id)
return -ENOTSUP;
if (conf.frequency & APTX_SAMPLING_FREQ_48000)
conf.frequency = APTX_SAMPLING_FREQ_48000;
else if (conf.frequency & APTX_SAMPLING_FREQ_44100)

View file

@ -138,8 +138,10 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags,
return -EINVAL;
memcpy(&conf, caps, sizeof(conf));
conf.info.vendor_id = LDAC_VENDOR_ID;
conf.info.codec_id = LDAC_CODEC_ID;
if (codec->vendor.vendor_id != conf.info.vendor_id ||
codec->vendor.codec_id != conf.info.codec_id)
return -ENOTSUP;
if (conf.frequency & LDACBT_SAMPLING_FREQ_044100)
conf.frequency = LDACBT_SAMPLING_FREQ_044100;

View file

@ -10,6 +10,24 @@
#include "a2dp-codecs.h"
bool a2dp_codec_check_caps(const struct a2dp_codec *codec, unsigned int codec_id, const void *caps, size_t caps_size)
{
uint8_t config[A2DP_MAX_CAPS_SIZE];
int res;
if (codec_id != codec->codec_id)
return false;
if (caps == NULL)
return false;
res = codec->select_config(codec, 0, caps, caps_size, NULL, config);
if (res < 0)
return false;
return ((size_t)res == caps_size);
}
#if ENABLE_MP3
const a2dp_mpeg_t bluez_a2dp_mpeg = {
.layer =

View file

@ -377,4 +377,6 @@ struct a2dp_codec {
extern const struct a2dp_codec **a2dp_codecs;
bool a2dp_codec_check_caps(const struct a2dp_codec *codec, unsigned int codec_id, const void *caps, size_t caps_size);
#endif