diff --git a/lib/wp/properties.c b/lib/wp/properties.c index e06b69fc94b57252e5e202c4e646998a51891c08..448c9caa99fc694f49c9d9c6bc654b85a4fcd4e8 100644 --- a/lib/wp/properties.c +++ b/lib/wp/properties.c @@ -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; +} + diff --git a/lib/wp/properties.h b/lib/wp/properties.h index 553f937acd669745eea2c3f555b0202603b0ead1..b41b4e98b42d171397f44bef6a238c72af0f8e20 100644 --- a/lib/wp/properties.h +++ b/lib/wp/properties.h @@ -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)