move PIPEWIRE_PROPS to stream and filter

Make all streams and filters handle PIPEWIRE_PROPS.
The order for applying stream/filter properties is:

1) application provided properties.
2) generic config.
3) match rules.
4) environment variables (PIPEWIRE_PROPS, ...) from generic to
   more specific.
5) defaults.
This commit is contained in:
Wim Taymans 2022-04-22 09:37:21 +02:00
parent 5a023c8c84
commit 61d318125e
5 changed files with 51 additions and 54 deletions

View file

@ -1211,20 +1211,16 @@ filter_new(struct pw_context *context, const char *name,
res = -errno;
goto error_properties;
}
spa_hook_list_init(&impl->hooks);
this->properties = props;
pw_context_conf_update_props(context, "filter.properties", props);
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
str = pw_properties_get(extra, PW_KEY_APP_NAME);
if (str == NULL)
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
if (str == NULL)
str = name;
pw_properties_set(props, PW_KEY_NODE_NAME, str);
}
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
pw_properties_set(props, PW_KEY_NODE_LATENCY, str);
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
pw_properties_set(props, PW_KEY_NODE_RATE, str);
pw_context_conf_section_match_rules(impl->context, "filter.rules",
&this->properties->dict, execute_match, this);
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
pw_properties_update_string(props, str, strlen(str));
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
struct spa_fraction q;
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
@ -1234,12 +1230,19 @@ filter_new(struct pw_context *context, const char *name,
"%u/%u", q.num, q.denom);
}
}
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
pw_properties_set(props, PW_KEY_NODE_LATENCY, str);
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
pw_properties_set(props, PW_KEY_NODE_RATE, str);
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);
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
str = pw_properties_get(extra, PW_KEY_APP_NAME);
if (str == NULL)
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
if (str == NULL)
str = name;
pw_properties_set(props, PW_KEY_NODE_NAME, str);
}
this->name = name ? strdup(name) : NULL;
this->node_id = SPA_ID_INVALID;

View file

@ -1411,23 +1411,16 @@ stream_new(struct pw_context *context, const char *name,
res = -errno;
goto error_properties;
}
spa_hook_list_init(&impl->hooks);
this->properties = props;
pw_context_conf_update_props(context, "stream.properties", props);
if (pw_properties_get(props, PW_KEY_STREAM_IS_LIVE) == NULL)
pw_properties_set(props, PW_KEY_STREAM_IS_LIVE, "true");
pw_context_conf_section_match_rules(context, "stream.rules",
&this->properties->dict, execute_match, this);
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
str = pw_properties_get(extra, PW_KEY_APP_NAME);
if (str == NULL)
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
if (str == NULL)
str = name;
pw_properties_set(props, PW_KEY_NODE_NAME, str);
}
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
pw_properties_set(props, PW_KEY_NODE_LATENCY, str);
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
pw_properties_set(props, PW_KEY_NODE_RATE, str);
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
pw_properties_update_string(props, str, strlen(str));
if ((str = getenv("PIPEWIRE_QUANTUM")) != NULL) {
struct spa_fraction q;
if (sscanf(str, "%u/%u", &q.num, &q.denom) == 2 && q.denom != 0) {
@ -1437,11 +1430,21 @@ stream_new(struct pw_context *context, const char *name,
"%u/%u", q.num, q.denom);
}
}
spa_hook_list_init(&impl->hooks);
this->properties = props;
if ((str = getenv("PIPEWIRE_LATENCY")) != NULL)
pw_properties_set(props, PW_KEY_NODE_LATENCY, str);
if ((str = getenv("PIPEWIRE_RATE")) != NULL)
pw_properties_set(props, PW_KEY_NODE_RATE, str);
pw_context_conf_section_match_rules(context, "stream.rules",
&this->properties->dict, execute_match, this);
if (pw_properties_get(props, PW_KEY_STREAM_IS_LIVE) == NULL)
pw_properties_set(props, PW_KEY_STREAM_IS_LIVE, "true");
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
str = pw_properties_get(extra, PW_KEY_APP_NAME);
if (str == NULL)
str = pw_properties_get(extra, PW_KEY_APP_PROCESS_BINARY);
if (str == NULL)
str = name;
pw_properties_set(props, PW_KEY_NODE_NAME, str);
}
this->name = name ? strdup(name) : NULL;
this->node_id = SPA_ID_INVALID;