mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
properties: copy_keys -> update_keys
Change copy_keys to update_keys and make it more powerful by taking a spa_dict as the source. Copy some more properties in the session.
This commit is contained in:
parent
60cd74fdb0
commit
9df6efcd8d
12 changed files with 23 additions and 18 deletions
|
|
@ -83,6 +83,8 @@ static int client_endpoint_stream_update(void *object,
|
||||||
PW_KEY_FACTORY_ID,
|
PW_KEY_FACTORY_ID,
|
||||||
PW_KEY_CLIENT_ID,
|
PW_KEY_CLIENT_ID,
|
||||||
PW_KEY_ENDPOINT_ID,
|
PW_KEY_ENDPOINT_ID,
|
||||||
|
PW_KEY_MEDIA_CLASS,
|
||||||
|
PW_KEY_PRIORITY_SESSION,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -93,7 +95,10 @@ static int client_endpoint_stream_update(void *object,
|
||||||
props = pw_properties_new(NULL, NULL);
|
props = pw_properties_new(NULL, NULL);
|
||||||
if (!props)
|
if (!props)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
pw_properties_copy_keys (endpoint->props, props, keys);
|
|
||||||
|
pw_properties_update_keys(props, &endpoint->props->dict, keys);
|
||||||
|
if (info && info->props)
|
||||||
|
pw_properties_update_keys(props, info->props, keys);
|
||||||
|
|
||||||
if (endpoint_stream_init(stream, stream_id, endpoint->info.id,
|
if (endpoint_stream_init(stream, stream_id, endpoint->info.id,
|
||||||
this, core, props) < 0)
|
this, core, props) < 0)
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ static int client_session_link_update(void *object,
|
||||||
props = pw_properties_new(NULL, NULL);
|
props = pw_properties_new(NULL, NULL);
|
||||||
if (!props)
|
if (!props)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
pw_properties_copy_keys (session->props, props, keys);
|
pw_properties_update_keys(props, &session->props->dict, keys);
|
||||||
|
|
||||||
if (endpoint_link_init(link, link_id, session->info.id,
|
if (endpoint_link_init(link, link_id, session->info.id,
|
||||||
this, core, props) < 0)
|
this, core, props) < 0)
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,7 @@ int endpoint_init(struct endpoint *this,
|
||||||
PW_KEY_FACTORY_ID,
|
PW_KEY_FACTORY_ID,
|
||||||
PW_KEY_CLIENT_ID,
|
PW_KEY_CLIENT_ID,
|
||||||
PW_KEY_DEVICE_ID,
|
PW_KEY_DEVICE_ID,
|
||||||
|
PW_KEY_MEDIA_CLASS,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -299,7 +300,7 @@ int endpoint_init(struct endpoint *this,
|
||||||
if (!properties)
|
if (!properties)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
pw_properties_copy_keys(this->props, properties, keys);
|
pw_properties_update_keys(properties, &this->props->dict, keys);
|
||||||
|
|
||||||
this->global = pw_global_new (core,
|
this->global = pw_global_new (core,
|
||||||
PW_TYPE_INTERFACE_Endpoint,
|
PW_TYPE_INTERFACE_Endpoint,
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ int session_init(struct session *this,
|
||||||
if (!properties)
|
if (!properties)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
pw_properties_copy_keys(this->props, properties, keys);
|
pw_properties_update_keys(properties, &this->props->dict, keys);
|
||||||
|
|
||||||
this->global = pw_global_new (core,
|
this->global = pw_global_new (core,
|
||||||
PW_TYPE_INTERFACE_Session,
|
PW_TYPE_INTERFACE_Session,
|
||||||
|
|
|
||||||
|
|
@ -394,7 +394,7 @@ int pw_client_register(struct pw_client *client,
|
||||||
if (properties == NULL)
|
if (properties == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pw_properties_copy_keys(client->properties, properties, keys);
|
pw_properties_update_keys(properties, &client->properties->dict, keys);
|
||||||
|
|
||||||
client->global = pw_global_new(core,
|
client->global = pw_global_new(core,
|
||||||
PW_TYPE_INTERFACE_Client,
|
PW_TYPE_INTERFACE_Client,
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@ int pw_device_register(struct pw_device *device,
|
||||||
if (properties == NULL)
|
if (properties == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pw_properties_copy_keys(device->properties, properties, keys);
|
pw_properties_update_keys(properties, &device->properties->dict, keys);
|
||||||
|
|
||||||
device->global = pw_global_new(core,
|
device->global = pw_global_new(core,
|
||||||
PW_TYPE_INTERFACE_Device,
|
PW_TYPE_INTERFACE_Device,
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ int pw_factory_register(struct pw_factory *factory,
|
||||||
if (properties == NULL)
|
if (properties == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pw_properties_copy_keys(factory->properties, properties, keys);
|
pw_properties_update_keys(properties, &factory->properties->dict, keys);
|
||||||
|
|
||||||
pw_properties_set(properties, PW_KEY_FACTORY_NAME, factory->info.name);
|
pw_properties_set(properties, PW_KEY_FACTORY_NAME, factory->info.name);
|
||||||
pw_properties_setf(properties, PW_KEY_FACTORY_TYPE_NAME, "%s",
|
pw_properties_setf(properties, PW_KEY_FACTORY_TYPE_NAME, "%s",
|
||||||
|
|
|
||||||
|
|
@ -1227,7 +1227,7 @@ int pw_link_register(struct pw_link *link,
|
||||||
link->info.input_node_id = input_node->global->id;
|
link->info.input_node_id = input_node->global->id;
|
||||||
link->info.input_port_id = link->input->global->id;
|
link->info.input_port_id = link->input->global->id;
|
||||||
|
|
||||||
pw_properties_copy_keys(link->properties, properties, keys);
|
pw_properties_update_keys(properties, &link->properties->dict, keys);
|
||||||
|
|
||||||
pw_properties_setf(properties, PW_KEY_LINK_OUTPUT_PORT, "%d", link->info.output_port_id);
|
pw_properties_setf(properties, PW_KEY_LINK_OUTPUT_PORT, "%d", link->info.output_port_id);
|
||||||
pw_properties_setf(properties, PW_KEY_LINK_INPUT_PORT, "%d", link->info.input_port_id);
|
pw_properties_setf(properties, PW_KEY_LINK_INPUT_PORT, "%d", link->info.input_port_id);
|
||||||
|
|
|
||||||
|
|
@ -592,7 +592,7 @@ int pw_node_register(struct pw_node *this,
|
||||||
if (properties == NULL)
|
if (properties == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pw_properties_copy_keys(this->properties, properties, keys);
|
pw_properties_update_keys(properties, &this->properties->dict, keys);
|
||||||
|
|
||||||
this->global = pw_global_new(core,
|
this->global = pw_global_new(core,
|
||||||
PW_TYPE_INTERFACE_Node,
|
PW_TYPE_INTERFACE_Node,
|
||||||
|
|
|
||||||
|
|
@ -801,7 +801,7 @@ int pw_port_register(struct pw_port *port,
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pw_properties_setf(properties, PW_KEY_NODE_ID, "%d", node->global->id);
|
pw_properties_setf(properties, PW_KEY_NODE_ID, "%d", node->global->id);
|
||||||
pw_properties_copy_keys(port->properties, properties, keys);
|
pw_properties_update_keys(properties, &port->properties->dict, keys);
|
||||||
|
|
||||||
port->global = pw_global_new(node->core,
|
port->global = pw_global_new(node->core,
|
||||||
PW_TYPE_INTERFACE_Port,
|
PW_TYPE_INTERFACE_Port,
|
||||||
|
|
|
||||||
|
|
@ -212,15 +212,15 @@ struct pw_properties *pw_properties_copy(const struct pw_properties *properties)
|
||||||
* \memberof pw_properties
|
* \memberof pw_properties
|
||||||
*/
|
*/
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
int pw_properties_copy_keys(const struct pw_properties *src,
|
int pw_properties_update_keys(struct pw_properties *props,
|
||||||
struct pw_properties *dst, const char *keys[])
|
const struct spa_dict *dict, const char *keys[])
|
||||||
{
|
{
|
||||||
int i, changed = 0;
|
int i, changed = 0;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
for (i = 0; keys[i]; i++) {
|
for (i = 0; keys[i]; i++) {
|
||||||
if ((str = pw_properties_get(src, keys[i])) != NULL)
|
if ((str = spa_dict_lookup(dict, keys[i])) != NULL)
|
||||||
changed += pw_properties_set(dst, keys[i], str);
|
changed += pw_properties_set(props, keys[i], str);
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,10 @@ pw_properties_new_string(const char *args);
|
||||||
struct pw_properties *
|
struct pw_properties *
|
||||||
pw_properties_copy(const struct pw_properties *properties);
|
pw_properties_copy(const struct pw_properties *properties);
|
||||||
|
|
||||||
int pw_properties_copy_keys(const struct pw_properties *src,
|
int pw_properties_update_keys(struct pw_properties *props,
|
||||||
struct pw_properties *dst, const char *keys[]);
|
const struct spa_dict *dict, const char *keys[]);
|
||||||
|
|
||||||
int
|
int pw_properties_update(struct pw_properties *oldprops,
|
||||||
pw_properties_update(struct pw_properties *oldprops,
|
|
||||||
const struct spa_dict *dict);
|
const struct spa_dict *dict);
|
||||||
|
|
||||||
void pw_properties_clear(struct pw_properties *properties);
|
void pw_properties_clear(struct pw_properties *properties);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue