mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
core: add bound_props event
this event extends the bound_id event and sends the global properties as well. This can be used to get the object.serial, for example. It can also be used in the future to let the server generate unique property values, like the node.name, and let the client know about the new property value.
This commit is contained in:
parent
59cd5670d7
commit
fb8709716c
14 changed files with 111 additions and 29 deletions
|
|
@ -1143,18 +1143,20 @@ static void client_node_destroy(void *_data)
|
|||
client_node_removed(_data);
|
||||
}
|
||||
|
||||
static void client_node_bound(void *_data, uint32_t global_id)
|
||||
static void client_node_bound_props(void *_data, uint32_t global_id, const struct spa_dict *props)
|
||||
{
|
||||
struct node_data *data = _data;
|
||||
pw_log_debug("%p: bound %u", data, global_id);
|
||||
data->remote_id = global_id;
|
||||
if (props)
|
||||
pw_properties_update(data->node->properties, props);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events proxy_client_node_events = {
|
||||
PW_VERSION_PROXY_EVENTS,
|
||||
.removed = client_node_removed,
|
||||
.destroy = client_node_destroy,
|
||||
.bound = client_node_bound,
|
||||
.bound_props = client_node_bound_props,
|
||||
};
|
||||
|
||||
static int node_ready(void *d, int status)
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ static void sink_proxy_removed(void *data)
|
|||
pw_proxy_destroy(impl->sink);
|
||||
}
|
||||
|
||||
static void sink_proxy_bound(void *data, uint32_t id)
|
||||
static void sink_proxy_bound_props(void *data, uint32_t id, const struct spa_dict *props)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ static void sink_proxy_destroy(void *data)
|
|||
static const struct pw_proxy_events sink_proxy_events = {
|
||||
PW_VERSION_PROXY_EVENTS,
|
||||
.removed = sink_proxy_removed,
|
||||
.bound = sink_proxy_bound,
|
||||
.bound_props = sink_proxy_bound_props,
|
||||
.destroy = sink_proxy_destroy,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -395,6 +395,27 @@ static int core_event_demarshal_bound_id(void *data, const struct pw_protocol_na
|
|||
return pw_proxy_notify(proxy, struct pw_core_events, bound_id, 0, id, global_id);
|
||||
}
|
||||
|
||||
static int core_event_demarshal_bound_props(void *data, const struct pw_protocol_native_message *msg)
|
||||
{
|
||||
struct pw_proxy *proxy = data;
|
||||
struct spa_pod_parser prs;
|
||||
uint32_t id, global_id;
|
||||
struct spa_pod_frame f[2];
|
||||
struct spa_dict props = SPA_DICT_INIT(NULL, 0);
|
||||
|
||||
spa_pod_parser_init(&prs, msg->data, msg->size);
|
||||
if (spa_pod_parser_push_struct(&prs, &f[0]) < 0)
|
||||
return -EINVAL;
|
||||
if (spa_pod_parser_get(&prs,
|
||||
SPA_POD_Int(&id),
|
||||
SPA_POD_Int(&global_id), NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
parse_dict_struct(&prs, &f[1], &props);
|
||||
|
||||
return pw_proxy_notify(proxy, struct pw_core_events, bound_props, 1, id, global_id, &props);
|
||||
}
|
||||
|
||||
static int core_event_demarshal_add_mem(void *data, const struct pw_protocol_native_message *msg)
|
||||
{
|
||||
struct pw_proxy *proxy = data;
|
||||
|
|
@ -526,6 +547,25 @@ static void core_event_marshal_bound_id(void *data, uint32_t id, uint32_t global
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static void core_event_marshal_bound_props(void *data, uint32_t id, uint32_t global_id, const struct spa_dict *props)
|
||||
{
|
||||
struct pw_resource *resource = data;
|
||||
struct spa_pod_builder *b;
|
||||
struct spa_pod_frame f;
|
||||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CORE_EVENT_BOUND_PROPS, NULL);
|
||||
|
||||
spa_pod_builder_push_struct(b, &f);
|
||||
spa_pod_builder_add(b,
|
||||
SPA_POD_Int(id),
|
||||
SPA_POD_Int(global_id),
|
||||
NULL);
|
||||
push_dict(b, props);
|
||||
spa_pod_builder_pop(b, &f);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static void core_event_marshal_add_mem(void *data, uint32_t id, uint32_t type, int fd, uint32_t flags)
|
||||
{
|
||||
struct pw_resource *resource = data;
|
||||
|
|
@ -1863,6 +1903,7 @@ static const struct pw_core_events pw_protocol_native_core_event_marshal = {
|
|||
.bound_id = &core_event_marshal_bound_id,
|
||||
.add_mem = &core_event_marshal_add_mem,
|
||||
.remove_mem = &core_event_marshal_remove_mem,
|
||||
.bound_props = &core_event_marshal_bound_props,
|
||||
};
|
||||
|
||||
static const struct pw_protocol_native_demarshal
|
||||
|
|
@ -1876,6 +1917,7 @@ pw_protocol_native_core_event_demarshal[PW_CORE_EVENT_NUM] =
|
|||
[PW_CORE_EVENT_BOUND_ID] = { &core_event_demarshal_bound_id, 0, },
|
||||
[PW_CORE_EVENT_ADD_MEM] = { &core_event_demarshal_add_mem, 0, },
|
||||
[PW_CORE_EVENT_REMOVE_MEM] = { &core_event_demarshal_remove_mem, 0, },
|
||||
[PW_CORE_EVENT_BOUND_PROPS] = { &core_event_demarshal_bound_props, 0, },
|
||||
};
|
||||
|
||||
static const struct pw_protocol_marshal pw_protocol_native_core_marshal = {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ static void module_null_sink_proxy_destroy(void *data)
|
|||
module_schedule_unload(module);
|
||||
}
|
||||
|
||||
static void module_null_sink_proxy_bound(void *data, uint32_t global_id)
|
||||
static void module_null_sink_proxy_bound_props(void *data, uint32_t global_id, const struct spa_dict *props)
|
||||
{
|
||||
struct module *module = data;
|
||||
struct module_null_sink_data *d = module->user_data;
|
||||
|
|
@ -63,7 +63,7 @@ static void module_null_sink_proxy_error(void *data, int seq, int res, const cha
|
|||
static const struct pw_proxy_events proxy_events = {
|
||||
PW_VERSION_PROXY_EVENTS,
|
||||
.removed = module_null_sink_proxy_removed,
|
||||
.bound = module_null_sink_proxy_bound,
|
||||
.bound_props = module_null_sink_proxy_bound_props,
|
||||
.error = module_null_sink_proxy_error,
|
||||
.destroy = module_null_sink_proxy_destroy,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue