mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
spa: add keys for properties
Define and document property keys
This commit is contained in:
parent
1f250046a3
commit
49ef8f9b5f
35 changed files with 333 additions and 134 deletions
|
|
@ -29,10 +29,11 @@
|
|||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
|
||||
#include <asoundlib.h>
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/utils/type.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/monitor/device.h>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/utils/type.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/monitor/monitor.h>
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/utils.h>
|
||||
#include <spa/monitor/device.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/param/audio/format.h>
|
||||
#include <spa/pod/filter.h>
|
||||
#include <spa/debug/pod.h>
|
||||
|
|
@ -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 <wim.taymans@gmail.com>" },
|
||||
{ "factory.description", "Play audio with the alsa API" },
|
||||
{ SPA_KEY_FACTORY_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ SPA_KEY_FACTORY_DESCRIPTION, "Play audio with the alsa API" },
|
||||
{ SPA_KEY_FACTORY_USAGE, "["SPA_KEY_API_ALSA_PATH"=<path>]" },
|
||||
};
|
||||
|
||||
static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@
|
|||
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/utils.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <spa/monitor/device.h>
|
||||
#include <spa/param/audio/format.h>
|
||||
#include <spa/pod/filter.h>
|
||||
|
||||
|
|
@ -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 <wim.taymans@gmail.com>" },
|
||||
{ "factory.description", "Record audio with the alsa API" },
|
||||
{ SPA_KEY_FACTORY_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ SPA_KEY_FACTORY_DESCRIPTION, "Record audio with the alsa API" },
|
||||
{ SPA_KEY_FACTORY_USAGE, "["SPA_KEY_API_ALSA_PATH"=<device>]" },
|
||||
};
|
||||
|
||||
static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <spa/support/log.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/utils.h>
|
||||
#include <spa/node/io.h>
|
||||
|
|
@ -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 <wim.taymans@gmail.com>" },
|
||||
{ "factory.description", "Generate an audio test pattern" },
|
||||
{ SPA_KEY_FACTORY_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ SPA_KEY_FACTORY_DESCRIPTION, "Generate an audio test pattern" },
|
||||
};
|
||||
|
||||
static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
#include <spa/support/loop.h>
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/monitor/device.h>
|
||||
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/utils.h>
|
||||
|
|
@ -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 <wim.taymans@gmail.com>" },
|
||||
{ "factory.description", "Play audio with the a2dp" },
|
||||
{ SPA_KEY_FACTORY_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ SPA_KEY_FACTORY_DESCRIPTION, "Play audio with the a2dp" },
|
||||
{ SPA_KEY_FACTORY_USAGE, SPA_KEY_API_BLUEZ5_TRANSPORT"=<transport>" },
|
||||
};
|
||||
|
||||
static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
#include <spa/support/loop.h>
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/monitor/device.h>
|
||||
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/utils.h>
|
||||
|
|
@ -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. <contact@collabora.com>" },
|
||||
{ "factory.description", "Capture bluetooth audio with a2dp" },
|
||||
{ SPA_KEY_FACTORY_AUTHOR, "Collabora Ltd. <contact@collabora.com>" },
|
||||
{ SPA_KEY_FACTORY_DESCRIPTION, "Capture bluetooth audio with a2dp" },
|
||||
{ SPA_KEY_FACTORY_USAGE, SPA_KEY_API_BLUEZ5_TRANSPORT"=<transport>" },
|
||||
};
|
||||
|
||||
static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/utils/type.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/monitor/device.h>
|
||||
|
|
@ -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 <wim.taymans@gmail.com>" },
|
||||
{ SPA_KEY_FACTORY_DESCRIPTION, "A bluetooth device" },
|
||||
{ SPA_KEY_FACTORY_USAGE, SPA_KEY_API_BLUEZ5_DEVICE"=<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,
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include <spa/monitor/monitor.h>
|
||||
#include <spa/monitor/utils.h>
|
||||
#include <spa/utils/type.h>
|
||||
#include <spa/utils/keys.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/pod/builder.h>
|
||||
#include <spa/monitor/device.h>
|
||||
#include <spa/monitor/utils.h>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include <spa/support/loop.h>
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/utils/type.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/monitor/monitor.h>
|
||||
#include <spa/monitor/utils.h>
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
#include <spa/support/log.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/monitor/device.h>
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/io.h>
|
||||
#include <spa/node/utils.h>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <spa/support/log.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <spa/utils/keys.h>
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/utils.h>
|
||||
#include <spa/node/io.h>
|
||||
|
|
@ -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 <wim.taymans@gmail.com>" },
|
||||
{ "factory.description", "Generate a video test pattern" },
|
||||
{ SPA_KEY_FACTORY_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ SPA_KEY_FACTORY_DESCRIPTION, "Generate a video test pattern" },
|
||||
};
|
||||
|
||||
static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue