summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2019-08-16 21:54:49 +0200
committerWim Taymans <wtaymans@redhat.com>2019-08-16 21:54:49 +0200
commit32ce5c4deb78deb0890e3d0b6988306074e2903e (patch)
tree143136ebdb119096d8d43a4d0446abae07d234ae
parent774e11bc1010b787f956d0dd455e76e8af173075 (diff)
properties: add function to copy list of keys
-rw-r--r--src/pipewire/properties.c23
-rw-r--r--src/pipewire/properties.h3
2 files changed, 26 insertions, 0 deletions
diff --git a/src/pipewire/properties.c b/src/pipewire/properties.c
index 6a486481..77be22bf 100644
--- a/src/pipewire/properties.c
+++ b/src/pipewire/properties.c
@@ -203,6 +203,29 @@ struct pw_properties *pw_properties_copy(const struct pw_properties *properties)
return pw_properties_new_dict(&properties->dict);
}
+/** Copy multiple keys from one property to another
+ *
+ * \param src properties to copy from
+ * \param dst properties to copy to
+ * \param keys a NULL terminated list of keys to copy
+ * \return the number of keys changed in \a dest
+ *
+ * \memberof pw_properties
+ */
+SPA_EXPORT
+int pw_properties_copy_keys(const struct pw_properties *src,
+ struct pw_properties *dst, 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);
+ }
+ return changed;
+}
+
/** Clear a properties object
*
* \param properties properties to clear
diff --git a/src/pipewire/properties.h b/src/pipewire/properties.h
index 05261083..4d5ce026 100644
--- a/src/pipewire/properties.h
+++ b/src/pipewire/properties.h
@@ -57,6 +57,9 @@ 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(struct pw_properties *oldprops,
const struct spa_dict *dict);