stream: add stream.rules and filter.rules

This commit is contained in:
Wim Taymans 2022-04-21 16:28:08 +02:00
parent d63deb140c
commit da6ab064d2
2 changed files with 31 additions and 2 deletions

View file

@ -1175,6 +1175,15 @@ static const struct pw_core_events core_events = {
.error = on_core_error,
};
static int execute_match(void *data, const char *location, const char *action,
const char *val, size_t len)
{
struct pw_filter *this = data;
if (spa_streq(action, "update-props"))
pw_properties_update_string(this->properties, val, len);
return 1;
}
static struct filter *
filter_new(struct pw_context *context, const char *name,
struct pw_properties *props, const struct pw_properties *extra)
@ -1229,6 +1238,9 @@ filter_new(struct pw_context *context, const char *name,
spa_hook_list_init(&impl->hooks);
this->properties = props;
pw_context_conf_section_match_rules(impl->context, "filter.rules",
&this->properties->dict, execute_match, this);
this->name = name ? strdup(name) : NULL;
this->node_id = SPA_ID_INVALID;
@ -1455,6 +1467,10 @@ int pw_filter_update_properties(struct pw_filter *filter, void *port_data, const
}
} else {
changed = pw_properties_update(filter->properties, dict);
pw_context_conf_section_match_rules(impl->context, "filter.rules",
&filter->properties->dict, execute_match, filter);
impl->info.props = &filter->properties->dict;
if (changed > 0) {
impl->info.change_mask |= SPA_NODE_CHANGE_MASK_PROPS;

View file

@ -1370,6 +1370,15 @@ static const struct pw_context_driver_events context_events = {
.drained = context_drained,
};
static int execute_match(void *data, const char *location, const char *action,
const char *val, size_t len)
{
struct pw_stream *this = data;
if (spa_streq(action, "update-props"))
pw_properties_update_string(this->properties, val, len);
return 1;
}
static struct stream *
stream_new(struct pw_context *context, const char *name,
struct pw_properties *props, const struct pw_properties *extra)
@ -1428,10 +1437,12 @@ stream_new(struct pw_context *context, const char *name,
"%u/%u", q.num, q.denom);
}
}
spa_hook_list_init(&impl->hooks);
this->properties = props;
pw_context_conf_section_match_rules(context, "stream.rules",
&this->properties->dict, execute_match, this);
this->name = name ? strdup(name) : NULL;
this->node_id = SPA_ID_INVALID;
@ -1642,10 +1653,12 @@ int pw_stream_update_properties(struct pw_stream *stream, const struct spa_dict
int changed, res = 0;
changed = pw_properties_update(stream->properties, dict);
if (!changed)
return 0;
pw_context_conf_section_match_rules(impl->context, "stream.rules",
&stream->properties->dict, execute_match, stream);
if (impl->node)
res = pw_impl_node_update_properties(impl->node, dict);