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 664720 - API: add gst_buffer_{set,get}_qdata()
API: add gst_buffer_{set,get}_qdata()
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: 0.10.36
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-11-24 12:20 UTC by Tim-Philipp Müller
Modified: 2011-11-25 23:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
buffer: add gst_buffer_{set,get}_qdata() (12.53 KB, patch)
2011-11-24 12:20 UTC, Tim-Philipp Müller
committed Details | Review

Description Tim-Philipp Müller 2011-11-24 12:20:48 UTC
Created attachment 202055 [details] [review]
buffer: add gst_buffer_{set,get}_qdata()

Allows people/us to attach arbitrary metadata to buffers without creating a subclass, which is handy for all kinds of things.

This is on GstBuffer and not GstMiniObject because it only really makes sense with buffers, and because all the conceptual bits of metadata writability and metadata copying are part of GstBuffer.

The cost of this should be negligible when not used (just extends the malloc sizeof the buffer object by sizeof(gpointer)). I opted for a private struct instead of just using the reserved field directly so we still have one public pointer left for public things.

(gtk-doc Since: markers will be fixed up before commit, obviously)
Comment 1 Tim-Philipp Müller 2011-11-25 18:28:37 UTC
commit 33078aaeb70a9218242e41fc4b110bd1a1ac7a56
Author: Tim-Philipp Müller <tim.muller@collabora.co.uk>
Date:   Wed Nov 16 01:04:45 2011 +0000

    buffer: add gst_buffer_{set,get}_qdata()
    
    Allows people/us to attach arbitrary metadata to buffers.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664720
    
    API: gst_buffer_set_qdata()
    API: get_buffer_get_qdata()
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2011-11-25 22:48:12 UTC
Whouldn't it be easier to use a hashmap with the quark as the key? instead of a slist?
Comment 3 Tim-Philipp Müller 2011-11-25 23:19:58 UTC
> Whouldn't it be easier to use a hashmap with the quark as the key? instead of a
> slist?

Didn't really seem worth it given that the normal case is no qdata at all and the next most-likely case is one or at most two pieces of qdata.. But it's an implementation detail anyway, it can be changed later if desired. I don't think it would make a huge difference in terms of lines of code either. (PS: it's a double-linked list, not an slist ;-))
Comment 4 Sebastian Dröge (slomo) 2011-11-25 23:33:41 UTC
Also for this few elements a hashtable will most likely have more overhead