From 49ef8f9b5f3444f1d676f8e6d4973a85df2b3db0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 3 Jun 2019 16:48:01 +0200 Subject: [PATCH] spa: add keys for properties Define and document property keys --- spa/include/spa/monitor/device.h | 36 ++++++++++ spa/include/spa/monitor/monitor.h | 3 + spa/include/spa/node/node.h | 9 +++ spa/include/spa/param/audio/raw.h | 3 + spa/include/spa/param/format.h | 3 + spa/include/spa/support/log.h | 5 ++ spa/include/spa/support/plugin.h | 21 +++++- spa/include/spa/utils/keys.h | 88 ++++++++++++++++++++++++ spa/plugins/alsa/alsa-device.c | 39 ++++++----- spa/plugins/alsa/alsa-monitor.c | 35 +++++----- spa/plugins/alsa/alsa-sink.c | 15 ++-- spa/plugins/alsa/alsa-source.c | 15 ++-- spa/plugins/audioconvert/merger.c | 6 +- spa/plugins/audioconvert/splitter.c | 4 +- spa/plugins/audiotestsrc/audiotestsrc.c | 7 +- spa/plugins/bluez5/a2dp-sink.c | 15 ++-- spa/plugins/bluez5/a2dp-source.c | 15 ++-- spa/plugins/bluez5/bluez5-device.c | 21 ++++-- spa/plugins/bluez5/bluez5-monitor.c | 15 ++-- spa/plugins/support/logger.c | 4 +- spa/plugins/v4l2/v4l2-device.c | 20 +++--- spa/plugins/v4l2/v4l2-monitor.c | 32 +++++---- spa/plugins/v4l2/v4l2-source.c | 14 ++-- spa/plugins/videotestsrc/videotestsrc.c | 7 +- src/examples/export-spa-device.c | 4 +- src/examples/export-spa.c | 4 +- src/examples/local-v4l2.c | 4 +- src/modules/module-audio-dsp/audio-dsp.c | 2 +- src/modules/spa/module-device-factory.c | 6 +- src/modules/spa/module-node-factory.c | 6 +- src/modules/spa/spa-device.c | 2 +- src/modules/spa/spa-monitor.c | 2 +- src/modules/spa/spa-node.c | 2 +- src/pipewire/keys.h | 1 + src/pipewire/pipewire.c | 2 +- 35 files changed, 333 insertions(+), 134 deletions(-) create mode 100644 spa/include/spa/utils/keys.h diff --git a/spa/include/spa/monitor/device.h b/spa/include/spa/monitor/device.h index e41bcc61a..448794533 100644 --- a/spa/include/spa/monitor/device.h +++ b/spa/include/spa/monitor/device.h @@ -236,6 +236,42 @@ struct spa_device_methods { #define spa_device_enum_params(d,...) spa_device_method(d, enum_params, 0, __VA_ARGS__) #define spa_device_set_param(d,...) spa_device_method(d, set_param, 0, __VA_ARGS__) +#define SPA_KEY_DEVICE_API "device.api" /**< the api used by the device + * Ex. "alsa", "v4l2". */ +#define SPA_KEY_DEVICE_NAME "device.name" /**< the name of the device */ +#define SPA_KEY_DEVICE_ALIAS "device.alias" /**< altenative name of the device */ +#define SPA_KEY_DEVICE_NICK "device.nick" /**< the device short name */ +#define SPA_KEY_DEVICE_ID "device.id" /**< the device id */ +#define SPA_KEY_DEVICE_DESCRIPTION "device.description" /**< a device description */ +#define SPA_KEY_DEVICE_ICON "device.icon" /**< icon for the device. A base64 blob + * containing PNG image data */ +#define SPA_KEY_DEVICE_ICON_NAME "device.icon-name" /**< an XDG icon name for the device. + * Ex. "sound-card-speakers-usb" */ +#define SPA_KEY_DEVICE_PLUGGED_USEC "device.plugged.usec" /**< when the device was plugged */ + +#define SPA_KEY_DEVICE_BUS_PATH "device.bus-path" /**< bus path to the device in the OS' + * format. + * Ex. "pci-0000:00:14.0-usb-0:3.2:1.0" */ +#define SPA_KEY_DEVICE_BUS "device.bus" /**< bus of the device if applicable. One of + * "isa", "pci", "usb", "firewire", + * "bluetooth" */ +#define SPA_KEY_DEVICE_SUBSYSTEM "device.subsystem" /**< device subsystem */ +#define SPA_KEY_DEVICE_SYSFS_PATH "device.sysfs.path" /**< device sysfs path */ + +#define SPA_KEY_DEVICE_VENDOR_ID "device.vendor.id" /**< vendor ID if applicable */ +#define SPA_KEY_DEVICE_VENDOR_NAME "device.vendor.name" /**< vendor name if applicable */ +#define SPA_KEY_DEVICE_PRODUCT_ID "device.product.id" /**< product ID if applicable */ +#define SPA_KEY_DEVICE_PRODUCT_NAME "device.product.name" /**< product name if applicable */ +#define SPA_KEY_DEVICE_SERIAL "device.serial" /**< Serial number if applicable */ +#define SPA_KEY_DEVICE_CLASS "device.class" /**< device class */ +#define SPA_KEY_DEVICE_CAPABILITIES "device.capabilities" /**< api specific device capabilities */ +#define SPA_KEY_DEVICE_FORM_FACTOR "device.form-factor" /**< form factor if applicable. One of + * "internal", "speaker", "handset", "tv", + * "webcam", "microphone", "headset", + * "headphone", "hands-free", "car", "hifi", + * "computer", "portable" */ + + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/monitor/monitor.h b/spa/include/spa/monitor/monitor.h index f2dfd5f62..ced24a61b 100644 --- a/spa/include/spa/monitor/monitor.h +++ b/spa/include/spa/monitor/monitor.h @@ -123,6 +123,9 @@ static inline int spa_monitor_set_callbacks(struct spa_monitor *m, } +#define SPA_KEY_MONITOR_API "monitor.api" /**< the api used by the monitor. + * Ex. "udev", "dbus", ... */ + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/node/node.h b/spa/include/spa/node/node.h index 1d0c97342..516921c11 100644 --- a/spa/include/spa/node/node.h +++ b/spa/include/spa/node/node.h @@ -659,6 +659,15 @@ struct spa_node_methods { #define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__) #define spa_node_process(n) spa_node_method(n, process, 0) + +/** node keys */ +#define SPA_KEY_NODE_DRIVER "node.driver" /**< the node can be a driver */ +#define SPA_KEY_NODE_PAUSE_ON_IDLE "node.pause-on-idle" /**< if the node should be paused + * immediately when idle. */ + +/** port keys */ +#define SPA_KEY_PORT_MONITOR "port.monitor" /**< this port is a monitor port */ + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/param/audio/raw.h b/spa/include/spa/param/audio/raw.h index 14be5fe35..40a86a5f9 100644 --- a/spa/include/spa/param/audio/raw.h +++ b/spa/include/spa/param/audio/raw.h @@ -206,6 +206,9 @@ struct spa_audio_info_raw { #define SPA_AUDIO_INFO_RAW_INIT(...) (struct spa_audio_info_raw) { __VA_ARGS__ } +#define SPA_KEY_AUDIO_CHANNEL "audio.channel" /**< an audio channel as string, + * Ex. "FL" */ + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/param/format.h b/spa/include/spa/param/format.h index 2ca77c58d..d73dae457 100644 --- a/spa/include/spa/param/format.h +++ b/spa/include/spa/param/format.h @@ -128,6 +128,9 @@ enum spa_format { SPA_FORMAT_START_Stream = 0x40000, }; +#define SPA_KEY_FORMAT_DSP "format.dsp" /**< a predefined DSP format, + * Ex. "32 bit float mono audio" */ + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h index 3f424c313..4346b9ae3 100644 --- a/spa/include/spa/support/log.h +++ b/spa/include/spa/support/log.h @@ -161,6 +161,11 @@ static inline void spa_log_trace_fp (struct spa_log *l, const char *format, ...) #endif #endif + +/** keys can be given when initializing the logger handle */ +#define SPA_KEY_LOG_COLORS "log.colors" /**< enable colors in the logger */ +#define SPA_KEY_LOG_FILE "log.file" /**< log to the specified file instead of + * stderr. */ #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/support/plugin.h b/spa/include/spa/support/plugin.h index 2bd5c2ccf..ad6298b43 100644 --- a/spa/include/spa/support/plugin.h +++ b/spa/include/spa/support/plugin.h @@ -102,7 +102,15 @@ struct spa_handle_factory { #define SPA_VERSION_HANDLE_FACTORY 0 uint32_t version; /** - * The name + * The name of the factory contains a logical name that describes + * the function of the handle. Other plugins might contain an alternative + * implementation with the same name. + * + * Examples include: + * + * api.alsa.pcm.sink: an object to write PCM samples to an alsa PLAYBACK + * device + * api.v4l2.source: an object to read from a v4l2 source. */ const char *name; /** @@ -187,6 +195,17 @@ typedef int (*spa_handle_factory_enum_func_t) (const struct spa_handle_factory * */ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index); + + +#define SPA_KEY_FACTORY_NAME "factory.name" /**< the name of a factory */ +#define SPA_KEY_FACTORY_AUTHOR "factory.author" /**< a comma separated list of factory authors */ +#define SPA_KEY_FACTORY_DESCRIPTION "factory.description" /**< description of a factory */ +#define SPA_KEY_FACTORY_USAGE "factory.usage" /**< usage of a factory */ + +#define SPA_KEY_LIBRARY_NAME "library.name" /**< the name of a library. This is usually + * the filename of the plugin without the + * path or the plugin extension. */ + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/utils/keys.h b/spa/include/spa/utils/keys.h new file mode 100644 index 000000000..98c03a1ca --- /dev/null +++ b/spa/include/spa/utils/keys.h @@ -0,0 +1,88 @@ +/* Simple Plugin API + * + * Copyright © 2019 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef SPA_UTILS_KEYS_H +#define SPA_UTILS_KEYS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** for objects */ +#define SPA_KEY_MEDIA_CLASS "media.class" /**< Media class + * Ex. "Audio/Device", + * "Video/Source",... */ +#define SPA_KEY_MEDIA_ROLE "media.role" /**< Role: Movie, Music, Camera, + * Screen, Communication, Game, + * Notification, DSP, Production, + * Accessibility, Test */ + +/** keys for alsa api */ +#define SPA_KEY_API_ALSA "api.alsa" /**< key for the alsa api */ +#define SPA_KEY_API_ALSA_PATH "api.alsa.path" /**< alsa device path as can be + * used in snd_pcm_open() and + * snd_ctl_open(). */ +#define SPA_KEY_API_ALSA_CARD "api.alsa.card" /**< alsa card number */ + +/** info from alsa card_info */ +#define SPA_KEY_API_ALSA_CARD_ID "api.alsa.card.id" /**< id from card_info */ +#define SPA_KEY_API_ALSA_CARD_COMPONENTS \ + "api.alsa.card.components" /**< components from card_info */ +#define SPA_KEY_API_ALSA_CARD_DRIVER "api.alsa.card.driver" /**< driver from card_info */ +#define SPA_KEY_API_ALSA_CARD_NAME "api.alsa.card.name" /**< name from card_info */ +#define SPA_KEY_API_ALSA_CARD_LONGNAME "api.alsa.card.longname" /**< longname from card_info */ +#define SPA_KEY_API_ALSA_CARD_MIXERNAME "api.alsa.card.mixername" /**< mixername from card_info */ + +/** info from alsa pcm_info */ +#define SPA_KEY_API_ALSA_PCM_ID "api.alsa.pcm.id" /**< id from pcm_info */ +#define SPA_KEY_API_ALSA_PCM_NAME "api.alsa.pcm.name" /**< name from pcm_info */ +#define SPA_KEY_API_ALSA_PCM_SUBNAME "api.alsa.pcm.subname" /**< subdevice_name from pcm_info */ +#define SPA_KEY_API_ALSA_PCM_CLASS "api.alsa.pcm.class" /**< class from pcm_info as string */ +#define SPA_KEY_API_ALSA_PCM_SUBCLASS "api.alsa.pcm.subclass" /**< subclass from pcm_info as string */ + +/** keys for v4l2 api */ +#define SPA_KEY_API_V4L2 "api.v4l2" /**< key for the v4l2 api */ +#define SPA_KEY_API_V4L2_PATH "api.v4l2.path" /**< v4l2 device path as can be + * used in open() */ + +/** info from v4l2_capability */ +#define SPA_KEY_API_V4L2_CAP_DRIVER "api.v4l2.cap.driver" /**< driver from capbility */ +#define SPA_KEY_API_V4L2_CAP_CARD "api.v4l2.cap.card" /**< caps from capability */ +#define SPA_KEY_API_V4L2_CAP_BUS_INFO "api.v4l2.cap.bus_info" /**< bus_info from capability */ + + +/** keys for bluez5 api */ +#define SPA_KEY_API_BLUEZ5 "api.bluez5" /**< key for the bluez5 api */ +#define SPA_KEY_API_BLUEZ5_PATH "api.bluez5.path" /**< a bluez5 path */ +#define SPA_KEY_API_BLUEZ5_DEVICE "api.bluez5.device" /**< an internal bluez5 device */ +#define SPA_KEY_API_BLUEZ5_TRANSPORT "api.bluez5.transport" /**< an internal bluez5 transport */ +#define SPA_KEY_API_BLUEZ5_ADDRESS "api.bluez5.address" /**< a bluetooth address */ + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SPA_UTILS_KEYS_H */ diff --git a/spa/plugins/alsa/alsa-device.c b/spa/plugins/alsa/alsa-device.c index 735244b24..e25d2b211 100644 --- a/spa/plugins/alsa/alsa-device.c +++ b/spa/plugins/alsa/alsa-device.c @@ -29,10 +29,11 @@ #include #include -#include +#include #include #include +#include #include #include #include @@ -115,12 +116,12 @@ static int emit_node(struct impl *this, snd_pcm_info_t *pcminfo, uint32_t id) info.change_mask = SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS; snprintf(device_name, 128, "%s,%d", this->props.device, snd_pcm_info_get_device(pcminfo)); - items[0] = SPA_DICT_ITEM_INIT("alsa.device", device_name); - items[1] = SPA_DICT_ITEM_INIT("alsa.pcm.id", snd_pcm_info_get_id(pcminfo)); - items[2] = SPA_DICT_ITEM_INIT("alsa.pcm.name", snd_pcm_info_get_name(pcminfo)); - items[3] = SPA_DICT_ITEM_INIT("alsa.pcm.subname", snd_pcm_info_get_subdevice_name(pcminfo)); - items[4] = SPA_DICT_ITEM_INIT("alsa.pcm.class", get_class(pcminfo)); - items[5] = SPA_DICT_ITEM_INIT("alsa.pcm.subclass", get_subclass(pcminfo)); + items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PATH, device_name); + items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PCM_ID, snd_pcm_info_get_id(pcminfo)); + items[2] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PCM_NAME, snd_pcm_info_get_name(pcminfo)); + items[3] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PCM_SUBNAME, snd_pcm_info_get_subdevice_name(pcminfo)); + items[4] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PCM_CLASS, get_class(pcminfo)); + items[5] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PCM_SUBCLASS, get_subclass(pcminfo)); info.props = &SPA_DICT_INIT_ARRAY(items); spa_device_emit_object_info(&this->hooks, id, &info); @@ -225,16 +226,16 @@ static int emit_info(struct impl *this, bool full) dinfo = SPA_DEVICE_INFO_INIT(); dinfo.change_mask = SPA_DEVICE_CHANGE_MASK_PROPS; - items[0] = SPA_DICT_ITEM_INIT("device.api", "alsa"); - items[1] = SPA_DICT_ITEM_INIT("device.path", (char *)this->props.device); - items[2] = SPA_DICT_ITEM_INIT("device.nick", snd_ctl_card_info_get_id(info)); - items[3] = SPA_DICT_ITEM_INIT("media.class", "Audio/Device"); - items[4] = SPA_DICT_ITEM_INIT("alsa.card.id", snd_ctl_card_info_get_id(info)); - items[5] = SPA_DICT_ITEM_INIT("alsa.card.components", snd_ctl_card_info_get_components(info)); - items[6] = SPA_DICT_ITEM_INIT("alsa.card.driver", snd_ctl_card_info_get_driver(info)); - items[7] = SPA_DICT_ITEM_INIT("alsa.card.name", snd_ctl_card_info_get_name(info)); - items[8] = SPA_DICT_ITEM_INIT("alsa.card.longname", snd_ctl_card_info_get_longname(info)); - items[9] = SPA_DICT_ITEM_INIT("alsa.card.mixername", snd_ctl_card_info_get_mixername(info)); + items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_API, "alsa"); + items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_NICK, snd_ctl_card_info_get_id(info)); + items[2] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Audio/Device"); + items[3] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PATH, (char *)this->props.device); + items[4] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_CARD_ID, snd_ctl_card_info_get_id(info)); + items[5] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_CARD_COMPONENTS, snd_ctl_card_info_get_components(info)); + items[6] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_CARD_DRIVER, snd_ctl_card_info_get_driver(info)); + items[7] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_CARD_NAME, snd_ctl_card_info_get_name(info)); + items[8] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_CARD_LONGNAME, snd_ctl_card_info_get_longname(info)); + items[9] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_CARD_MIXERNAME, snd_ctl_card_info_get_mixername(info)); dinfo.props = &SPA_DICT_INIT(items, 10); dinfo.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS; @@ -463,8 +464,8 @@ impl_init(const struct spa_handle_factory *factory, reset_props(&this->props); - if (info && (str = spa_dict_lookup(info, "alsa.card"))) - snprintf(this->props.device, 64, "hw:%d", atoi(str)); + if (info && (str = spa_dict_lookup(info, SPA_KEY_API_ALSA_PATH))) + snprintf(this->props.device, 64, "%s", str); return 0; } diff --git a/spa/plugins/alsa/alsa-monitor.c b/spa/plugins/alsa/alsa-monitor.c index ae4171b1a..87d9c4b39 100644 --- a/spa/plugins/alsa/alsa-monitor.c +++ b/spa/plugins/alsa/alsa-monitor.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -124,41 +125,41 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device * if (!(name && *name)) name = "Unknown"; - items[n_items++] = SPA_DICT_ITEM_INIT("udev-probed", "1"); - items[n_items++] = SPA_DICT_ITEM_INIT("device.path", udev_device_get_devnode(dev)); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_MONITOR_API, "udev"); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PATH, udev_device_get_devnode(dev)); if ((str = path_get_card_id(udev_device_get_property_value(dev, "DEVPATH"))) == NULL) return 0; - items[n_items++] = SPA_DICT_ITEM_INIT("alsa.card", str); - items[n_items++] = SPA_DICT_ITEM_INIT("device.name", name); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_CARD, str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_NAME, name); if ((str = udev_device_get_property_value(dev, "SOUND_CLASS")) && *str) - items[n_items++] = SPA_DICT_ITEM_INIT("device.class", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_CLASS, str); if ((str = udev_device_get_property_value(dev, "USEC_INITIALIZED")) && *str) - items[n_items++] = SPA_DICT_ITEM_INIT("device.plugged.usec", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PLUGGED_USEC, str); str = udev_device_get_property_value(dev, "ID_PATH"); if (!(str && *str)) str = udev_device_get_syspath(dev); if (str && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.bus_path", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_BUS_PATH, str); } if ((str = udev_device_get_syspath(dev)) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("sysfs.path", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SYSFS_PATH, str); } if ((str = udev_device_get_property_value(dev, "ID_ID")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("udev.id", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_ID, str); } if ((str = udev_device_get_property_value(dev, "ID_BUS")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.bus", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_BUS, str); } if ((str = udev_device_get_property_value(dev, "SUBSYSTEM")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.subsystem", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SUBSYSTEM, str); } if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.vendor.id", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, str); } str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE"); if (!(str && *str)) { @@ -168,18 +169,18 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device * } } if (str && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.vendor.name", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_NAME, str); } if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.product.id", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, str); } - items[n_items++] = SPA_DICT_ITEM_INIT("device.product.name", name); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_NAME, name); if ((str = udev_device_get_property_value(dev, "ID_SERIAL")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.serial", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SERIAL, str); } if ((str = udev_device_get_property_value(dev, "SOUND_FORM_FACTOR")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.form_factor", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_FORM_FACTOR, str); } info.props = &SPA_DICT_INIT(items, n_items); spa_monitor_call_object_info(&this->callbacks, id, &info); diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index bad35488d..f0ae3a445 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include #include @@ -226,9 +228,9 @@ static int impl_node_send_command(void *object, const struct spa_command *comman } static const struct spa_dict_item node_info_items[] = { - { "device.api", "alsa" }, - { "media.class", "Audio/Sink" }, - { "node.driver", "true" }, + { SPA_KEY_DEVICE_API, "alsa" }, + { SPA_KEY_MEDIA_CLASS, "Audio/Sink" }, + { SPA_KEY_NODE_DRIVER, "true" }, }; static void emit_node_info(struct state *this, bool full) @@ -761,7 +763,7 @@ impl_init(const struct spa_handle_factory *factory, spa_list_init(&this->ready); for (i = 0; info && i < info->n_items; i++) { - if (!strcmp(info->items[i].key, "alsa.device")) { + if (!strcmp(info->items[i].key, SPA_KEY_API_ALSA_PATH)) { snprintf(this->props.device, 63, "%s", info->items[i].value); } } @@ -793,8 +795,9 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, } static const struct spa_dict_item info_items[] = { - { "factory.author", "Wim Taymans " }, - { "factory.description", "Play audio with the alsa API" }, + { SPA_KEY_FACTORY_AUTHOR, "Wim Taymans " }, + { SPA_KEY_FACTORY_DESCRIPTION, "Play audio with the alsa API" }, + { SPA_KEY_FACTORY_USAGE, "["SPA_KEY_API_ALSA_PATH"=]" }, }; static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 817521527..91e58adf3 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -28,7 +28,9 @@ #include #include +#include #include +#include #include #include @@ -226,9 +228,9 @@ static int impl_node_send_command(void *object, const struct spa_command *comman } static const struct spa_dict_item node_info_items[] = { - { "device.api", "alsa" }, - { "media.class", "Audio/Source" }, - { "node.driver", "true" }, + { SPA_KEY_DEVICE_API, "alsa" }, + { SPA_KEY_MEDIA_CLASS, "Audio/Source" }, + { SPA_KEY_NODE_DRIVER, "true" }, }; static void emit_node_info(struct state *this, bool full) @@ -776,7 +778,7 @@ impl_init(const struct spa_handle_factory *factory, spa_list_init(&this->ready); for (i = 0; info && i < info->n_items; i++) { - if (!strcmp(info->items[i].key, "alsa.device")) { + if (!strcmp(info->items[i].key, SPA_KEY_API_ALSA_PATH)) { snprintf(this->props.device, 63, "%s", info->items[i].value); } } @@ -805,8 +807,9 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, } static const struct spa_dict_item info_items[] = { - { "factory.author", "Wim Taymans " }, - { "factory.description", "Record audio with the alsa API" }, + { SPA_KEY_FACTORY_AUTHOR, "Wim Taymans " }, + { SPA_KEY_FACTORY_DESCRIPTION, "Record audio with the alsa API" }, + { SPA_KEY_FACTORY_USAGE, "["SPA_KEY_API_ALSA_PATH"=]" }, }; static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index 258b54419..6bd2c7e90 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -139,10 +139,10 @@ static void emit_port_info(struct impl *this, struct port *port, bool full) uint32_t n_items = 0; if (PORT_IS_DSP(port->direction, port->id)) { - items[n_items++] = SPA_DICT_ITEM_INIT("format.dsp", "32 bit float mono audio"); - items[n_items++] = SPA_DICT_ITEM_INIT("audio.channel", port->position); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "32 bit float mono audio"); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_AUDIO_CHANNEL, port->position); if (port->direction == SPA_DIRECTION_OUTPUT) - items[n_items++] = SPA_DICT_ITEM_INIT("port.monitor", "1"); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_PORT_MONITOR, "1"); } port->info.props = &SPA_DICT_INIT(items, n_items); diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index c82351424..7e687a227 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -159,8 +159,8 @@ static int init_port(struct impl *this, enum spa_direction direction, port->info = SPA_PORT_INFO_INIT(); port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | SPA_PORT_FLAG_DYNAMIC_DATA; - port->info_props_items[0] = SPA_DICT_ITEM_INIT("format.dsp", "32 bit float mono audio"); - port->info_props_items[1] = SPA_DICT_ITEM_INIT("audio.channel", port->position); + port->info_props_items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "32 bit float mono audio"); + port->info_props_items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_AUDIO_CHANNEL, port->position); port->info_props = SPA_DICT_INIT(port->info_props_items, 2); port->info.props = &port->info_props; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 6b6daad42..62f30ae4c 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -441,7 +442,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman } static const struct spa_dict_item node_info_items[] = { - { "media.class", "Audio/Source" }, + { SPA_KEY_MEDIA_CLASS, "Audio/Source" }, }; static void emit_node_info(struct impl *this, bool full) @@ -1088,8 +1089,8 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, } static const struct spa_dict_item info_items[] = { - { "factory.author", "Wim Taymans " }, - { "factory.description", "Generate an audio test pattern" }, + { SPA_KEY_FACTORY_AUTHOR, "Wim Taymans " }, + { SPA_KEY_FACTORY_DESCRIPTION, "Generate an audio test pattern" }, }; static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index 9e8c67c90..0202aa19c 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -906,9 +908,9 @@ static int impl_node_send_command(void *object, const struct spa_command *comman } static const struct spa_dict_item node_info_items[] = { - { "device.api", "bluez5" }, - { "media.class", "Audio/Sink" }, - { "node.driver", "true" }, + { SPA_KEY_DEVICE_API, "bluez5" }, + { SPA_KEY_MEDIA_CLASS, "Audio/Sink" }, + { SPA_KEY_NODE_DRIVER, "true" }, }; static void emit_node_info(struct impl *this, bool full) @@ -1470,7 +1472,7 @@ impl_init(const struct spa_handle_factory *factory, spa_list_init(&port->ready); for (i = 0; info && i < info->n_items; i++) { - if (strcmp(info->items[i].key, "bluez5.transport") == 0) + if (strcmp(info->items[i].key, SPA_KEY_API_BLUEZ5_TRANSPORT) == 0) sscanf(info->items[i].value, "%p", &this->transport); } if (this->transport == NULL) { @@ -1509,8 +1511,9 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, } static const struct spa_dict_item info_items[] = { - { "factory.author", "Wim Taymans " }, - { "factory.description", "Play audio with the a2dp" }, + { SPA_KEY_FACTORY_AUTHOR, "Wim Taymans " }, + { SPA_KEY_FACTORY_DESCRIPTION, "Play audio with the a2dp" }, + { SPA_KEY_FACTORY_USAGE, SPA_KEY_API_BLUEZ5_TRANSPORT"=" }, }; static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index 68b3f136d..092f41688 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include @@ -557,9 +559,9 @@ static int impl_node_send_command(void *object, const struct spa_command *comman } static const struct spa_dict_item node_info_items[] = { - { "device.api", "bluez5" }, - { "media.class", "Audio/Source" }, - { "node.driver", "true" }, + { SPA_KEY_DEVICE_API, "bluez5" }, + { SPA_KEY_MEDIA_CLASS, "Audio/Source" }, + { SPA_KEY_NODE_DRIVER, "true" }, }; static void emit_node_info(struct impl *this, bool full) @@ -1168,7 +1170,7 @@ impl_init(const struct spa_handle_factory *factory, spa_list_init(&port->free); for (i = 0; info && i < info->n_items; i++) { - if (strcmp(info->items[i].key, "bluez5.transport") == 0) + if (strcmp(info->items[i].key, SPA_KEY_API_BLUEZ5_TRANSPORT) == 0) sscanf(info->items[i].value, "%p", &this->transport); } if (this->transport == NULL) { @@ -1209,8 +1211,9 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, } static const struct spa_dict_item info_items[] = { - { "factory.author", "Collabora Ltd. " }, - { "factory.description", "Capture bluetooth audio with a2dp" }, + { SPA_KEY_FACTORY_AUTHOR, "Collabora Ltd. " }, + { SPA_KEY_FACTORY_DESCRIPTION, "Capture bluetooth audio with a2dp" }, + { SPA_KEY_FACTORY_USAGE, SPA_KEY_API_BLUEZ5_TRANSPORT"=" }, }; static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c index cd5191ea6..41c4d16a0 100644 --- a/spa/plugins/bluez5/bluez5-device.c +++ b/spa/plugins/bluez5/bluez5-device.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -101,7 +102,7 @@ static int emit_source_node(struct impl *this) char transport[16]; snprintf(transport, 16, "%p", t); - items[0] = SPA_DICT_ITEM_INIT("bluez5.transport", transport); + items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_API_BLUEZ5_TRANSPORT, transport); spa_bt_transport_acquire(t, true); @@ -150,7 +151,7 @@ static int emit_sink_node(struct impl *this) char transport[16]; snprintf(transport, 16, "%p", t); - items[0] = SPA_DICT_ITEM_INIT("bluez5.transport", transport); + items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_API_BLUEZ5_TRANSPORT, transport); info = SPA_DEVICE_OBJECT_INFO_INIT(); info.type = SPA_TYPE_INTERFACE_Node; @@ -181,8 +182,8 @@ static int emit_nodes(struct impl *this) } static const struct spa_dict_item info_items[] = { - { "device.api", "bluez5" }, - { "media.class", "Audio/Device" }, + { SPA_KEY_DEVICE_API, "bluez5" }, + { SPA_KEY_MEDIA_CLASS, "Audio/Device" }, }; static int impl_add_listener(void *object, @@ -302,7 +303,7 @@ impl_init(const struct spa_handle_factory *factory, } for (i = 0; info && i < info->n_items; i++) { - if (strcmp(info->items[i].key, "bluez5.device") == 0) + if (strcmp(info->items[i].key, SPA_KEY_API_BLUEZ5_DEVICE) == 0) sscanf(info->items[i].value, "%p", &this->bt_dev); } if (this->bt_dev == NULL) { @@ -341,10 +342,18 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, return 1; } +static const struct spa_dict_item handle_info_items[] = { + { SPA_KEY_FACTORY_AUTHOR, "Wim Taymans " }, + { SPA_KEY_FACTORY_DESCRIPTION, "A bluetooth device" }, + { SPA_KEY_FACTORY_USAGE, SPA_KEY_API_BLUEZ5_DEVICE"=" }, +}; + +static const struct spa_dict handle_info = SPA_DICT_INIT_ARRAY(handle_info_items); + const struct spa_handle_factory spa_bluez5_device_factory = { SPA_VERSION_HANDLE_FACTORY, "api.bluez5.device", - NULL, + &handle_info, impl_get_size, impl_init, impl_enum_interface_info, diff --git a/spa/plugins/bluez5/bluez5-monitor.c b/spa/plugins/bluez5/bluez5-monitor.c index b869d5380..9dc69558b 100644 --- a/spa/plugins/bluez5/bluez5-monitor.c +++ b/spa/plugins/bluez5/bluez5-monitor.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "a2dp-codecs.h" #include "defs.h" @@ -503,14 +504,14 @@ static int device_add(struct spa_bt_monitor *monitor, struct spa_bt_device *devi SPA_MONITOR_OBJECT_CHANGE_MASK_PROPS; info.flags = 0; - items[n_items++] = SPA_DICT_ITEM_INIT("device.path", device->path); - items[n_items++] = SPA_DICT_ITEM_INIT("device.name", device->name); - items[n_items++] = SPA_DICT_ITEM_INIT("device.api", "bluez5"); - items[n_items++] = SPA_DICT_ITEM_INIT("device.alias", device->alias); - items[n_items++] = SPA_DICT_ITEM_INIT("device.icon", device->icon); - items[n_items++] = SPA_DICT_ITEM_INIT("device.bluez5.address", device->address); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_API, "bluez5"); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_NAME, device->name); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_ALIAS, device->alias); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_ICON_NAME, device->icon); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_BLUEZ5_PATH, device->path); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_BLUEZ5_ADDRESS, device->address); snprintf(dev, sizeof(dev), "%p", device); - items[n_items++] = SPA_DICT_ITEM_INIT("bluez5.device", dev); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_BLUEZ5_DEVICE, dev); info.props = &SPA_DICT_INIT(items, n_items); diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 64dcc0a9d..18561837f 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -226,9 +226,9 @@ impl_init(const struct spa_handle_factory *factory, loop = support[i].data; } if (info) { - if ((str = spa_dict_lookup(info, "log.colors")) != NULL) + if ((str = spa_dict_lookup(info, SPA_KEY_LOG_COLORS)) != NULL) this->colors = (strcmp(str, "true") == 0 || atoi(str) == 1); - if ((str = spa_dict_lookup(info, "log.file")) != NULL) { + if ((str = spa_dict_lookup(info, SPA_KEY_LOG_FILE)) != NULL) { this->file = fopen(str, "w"); if (this->file == NULL) fprintf(stderr, "failed to open file %s: (%s)", str, strerror(errno)); diff --git a/spa/plugins/v4l2/v4l2-device.c b/spa/plugins/v4l2/v4l2-device.c index 9842136af..892246a09 100644 --- a/spa/plugins/v4l2/v4l2-device.c +++ b/spa/plugins/v4l2/v4l2-device.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -71,6 +72,7 @@ static int emit_info(struct impl *this, bool full) { int res; struct spa_dict_item items[6]; + uint32_t n_items = 0; struct spa_device_info info; struct spa_param_info params[2]; @@ -80,13 +82,13 @@ static int emit_info(struct impl *this, bool full) info = SPA_DEVICE_INFO_INIT(); info.change_mask = SPA_DEVICE_CHANGE_MASK_PROPS; - items[0] = SPA_DICT_ITEM_INIT("device.api", "v4l2"); - items[1] = SPA_DICT_ITEM_INIT("device.path", (char *)this->props.device); - items[2] = SPA_DICT_ITEM_INIT("media.class", "Video/Device"); - items[3] = SPA_DICT_ITEM_INIT("v4l2.driver", (char *)this->dev.cap.driver); - items[4] = SPA_DICT_ITEM_INIT("v4l2.card", (char *)this->dev.cap.card); - items[5] = SPA_DICT_ITEM_INIT("v4l2.bus", (char *)this->dev.cap.bus_info); - info.props = &SPA_DICT_INIT(items, 6); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Video/Device"); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_API, "v4l2"); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_V4L2_PATH, (char *)this->props.device); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_V4L2_CAP_DRIVER, (char *)this->dev.cap.driver); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_V4L2_CAP_CARD, (char *)this->dev.cap.card); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_V4L2_CAP_BUS_INFO, (char *)this->dev.cap.bus_info); + info.props = &SPA_DICT_INIT(items, n_items); info.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS; params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumProfile, SPA_PARAM_INFO_READ); @@ -103,7 +105,7 @@ static int emit_info(struct impl *this, bool full) oinfo.type = SPA_TYPE_INTERFACE_Node; oinfo.factory_name = "api.v4l2.source"; oinfo.change_mask = SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS; - oinfo.props = &SPA_DICT_INIT(items, 6); + oinfo.props = &SPA_DICT_INIT(items, n_items); spa_device_emit_object_info(&this->hooks, 0, &oinfo); } @@ -236,7 +238,7 @@ impl_init(const struct spa_handle_factory *factory, reset_props(&this->props); - if (info && (str = spa_dict_lookup(info, "device.path"))) + if (info && (str = spa_dict_lookup(info, SPA_KEY_API_V4L2_PATH))) strncpy(this->props.device, str, 63); return 0; diff --git a/spa/plugins/v4l2/v4l2-monitor.c b/spa/plugins/v4l2/v4l2-monitor.c index 4a2b5b7f9..84faebbdb 100644 --- a/spa/plugins/v4l2/v4l2-monitor.c +++ b/spa/plugins/v4l2/v4l2-monitor.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -116,33 +117,34 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device * if (!(name && *name)) name = "Unknown"; - items[n_items++] = SPA_DICT_ITEM_INIT("udev-probed", "1"); - items[n_items++] = SPA_DICT_ITEM_INIT("device.path", udev_device_get_devnode(dev)); - items[n_items++] = SPA_DICT_ITEM_INIT("device.name", name); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_MONITOR_API,"udev"); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_API, "v4l2"); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_NAME, name); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_API_V4L2_PATH, udev_device_get_devnode(dev)); if ((str = udev_device_get_property_value(dev, "USEC_INITIALIZED")) && *str) - items[n_items++] = SPA_DICT_ITEM_INIT("device.plugged.usec", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PLUGGED_USEC, str); str = udev_device_get_property_value(dev, "ID_PATH"); if (!(str && *str)) str = udev_device_get_syspath(dev); if (str && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.bus_path", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_BUS_PATH, str); } if ((str = udev_device_get_syspath(dev)) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("sysfs.path", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SYSFS_PATH, str); } if ((str = udev_device_get_property_value(dev, "ID_ID")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("udev.id", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_ID, str); } if ((str = udev_device_get_property_value(dev, "ID_BUS")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.bus", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_BUS, str); } if ((str = udev_device_get_property_value(dev, "SUBSYSTEM")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.subsystem", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SUBSYSTEM, str); } if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.vendor.id", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, str); } str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE"); if (!(str && *str)) { @@ -152,17 +154,17 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device * } } if (str && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.vendor.name", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_NAME, str); } if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.product.id", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, str); } - items[n_items++] = SPA_DICT_ITEM_INIT("device.product.name", name); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_NAME, name); if ((str = udev_device_get_property_value(dev, "ID_SERIAL")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.serial", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SERIAL, str); } if ((str = udev_device_get_property_value(dev, "ID_V4L_CAPABILITIES")) && *str) { - items[n_items++] = SPA_DICT_ITEM_INIT("device.capabilities", str); + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_CAPABILITIES, str); } info.props = &SPA_DICT_INIT(items, n_items); spa_monitor_call_object_info(&this->callbacks, id, &info); diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 9f6bcf5aa..15abedef8 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -315,11 +317,11 @@ static int impl_node_send_command(void *object, const struct spa_command *comman } static const struct spa_dict_item info_items[] = { - { "device.api", "v4l2" }, - { "media.class", "Video/Source" }, - { "media.role", "Camera" }, - { "node.pause-on-idle", "false" }, - { "node.driver", "true" }, + { SPA_KEY_DEVICE_API, "v4l2" }, + { SPA_KEY_MEDIA_CLASS, "Video/Source" }, + { SPA_KEY_MEDIA_ROLE, "Camera" }, + { SPA_KEY_NODE_PAUSE_ON_IDLE, "false" }, + { SPA_KEY_NODE_DRIVER, "true" }, }; static void emit_node_info(struct impl *this, bool full) @@ -1013,7 +1015,7 @@ impl_init(const struct spa_handle_factory *factory, port->dev.log = this->log; port->dev.fd = -1; - if (info && (str = spa_dict_lookup(info, "device.path"))) { + if (info && (str = spa_dict_lookup(info, SPA_KEY_API_V4L2_PATH))) { strncpy(this->props.device, str, 63); if ((res = spa_v4l2_open(&port->dev, this->props.device)) < 0) return res; diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index 54e781477..92caed857 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -393,7 +394,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman } static const struct spa_dict_item node_info_items[] = { - { "media.class", "Video/Source" }, + { SPA_KEY_MEDIA_CLASS, "Video/Source" }, }; static void emit_node_info(struct impl *this, bool full) @@ -972,8 +973,8 @@ impl_enum_interface_info(const struct spa_handle_factory *factory, } static const struct spa_dict_item info_items[] = { - { "factory.author", "Wim Taymans " }, - { "factory.description", "Generate a video test pattern" }, + { SPA_KEY_FACTORY_AUTHOR, "Wim Taymans " }, + { SPA_KEY_FACTORY_DESCRIPTION, "Generate a video test pattern" }, }; static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); diff --git a/src/examples/export-spa-device.c b/src/examples/export-spa-device.c index 506d959ad..418a707fb 100644 --- a/src/examples/export-spa-device.c +++ b/src/examples/export-spa-device.c @@ -54,8 +54,8 @@ static int make_device(struct data *data) if (factory == NULL) return -1; - props = pw_properties_new("spa.library.name", data->library, - "spa.factory.name", data->factory, NULL); + props = pw_properties_new(SPA_KEY_LIBRARY_NAME, data->library, + SPA_KEY_FACTORY_NAME, data->factory, NULL); data->device = pw_factory_create_object(factory, NULL, diff --git a/src/examples/export-spa.c b/src/examples/export-spa.c index 188f6e528..6dd7ecb44 100644 --- a/src/examples/export-spa.c +++ b/src/examples/export-spa.c @@ -54,8 +54,8 @@ static int make_node(struct data *data) if (factory == NULL) return -1; - props = pw_properties_new("spa.library.name", data->library, - "spa.factory.name", data->factory, NULL); + props = pw_properties_new(SPA_KEY_LIBRARY_NAME, data->library, + SPA_KEY_FACTORY_NAME, data->factory, NULL); if (data->path) { pw_properties_set(props, PW_KEY_NODE_AUTOCONNECT, "1"); diff --git a/src/examples/local-v4l2.c b/src/examples/local-v4l2.c index d8effa6d4..42dbb6536 100644 --- a/src/examples/local-v4l2.c +++ b/src/examples/local-v4l2.c @@ -347,8 +347,8 @@ static int make_nodes(struct data *data) pw_node_register(data->node, NULL, NULL, NULL); factory = pw_core_find_factory(data->core, "spa-node-factory"); - props = pw_properties_new("spa.library.name", "v4l2/libspa-v4l2", - "spa.factory.name", "api.v4l2.source", NULL); + props = pw_properties_new(SPA_KEY_LIBRARY_NAME, "v4l2/libspa-v4l2", + SPA_KEY_FACTORY_NAME, "api.v4l2.source", NULL); data->v4l2 = pw_factory_create_object(factory, NULL, PW_TYPE_INTERFACE_Node, diff --git a/src/modules/module-audio-dsp/audio-dsp.c b/src/modules/module-audio-dsp/audio-dsp.c index d9f0a70fc..5609442c9 100644 --- a/src/modules/module-audio-dsp/audio-dsp.c +++ b/src/modules/module-audio-dsp/audio-dsp.c @@ -316,7 +316,7 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core, } pw_properties_set(pr, "factory.mode", factory); factory = "audioconvert"; - pw_properties_set(pr, "spa.library.name", "audioconvert/libspa-audioconvert"); + pw_properties_set(pr, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert"); node = pw_spa_node_load(core, NULL, NULL, factory, diff --git a/src/modules/spa/module-device-factory.c b/src/modules/spa/module-device-factory.c index dadb7cd10..480f4cf13 100644 --- a/src/modules/spa/module-device-factory.c +++ b/src/modules/spa/module-device-factory.c @@ -33,8 +33,8 @@ #include "spa-device.h" -#define FACTORY_USAGE "spa.factory.name= " \ - "[spa.library.name=]" +#define FACTORY_USAGE SPA_KEY_FACTORY_NAME"= " \ + "["SPA_KEY_LIBRARY_NAME"=]" static const struct spa_dict_item module_props[] = { { PW_KEY_MODULE_AUTHOR, "Wim Taymans " }, @@ -87,7 +87,7 @@ static void *create_object(void *_data, if (properties == NULL) goto no_properties; - factory_name = pw_properties_get(properties, "spa.factory.name"); + factory_name = pw_properties_get(properties, SPA_KEY_FACTORY_NAME); if (factory_name == NULL) goto no_properties; diff --git a/src/modules/spa/module-node-factory.c b/src/modules/spa/module-node-factory.c index ec666dc71..fc30def3f 100644 --- a/src/modules/spa/module-node-factory.c +++ b/src/modules/spa/module-node-factory.c @@ -33,8 +33,8 @@ #include "spa-node.h" -#define FACTORY_USAGE "spa.factory.name= " \ - "[spa.library.name=]" +#define FACTORY_USAGE SPA_KEY_FACTORY_NAME"= " \ + "["SPA_KEY_LIBRARY_NAME"=]" static const struct spa_dict_item module_props[] = { { PW_KEY_MODULE_AUTHOR, "Wim Taymans " }, @@ -87,7 +87,7 @@ static void *create_object(void *_data, if (properties == NULL) goto no_properties; - factory_name = pw_properties_get(properties, "spa.factory.name"); + factory_name = pw_properties_get(properties, SPA_KEY_FACTORY_NAME); if (factory_name == NULL) goto no_properties; diff --git a/src/modules/spa/spa-device.c b/src/modules/spa/spa-device.c index 2756b9696..f5f35504b 100644 --- a/src/modules/spa/spa-device.c +++ b/src/modules/spa/spa-device.c @@ -142,7 +142,7 @@ struct pw_device *pw_spa_device_load(struct pw_core *core, support = pw_core_get_support(core, &n_support); if (lib == NULL && properties) - lib = pw_properties_get(properties, "spa.library.name"); + lib = pw_properties_get(properties, SPA_KEY_LIBRARY_NAME); if (lib == NULL) lib = pw_core_find_spa_lib(core, factory_name); if (lib == NULL) diff --git a/src/modules/spa/spa-monitor.c b/src/modules/spa/spa-monitor.c index 31bb57b64..25e771422 100644 --- a/src/modules/spa/spa-monitor.c +++ b/src/modules/spa/spa-monitor.c @@ -279,7 +279,7 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core, uint32_t n_support; if (lib == NULL && properties) - lib = pw_properties_get(properties, "spa.library.name"); + lib = pw_properties_get(properties, SPA_KEY_LIBRARY_NAME); if (lib == NULL) lib = pw_core_find_spa_lib(core, factory_name); if (lib == NULL) diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index 0e587700a..7a17788a8 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -257,7 +257,7 @@ struct pw_node *pw_spa_node_load(struct pw_core *core, uint32_t n_support; if (lib == NULL && properties) - lib = pw_properties_get(properties, "spa.library.name"); + lib = pw_properties_get(properties, SPA_KEY_LIBRARY_NAME); if (lib == NULL) lib = pw_core_find_spa_lib(core, factory_name); if (lib == NULL) diff --git a/src/pipewire/keys.h b/src/pipewire/keys.h index 20c693e57..5fab0850c 100644 --- a/src/pipewire/keys.h +++ b/src/pipewire/keys.h @@ -162,6 +162,7 @@ extern "C" { #define PW_KEY_DEVICE_BUS "device.bus" /**< bus of the device if applicable. One of * "isa", "pci", "usb", "firewire", * "bluetooth" */ +#define PW_KEY_DEVICE_SUBSYSTEM "device.subsystem" /**< device subsystem */ #define PW_KEY_DEVICE_ICON "device.icon" /**< icon for the device. A base64 blob * containing PNG image data */ #define PW_KEY_DEVICE_ICON_NAME "device.icon-name" /**< an XDG icon name for the device. diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index 6ab8c9529..f6d10cb8e 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -364,7 +364,7 @@ void pw_init(int *argc, char **argv[]) support->support_plugin = plugin; - items[0] = SPA_DICT_ITEM_INIT("log.colors", "1"); + items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_LOG_COLORS, "1"); info = SPA_DICT_INIT(items, 1); handle = load_handle(plugin, "logger", &info, support->n_support, support->support);