bluez5: in SelectProperties, parse QoS values and pass to get_qos

The codec may need to take into account endpoint preferred QoS values,
so parse this information and pass it to the codec's get_qos.

All the QoS struct values need to be set, as otherwise BlueZ may pass
uninitialized zero values over the air, which devices can reject.  This
does not apply to CIG/CIS ids, which are automatically allocated by
default.

Fixes connecting to nrf5340 devkit, which requires a valid TargetLatency
value.
This commit is contained in:
Pauli Virtanen 2022-10-09 20:49:43 +03:00 committed by Wim Taymans
parent 61453b91bd
commit 9846e0cb7a
4 changed files with 225 additions and 120 deletions

View file

@ -36,6 +36,7 @@
#include <spa/support/log.h>
#include "a2dp-codec-caps.h"
#include "bap-codec-caps.h"
/*
* The codec plugin SPA interface is private. The version should be incremented
@ -44,7 +45,7 @@
#define SPA_TYPE_INTERFACE_Bluez5CodecMedia SPA_TYPE_INFO_INTERFACE_BASE "Bluez5:Codec:Media:Private"
#define SPA_VERSION_BLUEZ5_CODEC_MEDIA 5
#define SPA_VERSION_BLUEZ5_CODEC_MEDIA 6
struct spa_bluez5_codec_a2dp {
struct spa_interface iface;
@ -79,16 +80,6 @@ struct media_codec_audio_info {
uint32_t channels;
};
struct codec_qos {
uint32_t interval;
bool framing;
char *phy;
uint16_t sdu;
uint8_t retransmission;
uint16_t latency;
uint32_t delay;
};
struct media_codec {
enum spa_bluetooth_audio_codec id;
uint8_t codec_id;
@ -119,9 +110,10 @@ struct media_codec {
int (*validate_config) (const struct media_codec *codec, uint32_t flags,
const void *caps, size_t caps_size,
struct spa_audio_info *info);
void (*get_qos)(const struct media_codec *codec,
int (*get_qos)(const struct media_codec *codec,
const void *config, size_t config_size,
struct codec_qos *qos);
const struct bap_endpoint_qos *endpoint_qos,
struct bap_codec_qos *qos);
/** qsort comparison sorting caps in order of preference for the codec.
* Used in codec switching to select best remote endpoints.