GNOME Bugzilla – Bug 739765
caps: Add gst_caps_foreach() and gst_caps_map_in_place()
Last modified: 2014-12-16 17:21:55 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.
Created attachment 290141 [details] [review] caps: Add gst_caps_foreach() and gst_caps_map_in_place()
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.
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?
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.
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.
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