GstStructure

## GstStructure GstStructure — Generic structure containing fields of names and values |

## Synopsis

    #include <gst/gst.h>

                        GstStructure;
    gboolean            (*GstStructureForeachFunc)          (GQuark field_id,
                                                             const GValue *value,
                                                             gpointer user_data);
    gboolean            (*GstStructureMapFunc)              (GQuark field_id,
                                                             GValue *value,
                                                             gpointer user_data);
    GstStructure *      gst_structure_empty_new             (const gchar *name);
    GstStructure *      gst_structure_id_empty_new          (GQuark quark);
    GstStructure *      gst_structure_new                   (const gchar *name,
                                                             const gchar *firstfield,
                                                             ...);
    GstStructure *      gst_structure_new_valist            (const gchar *name,
                                                             const gchar *firstfield,
                                                             va_list varargs);
    GstStructure *      gst_structure_id_new                (GQuark name_quark,
                                                             GQuark field_quark,
                                                             ...);
    GstStructure *      gst_structure_copy                  (const GstStructure *structure);
    void                gst_structure_free                  (GstStructure *structure);
    const gchar *       gst_structure_get_name              (const GstStructure *structure);
    gboolean            gst_structure_has_name              (const GstStructure *structure,
                                                             const gchar *name);
    void                gst_structure_set_name              (GstStructure *structure,
                                                             const gchar *name);
    GQuark              gst_structure_get_name_id           (const GstStructure *structure);
    gboolean            gst_structure_id_get                (const GstStructure *structure,
                                                             GQuark first_field_id,
                                                             ...);
    gboolean            gst_structure_id_get_valist         (const GstStructure *structure,
                                                             GQuark first_field_id,
                                                             va_list args);
    const GValue *      gst_structure_id_get_value          (const GstStructure *structure,
                                                             GQuark field);
    void                gst_structure_id_set_value          (GstStructure *structure,
                                                             GQuark field,
                                                             const GValue *value);
    void                gst_structure_id_take_value         (GstStructure *structure,
                                                             GQuark field,
                                                             GValue *value);
    gboolean            gst_structure_get                   (const GstStructure *structure,
                                                             const char *first_fieldname,
                                                             ...);
    gboolean            gst_structure_get_valist            (const GstStructure *structure,
                                                             const char *first_fieldname,
                                                             va_list args);
    const GValue *      gst_structure_get_value             (const GstStructure *structure,
                                                             const gchar *fieldname);
    void                gst_structure_set_value             (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             const GValue *value);
    void                gst_structure_take_value            (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GValue *value);
    void                gst_structure_set                   (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             ...);
    void                gst_structure_set_valist            (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             va_list varargs);
    void                gst_structure_id_set                (GstStructure *structure,
                                                             GQuark fieldname,
                                                             ...);
    void                gst_structure_id_set_valist         (GstStructure *structure,
                                                             GQuark fieldname,
                                                             va_list varargs);
    void                gst_structure_remove_field          (GstStructure *structure,
                                                             const gchar *fieldname);
    void                gst_structure_remove_fields         (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             ...);
    void                gst_structure_remove_fields_valist  (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             va_list varargs);
    void                gst_structure_remove_all_fields     (GstStructure *structure);
    GType               gst_structure_get_field_type        (const GstStructure *structure,
                                                             const gchar *fieldname);
    gboolean            gst_structure_foreach               (const GstStructure *structure,
                                                             GstStructureForeachFunc func,
                                                             gpointer user_data);
    gint                gst_structure_n_fields              (const GstStructure *structure);
    gboolean            gst_structure_has_field             (const GstStructure *structure,
                                                             const gchar *fieldname);
    gboolean            gst_structure_has_field_typed       (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GType type);
    gboolean            gst_structure_id_has_field          (const GstStructure *structure,
                                                             GQuark field);
    gboolean            gst_structure_id_has_field_typed    (const GstStructure *structure,
                                                             GQuark field,
                                                             GType type);
    gboolean            gst_structure_get_boolean           (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             gboolean *value);
    gboolean            gst_structure_get_int               (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             gint *value);
    gboolean            gst_structure_get_uint              (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             guint *value);
    gboolean            gst_structure_get_fourcc            (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             guint32 *value);
    gboolean            gst_structure_get_double            (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             gdouble *value);
    const gchar *       gst_structure_get_string            (const GstStructure *structure,
                                                             const gchar *fieldname);
    gboolean            gst_structure_get_date              (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GDate **value);
    gboolean            gst_structure_get_date_time         (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GstDateTime **value);
    gboolean            gst_structure_get_clock_time        (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GstClockTime *value);
    gboolean            gst_structure_get_enum              (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GType enumtype,
                                                             gint *value);
    gboolean            gst_structure_get_fraction          (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             gint *value_numerator,
                                                             gint *value_denominator);
    gboolean            gst_structure_map_in_place          (GstStructure *structure,
                                                             GstStructureMapFunc func,
                                                             gpointer user_data);
    const gchar *       gst_structure_nth_field_name        (const GstStructure *structure,
                                                             guint index);
    void                gst_structure_set_parent_refcount   (GstStructure *structure,
                                                             gint *refcount);
    gchar *             gst_structure_to_string             (const GstStructure *structure);
    GstStructure *      gst_structure_from_string           (const gchar *string,
                                                             gchar **end);
    gboolean            gst_structure_fixate_field_nearest_int
                                                            (GstStructure *structure,
                                                             const char *field_name,
                                                             int target);
    gboolean            gst_structure_fixate_field_nearest_double
                                                            (GstStructure *structure,
                                                             const char *field_name,
                                                             double target);
    gboolean            gst_structure_fixate_field_nearest_fraction
                                                            (GstStructure *structure,
                                                             const char *field_name,
                                                             const gint target_numerator,
                                                             const gint target_denominator);
    gboolean            gst_structure_fixate_field_boolean  (GstStructure *structure,
                                                             const char *field_name,
                                                             gboolean target);
    gboolean            gst_structure_fixate_field_string   (GstStructure *structure,
                                                             const char *field_name,
                                                             const gchar *target);

