mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
client-node: update port properties
Handle port properties Set the client name
This commit is contained in:
parent
342f0d59d0
commit
70687e466d
2 changed files with 49 additions and 8 deletions
|
|
@ -74,6 +74,7 @@ struct buffer {
|
|||
struct port {
|
||||
bool valid;
|
||||
struct spa_port_info info;
|
||||
struct pw_properties *properties;
|
||||
|
||||
bool have_format;
|
||||
uint32_t n_params;
|
||||
|
|
@ -337,8 +338,20 @@ do_update_port(struct proxy *this,
|
|||
}
|
||||
}
|
||||
|
||||
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO && info)
|
||||
port->info = *info;
|
||||
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO) {
|
||||
if (port->properties)
|
||||
pw_properties_free(port->properties);
|
||||
port->properties = NULL;
|
||||
port->info.props = NULL;
|
||||
|
||||
if (info) {
|
||||
port->info = *info;
|
||||
if (info->props) {
|
||||
port->properties = pw_properties_new_dict(info->props);
|
||||
port->info.props = &port->properties->dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!port->valid) {
|
||||
spa_log_info(this->log, "proxy %p: adding port %d", this, port_id);
|
||||
|
|
@ -1188,7 +1201,7 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
|||
struct pw_core *core = pw_client_get_core(client);
|
||||
const struct spa_support *support;
|
||||
uint32_t n_support;
|
||||
const char *name = "client-node";
|
||||
const char *name;
|
||||
const char *str;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
|
|
@ -1207,6 +1220,9 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
|||
proxy_init(&impl->proxy, NULL, support, n_support);
|
||||
impl->proxy.impl = impl;
|
||||
|
||||
if ((name = pw_properties_get(properties, "node.name")) == NULL)
|
||||
name = "client-node";
|
||||
|
||||
this->resource = resource;
|
||||
this->node = pw_spa_node_new(core,
|
||||
pw_resource_get_client(this->resource),
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ client_node_marshal_port_update(void *object,
|
|||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_builder *b;
|
||||
int i;
|
||||
int i, n_items;
|
||||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_PORT_UPDATE);
|
||||
|
||||
|
|
@ -102,9 +102,19 @@ client_node_marshal_port_update(void *object,
|
|||
spa_pod_builder_add(b, "P", params[i], NULL);
|
||||
|
||||
if (info) {
|
||||
spa_pod_builder_struct(b,
|
||||
"i", info->flags,
|
||||
"i", info->rate);
|
||||
n_items = info->props ? info->props->n_items : 0;
|
||||
|
||||
spa_pod_builder_add(b,
|
||||
"[",
|
||||
"i", info->flags,
|
||||
"i", info->rate,
|
||||
"i", n_items, NULL);
|
||||
for (i = 0; i < n_items; i++) {
|
||||
spa_pod_builder_add(b,
|
||||
"s", info->props->items[i].key,
|
||||
"s", info->props->items[i].value, NULL);
|
||||
}
|
||||
spa_pod_builder_add(b, "]", NULL);
|
||||
} else {
|
||||
spa_pod_builder_add(b, "P", NULL, NULL);
|
||||
}
|
||||
|
|
@ -727,6 +737,7 @@ static int client_node_demarshal_port_update(void *object, void *data, size_t si
|
|||
const struct spa_pod **params = NULL;
|
||||
struct spa_port_info info = { 0 }, *infop = NULL;
|
||||
struct spa_pod *ipod;
|
||||
struct spa_dict props;
|
||||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs,
|
||||
|
|
@ -753,8 +764,22 @@ static int client_node_demarshal_port_update(void *object, void *data, size_t si
|
|||
if (spa_pod_parser_get(&p2,
|
||||
"["
|
||||
"i", &info.flags,
|
||||
"i", &info.rate, NULL) < 0)
|
||||
"i", &info.rate,
|
||||
"i", &props.n_items, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (props.n_items > 0) {
|
||||
info.props = &props;
|
||||
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
for (i = 0; i < props.n_items; i++) {
|
||||
if (spa_pod_parser_get(&p2,
|
||||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value,
|
||||
NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, port_update, direction,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue