diff --git a/spa/include/spa/utils/names.h b/spa/include/spa/utils/names.h index 7d60b07ed..d8b2a0d26 100644 --- a/spa/include/spa/utils/names.h +++ b/spa/include/spa/utils/names.h @@ -114,13 +114,13 @@ extern "C" { /** keys for bluez5 factory names */ #define SPA_NAME_API_BLUEZ5_ENUM_DBUS "api.bluez5.enum.dbus" /**< a dbus Device interface */ #define SPA_NAME_API_BLUEZ5_DEVICE "api.bluez5.device" /**< a Device interface */ -#define SPA_NAME_API_BLUEZ5_A2DP_SINK "api.bluez5.a2dp.sink" /**< a playback Node interface for A2DP profiles */ -#define SPA_NAME_API_BLUEZ5_A2DP_SOURCE "api.bluez5.a2dp.source" /**< a capture Node interface for A2DP profiles */ +#define SPA_NAME_API_BLUEZ5_MEDIA_SINK "api.bluez5.media.sink" /**< a playback Node interface for A2DP/BAP profiles */ +#define SPA_NAME_API_BLUEZ5_MEDIA_SOURCE "api.bluez5.media.source" /**< a capture Node interface for A2DP/BAP profiles */ #define SPA_NAME_API_BLUEZ5_SCO_SINK "api.bluez5.sco.sink" /**< a playback Node interface for HSP/HFP profiles */ #define SPA_NAME_API_BLUEZ5_SCO_SOURCE "api.bluez5.sco.source" /**< a capture Node interface for HSP/HFP profiles */ /** keys for codec factory names */ -#define SPA_NAME_API_CODEC_BLUEZ5_A2DP "api.codec.bluez5.a2dp" /**< Bluez5 A2DP codec plugin */ +#define SPA_NAME_API_CODEC_BLUEZ5_MEDIA "api.codec.bluez5.media" /**< Bluez5 Media codec plugin */ /** keys for v4l2 factory names */ #define SPA_NAME_API_V4L2_ENUM_UDEV "api.v4l2.enum.udev" /**< a v4l2 udev Device interface */ diff --git a/spa/plugins/bluez5/a2dp-codec-aac.c b/spa/plugins/bluez5/a2dp-codec-aac.c index c14ff2af9..927000de1 100644 --- a/spa/plugins/bluez5/a2dp-codec-aac.c +++ b/spa/plugins/bluez5/a2dp-codec-aac.c @@ -34,7 +34,7 @@ #include #include "rtp.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" static struct spa_log *log; static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.codecs.aac"); @@ -65,7 +65,7 @@ struct impl { int samplesize; }; -static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, +static int codec_fill_caps(const struct media_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { static const a2dp_aac_t a2dp_aac = { @@ -98,7 +98,7 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, return sizeof(a2dp_aac); } -static const struct a2dp_codec_config +static const struct media_codec_config aac_frequencies[] = { { AAC_SAMPLING_FREQ_48000, 48000, 11 }, { AAC_SAMPLING_FREQ_44100, 44100, 10 }, @@ -114,7 +114,7 @@ aac_frequencies[] = { { AAC_SAMPLING_FREQ_8000, 8000, 0 }, }; -static const struct a2dp_codec_config +static const struct media_codec_config aac_channel_modes[] = { { AAC_CHANNELS_2, 2, 1 }, { AAC_CHANNELS_1, 1, 0 }, @@ -130,9 +130,9 @@ static int get_valid_aac_bitrate(a2dp_aac_t *conf) } } -static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_select_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *settings, uint8_t config[A2DP_MAX_CAPS_SIZE]) { a2dp_aac_t conf; @@ -154,7 +154,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, else return -ENOTSUP; - if ((i = a2dp_codec_select_config(aac_frequencies, + if ((i = media_codec_select_config(aac_frequencies, SPA_N_ELEMENTS(aac_frequencies), AAC_GET_FREQUENCY(conf), info ? info->rate : A2DP_CODEC_DEFAULT_RATE @@ -162,7 +162,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return -ENOTSUP; AAC_SET_FREQUENCY(conf, aac_frequencies[i].config); - if ((i = a2dp_codec_select_config(aac_channel_modes, + if ((i = media_codec_select_config(aac_channel_modes, SPA_N_ELEMENTS(aac_channel_modes), conf.channels, info ? info->channels : A2DP_CODEC_DEFAULT_CHANNELS @@ -177,7 +177,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return sizeof(conf); } -static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { @@ -246,7 +246,7 @@ static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, return *param == NULL ? -EIO : 1; } -static int codec_validate_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_validate_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, struct spa_audio_info *info) { @@ -296,7 +296,7 @@ static int codec_validate_config(const struct a2dp_codec *codec, uint32_t flags, return 0; } -static void *codec_init_props(const struct a2dp_codec *codec, uint32_t flags, const struct spa_dict *settings) +static void *codec_init_props(const struct media_codec *codec, uint32_t flags, const struct spa_dict *settings) { struct props *p = calloc(1, sizeof(struct props)); const char *str; @@ -316,7 +316,7 @@ static void codec_clear_props(void *props) free(props); } -static void *codec_init(const struct a2dp_codec *codec, uint32_t flags, +static void *codec_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { @@ -630,7 +630,7 @@ static void codec_set_log(struct spa_log *global_log) spa_log_topic_init(log, &log_topic); } -const struct a2dp_codec a2dp_codec_aac = { +const struct media_codec a2dp_codec_aac = { .id = SPA_BLUETOOTH_AUDIO_CODEC_AAC, .codec_id = A2DP_CODEC_MPEG24, .name = "aac", @@ -654,7 +654,7 @@ const struct a2dp_codec a2dp_codec_aac = { .set_log = codec_set_log, }; -A2DP_CODEC_EXPORT_DEF( +MEDIA_CODEC_EXPORT_DEF( "aac", &a2dp_codec_aac ); diff --git a/spa/plugins/bluez5/a2dp-codec-aptx.c b/spa/plugins/bluez5/a2dp-codec-aptx.c index 721b90599..6938e479c 100644 --- a/spa/plugins/bluez5/a2dp-codec-aptx.c +++ b/spa/plugins/bluez5/a2dp-codec-aptx.c @@ -35,7 +35,7 @@ #include #include "rtp.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" #define APTX_LL_LEVEL1(level) (((level) >> 8) & 0xFF) #define APTX_LL_LEVEL2(level) (((level) >> 0) & 0xFF) @@ -71,19 +71,19 @@ struct msbc_impl { sbc_t msbc; }; -static inline bool codec_is_hd(const struct a2dp_codec *codec) +static inline bool codec_is_hd(const struct media_codec *codec) { return codec->vendor.codec_id == APTX_HD_CODEC_ID && codec->vendor.vendor_id == APTX_HD_VENDOR_ID; } -static inline bool codec_is_ll(const struct a2dp_codec *codec) +static inline bool codec_is_ll(const struct media_codec *codec) { return (codec->id == SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL) || (codec->id == SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL_DUPLEX); } -static inline size_t codec_get_caps_size(const struct a2dp_codec *codec) +static inline size_t codec_get_caps_size(const struct media_codec *codec) { if (codec_is_hd(codec)) return sizeof(a2dp_aptx_hd_t); @@ -93,7 +93,7 @@ static inline size_t codec_get_caps_size(const struct a2dp_codec *codec) return sizeof(a2dp_aptx_t); } -static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, +static int codec_fill_caps(const struct media_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { size_t actual_conf_size = codec_get_caps_size(codec); @@ -119,7 +119,7 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, return actual_conf_size; } -static const struct a2dp_codec_config +static const struct media_codec_config aptx_frequencies[] = { { APTX_SAMPLING_FREQ_48000, 48000, 3 }, { APTX_SAMPLING_FREQ_44100, 44100, 2 }, @@ -127,9 +127,9 @@ aptx_frequencies[] = { { APTX_SAMPLING_FREQ_16000, 16000, 0 }, }; -static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_select_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *settings, uint8_t config[A2DP_MAX_CAPS_SIZE]) { a2dp_aptx_t conf; @@ -145,7 +145,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, codec->vendor.codec_id != conf.info.codec_id) return -ENOTSUP; - if ((i = a2dp_codec_select_config(aptx_frequencies, + if ((i = media_codec_select_config(aptx_frequencies, SPA_N_ELEMENTS(aptx_frequencies), conf.frequency, info ? info->rate : A2DP_CODEC_DEFAULT_RATE @@ -163,9 +163,9 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return actual_conf_size; } -static int codec_select_config_ll(const struct a2dp_codec *codec, uint32_t flags, +static int codec_select_config_ll(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *settings, uint8_t config[A2DP_MAX_CAPS_SIZE]) { a2dp_aptx_ll_ext_t conf = { 0 }; @@ -218,7 +218,7 @@ static int codec_select_config_ll(const struct a2dp_codec *codec, uint32_t flags return actual_conf_size; } -static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { @@ -315,7 +315,7 @@ static int codec_get_block_size(void *data) return this->codesize; } -static void *codec_init(const struct a2dp_codec *codec, uint32_t flags, +static void *codec_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { @@ -458,7 +458,7 @@ static int codec_decode(void *data, * When connected as SRC to SNK, aptX-LL sink may send back mSBC data. */ -static int msbc_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int msbc_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { @@ -479,7 +479,7 @@ static int msbc_enum_config(const struct a2dp_codec *codec, uint32_t flags, return *param == NULL ? -EIO : 1; } -static int msbc_validate_config(const struct a2dp_codec *codec, uint32_t flags, +static int msbc_validate_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, struct spa_audio_info *info) { @@ -508,7 +508,7 @@ static int msbc_get_block_size(void *data) return MSBC_DECODED_SIZE; } -static void *msbc_init(const struct a2dp_codec *codec, uint32_t flags, +static void *msbc_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { @@ -610,7 +610,7 @@ static int msbc_decode(void *data, } -const struct a2dp_codec a2dp_codec_aptx = { +const struct media_codec a2dp_codec_aptx = { .id = SPA_BLUETOOTH_AUDIO_CODEC_APTX, .codec_id = A2DP_CODEC_VENDOR, .vendor = { .vendor_id = APTX_VENDOR_ID, @@ -633,7 +633,7 @@ const struct a2dp_codec a2dp_codec_aptx = { }; -const struct a2dp_codec a2dp_codec_aptx_hd = { +const struct media_codec a2dp_codec_aptx_hd = { .id = SPA_BLUETOOTH_AUDIO_CODEC_APTX_HD, .codec_id = A2DP_CODEC_VENDOR, .vendor = { .vendor_id = APTX_HD_VENDOR_ID, @@ -671,7 +671,7 @@ const struct a2dp_codec a2dp_codec_aptx_hd = { .increase_bitpool = codec_increase_bitpool -const struct a2dp_codec a2dp_codec_aptx_ll_0 = { +const struct media_codec a2dp_codec_aptx_ll_0 = { APTX_LL_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL, .vendor = { .vendor_id = APTX_LL_VENDOR_ID, @@ -680,7 +680,7 @@ const struct a2dp_codec a2dp_codec_aptx_ll_0 = { .endpoint_name = "aptx_ll_0", }; -const struct a2dp_codec a2dp_codec_aptx_ll_1 = { +const struct media_codec a2dp_codec_aptx_ll_1 = { APTX_LL_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL, .vendor = { .vendor_id = APTX_LL_VENDOR_ID2, @@ -690,7 +690,7 @@ const struct a2dp_codec a2dp_codec_aptx_ll_1 = { }; /* Voice channel mSBC, not a real A2DP codec */ -static const struct a2dp_codec aptx_ll_msbc = { +static const struct media_codec aptx_ll_msbc = { .codec_id = A2DP_CODEC_VENDOR, .name = "aptx_ll_msbc", .description = "aptX-LL mSBC", @@ -715,7 +715,7 @@ static const struct spa_dict_item duplex_info_items[] = { }; static const struct spa_dict duplex_info = SPA_DICT_INIT_ARRAY(duplex_info_items); -const struct a2dp_codec a2dp_codec_aptx_ll_duplex_0 = { +const struct media_codec a2dp_codec_aptx_ll_duplex_0 = { APTX_LL_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL_DUPLEX, .vendor = { .vendor_id = APTX_LL_VENDOR_ID, @@ -726,7 +726,7 @@ const struct a2dp_codec a2dp_codec_aptx_ll_duplex_0 = { .info = &duplex_info, }; -const struct a2dp_codec a2dp_codec_aptx_ll_duplex_1 = { +const struct media_codec a2dp_codec_aptx_ll_duplex_1 = { APTX_LL_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL_DUPLEX, .vendor = { .vendor_id = APTX_LL_VENDOR_ID2, @@ -737,7 +737,7 @@ const struct a2dp_codec a2dp_codec_aptx_ll_duplex_1 = { .info = &duplex_info, }; -A2DP_CODEC_EXPORT_DEF( +MEDIA_CODEC_EXPORT_DEF( "aptx", &a2dp_codec_aptx_hd, &a2dp_codec_aptx, diff --git a/spa/plugins/bluez5/a2dp-codec-faststream.c b/spa/plugins/bluez5/a2dp-codec-faststream.c index 03911945c..a579eadd0 100644 --- a/spa/plugins/bluez5/a2dp-codec-faststream.c +++ b/spa/plugins/bluez5/a2dp-codec-faststream.c @@ -36,7 +36,7 @@ #include -#include "a2dp-codecs.h" +#include "media-codecs.h" struct impl { sbc_t sbc; @@ -51,7 +51,7 @@ struct duplex_impl { sbc_t sbc; }; -static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, +static int codec_fill_caps(const struct media_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { const a2dp_faststream_t a2dp_faststream = { @@ -69,20 +69,20 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, return sizeof(a2dp_faststream); } -static const struct a2dp_codec_config +static const struct media_codec_config frequencies[] = { { FASTSTREAM_SINK_SAMPLING_FREQ_48000, 48000, 1 }, { FASTSTREAM_SINK_SAMPLING_FREQ_44100, 44100, 0 }, }; -static const struct a2dp_codec_config +static const struct media_codec_config duplex_frequencies[] = { { FASTSTREAM_SOURCE_SAMPLING_FREQ_16000, 16000, 0 }, }; -static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_select_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *settings, uint8_t config[A2DP_MAX_CAPS_SIZE]) { a2dp_faststream_t conf; @@ -108,7 +108,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, if (codec->duplex_codec) conf.direction |= FASTSTREAM_DIRECTION_SOURCE; - if ((i = a2dp_codec_select_config(frequencies, + if ((i = media_codec_select_config(frequencies, SPA_N_ELEMENTS(frequencies), conf.sink_frequency, info ? info->rate : A2DP_CODEC_DEFAULT_RATE @@ -116,7 +116,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return -ENOTSUP; conf.sink_frequency = frequencies[i].config; - if ((i = a2dp_codec_select_config(duplex_frequencies, + if ((i = media_codec_select_config(duplex_frequencies, SPA_N_ELEMENTS(duplex_frequencies), conf.source_frequency, 16000 @@ -129,7 +129,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return sizeof(conf); } -static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { @@ -209,7 +209,7 @@ static size_t ceil2(size_t v) return v; } -static void *codec_init(const struct a2dp_codec *codec, uint32_t flags, +static void *codec_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { @@ -372,7 +372,7 @@ static SPA_UNUSED int codec_decode(void *data, * When connected as SRC to SNK, FastStream sink may send back SBC data. */ -static int duplex_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int duplex_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { @@ -411,7 +411,7 @@ static int duplex_enum_config(const struct a2dp_codec *codec, uint32_t flags, return *param == NULL ? -EIO : 1; } -static int duplex_validate_config(const struct a2dp_codec *codec, uint32_t flags, +static int duplex_validate_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, struct spa_audio_info *info) { @@ -441,7 +441,7 @@ static int duplex_get_block_size(void *data) return 0; } -static void *duplex_init(const struct a2dp_codec *codec, uint32_t flags, +static void *duplex_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { @@ -577,7 +577,7 @@ static int duplex_decode(void *data, } /* Voice channel SBC, not a real A2DP codec */ -static const struct a2dp_codec duplex_codec = { +static const struct media_codec duplex_codec = { .codec_id = A2DP_CODEC_VENDOR, .name = "faststream_sbc", .description = "FastStream duplex SBC", @@ -614,7 +614,7 @@ static const struct a2dp_codec duplex_codec = { .reduce_bitpool = codec_reduce_bitpool, \ .increase_bitpool = codec_increase_bitpool -static const struct a2dp_codec a2dp_codec_faststream = { +const struct media_codec a2dp_codec_faststream = { FASTSTREAM_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_FASTSTREAM, .name = "faststream", @@ -625,7 +625,7 @@ static const struct spa_dict_item duplex_info_items[] = { }; static const struct spa_dict duplex_info = SPA_DICT_INIT_ARRAY(duplex_info_items); -const struct a2dp_codec a2dp_codec_faststream_duplex = { +const struct media_codec a2dp_codec_faststream_duplex = { FASTSTREAM_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_FASTSTREAM_DUPLEX, .name = "faststream_duplex", @@ -633,7 +633,7 @@ const struct a2dp_codec a2dp_codec_faststream_duplex = { .info = &duplex_info, }; -A2DP_CODEC_EXPORT_DEF( +MEDIA_CODEC_EXPORT_DEF( "faststream", &a2dp_codec_faststream, &a2dp_codec_faststream_duplex diff --git a/spa/plugins/bluez5/a2dp-codec-lc3plus.c b/spa/plugins/bluez5/a2dp-codec-lc3plus.c index 40ca0e0db..d8e1d284e 100644 --- a/spa/plugins/bluez5/a2dp-codec-lc3plus.c +++ b/spa/plugins/bluez5/a2dp-codec-lc3plus.c @@ -41,7 +41,7 @@ #endif #include "rtp.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" #define BITRATE_MIN 96000 #define BITRATE_MAX 512000 @@ -86,7 +86,7 @@ struct impl { int32_t buf[2][LC3PLUS_MAX_SAMPLES]; }; -static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, +static int codec_fill_caps(const struct media_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { const a2dp_lc3plus_hr_t a2dp_lc3plus_hr = { @@ -102,9 +102,9 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, return sizeof(a2dp_lc3plus_hr); } -static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_select_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *settings, uint8_t config[A2DP_MAX_CAPS_SIZE]) { a2dp_lc3plus_hr_t conf; @@ -150,8 +150,8 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return sizeof(conf); } -static int codec_caps_preference_cmp(const struct a2dp_codec *codec, uint32_t flags, const void *caps1, size_t caps1_size, - const void *caps2, size_t caps2_size, const struct a2dp_codec_audio_info *info, const struct spa_dict *global_settings) +static int codec_caps_preference_cmp(const struct media_codec *codec, uint32_t flags, const void *caps1, size_t caps1_size, + const void *caps2, size_t caps2_size, const struct media_codec_audio_info *info, const struct spa_dict *global_settings) { a2dp_lc3plus_hr_t conf1, conf2; a2dp_lc3plus_hr_t *conf; @@ -160,7 +160,7 @@ static int codec_caps_preference_cmp(const struct a2dp_codec *codec, uint32_t fl /* Order selected configurations by preference */ res1 = codec->select_config(codec, 0, caps1, caps1_size, info, NULL, (uint8_t *)&conf1); - res2 = codec->select_config(codec, 0, caps2, caps2_size, info, NULL, (uint8_t *)&conf2); + res2 = codec->select_config(codec, 0, caps2, caps2_size, info , NULL, (uint8_t *)&conf2); #define PREFER_EXPR(expr) \ do { \ @@ -190,7 +190,7 @@ static int codec_caps_preference_cmp(const struct a2dp_codec *codec, uint32_t fl #undef PREFER_BOOL } -static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { @@ -263,7 +263,7 @@ static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, return *param == NULL ? -EIO : 1; } -static int codec_validate_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_validate_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, struct spa_audio_info *info) { @@ -342,7 +342,7 @@ static bool check_mtu_vs_frame_dms(struct impl *this) return (size_t)this->mtu >= header_size + ceildiv(payload_size, max_fragments); } -static void *codec_init(const struct a2dp_codec *codec, uint32_t flags, +static void *codec_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { @@ -758,7 +758,7 @@ static int codec_increase_bitpool(void *data) return 0; } -const struct a2dp_codec a2dp_codec_lc3plus_hr = { +const struct media_codec a2dp_codec_lc3plus_hr = { .id = SPA_BLUETOOTH_AUDIO_CODEC_LC3PLUS_HR, .name = "lc3plus_hr", .codec_id = A2DP_CODEC_VENDOR, @@ -782,7 +782,7 @@ const struct a2dp_codec a2dp_codec_lc3plus_hr = { .increase_bitpool = codec_increase_bitpool }; -A2DP_CODEC_EXPORT_DEF( +MEDIA_CODEC_EXPORT_DEF( "lc3plus", &a2dp_codec_lc3plus_hr ); diff --git a/spa/plugins/bluez5/a2dp-codec-ldac.c b/spa/plugins/bluez5/a2dp-codec-ldac.c index 3906104e8..6649c772e 100644 --- a/spa/plugins/bluez5/a2dp-codec-ldac.c +++ b/spa/plugins/bluez5/a2dp-codec-ldac.c @@ -40,7 +40,7 @@ #endif #include "rtp.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" #define LDACBT_EQMID_AUTO -1 @@ -79,7 +79,7 @@ struct impl { int frame_count; }; -static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) +static int codec_fill_caps(const struct media_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { static const a2dp_ldac_t a2dp_ldac = { .info.vendor_id = LDAC_VENDOR_ID, @@ -97,7 +97,7 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, uint8 return sizeof(a2dp_ldac); } -static const struct a2dp_codec_config +static const struct media_codec_config ldac_frequencies[] = { { LDACBT_SAMPLING_FREQ_044100, 44100, 3 }, { LDACBT_SAMPLING_FREQ_048000, 48000, 2 }, @@ -105,16 +105,16 @@ ldac_frequencies[] = { { LDACBT_SAMPLING_FREQ_096000, 96000, 0 }, }; -static const struct a2dp_codec_config +static const struct media_codec_config ldac_channel_modes[] = { { LDACBT_CHANNEL_MODE_STEREO, 2, 2 }, { LDACBT_CHANNEL_MODE_DUAL_CHANNEL, 2, 1 }, { LDACBT_CHANNEL_MODE_MONO, 1, 0 }, }; -static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_select_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *settings, uint8_t config[A2DP_MAX_CAPS_SIZE]) { a2dp_ldac_t conf; @@ -129,7 +129,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, codec->vendor.codec_id != conf.info.codec_id) return -ENOTSUP; - if ((i = a2dp_codec_select_config(ldac_frequencies, + if ((i = media_codec_select_config(ldac_frequencies, SPA_N_ELEMENTS(ldac_frequencies), conf.frequency, info ? info->rate : A2DP_CODEC_DEFAULT_RATE @@ -137,7 +137,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return -ENOTSUP; conf.frequency = ldac_frequencies[i].config; - if ((i = a2dp_codec_select_config(ldac_channel_modes, + if ((i = media_codec_select_config(ldac_channel_modes, SPA_N_ELEMENTS(ldac_channel_modes), conf.channel_mode, info ? info->channels : A2DP_CODEC_DEFAULT_CHANNELS @@ -150,7 +150,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return sizeof(conf); } -static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { @@ -284,7 +284,7 @@ static int string_to_eqmid(const char * eqmid) return LDACBT_EQMID_AUTO; } -static void *codec_init_props(const struct a2dp_codec *codec, uint32_t flags, const struct spa_dict *settings) +static void *codec_init_props(const struct media_codec *codec, uint32_t flags, const struct spa_dict *settings) { struct props *p = calloc(1, sizeof(struct props)); const char *str; @@ -385,7 +385,7 @@ static int codec_set_props(void *props, const struct spa_pod *param) return prev_eqmid != p->eqmid; } -static void *codec_init(const struct a2dp_codec *codec, uint32_t flags, +static void *codec_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { @@ -570,7 +570,7 @@ static int codec_encode(void *data, return src_used; } -const struct a2dp_codec a2dp_codec_ldac = { +const struct media_codec a2dp_codec_ldac = { .id = SPA_BLUETOOTH_AUDIO_CODEC_LDAC, .codec_id = A2DP_CODEC_VENDOR, .vendor = { .vendor_id = LDAC_VENDOR_ID, @@ -598,7 +598,7 @@ const struct a2dp_codec a2dp_codec_ldac = { .increase_bitpool = codec_increase_bitpool, }; -A2DP_CODEC_EXPORT_DEF( +MEDIA_CODEC_EXPORT_DEF( "ldac", &a2dp_codec_ldac ); diff --git a/spa/plugins/bluez5/a2dp-codec-opus.c b/spa/plugins/bluez5/a2dp-codec-opus.c index 7f1df12df..87d7bd706 100644 --- a/spa/plugins/bluez5/a2dp-codec-opus.c +++ b/spa/plugins/bluez5/a2dp-codec-opus.c @@ -44,7 +44,7 @@ #include #include "rtp.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" static struct spa_log *log; static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.codecs.opus"); @@ -395,7 +395,7 @@ static void parse_settings(struct props *props, const struct spa_dict *settings) props->bidi_application = OPUS_APPLICATION_RESTRICTED_LOWDELAY; } -static int set_channel_conf(const struct a2dp_codec *codec, a2dp_opus_05_t *caps, const struct props *props) +static int set_channel_conf(const struct media_codec *codec, a2dp_opus_05_t *caps, const struct props *props) { /* * Predefined codec profiles @@ -469,7 +469,7 @@ static int set_channel_conf(const struct a2dp_codec *codec, a2dp_opus_05_t *caps return 0; } -static void get_default_bitrates(const struct a2dp_codec *codec, bool bidi, int *min, int *max, int *init) +static void get_default_bitrates(const struct media_codec *codec, bool bidi, int *min, int *max, int *init) { int tmp; @@ -514,7 +514,7 @@ static void get_default_bitrates(const struct a2dp_codec *codec, bool bidi, int }; } -static int get_mapping(const struct a2dp_codec *codec, const a2dp_opus_05_direction_t *conf, +static int get_mapping(const struct media_codec *codec, const a2dp_opus_05_direction_t *conf, bool use_surround_encoder, uint8_t *streams_ret, uint8_t *coupled_streams_ret, const uint8_t **surround_mapping, uint32_t *positions) { @@ -576,7 +576,7 @@ static int get_mapping(const struct a2dp_codec *codec, const a2dp_opus_05_direct return 0; } -static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, +static int codec_fill_caps(const struct media_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { a2dp_opus_05_t a2dp_opus_05 = { @@ -613,9 +613,9 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, return sizeof(a2dp_opus_05); } -static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_select_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *global_settings, uint8_t config[A2DP_MAX_CAPS_SIZE]) { struct props props; @@ -715,8 +715,8 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return sizeof(conf); } -static int codec_caps_preference_cmp(const struct a2dp_codec *codec, uint32_t flags, const void *caps1, size_t caps1_size, - const void *caps2, size_t caps2_size, const struct a2dp_codec_audio_info *info, +static int codec_caps_preference_cmp(const struct media_codec *codec, uint32_t flags, const void *caps1, size_t caps1_size, + const void *caps2, size_t caps2_size, const struct media_codec_audio_info *info, const struct spa_dict *global_settings) { a2dp_opus_05_t conf1, conf2, cap1, cap2; @@ -768,12 +768,12 @@ static int codec_caps_preference_cmp(const struct a2dp_codec *codec, uint32_t fl #undef PREFER_BOOL } -static bool is_duplex_codec(const struct a2dp_codec *codec) +static bool is_duplex_codec(const struct media_codec *codec) { return codec->id == 0; } -static bool use_surround_encoder(const struct a2dp_codec *codec, bool is_sink) +static bool use_surround_encoder(const struct media_codec *codec, bool is_sink) { if (codec->id == SPA_BLUETOOTH_AUDIO_CODEC_OPUS_05_PRO) return false; @@ -784,11 +784,11 @@ static bool use_surround_encoder(const struct a2dp_codec *codec, bool is_sink) return !is_sink; } -static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { - const bool surround_encoder = use_surround_encoder(codec, flags & A2DP_CODEC_FLAG_SINK); + const bool surround_encoder = use_surround_encoder(codec, flags & MEDIA_CODEC_FLAG_SINK); a2dp_opus_05_t conf; a2dp_opus_05_direction_t *dir; struct spa_pod_frame f[1]; @@ -823,11 +823,11 @@ static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, return *param == NULL ? -EIO : 1; } -static int codec_validate_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_validate_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, struct spa_audio_info *info) { - const bool surround_encoder = use_surround_encoder(codec, flags & A2DP_CODEC_FLAG_SINK); + const bool surround_encoder = use_surround_encoder(codec, flags & MEDIA_CODEC_FLAG_SINK); const a2dp_opus_05_direction_t *dir1, *dir2; const a2dp_opus_05_t *conf; @@ -898,7 +898,7 @@ static int parse_frame_dms(int bitfield) } } -static void *codec_init_props(const struct a2dp_codec *codec, uint32_t flags, const struct spa_dict *settings) +static void *codec_init_props(const struct media_codec *codec, uint32_t flags, const struct spa_dict *settings) { struct props *p; @@ -919,11 +919,11 @@ static void codec_clear_props(void *props) free(props); } -static void *codec_init(const struct a2dp_codec *codec, uint32_t flags, +static void *codec_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { - const bool surround_encoder = use_surround_encoder(codec, flags & A2DP_CODEC_FLAG_SINK); + const bool surround_encoder = use_surround_encoder(codec, flags & MEDIA_CODEC_FLAG_SINK); a2dp_opus_05_t *conf = config; a2dp_opus_05_direction_t *dir; struct impl *this = NULL; @@ -1380,21 +1380,21 @@ static void codec_set_log(struct spa_log *global_log) .start_decode = codec_start_decode, \ .decode = codec_decode -const struct a2dp_codec a2dp_codec_opus_05 = { +const struct media_codec a2dp_codec_opus_05 = { OPUS_05_COMMON_FULL_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_OPUS_05, .name = "opus_05", .description = "Opus", }; -const struct a2dp_codec a2dp_codec_opus_05_51 = { +const struct media_codec a2dp_codec_opus_05_51 = { OPUS_05_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_OPUS_05_51, .name = "opus_05_51", .description = "Opus 5.1 Surround", }; -const struct a2dp_codec a2dp_codec_opus_05_71 = { +const struct media_codec a2dp_codec_opus_05_71 = { OPUS_05_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_OPUS_05_71, .name = "opus_05_71", @@ -1402,14 +1402,14 @@ const struct a2dp_codec a2dp_codec_opus_05_71 = { }; /* Bidi return channel codec: doesn't have endpoints */ -const struct a2dp_codec a2dp_codec_opus_05_return = { +const struct media_codec a2dp_codec_opus_05_return = { OPUS_05_COMMON_FULL_DEFS, .id = 0, .name = "opus_05_duplex_bidi", .description = "Opus Duplex Bidi channel", }; -const struct a2dp_codec a2dp_codec_opus_05_duplex = { +const struct media_codec a2dp_codec_opus_05_duplex = { OPUS_05_COMMON_FULL_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_OPUS_05_DUPLEX, .name = "opus_05_duplex", @@ -1417,7 +1417,7 @@ const struct a2dp_codec a2dp_codec_opus_05_duplex = { .duplex_codec = &a2dp_codec_opus_05_return, }; -const struct a2dp_codec a2dp_codec_opus_05_pro = { +const struct media_codec a2dp_codec_opus_05_pro = { OPUS_05_COMMON_DEFS, .id = SPA_BLUETOOTH_AUDIO_CODEC_OPUS_05_PRO, .name = "opus_05_pro", @@ -1427,7 +1427,7 @@ const struct a2dp_codec a2dp_codec_opus_05_pro = { .duplex_codec = &a2dp_codec_opus_05_return, }; -A2DP_CODEC_EXPORT_DEF( +MEDIA_CODEC_EXPORT_DEF( "opus", &a2dp_codec_opus_05, &a2dp_codec_opus_05_51, diff --git a/spa/plugins/bluez5/a2dp-codec-sbc.c b/spa/plugins/bluez5/a2dp-codec-sbc.c index 35d55355a..27a57bded 100644 --- a/spa/plugins/bluez5/a2dp-codec-sbc.c +++ b/spa/plugins/bluez5/a2dp-codec-sbc.c @@ -33,7 +33,7 @@ #include #include "rtp.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" #define MAX_FRAME_COUNT 16 @@ -51,7 +51,7 @@ struct impl { int max_bitpool; }; -static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, +static int codec_fill_caps(const struct media_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { static const a2dp_sbc_t a2dp_sbc = { @@ -121,7 +121,7 @@ static uint8_t default_bitpool(uint8_t freq, uint8_t mode, bool xq) } -static const struct a2dp_codec_config +static const struct media_codec_config sbc_frequencies[] = { { SBC_SAMPLING_FREQ_48000, 48000, 3 }, { SBC_SAMPLING_FREQ_44100, 44100, 2 }, @@ -129,13 +129,13 @@ sbc_frequencies[] = { { SBC_SAMPLING_FREQ_16000, 16000, 0 }, }; -static const struct a2dp_codec_config +static const struct media_codec_config sbc_xq_frequencies[] = { { SBC_SAMPLING_FREQ_44100, 44100, 1 }, { SBC_SAMPLING_FREQ_48000, 48000, 0 }, }; -static const struct a2dp_codec_config +static const struct media_codec_config sbc_channel_modes[] = { { SBC_CHANNEL_MODE_JOINT_STEREO, 2, 3 }, { SBC_CHANNEL_MODE_STEREO, 2, 2 }, @@ -143,22 +143,22 @@ sbc_channel_modes[] = { { SBC_CHANNEL_MODE_MONO, 1, 0 }, }; -static const struct a2dp_codec_config +static const struct media_codec_config sbc_xq_channel_modes[] = { { SBC_CHANNEL_MODE_DUAL_CHANNEL, 2, 2 }, { SBC_CHANNEL_MODE_JOINT_STEREO, 2, 1 }, { SBC_CHANNEL_MODE_STEREO, 2, 0 }, }; -static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_select_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *settings, uint8_t config[A2DP_MAX_CAPS_SIZE]) { a2dp_sbc_t conf; int bitpool, i; size_t n; - const struct a2dp_codec_config *configs; + const struct media_codec_config *configs; bool xq = false; @@ -176,7 +176,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, configs = sbc_frequencies; n = SPA_N_ELEMENTS(sbc_frequencies); } - if ((i = a2dp_codec_select_config(configs, n, conf.frequency, + if ((i = media_codec_select_config(configs, n, conf.frequency, info ? info->rate : A2DP_CODEC_DEFAULT_RATE )) < 0) return -ENOTSUP; @@ -189,7 +189,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, configs = sbc_channel_modes; n = SPA_N_ELEMENTS(sbc_channel_modes); } - if ((i = a2dp_codec_select_config(configs, n, conf.channel_mode, + if ((i = media_codec_select_config(configs, n, conf.channel_mode, info ? info->channels : A2DP_CODEC_DEFAULT_CHANNELS )) < 0) return -ENOTSUP; @@ -229,8 +229,8 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, return sizeof(conf); } -static int codec_caps_preference_cmp(const struct a2dp_codec *codec, uint32_t flags, const void *caps1, size_t caps1_size, - const void *caps2, size_t caps2_size, const struct a2dp_codec_audio_info *info, const struct spa_dict *global_settings) +static int codec_caps_preference_cmp(const struct media_codec *codec, uint32_t flags, const void *caps1, size_t caps1_size, + const void *caps2, size_t caps2_size, const struct media_codec_audio_info *info, const struct spa_dict *global_settings) { a2dp_sbc_t conf1, conf2; a2dp_sbc_t *conf; @@ -275,7 +275,7 @@ static int codec_caps_preference_cmp(const struct a2dp_codec *codec, uint32_t fl #undef PREFER_BOOL } -static int codec_validate_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_validate_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, struct spa_audio_info *info) { @@ -356,7 +356,7 @@ static int codec_set_bitpool(struct impl *this, int bitpool) return this->sbc.bitpool; } -static int codec_enum_config(const struct a2dp_codec *codec, uint32_t flags, +static int codec_enum_config(const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *b, struct spa_pod **param) { @@ -453,7 +453,7 @@ static int codec_get_block_size(void *data) return this->codesize; } -static void *codec_init(const struct a2dp_codec *codec, uint32_t flags, +static void *codec_init(const struct media_codec *codec, uint32_t flags, void *config, size_t config_len, const struct spa_audio_info *info, void *props, size_t mtu) { @@ -638,7 +638,7 @@ static int codec_decode(void *data, return res; } -const struct a2dp_codec a2dp_codec_sbc = { +const struct media_codec a2dp_codec_sbc = { .id = SPA_BLUETOOTH_AUDIO_CODEC_SBC, .codec_id = A2DP_CODEC_SBC, .name = "sbc", @@ -660,7 +660,7 @@ const struct a2dp_codec a2dp_codec_sbc = { .increase_bitpool = codec_increase_bitpool, }; -const struct a2dp_codec a2dp_codec_sbc_xq = { +const struct media_codec a2dp_codec_sbc_xq = { .id = SPA_BLUETOOTH_AUDIO_CODEC_SBC_XQ, .codec_id = A2DP_CODEC_SBC, .name = "sbc_xq", @@ -682,7 +682,7 @@ const struct a2dp_codec a2dp_codec_sbc_xq = { .increase_bitpool = codec_increase_bitpool, }; -A2DP_CODEC_EXPORT_DEF( +MEDIA_CODEC_EXPORT_DEF( "sbc", &a2dp_codec_sbc, &a2dp_codec_sbc_xq diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index 93f8e7217..ce1742885 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -100,7 +100,7 @@ struct spa_bt_monitor { uint32_t id; - const struct a2dp_codec * const * a2dp_codecs; + const struct media_codec * const * media_codecs; /* * Lists of BlueZ objects, kept up-to-date by following DBus events @@ -130,7 +130,7 @@ struct spa_bt_monitor { struct spa_dict global_settings; /* A reference audio info for A2DP codec configuration. */ - struct a2dp_codec_audio_info default_audio_info; + struct media_codec_audio_info default_audio_info; }; /* Stream endpoints owned by BlueZ for each device */ @@ -155,7 +155,7 @@ struct spa_bt_remote_endpoint { * with the desired capabilities. * The codec switch struct tracks candidates still to be tried. */ -struct spa_bt_a2dp_codec_switch { +struct spa_bt_media_codec_switch { struct spa_bt_device *device; struct spa_list device_link; @@ -172,10 +172,10 @@ struct spa_bt_a2dp_codec_switch { * Called asynchronously, so endpoint paths instead of pointers (which may be * invalidated in the meantime). */ - const struct a2dp_codec **codecs; + const struct media_codec **codecs; char **paths; - const struct a2dp_codec **codec_iter; /**< outer iterator over codecs */ + const struct media_codec **codec_iter; /**< outer iterator over codecs */ char **path_iter; /**< inner iterator over endpoint paths */ uint16_t retries; @@ -430,7 +430,7 @@ static void register_battery_provider(struct spa_bt_device *device) } } -static int a2dp_codec_to_endpoint(const struct a2dp_codec *codec, +static int media_codec_to_endpoint(const struct media_codec *codec, const char * endpoint, char** object_path) { @@ -441,10 +441,10 @@ static int a2dp_codec_to_endpoint(const struct a2dp_codec *codec, return 0; } -static const struct a2dp_codec *a2dp_endpoint_to_codec(struct spa_bt_monitor *monitor, const char *endpoint, bool *sink) +static const struct media_codec *media_endpoint_to_codec(struct spa_bt_monitor *monitor, const char *endpoint, bool *sink) { const char *ep_name; - const struct a2dp_codec * const * const a2dp_codecs = monitor->a2dp_codecs; + const struct media_codec * const * const media_codecs = monitor->media_codecs; int i; if (spa_strstartswith(endpoint, A2DP_SINK_ENDPOINT "/")) { @@ -457,8 +457,8 @@ static const struct a2dp_codec *a2dp_endpoint_to_codec(struct spa_bt_monitor *mo return NULL; } - for (i = 0; a2dp_codecs[i]; i++) { - const struct a2dp_codec *codec = a2dp_codecs[i]; + for (i = 0; media_codecs[i]; i++) { + const struct media_codec *codec = media_codecs[i]; const char *codec_ep_name = codec->endpoint_name ? codec->endpoint_name : codec->name; if (spa_streq(ep_name, codec_ep_name)) @@ -467,7 +467,7 @@ static const struct a2dp_codec *a2dp_endpoint_to_codec(struct spa_bt_monitor *mo return NULL; } -static int a2dp_endpoint_to_profile(const char *endpoint) +static int media_endpoint_to_profile(const char *endpoint) { if (spa_strstartswith(endpoint, A2DP_SINK_ENDPOINT "/")) @@ -478,7 +478,7 @@ static int a2dp_endpoint_to_profile(const char *endpoint) return SPA_BT_PROFILE_NULL; } -static bool is_a2dp_codec_enabled(struct spa_bt_monitor *monitor, const struct a2dp_codec *codec) +static bool is_media_codec_enabled(struct spa_bt_monitor *monitor, const struct media_codec *codec) { return spa_dict_lookup(&monitor->enabled_codecs, codec->name) != NULL; } @@ -492,7 +492,7 @@ static DBusHandlerResult endpoint_select_configuration(DBusConnection *conn, DBu DBusMessage *r; DBusError err; int size, res; - const struct a2dp_codec *codec; + const struct media_codec *codec; bool sink; dbus_error_init(&err); @@ -508,14 +508,14 @@ static DBusHandlerResult endpoint_select_configuration(DBusConnection *conn, DBu spa_log_info(monitor->log, "%p: %s select conf %d", monitor, path, size); spa_log_hexdump(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, cap, (size_t)size); - codec = a2dp_endpoint_to_codec(monitor, path, &sink); + codec = media_endpoint_to_codec(monitor, path, &sink); if (codec != NULL) /* FIXME: We can't determine which device the SelectConfiguration() * call is associated with, therefore device settings are not passed. * This causes inconsistency with SelectConfiguration() triggered * by codec switching. */ - res = codec->select_config(codec, sink ? A2DP_CODEC_FLAG_SINK : 0, cap, size, &monitor->default_audio_info, + res = codec->select_config(codec, sink ? MEDIA_CODEC_FLAG_SINK : 0, cap, size, &monitor->default_audio_info, &monitor->global_settings, config); else res = -ENOTSUP; @@ -905,7 +905,7 @@ static struct spa_bt_device *device_create(struct spa_bt_monitor *monitor, const static int device_stop_timer(struct spa_bt_device *device); -static void a2dp_codec_switch_free(struct spa_bt_a2dp_codec_switch *sw); +static void media_codec_switch_free(struct spa_bt_media_codec_switch *sw); static void device_clear_sub(struct spa_bt_device *device) { @@ -916,7 +916,7 @@ static void device_clear_sub(struct spa_bt_device *device) static void device_free(struct spa_bt_device *device) { struct spa_bt_remote_endpoint *ep, *tep; - struct spa_bt_a2dp_codec_switch *sw; + struct spa_bt_media_codec_switch *sw; struct spa_bt_transport *t, *tt; struct spa_bt_monitor *monitor = device->monitor; @@ -946,7 +946,7 @@ static void device_free(struct spa_bt_device *device) } spa_list_consume(sw, &device->codec_switch_list, device_link) - a2dp_codec_switch_free(sw); + media_codec_switch_free(sw); spa_list_remove(&device->link); free(device->path); @@ -1347,9 +1347,9 @@ static void device_set_connected(struct spa_bt_device *device, int connected) spa_bt_device_check_profiles(device, false); else { /* Stop codec switch on disconnect */ - struct spa_bt_a2dp_codec_switch *sw; + struct spa_bt_media_codec_switch *sw; spa_list_consume(sw, &device->codec_switch_list, device_link) - a2dp_codec_switch_free(sw); + media_codec_switch_free(sw); if (device->reconnect_state != BT_DEVICE_RECONNECT_INIT) device_stop_timer(device); @@ -1550,7 +1550,7 @@ static bool device_props_ready(struct spa_bt_device *device) return device->adapter && device->address; } -bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec *codec, bool sink) +bool spa_bt_device_supports_media_codec(struct spa_bt_device *device, const struct media_codec *codec, bool sink) { struct spa_bt_monitor *monitor = device->monitor; struct spa_bt_remote_endpoint *ep; @@ -1563,7 +1563,7 @@ bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struc }; size_t i; - if (!is_a2dp_codec_enabled(device->monitor, codec)) + if (!is_media_codec_enabled(device->monitor, codec)) return false; if (!device->adapter->application_registered) { @@ -1593,7 +1593,7 @@ bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struc if (profile != expected) continue; - if (a2dp_codec_check_caps(codec, ep->codec, ep->capabilities, ep->capabilities_len, + if (media_codec_check_caps(codec, ep->codec, ep->capabilities, ep->capabilities_len, &ep->monitor->default_audio_info, &monitor->global_settings)) return true; } @@ -1601,34 +1601,34 @@ bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struc return false; } -const struct a2dp_codec **spa_bt_device_get_supported_a2dp_codecs(struct spa_bt_device *device, size_t *count, bool sink) +const struct media_codec **spa_bt_device_get_supported_media_codecs(struct spa_bt_device *device, size_t *count, bool sink) { struct spa_bt_monitor *monitor = device->monitor; - const struct a2dp_codec * const * const a2dp_codecs = monitor->a2dp_codecs; - const struct a2dp_codec **supported_codecs; + const struct media_codec * const * const media_codecs = monitor->media_codecs; + const struct media_codec **supported_codecs; size_t i, j, size; *count = 0; size = 8; - supported_codecs = malloc(size * sizeof(const struct a2dp_codec *)); + supported_codecs = malloc(size * sizeof(const struct media_codec *)); if (supported_codecs == NULL) return NULL; j = 0; - for (i = 0; a2dp_codecs[i] != NULL; ++i) { - if (spa_bt_device_supports_a2dp_codec(device, a2dp_codecs[i], sink)) { - supported_codecs[j] = a2dp_codecs[i]; + for (i = 0; media_codecs[i] != NULL; ++i) { + if (spa_bt_device_supports_media_codec(device, media_codecs[i], sink)) { + supported_codecs[j] = media_codecs[i]; ++j; } if (j >= size) { - const struct a2dp_codec **p; + const struct media_codec **p; size = size * 2; #ifdef HAVE_REALLOCARRRAY - p = reallocarray(supported_codecs, size, sizeof(const struct a2dp_codec *)); + p = reallocarray(supported_codecs, size, sizeof(const struct media_codec *)); #else - p = realloc(supported_codecs, size * sizeof(const struct a2dp_codec *)); + p = realloc(supported_codecs, size * sizeof(const struct media_codec *)); #endif if (p == NULL) { free(supported_codecs); @@ -2170,10 +2170,10 @@ int64_t spa_bt_transport_get_delay_nsec(struct spa_bt_transport *t) /* Fallback values when device does not provide information */ - if (t->a2dp_codec == NULL) + if (t->media_codec == NULL) return 30 * SPA_NSEC_PER_MSEC; - switch (t->a2dp_codec->id) { + switch (t->media_codec->id) { case SPA_BLUETOOTH_AUDIO_CODEC_SBC: case SPA_BLUETOOTH_AUDIO_CODEC_SBC_XQ: return 200 * SPA_NSEC_PER_MSEC; @@ -2525,21 +2525,21 @@ static const struct spa_bt_transport_implementation transport_impl = { static void append_basic_array_variant_dict_entry(DBusMessageIter *dict, const char* key, const char* variant_type_str, const char* array_type_str, int array_type_int, void* data, int data_size); -static void a2dp_codec_switch_reply(DBusPendingCall *pending, void *userdata); +static void media_codec_switch_reply(DBusPendingCall *pending, void *userdata); -static int a2dp_codec_switch_cmp(const void *a, const void *b); +static int media_codec_switch_cmp(const void *a, const void *b); -static struct spa_bt_a2dp_codec_switch *a2dp_codec_switch_cmp_sw; /* global for qsort */ +static struct spa_bt_media_codec_switch *media_codec_switch_cmp_sw; /* global for qsort */ -static int a2dp_codec_switch_start_timer(struct spa_bt_a2dp_codec_switch *sw, uint64_t timeout); +static int media_codec_switch_start_timer(struct spa_bt_media_codec_switch *sw, uint64_t timeout); -static int a2dp_codec_switch_stop_timer(struct spa_bt_a2dp_codec_switch *sw); +static int media_codec_switch_stop_timer(struct spa_bt_media_codec_switch *sw); -static void a2dp_codec_switch_free(struct spa_bt_a2dp_codec_switch *sw) +static void media_codec_switch_free(struct spa_bt_media_codec_switch *sw) { char **p; - a2dp_codec_switch_stop_timer(sw); + media_codec_switch_stop_timer(sw); if (sw->pending != NULL) { dbus_pending_call_cancel(sw->pending); @@ -2558,7 +2558,7 @@ static void a2dp_codec_switch_free(struct spa_bt_a2dp_codec_switch *sw) free(sw); } -static void a2dp_codec_switch_next(struct spa_bt_a2dp_codec_switch *sw) +static void media_codec_switch_next(struct spa_bt_media_codec_switch *sw) { spa_assert(*sw->codec_iter != NULL && *sw->path_iter != NULL); @@ -2571,11 +2571,11 @@ static void a2dp_codec_switch_next(struct spa_bt_a2dp_codec_switch *sw) sw->retries = CODEC_SWITCH_RETRIES; } -static bool a2dp_codec_switch_process_current(struct spa_bt_a2dp_codec_switch *sw) +static bool media_codec_switch_process_current(struct spa_bt_media_codec_switch *sw) { struct spa_bt_remote_endpoint *ep; struct spa_bt_transport *t; - const struct a2dp_codec *codec; + const struct media_codec *codec; uint8_t config[A2DP_MAX_CAPS_SIZE]; char *local_endpoint_base; char *local_endpoint = NULL; @@ -2590,25 +2590,25 @@ static bool a2dp_codec_switch_process_current(struct spa_bt_a2dp_codec_switch *s codec = *sw->codec_iter; - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: consider codec %s for remote endpoint %s", + spa_log_debug(sw->device->monitor->log, "media codec switch %p: consider codec %s for remote endpoint %s", sw, (*sw->codec_iter)->name, *sw->path_iter); ep = device_remote_endpoint_find(sw->device, *sw->path_iter); if (ep == NULL || ep->capabilities == NULL || ep->uuid == NULL) { - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: endpoint %s not valid, try next", + spa_log_debug(sw->device->monitor->log, "media codec switch %p: endpoint %s not valid, try next", sw, *sw->path_iter); goto next; } /* Setup and check compatible configuration */ if (ep->codec != codec->codec_id) { - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: different codec, try next", sw); + spa_log_debug(sw->device->monitor->log, "media codec switch %p: different codec, try next", sw); goto next; } if (!(sw->profile & spa_bt_profile_from_uuid(ep->uuid))) { - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: wrong uuid (%s) for profile, try next", + spa_log_debug(sw->device->monitor->log, "media codec switch %p: wrong uuid (%s) for profile, try next", sw, ep->uuid); goto next; } @@ -2620,13 +2620,13 @@ static bool a2dp_codec_switch_process_current(struct spa_bt_a2dp_codec_switch *s local_endpoint_base = A2DP_SINK_ENDPOINT; sink = true; } else { - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: bad profile (%d), try next", + spa_log_debug(sw->device->monitor->log, "media codec switch %p: bad profile (%d), try next", sw, sw->profile); goto next; } - if (a2dp_codec_to_endpoint(codec, local_endpoint_base, &local_endpoint) < 0) { - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: no endpoint for codec %s, try next", + if (media_codec_to_endpoint(codec, local_endpoint_base, &local_endpoint) < 0) { + spa_log_debug(sw->device->monitor->log, "media codec switch %p: no endpoint for codec %s, try next", sw, codec->name); goto next; } @@ -2638,36 +2638,36 @@ static bool a2dp_codec_switch_process_current(struct spa_bt_a2dp_codec_switch *s if (t->device->adapter != sw->device->adapter) continue; if (spa_streq(t->endpoint_path, local_endpoint)) { - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: endpoint %s in use, try next", + spa_log_debug(sw->device->monitor->log, "media codec switch %p: endpoint %s in use, try next", sw, local_endpoint); goto next; } } - res = codec->select_config(codec, sink ? A2DP_CODEC_FLAG_SINK : 0, ep->capabilities, ep->capabilities_len, + res = codec->select_config(codec, sink ? MEDIA_CODEC_FLAG_SINK : 0, ep->capabilities, ep->capabilities_len, &sw->device->monitor->default_audio_info, &sw->device->monitor->global_settings, config); if (res < 0) { - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: incompatible capabilities (%d), try next", + spa_log_debug(sw->device->monitor->log, "media codec switch %p: incompatible capabilities (%d), try next", sw, res); goto next; } config_size = res; - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: configuration %d", sw, config_size); + spa_log_debug(sw->device->monitor->log, "media codec switch %p: configuration %d", sw, config_size); for (i = 0; i < config_size; i++) - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: %d: %02x", sw, i, config[i]); + spa_log_debug(sw->device->monitor->log, "media codec switch %p: %d: %02x", sw, i, config[i]); /* org.bluez.MediaEndpoint1.SetConfiguration on remote endpoint */ m = dbus_message_new_method_call(BLUEZ_SERVICE, ep->path, BLUEZ_MEDIA_ENDPOINT_INTERFACE, "SetConfiguration"); if (m == NULL) { - spa_log_debug(sw->device->monitor->log, "a2dp codec switch %p: dbus allocation failure, try next", sw); + spa_log_debug(sw->device->monitor->log, "media codec switch %p: dbus allocation failure, try next", sw); goto next; } spa_bt_device_update_last_bluez_action_time(sw->device); - spa_log_info(sw->device->monitor->log, "a2dp codec switch %p: trying codec %s for endpoint %s, local endpoint %s", + spa_log_info(sw->device->monitor->log, "media codec switch %p: trying codec %s for endpoint %s, local endpoint %s", sw, codec->name, ep->path, local_endpoint); dbus_message_iter_init_append(m, &iter); @@ -2680,16 +2680,16 @@ static bool a2dp_codec_switch_process_current(struct spa_bt_a2dp_codec_switch *s dbus_ret = dbus_connection_send_with_reply(sw->device->monitor->conn, m, &sw->pending, -1); if (!dbus_ret || sw->pending == NULL) { - spa_log_error(sw->device->monitor->log, "a2dp codec switch %p: dbus call failure, try next", sw); + spa_log_error(sw->device->monitor->log, "media codec switch %p: dbus call failure, try next", sw); dbus_message_unref(m); goto next; } - dbus_ret = dbus_pending_call_set_notify(sw->pending, a2dp_codec_switch_reply, sw, NULL); + dbus_ret = dbus_pending_call_set_notify(sw->pending, media_codec_switch_reply, sw, NULL); dbus_message_unref(m); if (!dbus_ret) { - spa_log_error(sw->device->monitor->log, "a2dp codec switch %p: dbus set notify failure", sw); + spa_log_error(sw->device->monitor->log, "media codec switch %p: dbus set notify failure", sw); goto next; } @@ -2701,7 +2701,7 @@ next: return false; } -static void a2dp_codec_switch_process(struct spa_bt_a2dp_codec_switch *sw) +static void media_codec_switch_process(struct spa_bt_media_codec_switch *sw) { while (*sw->codec_iter != NULL && *sw->path_iter != NULL) { struct timespec ts; @@ -2713,60 +2713,60 @@ static void a2dp_codec_switch_process(struct spa_bt_a2dp_codec_switch *sw) threshold = sw->device->last_bluez_action_time + BLUEZ_ACTION_RATE_MSEC * SPA_NSEC_PER_MSEC; if (now < threshold) { /* Wait for timeout */ - a2dp_codec_switch_start_timer(sw, threshold - now); + media_codec_switch_start_timer(sw, threshold - now); return; } if (sw->path_iter == sw->paths && (*sw->codec_iter)->caps_preference_cmp) { /* Sort endpoints according to codec preference, when at a new codec. */ - a2dp_codec_switch_cmp_sw = sw; - qsort(sw->paths, sw->num_paths, sizeof(char *), a2dp_codec_switch_cmp); + media_codec_switch_cmp_sw = sw; + qsort(sw->paths, sw->num_paths, sizeof(char *), media_codec_switch_cmp); } - if (a2dp_codec_switch_process_current(sw)) { + if (media_codec_switch_process_current(sw)) { /* Wait for dbus reply */ return; } - a2dp_codec_switch_next(sw); + media_codec_switch_next(sw); }; /* Didn't find any suitable endpoint. Report failure. */ - spa_log_info(sw->device->monitor->log, "a2dp codec switch %p: failed to get an endpoint", sw); + spa_log_info(sw->device->monitor->log, "media codec switch %p: failed to get an endpoint", sw); spa_bt_device_emit_codec_switched(sw->device, -ENODEV); spa_bt_device_check_profiles(sw->device, false); - a2dp_codec_switch_free(sw); + media_codec_switch_free(sw); } -static bool a2dp_codec_switch_goto_active(struct spa_bt_a2dp_codec_switch *sw) +static bool media_codec_switch_goto_active(struct spa_bt_media_codec_switch *sw) { struct spa_bt_device *device = sw->device; - struct spa_bt_a2dp_codec_switch *active_sw; + struct spa_bt_media_codec_switch *active_sw; - active_sw = spa_list_first(&device->codec_switch_list, struct spa_bt_a2dp_codec_switch, device_link); + active_sw = spa_list_first(&device->codec_switch_list, struct spa_bt_media_codec_switch, device_link); if (active_sw != sw) { - struct spa_bt_a2dp_codec_switch *t; + struct spa_bt_media_codec_switch *t; /* This codec switch has been canceled. Switch to the newest one. */ spa_log_debug(sw->device->monitor->log, - "a2dp codec switch %p: canceled, go to new switch", sw); + "media codec switch %p: canceled, go to new switch", sw); spa_list_for_each_safe(sw, t, &device->codec_switch_list, device_link) { if (sw != active_sw) - a2dp_codec_switch_free(sw); + media_codec_switch_free(sw); } - a2dp_codec_switch_process(active_sw); + media_codec_switch_process(active_sw); return false; } return true; } -static void a2dp_codec_switch_timer_event(struct spa_source *source) +static void media_codec_switch_timer_event(struct spa_source *source) { - struct spa_bt_a2dp_codec_switch *sw = source->data; + struct spa_bt_media_codec_switch *sw = source->data; struct spa_bt_device *device = sw->device; struct spa_bt_monitor *monitor = device->monitor; uint64_t exp; @@ -2774,19 +2774,19 @@ static void a2dp_codec_switch_timer_event(struct spa_source *source) if (spa_system_timerfd_read(monitor->main_system, source->fd, &exp) < 0) spa_log_warn(monitor->log, "error reading timerfd: %s", strerror(errno)); - spa_log_debug(monitor->log, "a2dp codec switch %p: rate limit timer event", sw); + spa_log_debug(monitor->log, "media codec switch %p: rate limit timer event", sw); - a2dp_codec_switch_stop_timer(sw); + media_codec_switch_stop_timer(sw); - if (!a2dp_codec_switch_goto_active(sw)) + if (!media_codec_switch_goto_active(sw)) return; - a2dp_codec_switch_process(sw); + media_codec_switch_process(sw); } -static void a2dp_codec_switch_reply(DBusPendingCall *pending, void *user_data) +static void media_codec_switch_reply(DBusPendingCall *pending, void *user_data) { - struct spa_bt_a2dp_codec_switch *sw = user_data; + struct spa_bt_media_codec_switch *sw = user_data; struct spa_bt_device *device = sw->device; DBusMessage *r; @@ -2798,7 +2798,7 @@ static void a2dp_codec_switch_reply(DBusPendingCall *pending, void *user_data) spa_bt_device_update_last_bluez_action_time(device); - if (!a2dp_codec_switch_goto_active(sw)) { + if (!media_codec_switch_goto_active(sw)) { if (r != NULL) dbus_message_unref(r); return; @@ -2806,14 +2806,14 @@ static void a2dp_codec_switch_reply(DBusPendingCall *pending, void *user_data) if (r == NULL) { spa_log_error(sw->device->monitor->log, - "a2dp codec switch %p: empty reply from dbus, trying next", + "media codec switch %p: empty reply from dbus, trying next", sw); goto next; } if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) { spa_log_debug(sw->device->monitor->log, - "a2dp codec switch %p: failed (%s), trying next", + "media codec switch %p: failed (%s), trying next", sw, dbus_message_get_error_name(r)); dbus_message_unref(r); goto next; @@ -2822,34 +2822,34 @@ static void a2dp_codec_switch_reply(DBusPendingCall *pending, void *user_data) dbus_message_unref(r); /* Success */ - spa_log_info(sw->device->monitor->log, "a2dp codec switch %p: success", sw); + spa_log_info(sw->device->monitor->log, "media codec switch %p: success", sw); spa_bt_device_emit_codec_switched(sw->device, 0); spa_bt_device_check_profiles(sw->device, false); - a2dp_codec_switch_free(sw); + media_codec_switch_free(sw); return; next: if (sw->retries > 0) --sw->retries; else - a2dp_codec_switch_next(sw); + media_codec_switch_next(sw); - a2dp_codec_switch_process(sw); + media_codec_switch_process(sw); return; } -static int a2dp_codec_switch_start_timer(struct spa_bt_a2dp_codec_switch *sw, uint64_t timeout) +static int media_codec_switch_start_timer(struct spa_bt_media_codec_switch *sw, uint64_t timeout) { struct spa_bt_monitor *monitor = sw->device->monitor; struct itimerspec ts; spa_assert(sw->timer.data == NULL); - spa_log_debug(monitor->log, "a2dp codec switch %p: starting rate limit timer", sw); + spa_log_debug(monitor->log, "media codec switch %p: starting rate limit timer", sw); if (sw->timer.data == NULL) { sw->timer.data = sw; - sw->timer.func = a2dp_codec_switch_timer_event; + sw->timer.func = media_codec_switch_timer_event; sw->timer.fd = spa_system_timerfd_create(monitor->main_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); sw->timer.mask = SPA_IO_IN; @@ -2864,7 +2864,7 @@ static int a2dp_codec_switch_start_timer(struct spa_bt_a2dp_codec_switch *sw, ui return 0; } -static int a2dp_codec_switch_stop_timer(struct spa_bt_a2dp_codec_switch *sw) +static int media_codec_switch_stop_timer(struct spa_bt_media_codec_switch *sw) { struct spa_bt_monitor *monitor = sw->device->monitor; struct itimerspec ts; @@ -2872,7 +2872,7 @@ static int a2dp_codec_switch_stop_timer(struct spa_bt_a2dp_codec_switch *sw) if (sw->timer.data == NULL) return 0; - spa_log_debug(monitor->log, "a2dp codec switch %p: stopping rate limit timer", sw); + spa_log_debug(monitor->log, "media codec switch %p: stopping rate limit timer", sw); spa_loop_remove_source(monitor->main_loop, &sw->timer); ts.it_value.tv_sec = 0; @@ -2885,10 +2885,10 @@ static int a2dp_codec_switch_stop_timer(struct spa_bt_a2dp_codec_switch *sw) return 0; } -static int a2dp_codec_switch_cmp(const void *a, const void *b) +static int media_codec_switch_cmp(const void *a, const void *b) { - struct spa_bt_a2dp_codec_switch *sw = a2dp_codec_switch_cmp_sw; - const struct a2dp_codec *codec = *sw->codec_iter; + struct spa_bt_media_codec_switch *sw = media_codec_switch_cmp_sw; + const struct media_codec *codec = *sw->codec_iter; const char *path1 = *(char **)a, *path2 = *(char **)b; struct spa_bt_remote_endpoint *ep1, *ep2; uint32_t flags; @@ -2912,7 +2912,7 @@ static int a2dp_codec_switch_cmp(const void *a, const void *b) else if (ep2 == NULL) return -1; - flags = spa_streq(ep1->uuid, SPA_BT_UUID_A2DP_SOURCE) ? A2DP_CODEC_FLAG_SINK : 0; + flags = spa_streq(ep1->uuid, SPA_BT_UUID_A2DP_SOURCE) ? MEDIA_CODEC_FLAG_SINK : 0; return codec->caps_preference_cmp(codec, flags, ep1->capabilities, ep1->capabilities_len, ep2->capabilities, ep2->capabilities_len, &sw->device->monitor->default_audio_info, @@ -2920,12 +2920,12 @@ static int a2dp_codec_switch_cmp(const void *a, const void *b) } /* Ensure there's a transport for at least one of the listed codecs */ -int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec * const *codecs) +int spa_bt_device_ensure_media_codec(struct spa_bt_device *device, const struct media_codec * const *codecs) { - struct spa_bt_a2dp_codec_switch *sw; + struct spa_bt_media_codec_switch *sw; struct spa_bt_remote_endpoint *ep; struct spa_bt_transport *t; - const struct a2dp_codec *preferred_codec = NULL; + const struct media_codec *preferred_codec = NULL; size_t i, j, num_codecs, num_eps; if (!device->adapter->application_registered) { @@ -2934,7 +2934,7 @@ int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a } for (i = 0; codecs[i] != NULL; ++i) { - if (spa_bt_device_supports_a2dp_codec(device, codecs[i], true)) { + if (spa_bt_device_supports_media_codec(device, codecs[i], true)) { preferred_codec = codecs[i]; break; } @@ -2946,7 +2946,7 @@ int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a */ if (spa_list_is_empty(&device->codec_switch_list) && preferred_codec != NULL) { spa_list_for_each(t, &device->transport_list, device_link) { - if (t->a2dp_codec != preferred_codec) + if (t->media_codec != preferred_codec) continue; if ((device->connected_profiles & t->profile) != t->profile) @@ -2959,7 +2959,7 @@ int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a /* Setup and start iteration */ - sw = calloc(1, sizeof(struct spa_bt_a2dp_codec_switch)); + sw = calloc(1, sizeof(struct spa_bt_media_codec_switch)); if (sw == NULL) return -ENOMEM; @@ -2971,17 +2971,17 @@ int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a while (codecs[num_codecs] != NULL) ++num_codecs; - sw->codecs = calloc(num_codecs + 1, sizeof(const struct a2dp_codec *)); + sw->codecs = calloc(num_codecs + 1, sizeof(const struct media_codec *)); sw->paths = calloc(num_eps + 1, sizeof(char *)); sw->num_paths = num_eps; if (sw->codecs == NULL || sw->paths == NULL) { - a2dp_codec_switch_free(sw); + media_codec_switch_free(sw); return -ENOMEM; } for (i = 0, j = 0; i < num_codecs; ++i) { - if (is_a2dp_codec_enabled(device->monitor, codecs[i])) { + if (is_media_codec_enabled(device->monitor, codecs[i])) { sw->codecs[j] = codecs[i]; ++j; } @@ -2992,7 +2992,7 @@ int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a spa_list_for_each(ep, &device->remote_endpoint_list, device_link) { sw->paths[i] = strdup(ep->path); if (sw->paths[i] == NULL) { - a2dp_codec_switch_free(sw); + media_codec_switch_free(sw); return -ENOMEM; } ++i; @@ -3018,13 +3018,13 @@ int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a * to wait to pass in any case, so we don't cancel it either. */ spa_log_debug(sw->device->monitor->log, - "a2dp codec switch %p: already in progress, canceling previous", + "media codec switch %p: already in progress, canceling previous", sw); spa_list_prepend(&device->codec_switch_list, &sw->device_link); } else { spa_list_prepend(&device->codec_switch_list, &sw->device_link); - a2dp_codec_switch_process(sw); + media_codec_switch_process(sw); } return 0; @@ -3050,7 +3050,7 @@ static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn, DBusMessageIter it[2]; DBusMessage *r; struct spa_bt_transport *transport; - const struct a2dp_codec *codec; + const struct media_codec *codec; int profile; bool sink; @@ -3060,8 +3060,8 @@ static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn, } endpoint = dbus_message_get_path(m); - profile = a2dp_endpoint_to_profile(endpoint); - codec = a2dp_endpoint_to_codec(monitor, endpoint, &sink); + profile = media_endpoint_to_profile(endpoint); + codec = media_endpoint_to_codec(monitor, endpoint, &sink); if (codec == NULL) { spa_log_warn(monitor->log, "unknown SetConfiguration() codec"); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -3102,7 +3102,7 @@ static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn, free(transport->endpoint_path); transport->endpoint_path = strdup(endpoint); transport->profile = profile; - transport->a2dp_codec = codec; + transport->media_codec = codec; transport_update_props(transport, &it[1], NULL); if (transport->device == NULL || transport->device->adapter == NULL) { @@ -3122,7 +3122,7 @@ static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn, if (codec->validate_config) { struct spa_audio_info info; - if (codec->validate_config(codec, sink ? A2DP_CODEC_FLAG_SINK : 0, + if (codec->validate_config(codec, sink ? MEDIA_CODEC_FLAG_SINK : 0, transport->configuration, transport->configuration_len, &info) < 0) { spa_log_error(monitor->log, "invalid transport configuration"); @@ -3304,8 +3304,8 @@ static void append_basic_array_variant_dict_entry(DBusMessageIter *dict, const c static int bluez_register_endpoint(struct spa_bt_monitor *monitor, const char *path, const char *endpoint, - const char *uuid, const struct a2dp_codec *codec) { - char *object_path = NULL; + const char *uuid, const struct media_codec *codec) { + char *object_path = NULL; DBusMessage *m; DBusMessageIter object_it, dict_it; DBusPendingCall *call; @@ -3314,13 +3314,13 @@ static int bluez_register_endpoint(struct spa_bt_monitor *monitor, uint16_t codec_id = codec->codec_id; bool sink; - ret = a2dp_codec_to_endpoint(codec, endpoint, &object_path); + ret = media_codec_to_endpoint(codec, endpoint, &object_path); if (ret < 0) goto error; sink = spa_streq(endpoint, A2DP_SINK_ENDPOINT); - ret = caps_size = codec->fill_caps(codec, sink ? A2DP_CODEC_FLAG_SINK : 0, caps); + ret = caps_size = codec->fill_caps(codec, sink ? MEDIA_CODEC_FLAG_SINK : 0, caps); if (ret < 0) goto error; @@ -3357,8 +3357,8 @@ error: return ret; } -static int register_a2dp_endpoint(struct spa_bt_monitor *monitor, - const struct a2dp_codec *codec, const char *endpoint) +static int register_media_endpoint(struct spa_bt_monitor *monitor, + const struct media_codec *codec, const char *endpoint) { int ret; char* object_path = NULL; @@ -3366,7 +3366,7 @@ static int register_a2dp_endpoint(struct spa_bt_monitor *monitor, .message_function = endpoint_handler, }; - ret = a2dp_codec_to_endpoint(codec, endpoint, &object_path); + ret = media_codec_to_endpoint(codec, endpoint, &object_path); if (ret < 0) return ret; @@ -3387,7 +3387,7 @@ static int register_a2dp_endpoint(struct spa_bt_monitor *monitor, static int adapter_register_endpoints(struct spa_bt_adapter *a) { struct spa_bt_monitor *monitor = a->monitor; - const struct a2dp_codec * const * const a2dp_codecs = monitor->a2dp_codecs; + const struct media_codec * const * const media_codecs = monitor->media_codecs; int i; int err = 0; @@ -3398,15 +3398,15 @@ static int adapter_register_endpoints(struct spa_bt_adapter *a) * It doesn't make sense to register codecs other than SBC * as bluez5 will probably use SBC anyway and we have no control over it * let's incentivize users to upgrade their bluez5 daemon - * if they want proper a2dp codec support + * if they want proper media codec support * */ spa_log_warn(monitor->log, "Using legacy bluez5 API for A2DP - only SBC will be supported. " "Please upgrade bluez5."); - for (i = 0; a2dp_codecs[i]; i++) { - const struct a2dp_codec *codec = a2dp_codecs[i]; + for (i = 0; media_codecs[i]; i++) { + const struct media_codec *codec = media_codecs[i]; - if (!is_a2dp_codec_enabled(monitor, codec)) + if (!is_media_codec_enabled(monitor, codec)) continue; if (!(codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc"))) @@ -3441,7 +3441,7 @@ static int adapter_register_endpoints(struct spa_bt_adapter *a) return err; } -static void append_a2dp_object(DBusMessageIter *iter, const char *endpoint, +static void append_media_object(DBusMessageIter *iter, const char *endpoint, const char *uuid, uint8_t codec_id, uint8_t *caps, size_t caps_size) { const char *interface_name = BLUEZ_MEDIA_ENDPOINT_INTERFACE; @@ -3475,7 +3475,7 @@ static void append_a2dp_object(DBusMessageIter *iter, const char *endpoint, static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage *m, void *user_data) { struct spa_bt_monitor *monitor = user_data; - const struct a2dp_codec * const * const a2dp_codecs = monitor->a2dp_codecs; + const struct media_codec * const * const media_codecs = monitor->media_codecs; const char *path, *interface, *member; char *endpoint; DBusMessage *r; @@ -3509,24 +3509,24 @@ static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage * dbus_message_iter_init_append(r, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{oa{sa{sv}}}", &array); - for (i = 0; a2dp_codecs[i]; i++) { - const struct a2dp_codec *codec = a2dp_codecs[i]; + for (i = 0; media_codecs[i]; i++) { + const struct media_codec *codec = media_codecs[i]; uint8_t caps[A2DP_MAX_CAPS_SIZE]; int caps_size, ret; uint16_t codec_id = codec->codec_id; - if (!is_a2dp_codec_enabled(monitor, codec)) + if (!is_media_codec_enabled(monitor, codec)) continue; if (codec->decode != NULL) { - caps_size = codec->fill_caps(codec, A2DP_CODEC_FLAG_SINK, caps); + caps_size = codec->fill_caps(codec, MEDIA_CODEC_FLAG_SINK, caps); if (caps_size < 0) continue; - ret = a2dp_codec_to_endpoint(codec, A2DP_SINK_ENDPOINT, &endpoint); + ret = media_codec_to_endpoint(codec, A2DP_SINK_ENDPOINT, &endpoint); if (ret == 0) { - spa_log_info(monitor->log, "register A2DP sink codec %s: %s", a2dp_codecs[i]->name, endpoint); - append_a2dp_object(&array, endpoint, SPA_BT_UUID_A2DP_SINK, + spa_log_info(monitor->log, "register media sink codec %s: %s", media_codecs[i]->name, endpoint); + append_media_object(&array, endpoint, SPA_BT_UUID_A2DP_SINK, codec_id, caps, caps_size); free(endpoint); } @@ -3537,10 +3537,10 @@ static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage * if (caps_size < 0) continue; - ret = a2dp_codec_to_endpoint(codec, A2DP_SOURCE_ENDPOINT, &endpoint); + ret = media_codec_to_endpoint(codec, A2DP_SOURCE_ENDPOINT, &endpoint); if (ret == 0) { - spa_log_info(monitor->log, "register A2DP source codec %s: %s", a2dp_codecs[i]->name, endpoint); - append_a2dp_object(&array, endpoint, SPA_BT_UUID_A2DP_SOURCE, + spa_log_info(monitor->log, "register media source codec %s: %s", media_codecs[i]->name, endpoint); + append_media_object(&array, endpoint, SPA_BT_UUID_A2DP_SOURCE, codec_id, caps, caps_size); free(endpoint); } @@ -3593,28 +3593,28 @@ finish: static int register_media_application(struct spa_bt_monitor * monitor) { - const struct a2dp_codec * const * const a2dp_codecs = monitor->a2dp_codecs; + const struct media_codec * const * const media_codecs = monitor->media_codecs; const DBusObjectPathVTable vtable_object_manager = { .message_function = object_manager_handler, }; - spa_log_info(monitor->log, "Registering media application object: " A2DP_OBJECT_MANAGER_PATH); + spa_log_info(monitor->log, "Registering media application object: " MEDIA_OBJECT_MANAGER_PATH); if (!dbus_connection_register_object_path(monitor->conn, - A2DP_OBJECT_MANAGER_PATH, + MEDIA_OBJECT_MANAGER_PATH, &vtable_object_manager, monitor)) return -EIO; - for (int i = 0; a2dp_codecs[i]; i++) { - const struct a2dp_codec *codec = a2dp_codecs[i]; + for (int i = 0; media_codecs[i]; i++) { + const struct media_codec *codec = media_codecs[i]; - if (!is_a2dp_codec_enabled(monitor, codec)) + if (!is_media_codec_enabled(monitor, codec)) continue; if (codec->encode != NULL) - register_a2dp_endpoint(monitor, codec, A2DP_SOURCE_ENDPOINT); + register_media_endpoint(monitor, codec, A2DP_SOURCE_ENDPOINT); if (codec->decode != NULL) - register_a2dp_endpoint(monitor, codec, A2DP_SINK_ENDPOINT); + register_media_endpoint(monitor, codec, A2DP_SINK_ENDPOINT); } return 0; @@ -3622,34 +3622,34 @@ static int register_media_application(struct spa_bt_monitor * monitor) static void unregister_media_application(struct spa_bt_monitor * monitor) { - const struct a2dp_codec * const * const a2dp_codecs = monitor->a2dp_codecs; + const struct media_codec * const * const media_codecs = monitor->media_codecs; int ret; char *object_path = NULL; - for (int i = 0; a2dp_codecs[i]; i++) { - const struct a2dp_codec *codec = a2dp_codecs[i]; + for (int i = 0; media_codecs[i]; i++) { + const struct media_codec *codec = media_codecs[i]; - if (!is_a2dp_codec_enabled(monitor, codec)) + if (!is_media_codec_enabled(monitor, codec)) continue; - ret = a2dp_codec_to_endpoint(codec, A2DP_SOURCE_ENDPOINT, &object_path); + ret = media_codec_to_endpoint(codec, A2DP_SOURCE_ENDPOINT, &object_path); if (ret == 0) { dbus_connection_unregister_object_path(monitor->conn, object_path); free(object_path); } - ret = a2dp_codec_to_endpoint(codec, A2DP_SINK_ENDPOINT, &object_path); + ret = media_codec_to_endpoint(codec, A2DP_SINK_ENDPOINT, &object_path); if (ret == 0) { dbus_connection_unregister_object_path(monitor->conn, object_path); free(object_path); } } - dbus_connection_unregister_object_path(monitor->conn, A2DP_OBJECT_MANAGER_PATH); + dbus_connection_unregister_object_path(monitor->conn, MEDIA_OBJECT_MANAGER_PATH); } static int adapter_register_application(struct spa_bt_adapter *a) { - const char *object_manager_path = A2DP_OBJECT_MANAGER_PATH; + const char *object_manager_path = MEDIA_OBJECT_MANAGER_PATH; struct spa_bt_monitor *monitor = a->monitor; DBusMessage *m; DBusMessageIter i, d; @@ -4361,7 +4361,7 @@ static int impl_clear(struct spa_handle *handle) spa_bt_quirks_destroy(monitor->quirks); - free_a2dp_codecs(monitor->a2dp_codecs); + free_media_codecs(monitor->media_codecs); return 0; } @@ -4405,7 +4405,7 @@ int spa_bt_profiles_from_json_array(const char *str) static int parse_codec_array(struct spa_bt_monitor *this, const struct spa_dict *info) { - const struct a2dp_codec * const * const a2dp_codecs = this->a2dp_codecs; + const struct media_codec * const * const media_codecs = this->media_codecs; const char *str; struct spa_dict_item *codecs; struct spa_json it, it_array; @@ -4416,7 +4416,7 @@ static int parse_codec_array(struct spa_bt_monitor *this, const struct spa_dict /* Parse bluez5.codecs property to a dict of enabled codecs */ num_codecs = 0; - while (a2dp_codecs[num_codecs]) + while (media_codecs[num_codecs]) ++num_codecs; codecs = calloc(num_codecs, sizeof(struct spa_dict_item)); @@ -4438,8 +4438,8 @@ static int parse_codec_array(struct spa_bt_monitor *this, const struct spa_dict while (spa_json_get_string(&it_array, codec_name, sizeof(codec_name)) > 0) { int i; - for (i = 0; a2dp_codecs[i]; ++i) { - const struct a2dp_codec *codec = a2dp_codecs[i]; + for (i = 0; media_codecs[i]; ++i) { + const struct media_codec *codec = media_codecs[i]; if (!spa_streq(codec->name, codec_name)) continue; @@ -4461,16 +4461,16 @@ static int parse_codec_array(struct spa_bt_monitor *this, const struct spa_dict spa_dict_qsort(&this->enabled_codecs); - for (i = 0; a2dp_codecs[i]; ++i) { - const struct a2dp_codec *codec = a2dp_codecs[i]; - if (!is_a2dp_codec_enabled(this, codec)) + for (i = 0; media_codecs[i]; ++i) { + const struct media_codec *codec = media_codecs[i]; + if (!is_media_codec_enabled(this, codec)) spa_log_debug(this->log, "disabling codec %s", codec->name); } return 0; fallback: - for (i = 0; a2dp_codecs[i]; ++i) { - const struct a2dp_codec *codec = a2dp_codecs[i]; + for (i = 0; media_codecs[i]; ++i) { + const struct media_codec *codec = media_codecs[i]; spa_log_debug(this->log, "enabling codec %s", codec->name); codecs[i].key = codec->name; codecs[i].value = "true"; @@ -4536,14 +4536,14 @@ impl_init(const struct spa_handle_factory *factory, return -EINVAL; } - this->a2dp_codecs = NULL; + this->media_codecs = NULL; this->quirks = NULL; this->conn = NULL; this->dbus_connection = NULL; - this->a2dp_codecs = load_a2dp_codecs(this->plugin_loader, this->log); - if (this->a2dp_codecs == NULL) { - spa_log_error(this->log, "failed to load required A2DP codec plugins"); + this->media_codecs = load_media_codecs(this->plugin_loader, this->log); + if (this->media_codecs == NULL) { + spa_log_error(this->log, "failed to load required media codec plugins"); res = -EIO; goto fail; } @@ -4640,15 +4640,15 @@ impl_init(const struct spa_handle_factory *factory, return 0; fail: - if (this->a2dp_codecs) - free_a2dp_codecs(this->a2dp_codecs); + if (this->media_codecs) + free_media_codecs(this->media_codecs); if (this->quirks) spa_bt_quirks_destroy(this->quirks); if (this->conn) dbus_connection_unref(this->conn); if (this->dbus_connection) spa_dbus_connection_destroy(this->dbus_connection); - this->a2dp_codecs = NULL; + this->media_codecs = NULL; this->quirks = NULL; this->conn = NULL; this->dbus_connection = NULL; diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c index 5a23ea440..3e65b1767 100644 --- a/spa/plugins/bluez5/bluez5-device.c +++ b/spa/plugins/bluez5/bluez5-device.c @@ -51,7 +51,7 @@ #include #include "defs.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.device"); #undef SPA_LOG_TOPIC_DEFAULT @@ -140,7 +140,7 @@ struct impl { unsigned int save_profile:1; uint32_t prev_bt_connected_profiles; - const struct a2dp_codec **supported_codecs; + const struct media_codec **supported_codecs; size_t supported_codec_count; struct dynamic_node dyn_a2dp_source; @@ -167,9 +167,9 @@ static void init_node(struct impl *this, struct node *node, uint32_t id) } } -static void get_a2dp_codecs(struct impl *this, enum spa_bluetooth_audio_codec id, const struct a2dp_codec **codecs, size_t size) +static void get_media_codecs(struct impl *this, enum spa_bluetooth_audio_codec id, const struct media_codec **codecs, size_t size) { - const struct a2dp_codec * const *c; + const struct media_codec * const *c; spa_assert(size > 0); spa_assert(this->supported_codecs); @@ -184,18 +184,18 @@ static void get_a2dp_codecs(struct impl *this, enum spa_bluetooth_audio_codec id *codecs = NULL; } -static const struct a2dp_codec *get_supported_a2dp_codec(struct impl *this, enum spa_bluetooth_audio_codec id, size_t *idx) +static const struct media_codec *get_supported_media_codec(struct impl *this, enum spa_bluetooth_audio_codec id, size_t *idx) { - const struct a2dp_codec *a2dp_codec = NULL; + const struct media_codec *media_codec = NULL; size_t i; for (i = 0; i < this->supported_codec_count; ++i) { if (this->supported_codecs[i]->id == id) { - a2dp_codec = this->supported_codecs[i]; + media_codec = this->supported_codecs[i]; if (idx) *idx = i; } } - return a2dp_codec; + return media_codec; } static unsigned int get_hfp_codec(enum spa_bluetooth_audio_codec id) @@ -245,10 +245,10 @@ static const char *get_hfp_codec_name(unsigned int codec) static const char *get_codec_name(struct spa_bt_transport *t, bool a2dp_duplex) { - if (t->a2dp_codec != NULL) { - if (a2dp_duplex && t->a2dp_codec->duplex_codec) - return t->a2dp_codec->duplex_codec->name; - return t->a2dp_codec->name; + if (t->media_codec != NULL) { + if (a2dp_duplex && t->media_codec->duplex_codec) + return t->media_codec->duplex_codec->name; + return t->media_codec->name; } return get_hfp_codec_name(t->codec); } @@ -301,7 +301,7 @@ static void emit_info(struct impl *this, bool full); static float get_soft_volume_boost(struct node *node) { - const struct a2dp_codec *codec = node->transport ? node->transport->a2dp_codec : NULL; + const struct media_codec *codec = node->transport ? node->transport->media_codec : NULL; /* * For A2DP duplex, the duplex microphone channel sometimes does not appear @@ -406,16 +406,16 @@ static const struct spa_bt_transport_events transport_events = { static void get_channels(struct spa_bt_transport *t, bool a2dp_duplex, uint32_t *n_channels, uint32_t *channels) { - const struct a2dp_codec *codec; + const struct media_codec *codec; struct spa_audio_info info = { 0 }; - if (!a2dp_duplex || !t->a2dp_codec || !t->a2dp_codec->duplex_codec) { + if (!a2dp_duplex || !t->media_codec || !t->media_codec->duplex_codec) { *n_channels = t->n_channels; memcpy(channels, t->channels, t->n_channels * sizeof(uint32_t)); return; } - codec = t->a2dp_codec->duplex_codec; + codec = t->media_codec->duplex_codec; if (!codec->validate_config || codec->validate_config(codec, 0, @@ -514,7 +514,7 @@ static struct spa_bt_transport *find_transport(struct impl *this, int profile, e spa_list_for_each(t, &device->transport_list, device_link) { bool codec_ok = codec == 0 || - (t->a2dp_codec != NULL && t->a2dp_codec->id == codec) || + (t->media_codec != NULL && t->media_codec->id == codec) || get_hfp_codec_id(t->codec) == codec; if ((t->profile & device->connected_profiles) && @@ -679,13 +679,13 @@ static int emit_nodes(struct impl *this) if (this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SOURCE) { t = find_transport(this, SPA_BT_PROFILE_A2DP_SOURCE, 0); if (t) { - this->props.codec = t->a2dp_codec->id; + this->props.codec = t->media_codec->id; emit_dynamic_node(&this->dyn_a2dp_source, this, t, - 2, SPA_NAME_API_BLUEZ5_A2DP_SOURCE, false); + 2, SPA_NAME_API_BLUEZ5_MEDIA_SOURCE, false); - if (t->a2dp_codec->duplex_codec) { + if (t->media_codec->duplex_codec) { emit_dynamic_node(&this->dyn_a2dp_sink, this, t, - 3, SPA_NAME_API_BLUEZ5_A2DP_SINK, true); + 3, SPA_NAME_API_BLUEZ5_MEDIA_SINK, true); } } } @@ -694,13 +694,13 @@ static int emit_nodes(struct impl *this) if (this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SOURCE) { t = find_transport(this, SPA_BT_PROFILE_A2DP_SOURCE, 0); if (t) { - this->props.codec = t->a2dp_codec->id; + this->props.codec = t->media_codec->id; emit_dynamic_node(&this->dyn_a2dp_source, this, t, - DEVICE_ID_SOURCE, SPA_NAME_API_BLUEZ5_A2DP_SOURCE, false); + DEVICE_ID_SOURCE, SPA_NAME_API_BLUEZ5_MEDIA_SOURCE, false); - if (t->a2dp_codec->duplex_codec) { + if (t->media_codec->duplex_codec) { emit_node(this, t, - DEVICE_ID_SINK, SPA_NAME_API_BLUEZ5_A2DP_SINK, true); + DEVICE_ID_SINK, SPA_NAME_API_BLUEZ5_MEDIA_SINK, true); } } } @@ -708,17 +708,17 @@ static int emit_nodes(struct impl *this) if (this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SINK) { t = find_transport(this, SPA_BT_PROFILE_A2DP_SINK, this->props.codec); if (t) { - this->props.codec = t->a2dp_codec->id; - emit_node(this, t, DEVICE_ID_SINK, SPA_NAME_API_BLUEZ5_A2DP_SINK, false); + this->props.codec = t->media_codec->id; + emit_node(this, t, DEVICE_ID_SINK, SPA_NAME_API_BLUEZ5_MEDIA_SOURCE, false); - if (t->a2dp_codec->duplex_codec) { + if (t->media_codec->duplex_codec) { emit_node(this, t, - DEVICE_ID_SOURCE, SPA_NAME_API_BLUEZ5_A2DP_SOURCE, true); + DEVICE_ID_SOURCE, SPA_NAME_API_BLUEZ5_MEDIA_SINK, true); } } } - if (get_supported_a2dp_codec(this, this->props.codec, NULL) == NULL) + if (get_supported_media_codec(this, this->props.codec, NULL) == NULL) this->props.codec = 0; break; case DEVICE_PROFILE_HSP_HFP: @@ -818,13 +818,13 @@ static int set_profile(struct impl *this, uint32_t profile, enum spa_bluetooth_a */ if (profile == DEVICE_PROFILE_A2DP && !(this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SOURCE)) { int ret; - const struct a2dp_codec *codecs[64]; + const struct media_codec *codecs[64]; - get_a2dp_codecs(this, codec, codecs, SPA_N_ELEMENTS(codecs)); + get_media_codecs(this, codec, codecs, SPA_N_ELEMENTS(codecs)); this->switching_codec = true; - ret = spa_bt_device_ensure_a2dp_codec(this->bt_dev, codecs); + ret = spa_bt_device_ensure_media_codec(this->bt_dev, codecs); if (ret < 0) { if (ret != -ENOTSUP) spa_log_error(this->log, "failed to switch codec (%d), setting basic profile", ret); @@ -914,7 +914,7 @@ static void profiles_changed(void *userdata, uint32_t prev_profiles, uint32_t pr if (this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SINK) { free(this->supported_codecs); - this->supported_codecs = spa_bt_device_get_supported_a2dp_codecs( + this->supported_codecs = spa_bt_device_get_supported_media_codecs( this->bt_dev, &this->supported_codec_count, true); } @@ -930,7 +930,7 @@ static void profiles_changed(void *userdata, uint32_t prev_profiles, uint32_t pr nodes_changed); break; case DEVICE_PROFILE_A2DP: - if (get_supported_a2dp_codec(this, this->props.codec, NULL) == NULL) + if (get_supported_media_codec(this, this->props.codec, NULL) == NULL) this->props.codec = 0; nodes_changed = (connected_change & (SPA_BT_PROFILE_A2DP_SINK | SPA_BT_PROFILE_A2DP_SOURCE)); @@ -1019,15 +1019,15 @@ static uint32_t profile_direction_mask(struct impl *this, uint32_t index, enum s struct spa_bt_device *device = this->bt_dev; uint32_t mask; bool have_output = false, have_input = false; - const struct a2dp_codec *a2dp_codec; + const struct media_codec *media_codec; switch (index) { case DEVICE_PROFILE_A2DP: if (device->connected_profiles & SPA_BT_PROFILE_A2DP_SINK) have_output = true; - a2dp_codec = get_supported_a2dp_codec(this, codec, NULL); - if (a2dp_codec && a2dp_codec->duplex_codec) + media_codec = get_supported_media_codec(this, codec, NULL); + if (media_codec && media_codec->duplex_codec) have_input = true; break; case DEVICE_PROFILE_HSP_HFP: @@ -1129,7 +1129,7 @@ static void set_initial_profile(struct impl *this) if (this->supported_codecs) free(this->supported_codecs); - this->supported_codecs = spa_bt_device_get_supported_a2dp_codecs( + this->supported_codecs = spa_bt_device_get_supported_media_codecs( this->bt_dev, &this->supported_codec_count, true); /* Prefer A2DP, then HFP, then null, but select AG if the device @@ -1152,7 +1152,7 @@ static void set_initial_profile(struct impl *this) if (t) { this->profile = (i == SPA_BT_PROFILE_A2DP_SOURCE) ? DEVICE_PROFILE_AG : DEVICE_PROFILE_A2DP; - this->props.codec = t->a2dp_codec->id; + this->props.codec = t->media_codec->id; spa_log_debug(this->log, "initial profile A2DP profile:%d codec:%d", this->profile, this->props.codec); return; @@ -1213,19 +1213,19 @@ static struct spa_pod *build_profile(struct impl *this, struct spa_pod_builder * n_sink++; if (codec) { size_t idx; - const struct a2dp_codec *a2dp_codec = get_supported_a2dp_codec(this, codec, &idx); - if (a2dp_codec == NULL) { + const struct media_codec *media_codec = get_supported_media_codec(this, codec, &idx); + if (media_codec == NULL) { errno = EINVAL; return NULL; } - name_and_codec = spa_aprintf("%s-%s", name, a2dp_codec->name); + name_and_codec = spa_aprintf("%s-%s", name, media_codec->name); name = name_and_codec; - if (profile == SPA_BT_PROFILE_A2DP_SINK && !a2dp_codec->duplex_codec) { + if (profile == SPA_BT_PROFILE_A2DP_SINK && !media_codec->duplex_codec) { desc_and_codec = spa_aprintf(_("High Fidelity Playback (A2DP Sink, codec %s)"), - a2dp_codec->description); + media_codec->description); } else { desc_and_codec = spa_aprintf(_("High Fidelity Duplex (A2DP Source/Sink, codec %s)"), - a2dp_codec->description); + media_codec->description); } desc = desc_and_codec; @@ -1560,7 +1560,7 @@ static struct spa_pod *build_route(struct impl *this, struct spa_pod_builder *b, return spa_pod_builder_pop(b, &f[0]); } -static bool iterate_supported_a2dp_codecs(struct impl *this, int *j, const struct a2dp_codec **codec) +static bool iterate_supported_media_codecs(struct impl *this, int *j, const struct media_codec **codec) { int i; @@ -1582,12 +1582,12 @@ static struct spa_pod *build_prop_info(struct impl *this, struct spa_pod_builder { struct spa_pod_frame f[2]; struct spa_pod_choice *choice; - const struct a2dp_codec *codec; + const struct media_codec *codec; size_t n; int j; #define FOR_EACH_A2DP_CODEC(j, codec) \ - for (j = -1; iterate_supported_a2dp_codecs(this, &j, &codec);) + for (j = -1; iterate_supported_media_codecs(this, &j, &codec);) #define FOR_EACH_HFP_CODEC(j) \ for (j = HFP_AUDIO_CODEC_MSBC; j >= HFP_AUDIO_CODEC_CVSD; --j) \ if (spa_bt_device_supports_hfp_codec(this->bt_dev, j) == 1) diff --git a/spa/plugins/bluez5/codec-loader.c b/spa/plugins/bluez5/codec-loader.c index 172c42309..9370f546e 100644 --- a/spa/plugins/bluez5/codec-loader.c +++ b/spa/plugins/bluez5/codec-loader.c @@ -29,7 +29,7 @@ #include "defs.h" #include "codec-loader.h" -#define A2DP_CODEC_LIB_BASE "bluez5/libspa-codec-bluez5-" +#define MEDIA_CODEC_LIB_BASE "bluez5/libspa-codec-bluez5-" /* AVDTP allows 0x3E endpoints, can't have more codecs than that */ #define MAX_CODECS 0x3E @@ -40,7 +40,7 @@ static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.codecs"); #define SPA_LOG_TOPIC_DEFAULT &log_topic struct impl { - const struct a2dp_codec *codecs[MAX_CODECS + 1]; + const struct media_codec *codecs[MAX_CODECS + 1]; struct spa_handle *handles[MAX_HANDLES]; size_t n_codecs; size_t n_handles; @@ -48,7 +48,7 @@ struct impl { struct spa_log *log; }; -static int codec_order(const struct a2dp_codec *c) +static int codec_order(const struct media_codec *c) { static const enum spa_bluetooth_audio_codec order[] = { SPA_BLUETOOTH_AUDIO_CODEC_LDAC, @@ -78,8 +78,8 @@ static int codec_order(const struct a2dp_codec *c) static int codec_order_cmp(const void *a, const void *b) { - const struct a2dp_codec * const *ca = a; - const struct a2dp_codec * const *cb = b; + const struct media_codec * const *ca = a; + const struct media_codec * const *cb = b; int ia = codec_order(*ca); int ib = codec_order(*cb); if (*ca == *cb) @@ -87,7 +87,7 @@ static int codec_order_cmp(const void *a, const void *b) return (ia == ib) ? (*ca < *cb ? -1 : 1) : ia - ib; } -static int load_a2dp_codecs_from(struct impl *impl, const char *factory_name, const char *libname) +static int load_media_codecs_from(struct impl *impl, const char *factory_name, const char *libname) { struct spa_handle *handle = NULL; void *iface; @@ -108,7 +108,7 @@ static int load_a2dp_codecs_from(struct impl *impl, const char *factory_name, co spa_log_debug(impl->log, "loading codecs from %s", factory_name); - if ((res = spa_handle_get_interface(handle, SPA_TYPE_INTERFACE_Bluez5CodecA2DP, &iface)) < 0) { + if ((res = spa_handle_get_interface(handle, SPA_TYPE_INTERFACE_Bluez5CodecMedia, &iface)) < 0) { spa_log_warn(impl->log, "Bluetooth codec plugin %s has no codec interface", factory_name); goto fail; @@ -116,15 +116,15 @@ static int load_a2dp_codecs_from(struct impl *impl, const char *factory_name, co bluez5_codec_a2dp = iface; - if (bluez5_codec_a2dp->iface.version != SPA_VERSION_BLUEZ5_CODEC_A2DP) { + if (bluez5_codec_a2dp->iface.version != SPA_VERSION_BLUEZ5_CODEC_MEDIA) { spa_log_warn(impl->log, "codec plugin %s has incompatible ABI version (%d != %d)", - factory_name, bluez5_codec_a2dp->iface.version, SPA_VERSION_BLUEZ5_CODEC_A2DP); + factory_name, bluez5_codec_a2dp->iface.version, SPA_VERSION_BLUEZ5_CODEC_MEDIA); res = -ENOENT; goto fail; } for (i = 0; bluez5_codec_a2dp->codecs[i]; ++i) { - const struct a2dp_codec *c = bluez5_codec_a2dp->codecs[i]; + const struct media_codec *c = bluez5_codec_a2dp->codecs[i]; size_t j; if (impl->n_codecs >= MAX_CODECS) { @@ -134,14 +134,14 @@ static int load_a2dp_codecs_from(struct impl *impl, const char *factory_name, co /* Don't load duplicate endpoints */ for (j = 0; j < impl->n_codecs; ++j) { - const struct a2dp_codec *c2 = impl->codecs[j]; + const struct media_codec *c2 = impl->codecs[j]; const char *ep1 = c->endpoint_name ? c->endpoint_name : c->name; const char *ep2 = c2->endpoint_name ? c2->endpoint_name : c2->name; if (spa_streq(ep1, ep2)) goto next_codec; } - spa_log_debug(impl->log, "loaded A2DP codec %s from %s", c->name, factory_name); + spa_log_debug(impl->log, "loaded media codec %s from %s", c->name, factory_name); if (c->set_log) c->set_log(impl->log); @@ -166,22 +166,22 @@ fail: return res; } -const struct a2dp_codec * const *load_a2dp_codecs(struct spa_plugin_loader *loader, struct spa_log *log) +const struct media_codec * const *load_media_codecs(struct spa_plugin_loader *loader, struct spa_log *log) { struct impl *impl; bool has_sbc; size_t i; const struct { const char *factory; const char *lib; } plugins[] = { -#define A2DP_CODEC_FACTORY_LIB(basename) \ - { A2DP_CODEC_FACTORY_NAME(basename), A2DP_CODEC_LIB_BASE basename } - A2DP_CODEC_FACTORY_LIB("aac"), - A2DP_CODEC_FACTORY_LIB("aptx"), - A2DP_CODEC_FACTORY_LIB("faststream"), - A2DP_CODEC_FACTORY_LIB("ldac"), - A2DP_CODEC_FACTORY_LIB("sbc"), - A2DP_CODEC_FACTORY_LIB("lc3plus"), - A2DP_CODEC_FACTORY_LIB("opus") -#undef A2DP_CODEC_FACTORY_LIB +#define MEDIA_CODEC_FACTORY_LIB(basename) \ + { MEDIA_CODEC_FACTORY_NAME(basename), MEDIA_CODEC_LIB_BASE basename } + MEDIA_CODEC_FACTORY_LIB("aac"), + MEDIA_CODEC_FACTORY_LIB("aptx"), + MEDIA_CODEC_FACTORY_LIB("faststream"), + MEDIA_CODEC_FACTORY_LIB("ldac"), + MEDIA_CODEC_FACTORY_LIB("sbc"), + MEDIA_CODEC_FACTORY_LIB("lc3plus"), + MEDIA_CODEC_FACTORY_LIB("opus") +#undef MEDIA_CODEC_FACTORY_LIB }; impl = calloc(sizeof(struct impl), 1); @@ -194,7 +194,7 @@ const struct a2dp_codec * const *load_a2dp_codecs(struct spa_plugin_loader *load spa_log_topic_init(impl->log, &log_topic); for (i = 0; i < SPA_N_ELEMENTS(plugins); ++i) - load_a2dp_codecs_from(impl, plugins[i].factory, plugins[i].lib); + load_media_codecs_from(impl, plugins[i].factory, plugins[i].lib); has_sbc = false; for (i = 0; i < impl->n_codecs; ++i) @@ -203,19 +203,19 @@ const struct a2dp_codec * const *load_a2dp_codecs(struct spa_plugin_loader *load if (!has_sbc) { spa_log_error(impl->log, "failed to load A2DP SBC codec from plugins"); - free_a2dp_codecs(impl->codecs); + free_media_codecs(impl->codecs); errno = ENOENT; return NULL; } - qsort(impl->codecs, impl->n_codecs, sizeof(const struct a2dp_codec *), codec_order_cmp); + qsort(impl->codecs, impl->n_codecs, sizeof(const struct media_codec *), codec_order_cmp); return impl->codecs; } -void free_a2dp_codecs(const struct a2dp_codec * const *a2dp_codecs) +void free_media_codecs(const struct media_codec * const *media_codecs) { - struct impl *impl = SPA_CONTAINER_OF(a2dp_codecs, struct impl, codecs); + struct impl *impl = SPA_CONTAINER_OF(media_codecs, struct impl, codecs); size_t i; for (i = 0; i < impl->n_handles; ++i) diff --git a/spa/plugins/bluez5/codec-loader.h b/spa/plugins/bluez5/codec-loader.h index 5422cc458..b77d9c49f 100644 --- a/spa/plugins/bluez5/codec-loader.h +++ b/spa/plugins/bluez5/codec-loader.h @@ -31,9 +31,9 @@ #include #include "a2dp-codec-caps.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" -const struct a2dp_codec * const *load_a2dp_codecs(struct spa_plugin_loader *loader, struct spa_log *log); -void free_a2dp_codecs(const struct a2dp_codec * const *a2dp_codecs); +const struct media_codec * const *load_media_codecs(struct spa_plugin_loader *loader, struct spa_log *log); +void free_media_codecs(const struct media_codec * const *media_codecs); #endif diff --git a/spa/plugins/bluez5/defs.h b/spa/plugins/bluez5/defs.h index 90348afa0..6acd479da 100644 --- a/spa/plugins/bluez5/defs.h +++ b/spa/plugins/bluez5/defs.h @@ -158,9 +158,9 @@ extern "C" { #define HFP_AUDIO_CODEC_CVSD 0x01 #define HFP_AUDIO_CODEC_MSBC 0x02 -#define A2DP_OBJECT_MANAGER_PATH "/MediaEndpoint" -#define A2DP_SINK_ENDPOINT A2DP_OBJECT_MANAGER_PATH "/A2DPSink" -#define A2DP_SOURCE_ENDPOINT A2DP_OBJECT_MANAGER_PATH "/A2DPSource" +#define MEDIA_OBJECT_MANAGER_PATH "/MediaEndpoint" +#define A2DP_SINK_ENDPOINT MEDIA_OBJECT_MANAGER_PATH "/A2DPSink" +#define A2DP_SOURCE_ENDPOINT MEDIA_OBJECT_MANAGER_PATH "/A2DPSource" #define SPA_BT_UNKNOWN_DELAY 0 @@ -412,7 +412,7 @@ static inline enum spa_bt_form_factor spa_bt_form_factor_from_class(uint32_t blu return SPA_BT_FORM_FACTOR_UNKNOWN; } -struct spa_bt_a2dp_codec_switch; +struct spa_bt_media_codec_switch; struct spa_bt_transport; struct spa_bt_device_events { @@ -482,16 +482,16 @@ struct spa_bt_device { DBusPendingCall *battery_pending_call; }; -struct a2dp_codec; +struct media_codec; struct spa_bt_device *spa_bt_device_find(struct spa_bt_monitor *monitor, const char *path); struct spa_bt_device *spa_bt_device_find_by_address(struct spa_bt_monitor *monitor, const char *remote_address, const char *local_address); int spa_bt_device_add_profile(struct spa_bt_device *device, enum spa_bt_profile profile); int spa_bt_device_connect_profile(struct spa_bt_device *device, enum spa_bt_profile profile); int spa_bt_device_check_profiles(struct spa_bt_device *device, bool force); -int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec * const *codecs); -bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec *codec, bool sink); -const struct a2dp_codec **spa_bt_device_get_supported_a2dp_codecs(struct spa_bt_device *device, size_t *count, bool sink); +int spa_bt_device_ensure_media_codec(struct spa_bt_device *device, const struct media_codec * const *codecs); +bool spa_bt_device_supports_media_codec(struct spa_bt_device *device, const struct media_codec *codec, bool sink); +const struct media_codec **spa_bt_device_get_supported_media_codecs(struct spa_bt_device *device, size_t *count, bool sink); int spa_bt_device_ensure_hfp_codec(struct spa_bt_device *device, unsigned int codec); int spa_bt_device_supports_hfp_codec(struct spa_bt_device *device, unsigned int codec); int spa_bt_device_release_transports(struct spa_bt_device *device); @@ -570,7 +570,7 @@ struct spa_bt_transport { struct spa_list device_link; enum spa_bt_profile profile; enum spa_bt_transport_state state; - const struct a2dp_codec *a2dp_codec; + const struct media_codec *media_codec; unsigned int codec; void *configuration; int configuration_len; diff --git a/spa/plugins/bluez5/a2dp-codecs.c b/spa/plugins/bluez5/media-codecs.c similarity index 89% rename from spa/plugins/bluez5/a2dp-codecs.c rename to spa/plugins/bluez5/media-codecs.c index 42c7a193c..6f64e82e4 100644 --- a/spa/plugins/bluez5/a2dp-codecs.c +++ b/spa/plugins/bluez5/media-codecs.c @@ -10,9 +10,9 @@ #include -#include "a2dp-codecs.h" +#include "media-codecs.h" -int a2dp_codec_select_config(const struct a2dp_codec_config configs[], size_t n, +int media_codec_select_config(const struct media_codec_config configs[], size_t n, uint32_t cap, int preferred_value) { size_t i; @@ -60,9 +60,9 @@ int a2dp_codec_select_config(const struct a2dp_codec_config configs[], size_t n, return res; } -bool a2dp_codec_check_caps(const struct a2dp_codec *codec, unsigned int codec_id, +bool media_codec_check_caps(const struct media_codec *codec, unsigned int codec_id, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *global_settings) { uint8_t config[A2DP_MAX_CAPS_SIZE]; @@ -98,7 +98,7 @@ impl_get_interface(struct spa_handle *handle, const char *type, void **interface this = (struct impl *) handle; - if (spa_streq(type, SPA_TYPE_INTERFACE_Bluez5CodecA2DP)) + if (spa_streq(type, SPA_TYPE_INTERFACE_Bluez5CodecMedia)) *interface = &this->bluez5_codec_a2dp; else return -ENOENT; @@ -136,10 +136,10 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; - this->bluez5_codec_a2dp.codecs = codec_plugin_a2dp_codecs; + this->bluez5_codec_a2dp.codecs = codec_plugin_media_codecs; this->bluez5_codec_a2dp.iface = SPA_INTERFACE_INIT( - SPA_TYPE_INTERFACE_Bluez5CodecA2DP, - SPA_VERSION_BLUEZ5_CODEC_A2DP, + SPA_TYPE_INTERFACE_Bluez5CodecMedia, + SPA_VERSION_BLUEZ5_CODEC_MEDIA, NULL, this); @@ -147,7 +147,7 @@ impl_init(const struct spa_handle_factory *factory, } static const struct spa_interface_info impl_interfaces[] = { - {SPA_TYPE_INTERFACE_Bluez5CodecA2DP,}, + {SPA_TYPE_INTERFACE_Bluez5CodecMedia,}, }; static int diff --git a/spa/plugins/bluez5/a2dp-codecs.h b/spa/plugins/bluez5/media-codecs.h similarity index 68% rename from spa/plugins/bluez5/a2dp-codecs.h rename to spa/plugins/bluez5/media-codecs.h index 7fb5cd510..bb7273dfa 100644 --- a/spa/plugins/bluez5/a2dp-codecs.h +++ b/spa/plugins/bluez5/media-codecs.h @@ -42,28 +42,28 @@ * when any of the structs or semantics change. */ -#define SPA_TYPE_INTERFACE_Bluez5CodecA2DP SPA_TYPE_INFO_INTERFACE_BASE "Bluez5:Codec:A2DP:Private" +#define SPA_TYPE_INTERFACE_Bluez5CodecMedia SPA_TYPE_INFO_INTERFACE_BASE "Bluez5:Codec:Media:Private" -#define SPA_VERSION_BLUEZ5_CODEC_A2DP 5 +#define SPA_VERSION_BLUEZ5_CODEC_MEDIA 5 struct spa_bluez5_codec_a2dp { struct spa_interface iface; - const struct a2dp_codec * const *codecs; /**< NULL terminated array */ + const struct media_codec * const *codecs; /**< NULL terminated array */ }; -#define A2DP_CODEC_FACTORY_NAME(basename) (SPA_NAME_API_CODEC_BLUEZ5_A2DP "." basename) +#define MEDIA_CODEC_FACTORY_NAME(basename) (SPA_NAME_API_CODEC_BLUEZ5_MEDIA "." basename) #ifdef CODEC_PLUGIN -#define A2DP_CODEC_EXPORT_DEF(basename,...) \ - const char *codec_plugin_factory_name = A2DP_CODEC_FACTORY_NAME(basename); \ - static const struct a2dp_codec * const codec_plugin_a2dp_codec_list[] = { __VA_ARGS__, NULL }; \ - const struct a2dp_codec * const * const codec_plugin_a2dp_codecs = codec_plugin_a2dp_codec_list; +#define MEDIA_CODEC_EXPORT_DEF(basename,...) \ + const char *codec_plugin_factory_name = MEDIA_CODEC_FACTORY_NAME(basename); \ + static const struct media_codec * const codec_plugin_media_codec_list[] = { __VA_ARGS__, NULL }; \ + const struct media_codec * const * const codec_plugin_media_codecs = codec_plugin_media_codec_list; -extern const struct a2dp_codec * const * const codec_plugin_a2dp_codecs; +extern const struct media_codec * const * const codec_plugin_media_codecs; extern const char *codec_plugin_factory_name; #endif -#define A2DP_CODEC_FLAG_SINK (1 << 0) +#define MEDIA_CODEC_FLAG_SINK (1 << 0) #define A2DP_CODEC_DEFAULT_RATE 48000 #define A2DP_CODEC_DEFAULT_CHANNELS 2 @@ -74,12 +74,12 @@ enum { NEED_FLUSH_FRAGMENT = 2, }; -struct a2dp_codec_audio_info { +struct media_codec_audio_info { uint32_t rate; uint32_t channels; }; -struct a2dp_codec { +struct media_codec { enum spa_bluetooth_audio_codec id; uint8_t codec_id; a2dp_vendor_codec_t vendor; @@ -91,18 +91,20 @@ struct a2dp_codec { const size_t send_buf_size; - const struct a2dp_codec *duplex_codec; /**< Codec for non-standard A2DP duplex channel */ + const struct media_codec *duplex_codec; /**< Codec for non-standard A2DP duplex channel */ - int (*fill_caps) (const struct a2dp_codec *codec, uint32_t flags, + struct spa_log *log; + + int (*fill_caps) (const struct media_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]); - int (*select_config) (const struct a2dp_codec *codec, uint32_t flags, + int (*select_config) (const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, - const struct a2dp_codec_audio_info *info, + const struct media_codec_audio_info *info, const struct spa_dict *global_settings, uint8_t config[A2DP_MAX_CAPS_SIZE]); - int (*enum_config) (const struct a2dp_codec *codec, uint32_t flags, + int (*enum_config) (const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, uint32_t id, uint32_t idx, struct spa_pod_builder *builder, struct spa_pod **param); - int (*validate_config) (const struct a2dp_codec *codec, uint32_t flags, + int (*validate_config) (const struct media_codec *codec, uint32_t flags, const void *caps, size_t caps_size, struct spa_audio_info *info); @@ -111,17 +113,17 @@ struct a2dp_codec { * The caps handed in correspond to this codec_id, but are * otherwise not checked beforehand. */ - int (*caps_preference_cmp) (const struct a2dp_codec *codec, uint32_t flags, const void *caps1, size_t caps1_size, - const void *caps2, size_t caps2_size, const struct a2dp_codec_audio_info *info, + int (*caps_preference_cmp) (const struct media_codec *codec, uint32_t flags, const void *caps1, size_t caps1_size, + const void *caps2, size_t caps2_size, const struct media_codec_audio_info *info, const struct spa_dict *global_settings); - void *(*init_props) (const struct a2dp_codec *codec, uint32_t flags, const struct spa_dict *settings); + void *(*init_props) (const struct media_codec *codec, uint32_t flags, const struct spa_dict *settings); void (*clear_props) (void *); int (*enum_props) (void *props, const struct spa_dict *settings, uint32_t id, uint32_t idx, struct spa_pod_builder *builder, struct spa_pod **param); int (*set_props) (void *props, const struct spa_pod *param); - void *(*init) (const struct a2dp_codec *codec, uint32_t flags, void *config, size_t config_size, + void *(*init) (const struct media_codec *codec, uint32_t flags, void *config, size_t config_size, const struct spa_audio_info *info, void *props, size_t mtu); void (*deinit) (void *data); @@ -151,17 +153,17 @@ struct a2dp_codec { void (*set_log) (struct spa_log *global_log); }; -struct a2dp_codec_config { +struct media_codec_config { uint32_t config; int value; unsigned int priority; }; -int a2dp_codec_select_config(const struct a2dp_codec_config configs[], size_t n, +int media_codec_select_config(const struct media_codec_config configs[], size_t n, uint32_t cap, int preferred_value); -bool a2dp_codec_check_caps(const struct a2dp_codec *codec, unsigned int codec_id, - const void *caps, size_t caps_size, const struct a2dp_codec_audio_info *info, +bool media_codec_check_caps(const struct media_codec *codec, unsigned int codec_id, + const void *caps, size_t caps_size, const struct media_codec_audio_info *info, const struct spa_dict *global_settings); #endif diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/media-sink.c similarity index 97% rename from spa/plugins/bluez5/a2dp-sink.c rename to spa/plugins/bluez5/media-sink.c index 9d712d815..e90659f59 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/media-sink.c @@ -1,4 +1,4 @@ -/* Spa A2DP Sink +/* Spa Media Sink * * Copyright © 2018 Wim Taymans * @@ -53,9 +53,9 @@ #include "defs.h" #include "rtp.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" -static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.sink.a2dp"); +static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.sink.media"); #undef SPA_LOG_TOPIC_DEFAULT #define SPA_LOG_TOPIC_DEFAULT &log_topic @@ -152,7 +152,7 @@ struct impl { uint64_t next_time; uint64_t last_error; - const struct a2dp_codec *codec; + const struct media_codec *codec; bool codec_props_changed; void *codec_props; void *codec_data; @@ -788,7 +788,7 @@ again: return 0; } -static void a2dp_on_flush(struct spa_source *source) +static void media_on_flush(struct spa_source *source) { struct impl *this = source->data; @@ -809,7 +809,7 @@ static void a2dp_on_flush(struct spa_source *source) flush_data(this, this->current_time); } -static void a2dp_on_flush_timeout(struct spa_source *source) +static void media_on_flush_timeout(struct spa_source *source) { struct impl *this = source->data; uint64_t exp; @@ -827,7 +827,7 @@ static void a2dp_on_flush_timeout(struct spa_source *source) flush_data(this, this->current_time); } -static void a2dp_on_timeout(struct spa_source *source) +static void media_on_timeout(struct spa_source *source) { struct impl *this = source->data; struct port *port = &this->port; @@ -897,7 +897,7 @@ static int do_start(struct impl *this) this->following = is_following(this); - spa_log_debug(this->log, "%p: start following:%d", this, this->following); + spa_log_debug(this->log, "%p: start following:%d", this, this->following); if ((res = spa_bt_transport_acquire(this->transport, false)) < 0) return res; @@ -911,7 +911,7 @@ static int do_start(struct impl *this) spa_log_hexdump(this->log, SPA_LOG_LEVEL_DEBUG, 2, conf, (size_t)size); this->codec_data = this->codec->init(this->codec, - this->is_duplex ? A2DP_CODEC_FLAG_SINK : 0, + this->is_duplex ? MEDIA_CODEC_FLAG_SINK : 0, this->transport->configuration, this->transport->configuration_len, &port->current_format, @@ -920,8 +920,8 @@ static int do_start(struct impl *this) if (this->codec_data == NULL) return -EIO; - spa_log_info(this->log, "%p: using A2DP codec %s, delay:%"PRIi64" ms", this, this->codec->description, - (int64_t)(spa_bt_transport_get_delay_nsec(this->transport) / SPA_NSEC_PER_MSEC)); + spa_log_info(this->log, "%p: using A2DP codec %s, delay:%"PRIi64" ms", this, this->codec->description, + (int64_t)(spa_bt_transport_get_delay_nsec(this->transport) / SPA_NSEC_PER_MSEC)); this->seqnum = 0; @@ -932,8 +932,7 @@ static int do_start(struct impl *this) return -EIO; } - spa_log_debug(this->log, "%p: block_size %d", this, - this->block_size); + spa_log_debug(this->log, "%p: block_size %d", this, this->block_size); val = this->codec->send_buf_size > 0 /* The kernel doubles the SO_SNDBUF option value set by setsockopt(). */ @@ -963,21 +962,21 @@ static int do_start(struct impl *this) this->source.data = this; this->source.fd = this->timerfd; - this->source.func = a2dp_on_timeout; + this->source.func = media_on_timeout; this->source.mask = SPA_IO_IN; this->source.rmask = 0; spa_loop_add_source(this->data_loop, &this->source); this->flush_timer_source.data = this; this->flush_timer_source.fd = this->flush_timerfd; - this->flush_timer_source.func = a2dp_on_flush_timeout; + this->flush_timer_source.func = media_on_flush_timeout; this->flush_timer_source.mask = SPA_IO_IN; this->flush_timer_source.rmask = 0; spa_loop_add_source(this->data_loop, &this->flush_timer_source); this->flush_source.data = this; this->flush_source.fd = this->transport->fd; - this->flush_source.func = a2dp_on_flush; + this->flush_source.func = media_on_flush; this->flush_source.mask = 0; this->flush_source.rmask = 0; spa_loop_add_source(this->data_loop, &this->flush_source); @@ -1198,7 +1197,7 @@ impl_node_port_enum_params(void *object, int seq, return -EIO; if ((res = this->codec->enum_config(this->codec, - this->is_duplex ? A2DP_CODEC_FLAG_SINK : 0, + this->is_duplex ? MEDIA_CODEC_FLAG_SINK : 0, this->transport->configuration, this->transport->configuration_len, id, result.index, &b, ¶m)) != 1) @@ -1711,12 +1710,12 @@ impl_init(const struct spa_handle_factory *factory, spa_log_error(this->log, "a transport is needed"); return -EINVAL; } - if (this->transport->a2dp_codec == NULL) { + if (this->transport->media_codec == NULL) { spa_log_error(this->log, "a transport codec is needed"); return -EINVAL; } - this->codec = this->transport->a2dp_codec; + this->codec = this->transport->media_codec; if (this->is_duplex) { if (!this->codec->duplex_codec) { @@ -1728,7 +1727,7 @@ impl_init(const struct spa_handle_factory *factory, if (this->codec->init_props != NULL) this->codec_props = this->codec->init_props(this->codec, - this->is_duplex ? A2DP_CODEC_FLAG_SINK : 0, + this->is_duplex ? MEDIA_CODEC_FLAG_SINK : 0, this->transport->device->settings); reset_props(this, &this->props); @@ -1770,15 +1769,15 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, static const struct spa_dict_item info_items[] = { { SPA_KEY_FACTORY_AUTHOR, "Wim Taymans " }, - { SPA_KEY_FACTORY_DESCRIPTION, "Play audio with the a2dp" }, + { SPA_KEY_FACTORY_DESCRIPTION, "Play audio with the media" }, { SPA_KEY_FACTORY_USAGE, SPA_KEY_API_BLUEZ5_TRANSPORT"=" }, }; static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); -const struct spa_handle_factory spa_a2dp_sink_factory = { +const struct spa_handle_factory spa_media_sink_factory = { SPA_VERSION_HANDLE_FACTORY, - SPA_NAME_API_BLUEZ5_A2DP_SINK, + SPA_NAME_API_BLUEZ5_MEDIA_SINK, &info, impl_get_size, impl_init, diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/media-source.c similarity index 97% rename from spa/plugins/bluez5/a2dp-source.c rename to spa/plugins/bluez5/media-source.c index 0082b9d1e..970ac31b4 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/media-source.c @@ -1,4 +1,4 @@ -/* Spa A2DP Source +/* Spa Media Source * * Copyright © 2018 Wim Taymans * Copyright © 2019 Collabora Ltd. @@ -54,9 +54,9 @@ #include "defs.h" #include "rtp.h" -#include "a2dp-codecs.h" +#include "media-codecs.h" -static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.source.a2dp"); +static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.source.media"); #undef SPA_LOG_TOPIC_DEFAULT #define SPA_LOG_TOPIC_DEFAULT &log_topic @@ -156,7 +156,7 @@ struct impl { uint64_t current_time; uint64_t next_time; - const struct a2dp_codec *codec; + const struct media_codec *codec; bool codec_props_changed; void *codec_props; void *codec_data; @@ -448,7 +448,7 @@ static int32_t decode_data(struct impl *this, uint8_t *src, uint32_t src_size, return dst_size - avail; } -static void a2dp_on_ready_read(struct spa_source *source) +static void media_on_ready_read(struct spa_source *source) { struct impl *this = source->data; struct port *port = &this->port; @@ -533,7 +533,7 @@ static int set_duplex_timeout(struct impl *this, uint64_t timeout) this->duplex_timerfd, 0, &ts, NULL); } -static void a2dp_on_duplex_timeout(struct spa_source *source) +static void media_on_duplex_timeout(struct spa_source *source) { struct impl *this = source->data; uint64_t exp; @@ -543,7 +543,7 @@ static void a2dp_on_duplex_timeout(struct spa_source *source) set_duplex_timeout(this, this->duplex_timeout); - a2dp_on_ready_read(source); + media_on_ready_read(source); } static int setup_matching(struct impl *this) @@ -567,7 +567,7 @@ static int setup_matching(struct impl *this) return 0; } -static void a2dp_on_timeout(struct spa_source *source) +static void media_on_timeout(struct spa_source *source) { struct impl *this = source->data; struct port *port = &this->port; @@ -631,7 +631,7 @@ static int transport_start(struct impl *this) this->transport_acquired = true; this->codec_data = this->codec->init(this->codec, - this->is_duplex ? 0 : A2DP_CODEC_FLAG_SINK, + this->is_duplex ? 0 : MEDIA_CODEC_FLAG_SINK, this->transport->configuration, this->transport->configuration_len, &port->current_format, @@ -640,7 +640,7 @@ static int transport_start(struct impl *this) if (this->codec_data == NULL) return -EIO; - spa_log_info(this->log, "%p: using A2DP codec %s", this, this->codec->description); + spa_log_info(this->log, "%p: using A2DP codec %s", this, this->codec->description); val = fcntl(this->transport->fd, F_GETFL); if (fcntl(this->transport->fd, F_SETFL, val | O_NONBLOCK) < 0) @@ -672,7 +672,7 @@ static int transport_start(struct impl *this) if (!this->use_duplex_source) { this->source.fd = this->transport->fd; - this->source.func = a2dp_on_ready_read; + this->source.func = media_on_ready_read; this->source.mask = SPA_IO_IN; this->source.rmask = 0; spa_loop_add_source(this->data_loop, &this->source); @@ -689,7 +689,7 @@ static int transport_start(struct impl *this) * XXX: forward stream. */ this->source.fd = this->duplex_timerfd; - this->source.func = a2dp_on_duplex_timeout; + this->source.func = media_on_duplex_timeout; this->source.mask = SPA_IO_IN; this->source.rmask = 0; spa_loop_add_source(this->data_loop, &this->source); @@ -700,7 +700,7 @@ static int transport_start(struct impl *this) this->timer_source.data = this; this->timer_source.fd = this->timerfd; - this->timer_source.func = a2dp_on_timeout; + this->timer_source.func = media_on_timeout; this->timer_source.mask = SPA_IO_IN; this->timer_source.rmask = 0; spa_loop_add_source(this->data_loop, &this->timer_source); @@ -968,7 +968,7 @@ impl_node_port_enum_params(void *object, int seq, return -EIO; if ((res = this->codec->enum_config(this->codec, - this->is_duplex ? 0 : A2DP_CODEC_FLAG_SINK, + this->is_duplex ? 0 : MEDIA_CODEC_FLAG_SINK, this->transport->configuration, this->transport->configuration_len, id, result.index, &b, ¶m)) != 1) @@ -1555,7 +1555,7 @@ impl_init(const struct spa_handle_factory *factory, spa_atou32(str, &this->quantum_limit, 0); if ((str = spa_dict_lookup(info, SPA_KEY_API_BLUEZ5_TRANSPORT)) != NULL) sscanf(str, "pointer:%p", &this->transport); - if ((str = spa_dict_lookup(info, "bluez5.a2dp-source-role")) != NULL) + if ((str = spa_dict_lookup(info, "bluez5.media-source-role")) != NULL) this->is_input = spa_streq(str, "input"); if ((str = spa_dict_lookup(info, "api.bluez5.a2dp-duplex")) != NULL) this->is_duplex = spa_atob(str); @@ -1565,11 +1565,11 @@ impl_init(const struct spa_handle_factory *factory, spa_log_error(this->log, "a transport is needed"); return -EINVAL; } - if (this->transport->a2dp_codec == NULL) { + if (this->transport->media_codec == NULL) { spa_log_error(this->log, "a transport codec is needed"); return -EINVAL; } - this->codec = this->transport->a2dp_codec; + this->codec = this->transport->media_codec; if (this->is_duplex) { if (!this->codec->duplex_codec) { @@ -1583,7 +1583,7 @@ impl_init(const struct spa_handle_factory *factory, if (this->codec->init_props != NULL) this->codec_props = this->codec->init_props(this->codec, - this->is_duplex ? 0 : A2DP_CODEC_FLAG_SINK, + this->is_duplex ? 0 : MEDIA_CODEC_FLAG_SINK, this->transport->device->settings); spa_bt_transport_add_listener(this->transport, @@ -1627,15 +1627,15 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, static const struct spa_dict_item info_items[] = { { SPA_KEY_FACTORY_AUTHOR, "Collabora Ltd. " }, - { SPA_KEY_FACTORY_DESCRIPTION, "Capture bluetooth audio with a2dp" }, + { SPA_KEY_FACTORY_DESCRIPTION, "Capture bluetooth audio with media" }, { SPA_KEY_FACTORY_USAGE, SPA_KEY_API_BLUEZ5_TRANSPORT"=" }, }; static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); -const struct spa_handle_factory spa_a2dp_source_factory = { +const struct spa_handle_factory spa_media_source_factory = { SPA_VERSION_HANDLE_FACTORY, - SPA_NAME_API_BLUEZ5_A2DP_SOURCE, + SPA_NAME_API_BLUEZ5_MEDIA_SOURCE, &info, impl_get_size, impl_init, diff --git a/spa/plugins/bluez5/meson.build b/spa/plugins/bluez5/meson.build index 2a17c78ee..910890f34 100644 --- a/spa/plugins/bluez5/meson.build +++ b/spa/plugins/bluez5/meson.build @@ -17,9 +17,9 @@ cdata.set('HAVE_BLUEZ_5_HCI', dependency('bluez', version: '< 6', required: fals bluez5_sources = [ 'plugin.c', 'codec-loader.c', - 'a2dp-codecs.c', - 'a2dp-sink.c', - 'a2dp-source.c', + 'media-codecs.c', + 'media-sink.c', + 'media-source.c', 'sco-sink.c', 'sco-source.c', 'sco-io.c', @@ -59,7 +59,7 @@ bluez5lib = shared_library('spa-bluez5', codec_args = [ '-DCODEC_PLUGIN' ] bluez_codec_sbc = shared_library('spa-codec-bluez5-sbc', - [ 'a2dp-codec-sbc.c', 'a2dp-codecs.c' ], + [ 'a2dp-codec-sbc.c', 'media-codecs.c' ], include_directories : [ configinc ], c_args : codec_args, dependencies : [ spa_dep, sbc_dep ], @@ -67,7 +67,7 @@ bluez_codec_sbc = shared_library('spa-codec-bluez5-sbc', install_dir : spa_plugindir / 'bluez5') bluez_codec_faststream = shared_library('spa-codec-bluez5-faststream', - [ 'a2dp-codec-faststream.c', 'a2dp-codecs.c' ], + [ 'a2dp-codec-faststream.c', 'media-codecs.c' ], include_directories : [ configinc ], c_args : codec_args, dependencies : [ spa_dep, sbc_dep ], @@ -76,7 +76,7 @@ bluez_codec_faststream = shared_library('spa-codec-bluez5-faststream', if fdk_aac_dep.found() bluez_codec_aac = shared_library('spa-codec-bluez5-aac', - [ 'a2dp-codec-aac.c', 'a2dp-codecs.c' ], + [ 'a2dp-codec-aac.c', 'media-codecs.c' ], include_directories : [ configinc ], c_args : codec_args, dependencies : [ spa_dep, fdk_aac_dep ], @@ -86,7 +86,7 @@ endif if aptx_dep.found() bluez_codec_aptx = shared_library('spa-codec-bluez5-aptx', - [ 'a2dp-codec-aptx.c', 'a2dp-codecs.c' ], + [ 'a2dp-codec-aptx.c', 'media-codecs.c' ], include_directories : [ configinc ], c_args : codec_args, dependencies : [ spa_dep, aptx_dep, sbc_dep ], @@ -102,7 +102,7 @@ if ldac_dep.found() ldac_dep += ldac_abr_dep endif bluez_codec_ldac = shared_library('spa-codec-bluez5-ldac', - [ 'a2dp-codec-ldac.c', 'a2dp-codecs.c' ], + [ 'a2dp-codec-ldac.c', 'media-codecs.c' ], include_directories : [ configinc ], c_args : ldac_args, dependencies : [ spa_dep, ldac_dep ], @@ -112,7 +112,7 @@ endif if get_option('bluez5-codec-lc3plus').allowed() and lc3plus_dep.found() bluez_codec_lc3plus = shared_library('spa-codec-bluez5-lc3plus', - [ 'a2dp-codec-lc3plus.c', 'a2dp-codecs.c' ], + [ 'a2dp-codec-lc3plus.c', 'media-codecs.c' ], include_directories : [ configinc ], c_args : codec_args, dependencies : [ spa_dep, lc3plus_dep, mathlib ], @@ -124,7 +124,7 @@ if get_option('bluez5-codec-opus').allowed() and opus_dep.found() opus_args = codec_args opus_dep = [ opus_dep ] bluez_codec_opus = shared_library('spa-codec-bluez5-opus', - [ 'a2dp-codec-opus.c', 'a2dp-codecs.c' ], + [ 'a2dp-codec-opus.c', 'media-codecs.c' ], include_directories : [ configinc ], c_args : opus_args, dependencies : [ spa_dep, opus_dep, mathlib ], diff --git a/spa/plugins/bluez5/plugin.c b/spa/plugins/bluez5/plugin.c index bb09a22a2..f01c9ea6b 100644 --- a/spa/plugins/bluez5/plugin.c +++ b/spa/plugins/bluez5/plugin.c @@ -29,8 +29,8 @@ extern const struct spa_handle_factory spa_bluez5_dbus_factory; extern const struct spa_handle_factory spa_bluez5_device_factory; -extern const struct spa_handle_factory spa_a2dp_sink_factory; -extern const struct spa_handle_factory spa_a2dp_source_factory; +extern const struct spa_handle_factory spa_media_sink_factory; +extern const struct spa_handle_factory spa_media_source_factory; extern const struct spa_handle_factory spa_sco_sink_factory; extern const struct spa_handle_factory spa_sco_source_factory; @@ -48,10 +48,10 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *factory = &spa_bluez5_device_factory; break; case 2: - *factory = &spa_a2dp_sink_factory; + *factory = &spa_media_sink_factory; break; case 3: - *factory = &spa_a2dp_source_factory; + *factory = &spa_media_source_factory; break; case 4: *factory = &spa_sco_sink_factory; diff --git a/spa/plugins/bluez5/quirks.c b/spa/plugins/bluez5/quirks.c index 7612e9ae6..ba47414c8 100644 --- a/spa/plugins/bluez5/quirks.c +++ b/spa/plugins/bluez5/quirks.c @@ -56,7 +56,6 @@ #include #include -#include "a2dp-codecs.h" #include "defs.h" static struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.bluez5.quirks");