mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-09 13:30:06 -05:00
stream: add stream.rules and filter.rules
This commit is contained in:
parent
d63deb140c
commit
da6ab064d2
2 changed files with 31 additions and 2 deletions
|
|
@ -1175,6 +1175,15 @@ static const struct pw_core_events core_events = {
|
||||||
.error = on_core_error,
|
.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 *
|
static struct filter *
|
||||||
filter_new(struct pw_context *context, const char *name,
|
filter_new(struct pw_context *context, const char *name,
|
||||||
struct pw_properties *props, const struct pw_properties *extra)
|
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);
|
spa_hook_list_init(&impl->hooks);
|
||||||
this->properties = props;
|
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->name = name ? strdup(name) : NULL;
|
||||||
this->node_id = SPA_ID_INVALID;
|
this->node_id = SPA_ID_INVALID;
|
||||||
|
|
||||||
|
|
@ -1455,6 +1467,10 @@ int pw_filter_update_properties(struct pw_filter *filter, void *port_data, const
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
changed = pw_properties_update(filter->properties, dict);
|
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;
|
impl->info.props = &filter->properties->dict;
|
||||||
if (changed > 0) {
|
if (changed > 0) {
|
||||||
impl->info.change_mask |= SPA_NODE_CHANGE_MASK_PROPS;
|
impl->info.change_mask |= SPA_NODE_CHANGE_MASK_PROPS;
|
||||||
|
|
|
||||||
|
|
@ -1370,6 +1370,15 @@ static const struct pw_context_driver_events context_events = {
|
||||||
.drained = context_drained,
|
.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 *
|
static struct stream *
|
||||||
stream_new(struct pw_context *context, const char *name,
|
stream_new(struct pw_context *context, const char *name,
|
||||||
struct pw_properties *props, const struct pw_properties *extra)
|
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);
|
"%u/%u", q.num, q.denom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_hook_list_init(&impl->hooks);
|
spa_hook_list_init(&impl->hooks);
|
||||||
this->properties = props;
|
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->name = name ? strdup(name) : NULL;
|
||||||
this->node_id = SPA_ID_INVALID;
|
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;
|
int changed, res = 0;
|
||||||
|
|
||||||
changed = pw_properties_update(stream->properties, dict);
|
changed = pw_properties_update(stream->properties, dict);
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
pw_context_conf_section_match_rules(impl->context, "stream.rules",
|
||||||
|
&stream->properties->dict, execute_match, stream);
|
||||||
|
|
||||||
if (impl->node)
|
if (impl->node)
|
||||||
res = pw_impl_node_update_properties(impl->node, dict);
|
res = pw_impl_node_update_properties(impl->node, dict);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue