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 739765 - caps: Add gst_caps_foreach() and gst_caps_map_in_place()
caps: Add gst_caps_foreach() and gst_caps_map_in_place()
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other All
: Normal enhancement
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-11-07 10:17 UTC by Sebastian Dröge (slomo)
Modified: 2014-12-16 17:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
caps: Add gst_caps_foreach() and gst_caps_map_in_place() (9.07 KB, patch)
2014-11-07 10:17 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2014-11-07 10:17:15 UTC
These functions will probably be useful for language bindings that allow
anonymous functions or have lambda expressions. And might even make some
caps code simpler in C for common tasks.
Comment 1 Sebastian Dröge (slomo) 2014-11-07 10:17:18 UTC
Created attachment 290141 [details] [review]
caps: Add gst_caps_foreach() and gst_caps_map_in_place()
Comment 2 Sebastian Dröge (slomo) 2014-11-07 10:18:34 UTC
API is the same as for GstStructure btw. We might consider allowing to remove structures in the map function, although it wouldn't be strictly a map anymore then.
Comment 3 Sebastian Dröge (slomo) 2014-11-10 09:20:34 UTC
Maybe additionally a gst_caps_filter_map_in_place() where the boolean return value decides if something should be dropped or kept? And the same for GstStructure?
Comment 4 Sebastian Dröge (slomo) 2014-12-14 12:01:38 UTC
I'll go with adding the attached patch and additionally
- gst_caps_filter_or_map_in_place()
- gst_structure_filter_or_map_in_place()

Works like the map_in_place(), just that it always iterates over all items and a return value of FALSE from the callback means that the item (structure field or caps structure) is dropped.
Comment 5 Sebastian Dröge (slomo) 2014-12-16 08:57:10 UTC
Rather with "and" as you can do both at the same time on the same caps/structure:
- gst_caps_filter_and_map_in_place()
- gst_structure_filter_and_map_in_place()


Adding non-inplace variants for all this doesn't seem too important as foreach already allows that by putting an empty caps/structure into the user_data and filling that during iteration.
Comment 6 Sebastian Dröge (slomo) 2014-12-16 17:21:51 UTC
commit 746d0879490887eba5b298f48662cfaf5baf462f
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Tue Dec 16 16:31:21 2014 +0100

    structure/caps: Add gst_{structure,caps}_filter_and_map_in_place()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739765

commit 6bcf79a732bc282bf6a7c54e8287cb58b73a4b00
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Tue Dec 16 18:14:22 2014 +0100

    structure: Add simple unit test for foreach() and map_in_place()

commit 26e8c9dd2d0ba3468a119b3968e04793cb325a46
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Fri Nov 7 11:15:09 2014 +0100

    caps: Add gst_caps_foreach() and gst_caps_map_in_place()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739765