mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
interfaces: add method to update properties
This commit is contained in:
parent
1a27d7da1d
commit
0072f9cf2b
3 changed files with 74 additions and 3 deletions
|
|
@ -1225,6 +1225,52 @@ static void client_marshal_get_permissions(void *object, uint32_t index, uint32_
|
|||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
||||
static void client_marshal_update_properties(void *object, const struct spa_dict *props)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_builder *b;
|
||||
uint32_t i, n_items;
|
||||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_PROXY_METHOD_UPDATE_PROPERTIES);
|
||||
|
||||
n_items = props ? props->n_items : 0;
|
||||
|
||||
spa_pod_builder_add(b, "[ i", n_items, NULL);
|
||||
|
||||
for (i = 0; i < n_items; i++) {
|
||||
spa_pod_builder_add(b,
|
||||
"s", props->items[i].key,
|
||||
"s", props->items[i].value, NULL);
|
||||
}
|
||||
spa_pod_builder_add(b, "]", NULL);
|
||||
|
||||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
||||
static int client_demarshal_update_properties(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_dict props;
|
||||
struct spa_pod_parser prs;
|
||||
uint32_t i;
|
||||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs, "[ i", &props.n_items, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
||||
for (i = 0; i < props.n_items; i++) {
|
||||
if (spa_pod_parser_get(&prs,
|
||||
"s", &props.items[i].key,
|
||||
"s", &props.items[i].value,
|
||||
NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
pw_resource_do(resource, struct pw_client_proxy_methods, update_properties, 0,
|
||||
&props);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int client_demarshal_get_permissions(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
|
|
@ -1645,12 +1691,14 @@ static const struct pw_protocol_marshal pw_protocol_native_port_marshal = {
|
|||
static const struct pw_client_proxy_methods pw_protocol_native_client_method_marshal = {
|
||||
PW_VERSION_CLIENT_PROXY_METHODS,
|
||||
&client_marshal_error,
|
||||
&client_marshal_update_properties,
|
||||
&client_marshal_get_permissions,
|
||||
&client_marshal_update_permissions,
|
||||
};
|
||||
|
||||
static const struct pw_protocol_native_demarshal pw_protocol_native_client_method_demarshal[] = {
|
||||
{ &client_demarshal_error, PW_PERM_W, },
|
||||
{ &client_demarshal_update_properties, PW_PERM_W, },
|
||||
{ &client_demarshal_get_permissions, 0, },
|
||||
{ &client_demarshal_update_permissions, PW_PERM_W, },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -107,6 +107,14 @@ static void client_error(void *object, uint32_t id, int res, const char *error)
|
|||
pw_resource_error(client->core_resource, id, res, error);
|
||||
}
|
||||
|
||||
static void client_update_properties(void *object, const struct spa_dict *props)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct resource_data *data = pw_resource_get_user_data(resource);
|
||||
struct pw_client *client = data->client;
|
||||
pw_client_update_properties(client, props);
|
||||
}
|
||||
|
||||
static void client_get_permissions(void *object, uint32_t index, uint32_t num)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
|
|
@ -128,6 +136,7 @@ static void client_update_permissions(void *object,
|
|||
static const struct pw_client_proxy_methods client_methods = {
|
||||
PW_VERSION_CLIENT_PROXY_METHODS,
|
||||
.error = client_error,
|
||||
.update_properties = client_update_properties,
|
||||
.get_permissions = client_get_permissions,
|
||||
.update_permissions = client_update_permissions
|
||||
};
|
||||
|
|
|
|||
|
|
@ -745,9 +745,10 @@ pw_factory_proxy_add_listener(struct pw_factory_proxy *factory,
|
|||
#define PW_VERSION_CLIENT 0
|
||||
|
||||
#define PW_CLIENT_PROXY_METHOD_ERROR 0
|
||||
#define PW_CLIENT_PROXY_METHOD_GET_PERMISSIONS 1
|
||||
#define PW_CLIENT_PROXY_METHOD_UPDATE_PERMISSIONS 2
|
||||
#define PW_CLIENT_PROXY_METHOD_NUM 3
|
||||
#define PW_CLIENT_PROXY_METHOD_UPDATE_PROPERTIES 1
|
||||
#define PW_CLIENT_PROXY_METHOD_GET_PERMISSIONS 2
|
||||
#define PW_CLIENT_PROXY_METHOD_UPDATE_PERMISSIONS 3
|
||||
#define PW_CLIENT_PROXY_METHOD_NUM 4
|
||||
|
||||
/** Client methods */
|
||||
struct pw_client_proxy_methods {
|
||||
|
|
@ -762,6 +763,13 @@ struct pw_client_proxy_methods {
|
|||
* \param error an error string
|
||||
*/
|
||||
void (*error) (void *object, uint32_t id, int res, const char *error);
|
||||
/**
|
||||
* Update client properties
|
||||
*
|
||||
* \param props new properties
|
||||
*/
|
||||
void (*update_properties) (void *object, const struct spa_dict *props);
|
||||
|
||||
/**
|
||||
* Get client permissions
|
||||
*
|
||||
|
|
@ -795,6 +803,12 @@ pw_client_proxy_error(struct pw_client_proxy *client, uint32_t id, int res, cons
|
|||
pw_proxy_do((struct pw_proxy*)client, struct pw_client_proxy_methods, error, id, res, error);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pw_client_proxy_update_properties(struct pw_client_proxy *client, const struct spa_dict *props)
|
||||
{
|
||||
pw_proxy_do((struct pw_proxy*)client, struct pw_client_proxy_methods, update_properties, props);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pw_client_proxy_get_permissions(struct pw_client_proxy *client, uint32_t index, uint32_t num)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue