properties: add wp_properties_matches API

This commit is contained in:
Julian Bouzas 2019-11-19 14:21:42 -05:00
parent 58f321f815
commit ea3b58c2cd
2 changed files with 22 additions and 0 deletions

View file

@ -262,3 +262,24 @@ wp_properties_to_pw_properties (WpProperties * self)
return pw_properties_new_dict (wp_properties_peek_dict (self));
}
gboolean
wp_properties_matches (WpProperties * self, WpProperties *other)
{
const struct spa_dict * dict;
const struct spa_dict_item *item;
const gchar *value;
g_return_val_if_fail (self != NULL, FALSE);
/* Check if the property vakues matches the ones from 'other' */
dict = wp_properties_peek_dict (self);
spa_dict_for_each(item, dict) {
value = wp_properties_get (other, item->key);
if (value && g_strcmp0 (item->value, value) != 0)
return FALSE;
}
return TRUE;
}

View file

@ -57,6 +57,7 @@ gint wp_properties_setf_valist (WpProperties * self, const gchar * key,
const struct spa_dict * wp_properties_peek_dict (WpProperties * self);
struct pw_properties * wp_properties_to_pw_properties (WpProperties * self);
gboolean wp_properties_matches (WpProperties * self, WpProperties *other);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpProperties, wp_properties_unref)