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:
Wim Taymans 2019-11-05 16:35:15 +01:00
parent 60cd74fdb0
commit 9df6efcd8d
12 changed files with 23 additions and 18 deletions

View file

@ -83,6 +83,8 @@ static int client_endpoint_stream_update(void *object,
PW_KEY_FACTORY_ID,
PW_KEY_CLIENT_ID,
PW_KEY_ENDPOINT_ID,
PW_KEY_MEDIA_CLASS,
PW_KEY_PRIORITY_SESSION,
NULL
};
@ -93,7 +95,10 @@ static int client_endpoint_stream_update(void *object,
props = pw_properties_new(NULL, NULL);
if (!props)
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,
this, core, props) < 0)

View file

@ -93,7 +93,7 @@ static int client_session_link_update(void *object,
props = pw_properties_new(NULL, NULL);
if (!props)
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,
this, core, props) < 0)

View file

@ -287,6 +287,7 @@ int endpoint_init(struct endpoint *this,
PW_KEY_FACTORY_ID,
PW_KEY_CLIENT_ID,
PW_KEY_DEVICE_ID,
PW_KEY_MEDIA_CLASS,
NULL
};
@ -299,7 +300,7 @@ int endpoint_init(struct endpoint *this,
if (!properties)
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,
PW_TYPE_INTERFACE_Endpoint,

View file

@ -298,7 +298,7 @@ int session_init(struct session *this,
if (!properties)
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,
PW_TYPE_INTERFACE_Session,

View file

@ -394,7 +394,7 @@ int pw_client_register(struct pw_client *client,
if (properties == NULL)
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,
PW_TYPE_INTERFACE_Client,

View file

@ -426,7 +426,7 @@ int pw_device_register(struct pw_device *device,
if (properties == NULL)
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,
PW_TYPE_INTERFACE_Device,

View file

@ -209,7 +209,7 @@ int pw_factory_register(struct pw_factory *factory,
if (properties == NULL)
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_setf(properties, PW_KEY_FACTORY_TYPE_NAME, "%s",

View file

@ -1227,7 +1227,7 @@ int pw_link_register(struct pw_link *link,
link->info.input_node_id = input_node->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_INPUT_PORT, "%d", link->info.input_port_id);

View file

@ -592,7 +592,7 @@ int pw_node_register(struct pw_node *this,
if (properties == NULL)
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,
PW_TYPE_INTERFACE_Node,

View file

@ -801,7 +801,7 @@ int pw_port_register(struct pw_port *port,
return -errno;
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,
PW_TYPE_INTERFACE_Port,

View file

@ -212,15 +212,15 @@ struct pw_properties *pw_properties_copy(const struct pw_properties *properties)
* \memberof pw_properties
*/
SPA_EXPORT
int pw_properties_copy_keys(const struct pw_properties *src,
struct pw_properties *dst, const char *keys[])
int pw_properties_update_keys(struct pw_properties *props,
const struct spa_dict *dict, const char *keys[])
{
int i, changed = 0;
const char *str;
for (i = 0; keys[i]; i++) {
if ((str = pw_properties_get(src, keys[i])) != NULL)
changed += pw_properties_set(dst, keys[i], str);
if ((str = spa_dict_lookup(dict, keys[i])) != NULL)
changed += pw_properties_set(props, keys[i], str);
}
return changed;
}

View file

@ -57,11 +57,10 @@ pw_properties_new_string(const char *args);
struct pw_properties *
pw_properties_copy(const struct pw_properties *properties);
int pw_properties_copy_keys(const struct pw_properties *src,
struct pw_properties *dst, const char *keys[]);
int pw_properties_update_keys(struct pw_properties *props,
const struct spa_dict *dict, const char *keys[]);
int
pw_properties_update(struct pw_properties *oldprops,
int pw_properties_update(struct pw_properties *oldprops,
const struct spa_dict *dict);
void pw_properties_clear(struct pw_properties *properties);