diff --git a/spa/plugins/bluez5/bap-codec-caps.h b/spa/plugins/bluez5/bap-codec-caps.h index 10dda6155..1ee39cb6b 100644 --- a/spa/plugins/bluez5/bap-codec-caps.h +++ b/spa/plugins/bluez5/bap-codec-caps.h @@ -51,38 +51,56 @@ #define LC3_CONFIG_DURATION_7_5 0x00 #define LC3_CONFIG_DURATION_10 0x01 -#define LC3_CONFIG_CHNL_NOT_ALLOWED 0x00000000 -#define LC3_CONFIG_CHNL_FL 0x00000001 /* front left */ -#define LC3_CONFIG_CHNL_FR 0x00000002 /* front right */ -#define LC3_CONFIG_CHNL_FC 0x00000004 /* front center */ -#define LC3_CONFIG_CHNL_LFE 0x00000008 /* LFE */ -#define LC3_CONFIG_CHNL_BL 0x00000010 /* back left */ -#define LC3_CONFIG_CHNL_BR 0x00000020 /* back right */ -#define LC3_CONFIG_CHNL_FLC 0x00000040 /* front left center */ -#define LC3_CONFIG_CHNL_FRC 0x00000080 /* front right center */ -#define LC3_CONFIG_CHNL_BC 0x00000100 /* back center */ -#define LC3_CONFIG_CHNL_LFE2 0x00000200 /* LFE 2 */ -#define LC3_CONFIG_CHNL_SL 0x00000400 /* side left */ -#define LC3_CONFIG_CHNL_SR 0x00000800 /* side right */ -#define LC3_CONFIG_CHNL_TFL 0x00001000 /* top front left */ -#define LC3_CONFIG_CHNL_TFR 0x00002000 /* top front right */ -#define LC3_CONFIG_CHNL_TFC 0x00004000 /* top front center */ -#define LC3_CONFIG_CHNL_TC 0x00008000 /* top center */ -#define LC3_CONFIG_CHNL_TBL 0x00010000 /* top back left */ -#define LC3_CONFIG_CHNL_TBR 0x00020000 /* top back right */ -#define LC3_CONFIG_CHNL_TSL 0x00040000 /* top side left */ -#define LC3_CONFIG_CHNL_TSR 0x00080000 /* top side right */ -#define LC3_CONFIG_CHNL_TBC 0x00100000 /* top back center */ -#define LC3_CONFIG_CHNL_BFC 0x00200000 /* bottom front center */ -#define LC3_CONFIG_CHNL_BFL 0x00400000 /* bottom front left */ -#define LC3_CONFIG_CHNL_BFR 0x00800000 /* bottom front right */ -#define LC3_CONFIG_CHNL_FLW 0x01000000 /* front left wide */ -#define LC3_CONFIG_CHNL_FRW 0x02000000 /* front right wide */ -#define LC3_CONFIG_CHNL_LS 0x04000000 /* left surround */ -#define LC3_CONFIG_CHNL_RS 0x08000000 /* right surround */ - #define LC3_MAX_CHANNELS 28 +#define BAP_CHANNEL_NOT_ALLOWED 0x00000000 +#define BAP_CHANNEL_FL 0x00000001 /* front left */ +#define BAP_CHANNEL_FR 0x00000002 /* front right */ +#define BAP_CHANNEL_FC 0x00000004 /* front center */ +#define BAP_CHANNEL_LFE 0x00000008 /* LFE */ +#define BAP_CHANNEL_BL 0x00000010 /* back left */ +#define BAP_CHANNEL_BR 0x00000020 /* back right */ +#define BAP_CHANNEL_FLC 0x00000040 /* front left center */ +#define BAP_CHANNEL_FRC 0x00000080 /* front right center */ +#define BAP_CHANNEL_BC 0x00000100 /* back center */ +#define BAP_CHANNEL_LFE2 0x00000200 /* LFE 2 */ +#define BAP_CHANNEL_SL 0x00000400 /* side left */ +#define BAP_CHANNEL_SR 0x00000800 /* side right */ +#define BAP_CHANNEL_TFL 0x00001000 /* top front left */ +#define BAP_CHANNEL_TFR 0x00002000 /* top front right */ +#define BAP_CHANNEL_TFC 0x00004000 /* top front center */ +#define BAP_CHANNEL_TC 0x00008000 /* top center */ +#define BAP_CHANNEL_TBL 0x00010000 /* top back left */ +#define BAP_CHANNEL_TBR 0x00020000 /* top back right */ +#define BAP_CHANNEL_TSL 0x00040000 /* top side left */ +#define BAP_CHANNEL_TSR 0x00080000 /* top side right */ +#define BAP_CHANNEL_TBC 0x00100000 /* top back center */ +#define BAP_CHANNEL_BFC 0x00200000 /* bottom front center */ +#define BAP_CHANNEL_BFL 0x00400000 /* bottom front left */ +#define BAP_CHANNEL_BFR 0x00800000 /* bottom front right */ +#define BAP_CHANNEL_FLW 0x01000000 /* front left wide */ +#define BAP_CHANNEL_FRW 0x02000000 /* front right wide */ +#define BAP_CHANNEL_LS 0x04000000 /* left surround */ +#define BAP_CHANNEL_RS 0x08000000 /* right surround */ + +#define BAP_CHANNEL_ALL 0x0fffffff /* mask of all */ + +#define BAP_CONTEXT_PROHIBITED 0x0000 /* Prohibited */ +#define BAP_CONTEXT_UNSPECIFIED 0x0001 /* Unspecified */ +#define BAP_CONTEXT_CONVERSATIONAL 0x0002 /* Telephony, video calls, ... */ +#define BAP_CONTEXT_MEDIA 0x0004 /* Music, radio, podcast, movie soundtrack, TV */ +#define BAP_CONTEXT_GAME 0x0008 /* Gaming media, game effects, music, in-game voice chat */ +#define BAP_CONTEXT_INSTRUCTIONAL 0x0010 /* Instructional audio, navigation, announcements, user guidance */ +#define BAP_CONTEXT_VOICE 0x0020 /* Man-machine communication, voice recognition, virtual assistants */ +#define BAP_CONTEXT_LIVE 0x0040 /* Live audio, perceived both via direct acoustic path and via BAP */ +#define BAP_CONTEXT_SOUND_EFFECTS 0x0080 /* Keyboard and touch feedback, menu, UI, other system sounds */ +#define BAP_CONTEXT_NOTIFICATIONS 0x0100 /* Attention-seeking, message arrival, reminders */ +#define BAP_CONTEXT_RINGTONE 0x0200 /* Incoming call alert audio */ +#define BAP_CONTEXT_ALERTS 0x0400 /* Alarms and timers, critical battery, alarm clock, toaster */ +#define BAP_CONTEXT_EMERGENCY 0x0800 /* Fire alarm, other urgent alerts */ + +#define BAP_CONTEXT_ALL 0x0fff + #define BT_ISO_QOS_CIG_UNSET 0xff #define BT_ISO_QOS_CIS_UNSET 0xff diff --git a/spa/plugins/bluez5/bap-codec-lc3.c b/spa/plugins/bluez5/bap-codec-lc3.c index 9283035b2..19e0af6bc 100644 --- a/spa/plugins/bluez5/bap-codec-lc3.c +++ b/spa/plugins/bluez5/bap-codec-lc3.c @@ -53,34 +53,34 @@ static const struct { uint32_t bit; enum spa_audio_channel channel; } channel_bits[] = { - { LC3_CONFIG_CHNL_FL, SPA_AUDIO_CHANNEL_FL }, - { LC3_CONFIG_CHNL_FR, SPA_AUDIO_CHANNEL_FR }, - { LC3_CONFIG_CHNL_FC, SPA_AUDIO_CHANNEL_FC }, - { LC3_CONFIG_CHNL_LFE, SPA_AUDIO_CHANNEL_LFE }, - { LC3_CONFIG_CHNL_BL, SPA_AUDIO_CHANNEL_RL }, - { LC3_CONFIG_CHNL_BR, SPA_AUDIO_CHANNEL_RR }, - { LC3_CONFIG_CHNL_FLC, SPA_AUDIO_CHANNEL_FLC }, - { LC3_CONFIG_CHNL_FRC, SPA_AUDIO_CHANNEL_FRC }, - { LC3_CONFIG_CHNL_BC, SPA_AUDIO_CHANNEL_BC }, - { LC3_CONFIG_CHNL_LFE2, SPA_AUDIO_CHANNEL_LFE2 }, - { LC3_CONFIG_CHNL_SL, SPA_AUDIO_CHANNEL_SL }, - { LC3_CONFIG_CHNL_SR, SPA_AUDIO_CHANNEL_SR }, - { LC3_CONFIG_CHNL_TFL, SPA_AUDIO_CHANNEL_TFL }, - { LC3_CONFIG_CHNL_TFR, SPA_AUDIO_CHANNEL_TFR }, - { LC3_CONFIG_CHNL_TFC, SPA_AUDIO_CHANNEL_TFC }, - { LC3_CONFIG_CHNL_TC, SPA_AUDIO_CHANNEL_TC }, - { LC3_CONFIG_CHNL_TBL, SPA_AUDIO_CHANNEL_TRL }, - { LC3_CONFIG_CHNL_TBR, SPA_AUDIO_CHANNEL_TRR }, - { LC3_CONFIG_CHNL_TSL, SPA_AUDIO_CHANNEL_TSL }, - { LC3_CONFIG_CHNL_TSR, SPA_AUDIO_CHANNEL_TSR }, - { LC3_CONFIG_CHNL_TBC, SPA_AUDIO_CHANNEL_TRC }, - { LC3_CONFIG_CHNL_BFC, SPA_AUDIO_CHANNEL_BC }, - { LC3_CONFIG_CHNL_BFL, SPA_AUDIO_CHANNEL_BLC }, - { LC3_CONFIG_CHNL_BFR, SPA_AUDIO_CHANNEL_BRC }, - { LC3_CONFIG_CHNL_FLW, SPA_AUDIO_CHANNEL_FLW }, - { LC3_CONFIG_CHNL_FRW, SPA_AUDIO_CHANNEL_FRW }, - { LC3_CONFIG_CHNL_LS, SPA_AUDIO_CHANNEL_SL }, /* is it the right mapping? */ - { LC3_CONFIG_CHNL_RS, SPA_AUDIO_CHANNEL_SR }, /* is it the right mapping? */ + { BAP_CHANNEL_FL, SPA_AUDIO_CHANNEL_FL }, + { BAP_CHANNEL_FR, SPA_AUDIO_CHANNEL_FR }, + { BAP_CHANNEL_FC, SPA_AUDIO_CHANNEL_FC }, + { BAP_CHANNEL_LFE, SPA_AUDIO_CHANNEL_LFE }, + { BAP_CHANNEL_BL, SPA_AUDIO_CHANNEL_RL }, + { BAP_CHANNEL_BR, SPA_AUDIO_CHANNEL_RR }, + { BAP_CHANNEL_FLC, SPA_AUDIO_CHANNEL_FLC }, + { BAP_CHANNEL_FRC, SPA_AUDIO_CHANNEL_FRC }, + { BAP_CHANNEL_BC, SPA_AUDIO_CHANNEL_BC }, + { BAP_CHANNEL_LFE2, SPA_AUDIO_CHANNEL_LFE2 }, + { BAP_CHANNEL_SL, SPA_AUDIO_CHANNEL_SL }, + { BAP_CHANNEL_SR, SPA_AUDIO_CHANNEL_SR }, + { BAP_CHANNEL_TFL, SPA_AUDIO_CHANNEL_TFL }, + { BAP_CHANNEL_TFR, SPA_AUDIO_CHANNEL_TFR }, + { BAP_CHANNEL_TFC, SPA_AUDIO_CHANNEL_TFC }, + { BAP_CHANNEL_TC, SPA_AUDIO_CHANNEL_TC }, + { BAP_CHANNEL_TBL, SPA_AUDIO_CHANNEL_TRL }, + { BAP_CHANNEL_TBR, SPA_AUDIO_CHANNEL_TRR }, + { BAP_CHANNEL_TSL, SPA_AUDIO_CHANNEL_TSL }, + { BAP_CHANNEL_TSR, SPA_AUDIO_CHANNEL_TSR }, + { BAP_CHANNEL_TBC, SPA_AUDIO_CHANNEL_TRC }, + { BAP_CHANNEL_BFC, SPA_AUDIO_CHANNEL_BC }, + { BAP_CHANNEL_BFL, SPA_AUDIO_CHANNEL_BLC }, + { BAP_CHANNEL_BFR, SPA_AUDIO_CHANNEL_BRC }, + { BAP_CHANNEL_FLW, SPA_AUDIO_CHANNEL_FLW }, + { BAP_CHANNEL_FRW, SPA_AUDIO_CHANNEL_FRW }, + { BAP_CHANNEL_LS, SPA_AUDIO_CHANNEL_SL }, /* is it the right mapping? */ + { BAP_CHANNEL_RS, SPA_AUDIO_CHANNEL_SR }, /* is it the right mapping? */ }; static int write_ltv(uint8_t *dest, uint8_t type, void* value, size_t len) diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index d3b4cd795..d81456505 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -38,6 +38,7 @@ #include "dbus-helpers.h" #include "player.h" #include "iso-io.h" +#include "bap-codec-caps.h" #include "defs.h" static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5"); @@ -4684,7 +4685,6 @@ static void append_media_object(DBusMessageIter *iter, const char *endpoint, { const char *interface_name = BLUEZ_MEDIA_ENDPOINT_INTERFACE; DBusMessageIter object, array, entry, dict; - dbus_bool_t delay_reporting; dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, NULL, &object); dbus_message_iter_append_basic(&object, DBUS_TYPE_OBJECT_PATH, &endpoint); @@ -4699,10 +4699,28 @@ static void append_media_object(DBusMessageIter *iter, const char *endpoint, append_basic_variant_dict_entry(&dict, "UUID", DBUS_TYPE_STRING, "s", &uuid); append_basic_variant_dict_entry(&dict, "Codec", DBUS_TYPE_BYTE, "y", &codec_id); append_basic_array_variant_dict_entry(&dict, "Capabilities", "ay", "y", DBUS_TYPE_BYTE, caps, caps_size); + if (spa_bt_profile_from_uuid(uuid) & SPA_BT_PROFILE_A2DP_SOURCE) { - delay_reporting = TRUE; + dbus_bool_t delay_reporting = TRUE; + append_basic_variant_dict_entry(&dict, "DelayReporting", DBUS_TYPE_BOOLEAN, "b", &delay_reporting); } + if (spa_bt_profile_from_uuid(uuid) & (SPA_BT_PROFILE_BAP_SINK | SPA_BT_PROFILE_BAP_SOURCE)) { + dbus_uint32_t locations; + dbus_uint16_t supported_context, context; + + locations = BAP_CHANNEL_ALL; + if (spa_bt_profile_from_uuid(uuid) & SPA_BT_PROFILE_BAP_SINK) { + supported_context = context = BAP_CONTEXT_ALL; + } else { + supported_context = context = (BAP_CONTEXT_UNSPECIFIED | BAP_CONTEXT_CONVERSATIONAL | + BAP_CONTEXT_MEDIA | BAP_CONTEXT_GAME); + } + + append_basic_variant_dict_entry(&dict, "Locations", DBUS_TYPE_UINT32, "u", &locations); + append_basic_variant_dict_entry(&dict, "Context", DBUS_TYPE_UINT16, "q", &context); + append_basic_variant_dict_entry(&dict, "SupportedContext", DBUS_TYPE_UINT16, "q", &supported_context); + } dbus_message_iter_close_container(&entry, &dict); dbus_message_iter_close_container(&array, &entry);