keys: add keys.h with defines and docs

Add a keys.h file that lists and documents all keys available to
be used in properties.
This commit is contained in:
Wim Taymans 2019-05-24 15:47:48 +02:00
parent 7bb6515800
commit 3ad73f0532
52 changed files with 483 additions and 291 deletions

View file

@ -35,9 +35,9 @@
#include <pipewire/pipewire.h>
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Perform access check" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Perform access check" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct impl {
@ -121,7 +121,7 @@ core_check_access(void *data, struct pw_client *client)
pid = -EINVAL;
if ((props = pw_client_get_properties(client)) != NULL) {
if ((str = pw_properties_get(props, PW_CLIENT_PROP_UCRED_PID)) != NULL)
if ((str = pw_properties_get(props, PW_KEY_SEC_PID)) != NULL)
pid = atoi(str);
}
@ -138,7 +138,7 @@ core_check_access(void *data, struct pw_client *client)
goto granted;
if (res > 0)
res = -EACCES;
items[0] = SPA_DICT_ITEM_INIT("pipewire.access", "blacklisted");
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_ACCESS, "blacklisted");
goto blacklisted;
}
@ -153,7 +153,7 @@ core_check_access(void *data, struct pw_client *client)
else if (res > 0) {
pw_log_debug("module %p: restricted client %p added", impl, client);
}
items[0] = SPA_DICT_ITEM_INIT("pipewire.access", "restricted");
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_ACCESS, "restricted");
goto wait_permissions;
}
@ -166,7 +166,7 @@ core_check_access(void *data, struct pw_client *client)
else if (res > 0) {
pw_log_debug("module %p: sandboxed client %p added", impl, client);
}
items[0] = SPA_DICT_ITEM_INIT("pipewire.access", "flatpak");
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_ACCESS, "flatpak");
goto wait_permissions;
}

View file

