spa: add keys for properties

Define and document property keys
This commit is contained in:
Wim Taymans 2019-06-03 16:48:01 +02:00
parent 1f250046a3
commit 49ef8f9b5f
35 changed files with 333 additions and 134 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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,

View file

@ -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);