[gst-devel] gst/gststructure.[ch] gst/gstvalue.[ch]

David Schleef ds at schleef.org
Thu Nov 20 12:53:08 CET 2003


On Thu, Nov 20, 2003 at 05:24:30PM +0100, Julien MOUTTE wrote:
> 
> Why not using GHashTable which is doing exactly the same thing ?
> 

You could implement GstStructure using either GHashTable or GData;
the first implementation I wrote was based on GData.  However, neither
specifically handles GQuark/GValue pairs, which makes it necessary
to write a bunch of wrapper code (i.e., lots of gst_structure_*()
functions) to give it the look and feel of a C structure.  Also,
GValues are not directly allocatable/freeable, so that requires
more wrapping.

At that point, I settled on making a new type (GstStructure), and
to choose the best implementation, which I decided should be a GArray
of GQuarks and GValues.  In this implementation, a decent sized
structure (10 fields) without any complex GValues requires only
2 memory allocations, wheras the GData implementation would require
about 12, and a GstProps would require 21 (if I count correctly.)

I think it's a reasonable choice as long as the number of fields
is not too large.  100 fields would be too large.

And exposing the internals of GstStructure to GstCaps allows faster
implementations of some of the caps functions.



dave...





More information about the gstreamer-devel mailing list