## Description

A GstStructure is a collection of key/value pairs. The keys are expressed as GQuarks and the values can be of any GType.

In addition to the key/value pairs, a GstStructure also has a name. The name starts with a letter and can be folled by letters, numbers and any of "/-_.:".

GstStructure is used by various GStreamer subsystems to store information in a flexible and extensible way. A GstStructure does not have a refcount because it usually is part of a higher level object such as GstCaps. It provides a means to enforce mutability using the refcount of the parent with the `gst_structure_set_parent_refcount()` method.

A GstStructure can be created with `gst_structure_empty_new()` or `gst_structure_new()`, which both take a name and an optional set of key/value pairs along with the types of the values.

Field values can be changed with `gst_structure_set_value()` or `gst_structure_set()`.

Field values can be retrieved with `gst_structure_get_value()` or the more convenient gst_structure_get_*() functions.

Fields can be removed with `gst_structure_remove_field()` or `gst_structure_remove_fields()`.

Strings in structures must be ASCII or UTF-8 encoded. Other encodings are not allowed. Strings must not be empty either, but may be NULL.

Last reviewed on 2009-06-08 (0.10.23)

## Details

### GstStructure

    typedef struct {
      GType type;
    } GstStructure;

The GstStructure object. Most fields are private.

GType `type`; | the GType of a structure

### GstStructureForeachFunc ()

    gboolean            (*GstStructureForeachFunc)          (GQuark field_id,
                                                             const GValue *value,
                                                             gpointer user_data);

A function that will be called in `gst_structure_foreach()`. The function may not modify `value`.

`field_id` : | the GQuark of the field name
`value` : | the GValue of the field
`user_data` : | user data
Returns : | TRUE if the foreach operation should continue, FALSE if the foreach operation should stop with FALSE.

