GNOME Bugzilla – Bug 739685
RFC: add API to GstPreset to compare presets
Last modified: 2018-11-03 12:23:53 UTC
Applications using the preset system will e.g. show a list of presets and the properties of the element. When selecting a preset the properties get updated. When the user now edits the properties further, the user derives the preset. It would be nice if the UI could check if the current settings are still equal to what was initially set by the preset and if not how they differ. One way to do this could be a function in the preset iface that returns the distance between the current settings and a given preset. Patch follows.
Created attachment 290051 [details] [review] preset: allow comparing settings with presets Does this make sense as API. Is the name okay?
Review of attachment 290051 [details] [review]: ::: gst/gstpreset.c @@ +1237,3 @@ + */ +gfloat +gst_preset_distance (GstPreset * preset, const gchar * name) A float value and "distance" seems weird. Maybe call it "compare" and if you need more than just "equal" and "not equal", use enums? "equal", "almost equal", ... or so But it seems difficult to quantize the similarity of presets in a meaningful way.
Few more ideas after irc discussions: 1) instead I could also add API: const gchar* gst_preset_find(GstPreset *preset); which would check if the current settings are equal to any of the presets and if so return the name or NULL if none of the presets match. This would be enough for a UI to show the preset that matches the selection. What it would not help is to avoid the UI storing a new preset where e.g. a double parameter slightly differs. The previously proposed API with the distance would allow to create a cross correlation matrix (at least for reviewing new presets) to see if a new preset is unique enough. And yes, that is an issue for some of the audio plugins I have. 2) another alternative for the gst_preset_distance() api would be to change it to: gboolean gst_preset_equals (GstPreset * preset, const gchar * name, GstStructure *details) it would now simply return TRUE if the settings are identical to the preset. If not and if details points to a GstStructure, it would fill the structure with details - e.g. the names of the changed properties and the normative delta + a total delta. Or whaterever is useful.
Crack idea: would a gst_preset_{intersect,diff}() be useful in any way?
Tim, yeah gst_preset_intersect() was what I meant with proposal 2) in my prev comment. It would return the diff/intersect in the details struct.
Before I rename everything. If we go with my proposal 2) from #comment 3 == what Tim proposed in #Comment 4 - any preference on the name? gst_preset_{equals,intersect,diff}() Also any preference between: gboolean gst_preset_equals (GstPreset * preset, const gchar * name, GstStructure *details) and GstStructure * gst_preset_{intersect,diff}(GstPreset * preset, const gchar * name)
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/78.