@ -40,9 +40,9 @@
#include "module-audio-dsp/audio-dsp.h"
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Manage audio DSP nodes" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Manage audio DSP nodes" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct factory_data {

View file

@ -187,13 +187,13 @@ static void node_port_init(void *data, struct pw_port *port)
old = pw_port_get_properties(port);
monitor = (str = pw_properties_get(old, "port.monitor")) != NULL &&
atoi(str) != 0;
monitor = (str = pw_properties_get(old, PW_KEY_PORT_MONITOR)) != NULL &&
pw_properties_parse_bool(str);
if (!monitor && direction == n->direction)
return;
new = pw_properties_new("port.dsp", "32 bit float mono audio", NULL);
new = pw_properties_new(PW_KEY_FORMAT_DSP, "32 bit float mono audio", NULL);
if (monitor)
prefix = "monitor";
@ -202,23 +202,23 @@ static void node_port_init(void *data, struct pw_port *port)
else
prefix = "capture";
if ((str = pw_properties_get(old, "port.channel")) == NULL ||
if ((str = pw_properties_get(old, PW_KEY_PORT_CHANNEL)) == NULL ||
strcmp(str, "UNK") == 0) {
snprintf(position, 7, "%d", port->port_id);
str = position;
}
pw_properties_setf(new, "port.name", "%s_%s", prefix, str);
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
if (direction != n->direction) {
pw_properties_setf(new, "port.alias1", "%s_pcm:%s:%s%s",
pw_properties_get(n->props, "device.api"),
pw_properties_setf(new, PW_KEY_PORT_ALIAS1, "%s_pcm:%s:%s%s",
pw_properties_get(n->props, PW_KEY_DEVICE_API),
pw_properties_get(n->props, "audio-dsp.name"),
direction == PW_DIRECTION_INPUT ? "in" : "out",
str);
pw_properties_set(new, "port.physical", "1");
pw_properties_set(new, "port.terminal", "1");
pw_properties_set(new, PW_KEY_PORT_PHYSICAL, "1");
pw_properties_set(new, PW_KEY_PORT_TERMINAL, "1");
}
pw_port_update_properties(port, &new->dict);
@ -271,8 +271,8 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
pr = pw_properties_copy(props);
if ((api = pw_properties_get(pr, "device.api")) == NULL) {
pw_log_error("missing device.api property");
if ((api = pw_properties_get(pr, PW_KEY_DEVICE_API)) == NULL) {
pw_log_error("missing "PW_KEY_DEVICE_API" property");
goto error;
}
if ((alias = pw_properties_get(pr, "audio-dsp.name")) == NULL) {
@ -287,14 +287,14 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
}
pw_properties_set(pr,
"media.class",
PW_KEY_MEDIA_CLASS,
direction == PW_DIRECTION_OUTPUT ?
"Audio/DSP/Playback" :
"Audio/DSP/Capture");
pw_properties_set(pr, "node.driver", NULL);
pw_properties_set(pr, PW_KEY_NODE_DRIVER, NULL);
if ((str = pw_properties_get(pr, "node.id")) != NULL)
pw_properties_set(pr, "node.session", str);
if ((str = pw_properties_get(pr, PW_KEY_NODE_ID)) != NULL)
pw_properties_set(pr, PW_KEY_NODE_SESSION, str);
if (direction == PW_DIRECTION_OUTPUT) {
pw_properties_set(pr, "merger.monitor", "1");

View file

@ -35,9 +35,9 @@
#include "module-client-node/client-stream.h"
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Allow clients to create and control remote nodes" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Allow clients to create and control remote nodes" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct pw_proxy *pw_remote_node_export(struct pw_remote *remote,
@ -76,7 +76,7 @@ static void *create_object(void *_data,
parent = pw_client_get_global(client);
if (properties && pw_properties_get(properties, "node.stream") != NULL) {
if (properties && pw_properties_get(properties, PW_KEY_NODE_STREAM) != NULL) {
result = pw_client_stream_new(node_resource, parent, properties);
}
else {

View file

@ -1671,7 +1671,7 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
pw_map_init(&impl->io_map, 64, 64);
pw_array_init(&impl->mems, 64);
if ((name = pw_properties_get(properties, "node.name")) == NULL)
if ((name = pw_properties_get(properties, PW_KEY_NODE_NAME)) == NULL)
name = "client-node";
this->resource = resource;

View file

@ -988,11 +988,12 @@ static void client_node_initialized(void *data)
dir);
props = pw_node_get_properties(impl->client_node->node);
if (props != NULL && (str = pw_properties_get(props, PW_NODE_PROP_EXCLUSIVE)) != NULL)
if (props != NULL && (str = pw_properties_get(props, PW_KEY_NODE_EXCLUSIVE)) != NULL)
exclusive = pw_properties_parse_bool(str);
else
exclusive = false;
if (props != NULL && (str = pw_properties_get(props, "pipewire.monitor")) != NULL)
if (props != NULL && (str = pw_properties_get(props, PW_KEY_STREAM_MONITOR)) != NULL)
monitor = pw_properties_parse_bool(str);
else
monitor = false;
@ -1105,7 +1106,7 @@ static void client_node_initialized(void *data)
snprintf(media_class, sizeof(media_class), "Stream/%s/%s", dir, type);
items[0] = SPA_DICT_ITEM_INIT("media.class", media_class);
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MEDIA_CLASS, media_class);
pw_node_update_properties(impl->this.node, &SPA_DICT_INIT(items, 1));
}
@ -1262,7 +1263,7 @@ struct pw_client_stream *pw_client_stream_new(struct pw_resource *resource,
pw_log_debug("client-stream %p: new", impl);
props = pw_properties_copy(properties);
pw_properties_set(props, "node.driver", NULL);
pw_properties_set(props, PW_KEY_NODE_DRIVER, NULL);
impl->client_node = pw_client_node_new(
resource,
@ -1280,7 +1281,7 @@ struct pw_client_stream *pw_client_stream_new(struct pw_resource *resource,
node_init(&impl->node, NULL, support, n_support);
impl->node.impl = impl;
if ((name = pw_properties_get(properties, "node.name")) == NULL)
if ((name = pw_properties_get(properties, PW_KEY_NODE_NAME)) == NULL)
name = "client-stream";
this->node = pw_spa_node_new(core,

View file

@ -33,9 +33,9 @@
#include "pipewire/private.h"
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Allow clients to create links" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Allow clients to create links" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct factory_data {
@ -153,20 +153,20 @@ static void *create_object(void *_data,
if (properties == NULL)
goto no_properties;
if ((str = pw_properties_get(properties, PW_LINK_OUTPUT_NODE_ID)) == NULL)
if ((str = pw_properties_get(properties, PW_KEY_LINK_OUTPUT_NODE)) == NULL)
goto no_properties;
output_node_id = pw_properties_parse_int(str);
if ((str = pw_properties_get(properties, PW_LINK_INPUT_NODE_ID)) == NULL)
if ((str = pw_properties_get(properties, PW_KEY_LINK_INPUT_NODE)) == NULL)
goto no_properties;
input_node_id = pw_properties_parse_int(str);
str = pw_properties_get(properties, PW_LINK_OUTPUT_PORT_ID);
str = pw_properties_get(properties, PW_KEY_LINK_OUTPUT_PORT);
output_port_id = str ? pw_properties_parse_int(str) : -1;
str = pw_properties_get(properties, PW_LINK_INPUT_PORT_ID);
str = pw_properties_get(properties, PW_KEY_LINK_INPUT_PORT);
input_port_id = str ? pw_properties_parse_int(str) : -1;
global = pw_core_find_global(core, output_node_id);
@ -206,7 +206,7 @@ static void *create_object(void *_data,
if (inport == NULL)
goto no_input_port;
str = pw_properties_get(properties, "object.linger");
str = pw_properties_get(properties, PW_KEY_OBJECT_LINGER);
linger = str ? pw_properties_parse_bool(str) : false;
link = pw_link_new(core, outport, inport, NULL, properties, sizeof(struct link_data));

View file

@ -371,10 +371,10 @@ handle_create_client_node(PipeWireDaemon1 * interface,
pw_log_debug("protocol-dbus %p: create client-node: %s", impl, sender);
props = pw_properties_from_variant(arg_properties);
target_node = pw_properties_get(props, PW_NODE_PROP_TARGET_NODE);
target_node = pw_properties_get(props, PW_KEY_NODE_TARGET);
if (target_node) {
if (strncmp(target_node, "/org/pipewire/node_", strlen("/org/pipewire/node_")) == 0) {
pw_properties_setf(props, PW_NODE_PROP_TARGET_NODE, "%s",
pw_properties_setf(props, PW_KEY_NODE_TARGET, "%s",
target_node + strlen("/org/pipewire/node_"));
}
}

View file

@ -54,9 +54,9 @@
#endif
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Native protocol using unix sockets" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Native protocol using unix sockets" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
static bool debug_messages = 0;
@ -256,7 +256,7 @@ static struct pw_client *client_new(struct server *s, int fd)
struct pw_properties *props;
char buffer[1024];
props = pw_properties_new(PW_CLIENT_PROP_PROTOCOL, "protocol-native", NULL);
props = pw_properties_new(PW_KEY_PROTOCOL, "protocol-native", NULL);
if (props == NULL)
goto exit;
@ -264,16 +264,16 @@ static struct pw_client *client_new(struct server *s, int fd)
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) < 0) {
pw_log_error("no peercred: %m");
} else {
pw_properties_setf(props, PW_CLIENT_PROP_UCRED_PID, "%d", ucred.pid);
pw_properties_setf(props, PW_CLIENT_PROP_UCRED_UID, "%d", ucred.uid);
pw_properties_setf(props, PW_CLIENT_PROP_UCRED_GID, "%d", ucred.gid);
pw_properties_setf(props, PW_KEY_SEC_PID, "%d", ucred.pid);
pw_properties_setf(props, PW_KEY_SEC_UID, "%d", ucred.uid);
pw_properties_setf(props, PW_KEY_SEC_GID, "%d", ucred.gid);
}
len = sizeof(buffer);
if (getsockopt(fd, SOL_SOCKET, SO_PEERSEC, buffer, &len) < 0) {
pw_log_error("no peersec: %m");
} else {
pw_properties_setf(props, PW_CLIENT_PROP_SEC_LABEL, "%s", buffer);
pw_properties_setf(props, PW_KEY_SEC_LABEL, "%s", buffer);
}
client = pw_client_new(protocol->core,
@ -651,7 +651,7 @@ impl_new_client(struct pw_protocol *protocol,
impl->properties = properties ? pw_properties_copy(properties) : NULL;
if (properties)
str = pw_properties_get(properties, "remote.intention");
str = pw_properties_get(properties, PW_KEY_REMOTE_INTENTION);
if (str == NULL)
str = "generic";
@ -719,7 +719,7 @@ get_name(const struct pw_properties *properties)
const char *name = NULL;
if (properties)
name = pw_properties_get(properties, PW_CORE_PROP_NAME);
name = pw_properties_get(properties, PW_KEY_CORE_NAME);
if (name == NULL)
name = getenv("PIPEWIRE_CORE");
if (name == NULL)
@ -888,7 +888,7 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
val = getenv("PIPEWIRE_DAEMON");
if (val == NULL)
val = pw_properties_get(pw_core_get_properties(core), PW_CORE_PROP_DAEMON);
val = pw_properties_get(pw_core_get_properties(core), PW_KEY_CORE_DAEMON);
if (val && pw_properties_parse_bool(val)) {
if (impl_add_server(this, core, properties) == NULL)
return -errno;

View file

@ -42,7 +42,7 @@ get_remote(const struct pw_properties *properties)
const char *name = NULL;
if (properties)
name = pw_properties_get(properties, PW_REMOTE_PROP_REMOTE_NAME);
name = pw_properties_get(properties, PW_KEY_REMOTE_NAME);
if (name == NULL)
name = getenv("PIPEWIRE_REMOTE");
if (name == NULL)

View file

@ -42,9 +42,9 @@
#include <pipewire/pipewire.h>
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Use RTKit to raise thread priorities" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Use RTKit to raise thread priorities" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct impl {

View file

@ -33,14 +33,15 @@
#include <pipewire/log.h>
#include <pipewire/module.h>
#include <pipewire/utils.h>
#include <pipewire/keys.h>
#include "spa-monitor.h"
#include "spa-device.h"
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Load and manage an SPA device" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Load and manage an SPA device" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct device_data {

View file

@ -35,13 +35,14 @@
#include <pipewire/log.h>
#include <pipewire/core.h>
#include <pipewire/module.h>
#include <pipewire/keys.h>
#include "spa-monitor.h"
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Manage SPA monitors" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Manage SPA monitors" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct data {

View file

@ -34,9 +34,9 @@
#include "spa-node.h"
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Provide a factory to make SPA nodes" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Provide a factory to make SPA nodes" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct factory_data {

View file

@ -32,6 +32,7 @@
#include <limits.h>
#include <pipewire/core.h>
#include <pipewire/keys.h>
#include <pipewire/log.h>
#include <pipewire/module.h>
#include <pipewire/utils.h>
@ -40,9 +41,9 @@
#include "spa-node.h"
static const struct spa_dict_item module_props[] = {
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_MODULE_PROP_DESCRIPTION, "Load and manage an SPA node" },
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Load and manage an SPA node" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
};
struct node_data {

View file

@ -42,6 +42,7 @@
#include <pipewire/type.h>
#include <pipewire/node.h>
#include <pipewire/device.h>
#include <pipewire/keys.h>
#include "spa-monitor.h"
#include "spa-device.h"
@ -117,11 +118,11 @@ static struct monitor_item *add_item(struct pw_spa_monitor *this,
}
}
if ((str = pw_properties_get(props, "device.form_factor")) != NULL)
if ((str = pw_properties_get(props, PW_KEY_DEVICE_FORM_FACTOR)) != NULL)
if (strcmp(str, "internal") == 0)
now = 0;
if (now != 0 && pw_properties_get(props, "device.plugged") == NULL)
pw_properties_setf(props, "device.plugged", "%"PRIu64, now);
if (now != 0 && pw_properties_get(props, PW_KEY_DEVICE_PLUGGED) == NULL)
pw_properties_setf(props, PW_KEY_DEVICE_PLUGGED, "%"PRIu64, now);
support = pw_core_get_support(impl->core, &n_support);