After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 739685 - RFC: add API to GstPreset to compare presets
RFC: add API to GstPreset to compare presets
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.x
Other Linux
: Normal enhancement
: git master
Assigned To: Stefan Sauer (gstreamer, gtkdoc dev)
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-11-05 19:56 UTC by Stefan Sauer (gstreamer, gtkdoc dev)
Modified: 2018-11-03 12:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
preset: allow comparing settings with presets (8.90 KB, patch)
2014-11-05 20:19 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
reviewed Details | Review

Description Stefan Sauer (gstreamer, gtkdoc dev) 2014-11-05 19:56:49 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.
Comment 1 Stefan Sauer (gstreamer, gtkdoc dev) 2014-11-05 20:19:57 UTC
Created attachment 290051 [details] [review]
preset: allow comparing settings with presets

Does this make sense as API. Is the name okay?
Comment 2 Sebastian Dröge (slomo) 2014-11-06 11:05:30 UTC
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.
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2014-11-06 12:54:44 UTC
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.
Comment 4 Tim-Philipp Müller 2014-11-06 13:13:56 UTC
Crack idea: would a gst_preset_{intersect,diff}() be useful in any way?
Comment 5 Stefan Sauer (gstreamer, gtkdoc dev) 2014-11-06 16:08:38 UTC
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.
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2014-11-07 16:05:34 UTC
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)
Comment 7 GStreamer system administrator 2018-11-03 12:23:53 UTC
-- 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.