### GstStructureMapFunc ()

    gboolean            (*GstStructureMapFunc)              (GQuark field_id,
                                                             GValue *value,
                                                             gpointer user_data);

A function that will be called in `gst_structure_map_in_place()`. The function may modify `value`.

`field_id` : | the GQuark of the field name
`value` : | the GValue of the field
`user_data` : | user data
Returns : | TRUE if the map operation should continue, FALSE if the map operation should stop with FALSE.

### gst_structure_empty_new ()

    GstStructure *      gst_structure_empty_new             (const gchar *name);

Creates a new, empty GstStructure with the given `name`.

See `gst_structure_set_name()` for constraints on the `name` parameter.

`name` : | name of new structure
Returns : | a new, empty GstStructure

### gst_structure_id_empty_new ()

    GstStructure *      gst_structure_id_empty_new          (GQuark quark);

Creates a new, empty GstStructure with the given name as a GQuark.

`quark` : | name of new structure
Returns : | a new, empty GstStructure

### gst_structure_new ()

    GstStructure *      gst_structure_new                   (const gchar *name,
                                                             const gchar *firstfield,
                                                             ...);

Creates a new GstStructure with the given name. Parses the list of variable arguments and sets fields to the values listed. Variable arguments should be passed as field name, field type, and value. Last variable argument should be NULL.

`name` : | name of new structure
`firstfield` : | name of first field to set
`...` : | additional arguments
Returns : | a new GstStructure

### gst_structure_new_valist ()

    GstStructure *      gst_structure_new_valist            (const gchar *name,
                                                             const gchar *firstfield,
                                                             va_list varargs);

Creates a new GstStructure with the given `name`. Structure fields are set according to the varargs in a manner similar to `gst_structure_new()`.

See `gst_structure_set_name()` for constraints on the `name` parameter.

`name` : | name of new structure
`firstfield` : | name of first field to set
`varargs` : | variable argument list
Returns : | a new GstStructure

### gst_structure_id_new ()

    GstStructure *      gst_structure_id_new                (GQuark name_quark,
                                                             GQuark field_quark,
                                                             ...);

Creates a new GstStructure with the given name as a GQuark, followed by fieldname quark, GType, argument(s) "triplets" in the same format as `gst_structure_id_set()`. Basically a convenience wrapper around `gst_structure_id_empty_new()` and `gst_structure_id_set()`.

The last variable argument must be NULL (or 0).

`name_quark` : | name of new structure
`field_quark` : | the GQuark for the name of the field to set
`...` : | variable arguments
Returns : | a new GstStructure

Since 0.10.24

### gst_structure_copy ()

    GstStructure *      gst_structure_copy                  (const GstStructure *structure);

Duplicates a GstStructure and all its fields and values.

`structure` : | a GstStructure to duplicate
Returns : | a new GstStructure.

### gst_structure_free ()

    void                gst_structure_free                  (GstStructure *structure);

Frees a GstStructure and all its fields and values. The structure must not have a parent when this function is called.

`structure` : | the GstStructure to free

### gst_structure_get_name ()

    const gchar *       gst_structure_get_name              (const GstStructure *structure);

Get the name of `structure` as a string.

`structure` : | a GstStructure
Returns : | the name of the structure.

### gst_structure_has_name ()

    gboolean            gst_structure_has_name              (const GstStructure *structure,
                                                             const gchar *name);

Checks if the structure has the given name

`structure` : | a GstStructure
`name` : | structure name to check for
Returns : | TRUE if `name` matches the name of the structure.

### gst_structure_set_name ()

    void                gst_structure_set_name              (GstStructure *structure,
                                                             const gchar *name);

Sets the name of the structure to the given `name`. The string provided is copied before being used. It must not be empty, start with a letter and can be followed by letters, numbers and any of "/-_.:".

`structure` : | a GstStructure
`name` : | the new name of the structure

### gst_structure_get_name_id ()

    GQuark              gst_structure_get_name_id           (const GstStructure *structure);

Get the name of `structure` as a GQuark.

`structure` : | a GstStructure
Returns : | the quark representing the name of the structure.

### gst_structure_id_get ()

    gboolean            gst_structure_id_get                (const GstStructure *structure,
                                                             GQuark first_field_id,
                                                             ...);

Parses the variable arguments and reads fields from `structure` accordingly. Variable arguments should be in the form field id quark, field type (as a GType), pointer(s) to a variable(s) to hold the return value(s). The last variable argument should be NULL (technically it should be a 0 quark, but we require NULL so compilers that support it can check for the NULL terminator and warn if it's not there).

This function is just like `gst_structure_get()` only that it is slightly more efficient since it saves the string-to-quark lookup in the global quark hashtable.

For refcounted (mini)objects you will acquire your own reference which you must release with a suitable `_unref()` when no longer needed. For strings and boxed types you will acquire a copy which you will need to release with either `g_free()` or the suiteable function for the boxed type.

`structure` : | a GstStructure
`first_field_id` : | the quark of the first field to read
`...` : | variable arguments
Returns : | FALSE if there was a problem reading any of the fields (e.g. because the field requested did not exist, or was of a type other than the type specified), otherwise TRUE.

Since 0.10.24

### gst_structure_id_get_valist ()

    gboolean            gst_structure_id_get_valist         (const GstStructure *structure,
                                                             GQuark first_field_id,
                                                             va_list args);

Parses the variable arguments and reads fields from `structure` accordingly. valist-variant of `gst_structure_id_get()`. Look at the documentation of `gst_structure_id_get()` for more details.

`structure` : | a GstStructure
`first_field_id` : | the quark of the first field to read
`args` : | variable arguments
Returns : | TRUE, or FALSE if there was a problem reading any of the fields

Since 0.10.24

### gst_structure_id_get_value ()

    const GValue *      gst_structure_id_get_value          (const GstStructure *structure,
                                                             GQuark field);

Get the value of the field with GQuark `field`.

`structure` : | a GstStructure
`field` : | the GQuark of the field to get
Returns : | the GValue corresponding to the field with the given name identifier.

### gst_structure_id_set_value ()

    void                gst_structure_id_set_value          (GstStructure *structure,
                                                             GQuark field,
                                                             const GValue *value);

Sets the field with the given GQuark `field` to `value`. If the field does not exist, it is created. If the field exists, the previous value is replaced and freed.

`structure` : | a GstStructure
`field` : | a GQuark representing a field
`value` : | the new value of the field

### gst_structure_id_take_value ()

    void                gst_structure_id_take_value         (GstStructure *structure,
                                                             GQuark field,
                                                             GValue *value);

Sets the field with the given GQuark `field` to `value`. If the field does not exist, it is created. If the field exists, the previous value is replaced and freed.

`structure` : | a GstStructure
`field` : | a GQuark representing a field
`value` : | the new value of the field. [transfer full]

Since 0.10.31

### gst_structure_get ()

    gboolean            gst_structure_get                   (const GstStructure *structure,
                                                             const char *first_fieldname,
                                                             ...);

Parses the variable arguments and reads fields from `structure` accordingly. Variable arguments should be in the form field name, field type (as a GType), pointer(s) to a variable(s) to hold the return value(s). The last variable argument should be NULL.

For refcounted (mini)objects you will acquire your own reference which you must release with a suitable `_unref()` when no longer needed. For strings and boxed types you will acquire a copy which you will need to release with either `g_free()` or the suiteable function for the boxed type.

`structure` : | a GstStructure
`first_fieldname` : | the name of the first field to read
`...` : | variable arguments
Returns : | FALSE if there was a problem reading any of the fields (e.g. because the field requested did not exist, or was of a type other than the type specified), otherwise TRUE.

Since 0.10.24

### gst_structure_get_valist ()

    gboolean            gst_structure_get_valist            (const GstStructure *structure,
                                                             const char *first_fieldname,
                                                             va_list args);

Parses the variable arguments and reads fields from `structure` accordingly. valist-variant of `gst_structure_get()`. Look at the documentation of `gst_structure_get()` for more details.

`structure` : | a GstStructure
`first_fieldname` : | the name of the first field to read
`args` : | variable arguments
Returns : | TRUE, or FALSE if there was a problem reading any of the fields

Since 0.10.24

### gst_structure_get_value ()

    const GValue *      gst_structure_get_value             (const GstStructure *structure,
                                                             const gchar *fieldname);

Get the value of the field with name `fieldname`.

`structure` : | a GstStructure
`fieldname` : | the name of the field to get
Returns : | the GValue corresponding to the field with the given name.

### gst_structure_set_value ()

    void                gst_structure_set_value             (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             const GValue *value);

Sets the field with the given name `field` to `value`. If the field does not exist, it is created. If the field exists, the previous value is replaced and freed.

`structure` : | a GstStructure
`fieldname` : | the name of the field to set
`value` : | the new value of the field

### gst_structure_take_value ()

    void                gst_structure_take_value            (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GValue *value);

Sets the field with the given name `field` to `value`. If the field does not exist, it is created. If the field exists, the previous value is replaced and freed. The function will take ownership of `value`.

`structure` : | a GstStructure
`fieldname` : | the name of the field to set
`value` : | the new value of the field. [transfer full]

Since 0.10.31

### gst_structure_set ()

    void                gst_structure_set                   (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             ...);

Parses the variable arguments and sets fields accordingly. Variable arguments should be in the form field name, field type (as a GType), value(s). The last variable argument should be NULL.

`structure` : | a GstStructure
`fieldname` : | the name of the field to set
`...` : | variable arguments

### gst_structure_set_valist ()

    void                gst_structure_set_valist            (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             va_list varargs);

va_list form of `gst_structure_set()`.

`structure` : | a GstStructure
`fieldname` : | the name of the field to set
`varargs` : | variable arguments

### gst_structure_id_set ()

    void                gst_structure_id_set                (GstStructure *structure,
                                                             GQuark fieldname,
                                                             ...);

Identical to gst_structure_set, except that field names are passed using the GQuark for the field name. This allows more efficient setting of the structure if the caller already knows the associated quark values. The last variable argument must be NULL.

`structure` : | a GstStructure
`fieldname` : | the GQuark for the name of the field to set
`...` : | variable arguments

Since 0.10.10

### gst_structure_id_set_valist ()

    void                gst_structure_id_set_valist         (GstStructure *structure,
                                                             GQuark fieldname,
                                                             va_list varargs);

va_list form of `gst_structure_id_set()`.

`structure` : | a GstStructure
`fieldname` : | the name of the field to set
`varargs` : | variable arguments

Since 0.10.10

### gst_structure_remove_field ()

    void                gst_structure_remove_field          (GstStructure *structure,
                                                             const gchar *fieldname);

Removes the field with the given name. If the field with the given name does not exist, the structure is unchanged.

`structure` : | a GstStructure
`fieldname` : | the name of the field to remove

### gst_structure_remove_fields ()

    void                gst_structure_remove_fields         (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             ...);

Removes the fields with the given names. If a field does not exist, the argument is ignored.

`structure` : | a GstStructure
`fieldname` : | the name of the field to remove
`...` : | NULL-terminated list of more fieldnames to remove

### gst_structure_remove_fields_valist ()

    void                gst_structure_remove_fields_valist  (GstStructure *structure,
                                                             const gchar *fieldname,
                                                             va_list varargs);

va_list form of `gst_structure_remove_fields()`.

`structure` : | a GstStructure
`fieldname` : | the name of the field to remove
`varargs` : | NULL-terminated list of more fieldnames to remove

### gst_structure_remove_all_fields ()

    void                gst_structure_remove_all_fields     (GstStructure *structure);

Removes all fields in a GstStructure.

`structure` : | a GstStructure

### gst_structure_get_field_type ()

    GType               gst_structure_get_field_type        (const GstStructure *structure,
                                                             const gchar *fieldname);

Finds the field with the given name, and returns the type of the value it contains. If the field is not found, G_TYPE_INVALID is returned.

`structure` : | a GstStructure
`fieldname` : | the name of the field
Returns : | the GValue of the field

### gst_structure_foreach ()

    gboolean            gst_structure_foreach               (const GstStructure *structure,
                                                             GstStructureForeachFunc func,
                                                             gpointer user_data);

Calls the provided function once for each field in the GstStructure. The function must not modify the fields. Also see `gst_structure_map_in_place()`.

`structure` : | a GstStructure
`func` : | a function to call for each field
`user_data` : | private data
Returns : | TRUE if the supplied function returns TRUE For each of the fields, FALSE otherwise.

### gst_structure_n_fields ()

    gint                gst_structure_n_fields              (const GstStructure *structure);

Get the number of fields in the structure.

`structure` : | a GstStructure
Returns : | the number of fields in the structure

### gst_structure_has_field ()

    gboolean            gst_structure_has_field             (const GstStructure *structure,
                                                             const gchar *fieldname);

Check if `structure` contains a field named `fieldname`.

`structure` : | a GstStructure
`fieldname` : | the name of a field
Returns : | TRUE if the structure contains a field with the given name

### gst_structure_has_field_typed ()

    gboolean            gst_structure_has_field_typed       (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GType type);

Check if `structure` contains a field named `fieldname` and with GType `type`.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`type` : | the type of a value
Returns : | TRUE if the structure contains a field with the given name and type

### gst_structure_id_has_field ()

    gboolean            gst_structure_id_has_field          (const GstStructure *structure,
                                                             GQuark field);

Check if `structure` contains a field named `field`.

`structure` : | a GstStructure
`field` : | GQuark of the field name
Returns : | TRUE if the structure contains a field with the given name

Since 0.10.26

### gst_structure_id_has_field_typed ()

    gboolean            gst_structure_id_has_field_typed    (const GstStructure *structure,
                                                             GQuark field,
                                                             GType type);

Check if `structure` contains a field named `field` and with GType `type`.

`structure` : | a GstStructure
`field` : | GQuark of the field name
`type` : | the type of a value
Returns : | TRUE if the structure contains a field with the given name and type

Since 0.10.26

### gst_structure_get_boolean ()

    gboolean            gst_structure_get_boolean           (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             gboolean *value);

Sets the boolean pointed to by `value` corresponding to the value of the given field. Caller is responsible for making sure the field exists and has the correct type.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value` : | a pointer to a gboolean to set
Returns : | TRUE if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain a boolean, this function returns FALSE.

### gst_structure_get_int ()

    gboolean            gst_structure_get_int               (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             gint *value);

Sets the int pointed to by `value` corresponding to the value of the given field. Caller is responsible for making sure the field exists and has the correct type.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value` : | a pointer to an int to set
Returns : | `TRUE` if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain an int, this function returns `FALSE`.

### gst_structure_get_uint ()

    gboolean            gst_structure_get_uint              (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             guint *value);

Sets the uint pointed to by `value` corresponding to the value of the given field. Caller is responsible for making sure the field exists and has the correct type.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value` : | a pointer to a uint to set
Returns : | `TRUE` if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain a uint, this function returns `FALSE`.

Since 0.10.15

### gst_structure_get_fourcc ()

    gboolean            gst_structure_get_fourcc            (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             guint32 *value);

Sets the Fourcc pointed to by `value` corresponding to the value of the given field. Caller is responsible for making sure the field exists and has the correct type.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value` : | a pointer to a 32bit unsigned int to set
Returns : | TRUE if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain a fourcc, this function returns FALSE.

### gst_structure_get_double ()

    gboolean            gst_structure_get_double            (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             gdouble *value);

Sets the double pointed to by `value` corresponding to the value of the given field. Caller is responsible for making sure the field exists and has the correct type.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value` : | a pointer to a gdouble to set
Returns : | TRUE if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain a double, this function returns FALSE.

### gst_structure_get_string ()

    const gchar *       gst_structure_get_string            (const GstStructure *structure,
                                                             const gchar *fieldname);

Finds the field corresponding to `fieldname`, and returns the string contained in the field's value. Caller is responsible for making sure the field exists and has the correct type.

The string should not be modified, and remains valid until the next call to a gst_structure_*() function with the given structure.

`structure` : | a GstStructure
`fieldname` : | the name of a field
Returns : | a pointer to the string or NULL when the field did not exist or did not contain a string.

### gst_structure_get_date ()

    gboolean            gst_structure_get_date              (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GDate **value);

Sets the date pointed to by `value` corresponding to the date of the given field. Caller is responsible for making sure the field exists and has the correct type.

On success `value` will point to a newly-allocated copy of the date which should be freed with `g_date_free()` when no longer needed (note: this is inconsistent with e.g. `gst_structure_get_string()` which doesn't return a copy of the string).

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value` : | a pointer to a GDate to set
Returns : | TRUE if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain a data, this function returns FALSE.

### gst_structure_get_date_time ()

    gboolean            gst_structure_get_date_time         (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GstDateTime **value);

Sets the datetime pointed to by `value` corresponding to the datetime of the given field. Caller is responsible for making sure the field exists and has the correct type.

On success `value` will point to a reference of the datetime which should be unreffed with `gst_date_time_unref()` when no longer needed (note: this is inconsistent with e.g. `gst_structure_get_string()` which doesn't return a copy of the string).

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value` : | a pointer to a GstDateTime to set
Returns : | TRUE if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain a data, this function returns FALSE.

### gst_structure_get_clock_time ()

    gboolean            gst_structure_get_clock_time        (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GstClockTime *value);

Sets the clock time pointed to by `value` corresponding to the clock time of the given field. Caller is responsible for making sure the field exists and has the correct type.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value` : | a pointer to a GstClockTime to set
Returns : | TRUE if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain a GstClockTime, this function returns FALSE.

### gst_structure_get_enum ()

    gboolean            gst_structure_get_enum              (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             GType enumtype,
                                                             gint *value);

Sets the int pointed to by `value` corresponding to the value of the given field. Caller is responsible for making sure the field exists, has the correct type and that the enumtype is correct.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`enumtype` : | the enum type of a field
`value` : | a pointer to an int to set
Returns : | TRUE if the value could be set correctly. If there was no field with `fieldname` or the existing field did not contain an enum of the given type, this function returns FALSE.

### gst_structure_get_fraction ()

    gboolean            gst_structure_get_fraction          (const GstStructure *structure,
                                                             const gchar *fieldname,
                                                             gint *value_numerator,
                                                             gint *value_denominator);

Sets the integers pointed to by `value_numerator` and `value_denominator` corresponding to the value of the given field. Caller is responsible for making sure the field exists and has the correct type.

`structure` : | a GstStructure
`fieldname` : | the name of a field
`value_numerator` : | a pointer to an int to set
`value_denominator` : | a pointer to an int to set
Returns : | TRUE if the values could be set correctly. If there was no field with `fieldname` or the existing field did not contain a GstFraction, this function returns FALSE.

### gst_structure_map_in_place ()

    gboolean            gst_structure_map_in_place          (GstStructure *structure,
                                                             GstStructureMapFunc func,
                                                             gpointer user_data);

Calls the provided function once for each field in the GstStructure. In contrast to `gst_structure_foreach()`, the function may modify but not delete the fields. The structure must be mutable.

`structure` : | a GstStructure
`func` : | a function to call for each field
`user_data` : | private data
Returns : | TRUE if the supplied function returns TRUE For each of the fields, FALSE otherwise.

### gst_structure_nth_field_name ()

    const gchar *       gst_structure_nth_field_name        (const GstStructure *structure,
                                                             guint index);

Get the name of the given field number, counting from 0 onwards.

`structure` : | a GstStructure
`index` : | the index to get the name of
Returns : | the name of the given field number

### gst_structure_set_parent_refcount ()

    void                gst_structure_set_parent_refcount   (GstStructure *structure,
                                                             gint *refcount);

Sets the parent_refcount field of GstStructure. This field is used to determine whether a structure is mutable or not. This function should only be called by code implementing parent objects of GstStructure, as described in the MT Refcounting section of the design documents.

`structure` : | a GstStructure
`refcount` : | a pointer to the parent's refcount

### gst_structure_to_string ()

    gchar *             gst_structure_to_string             (const GstStructure *structure);

Converts `structure` to a human-readable string representation.

For debugging purposes its easier to do something like this:

    1
    GST_LOG ("structure is %" GST_PTR_FORMAT, structure);

This prints the structure in human readble form.

`structure` : | a GstStructure
Returns : | a pointer to string allocated by `g_malloc()`. `g_free()` after usage.

### gst_structure_from_string ()

    GstStructure *      gst_structure_from_string           (const gchar *string,
                                                             gchar **end);

Creates a GstStructure from a string representation. If end is not NULL, a pointer to the place inside the given string where parsing ended will be returned.

`string` : | a string representation of a GstStructure.
`end` : | pointer to store the end of the string in.
Returns : | a new GstStructure or NULL when the string could not be parsed. Free with `gst_structure_free()` after use.

### gst_structure_fixate_field_nearest_int ()

    gboolean            gst_structure_fixate_field_nearest_int
                                                            (GstStructure *structure,
                                                             const char *field_name,
                                                             int target);

Fixates a GstStructure by changing the given field to the nearest integer to `target` that is a subset of the existing field.

`structure` : | a GstStructure
`field_name` : | a field in `structure`
`target` : | the target value of the fixation
Returns : | TRUE if the structure could be fixated

### gst_structure_fixate_field_nearest_double ()

    gboolean            gst_structure_fixate_field_nearest_double
                                                            (GstStructure *structure,
                                                             const char *field_name,
                                                             double target);

Fixates a GstStructure by changing the given field to the nearest double to `target` that is a subset of the existing field.

`structure` : | a GstStructure
`field_name` : | a field in `structure`
`target` : | the target value of the fixation
Returns : | TRUE if the structure could be fixated

### gst_structure_fixate_field_nearest_fraction ()

    gboolean            gst_structure_fixate_field_nearest_fraction
                                                            (GstStructure *structure,
                                                             const char *field_name,
                                                             const gint target_numerator,
                                                             const gint target_denominator);

Fixates a GstStructure by changing the given field to the nearest fraction to `target_numerator`/`target_denominator` that is a subset of the existing field.

`structure` : | a GstStructure
`field_name` : | a field in `structure`
`target_numerator` : | The numerator of the target value of the fixation
`target_denominator` : | The denominator of the target value of the fixation
Returns : | TRUE if the structure could be fixated

### gst_structure_fixate_field_boolean ()

    gboolean            gst_structure_fixate_field_boolean  (GstStructure *structure,
                                                             const char *field_name,
                                                             gboolean target);

Fixates a GstStructure by changing the given `field_name` field to the given `target` boolean if that field is not fixed yet.

`structure` : | a GstStructure
`field_name` : | a field in `structure`
`target` : | the target value of the fixation
Returns : | TRUE if the structure could be fixated

### gst_structure_fixate_field_string ()

    gboolean            gst_structure_fixate_field_string   (GstStructure *structure,
                                                             const char *field_name,
                                                             const gchar *target);

Fixates a GstStructure by changing the given `field_name` field to the given `target` string if that field is not fixed yet.

`structure` : | a GstStructure
`field_name` : | a field in `structure`
`target` : | the target value of the fixation
Returns : | TRUE if the structure could be fixated

Since 0.10.30

## See Also

GstCaps, GstMessage, GstEvent, GstQuery