Gjsify LogoGjsify Logo

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 filled 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, #GstMessage, #GstEvent, #GstQuery. 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_new_empty() 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 may be %NULL however.

The serialization format

GstStructure serialization format serialize the GstStructure name, keys/GType/values in a comma separated list with the structure name as first field without value followed by separated key/value pairs in the form key=value, for example:

a-structure, key=value

The values type will be inferred if not explicitly specified with the (GTypeName)value syntax, for example the following struct will have one field called 'is-string' which has the string 'true' as a value:

a-struct, field-is-string=(string)true, field-is-boolean=true

Note: without specifying (string), field-is-string` type would have been inferred as boolean.

Note: we specified (string) as a type even if gchararray is the actual GType name as for convenience some well known types have been aliased or abbreviated.

To avoid specifying the type, you can give some hints to the "type system". For example to specify a value as a double, you should add a decimal (ie. 1 is an int while 1.0 is a double).

Note: when a structure is serialized with #gst_structure_to_string, all values are explicitly typed.

Some types have special delimiters:

  • GstValueArray are inside curly brackets ({ and }). For example a-structure, array={1, 2, 3}
  • Ranges are inside brackets ([ and ]). For example a-structure, range=[1, 6, 2] 1 being the min value, 6 the maximum and 2 the step. To specify a #GST_TYPE_INT64_RANGE you need to explicitly specify it like: a-structure, a-int64-range=(gint64) [1, 5]
  • GstValueList are inside "less and greater than" (< and >). For example `a-structure, list=<1, 2, 3>

Structures are delimited either by a null character \0 or a semicolon ; the latter allowing to store multiple structures in the same string (see #GstCaps).

Quotes are used as "default" delimiters and can be used around any types that don't use other delimiters (for example a-struct, i=(int)"1"). They are use to allow adding spaces or special characters (such as delimiters, semicolumns, etc..) inside strings and you can use backslashes \ to escape characters inside them, for example:

a-struct, special="\"{[(;)]}\" can be used inside quotes"

They also allow for nested structure, such as:

a-struct, nested=(GstStructure)"nested-struct, nested=true"

Since 1.20, nested structures and caps can be specified using brackets ([ and ]), for example:

a-struct, nested=[nested-struct, nested=true]

note: gst_structure_to_string() won't use that syntax for backward compatibility reason, gst_structure_serialize() has been added for that purpose.

record

Hierarchy

  • Structure

Index

Constructors

Properties

type: GType<unknown>

the GType of a structure

field
name: string

Methods

  • Calls the provided function once for each field in the #GstStructure. In contrast to gst_structure_foreach(), the function may modify the fields. In contrast to gst_structure_map_in_place(), the field is removed from the structure if %FALSE is returned from the function. The structure must be mutable.

    Parameters

    Returns void

  • fixate(): void
  • Fixate all values in structure using gst_value_fixate(). structure will be modified in-place and should be writable.

    Returns void

  • fixate_field(field_name: string): boolean
  • Fixates a #GstStructure by changing the given field with its fixated value.

    Parameters

    • field_name: string

      a field in structure

    Returns boolean

  • fixate_field_boolean(field_name: string, target: boolean): boolean
  • Fixates a #GstStructure by changing the given field_name field to the given target boolean if that field is not fixed yet.

    Parameters

    • field_name: string

      a field in structure

    • target: boolean

      the target value of the fixation

    Returns boolean

  • fixate_field_nearest_double(field_name: string, target: number): boolean
  • Fixates a #GstStructure by changing the given field to the nearest double to target that is a subset of the existing field.

    Parameters

    • field_name: string

      a field in structure

    • target: number

      the target value of the fixation

    Returns boolean

  • fixate_field_nearest_fraction(field_name: string, target_numerator: number, target_denominator: number): boolean
  • 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.

    Parameters

    • field_name: string

      a field in structure

    • target_numerator: number

      The numerator of the target value of the fixation

    • target_denominator: number

      The denominator of the target value of the fixation

    Returns boolean

  • fixate_field_nearest_int(field_name: string, target: number): boolean
  • Fixates a #GstStructure by changing the given field to the nearest integer to target that is a subset of the existing field.

    Parameters

    • field_name: string

      a field in structure

    • target: number

      the target value of the fixation

    Returns boolean

  • fixate_field_string(field_name: string, target: string): boolean
  • Fixates a #GstStructure by changing the given field_name field to the given target string if that field is not fixed yet.

    Parameters

    • field_name: string

      a field in structure

    • target: string

      the target value of the fixation

    Returns boolean

  • 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() and gst_structure_filter_and_map_in_place().

    Parameters

    Returns boolean

  • free(): void
  • Frees a #GstStructure and all its fields and values. The structure must not have a parent when this function is called.

    Returns void

  • This is useful in language bindings where unknown #GValue types are not supported. This function will convert the %GST_TYPE_ARRAY into a newly allocated #GValueArray and return it through array. Be aware that this is slower then getting the #GValue directly.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, GObject.ValueArray]

  • get_boolean(fieldname: string): [boolean, boolean]
  • 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, boolean]

  • get_clock_time(fieldname: string): [boolean, number]
  • 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, number]

  • get_date(fieldname: string): [boolean, GLib.Date]
  • 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).

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, GLib.Date]

  • get_date_time(fieldname: string): [boolean, Gst.DateTime]
  • 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).

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, Gst.DateTime]

  • get_double(fieldname: string): [boolean, number]
  • 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, number]

  • get_enum(fieldname: string, enumtype: GType<unknown>): [boolean, number]
  • 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.

    Parameters

    • fieldname: string

      the name of a field

    • enumtype: GType<unknown>

      the enum type of a field

    Returns [boolean, number]

  • get_field_type(fieldname: string): GType<unknown>
  • 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.

    Parameters

    • fieldname: string

      the name of the field

    Returns GType<unknown>

  • get_flagset(fieldname: string): [boolean, number, number]
  • Read the GstFlagSet flags and mask out of the structure into the provided pointers.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, number, number]

  • get_fraction(fieldname: string): [boolean, number, number]
  • 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, number, number]

  • get_int(fieldname: string): [boolean, number]
  • 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, number]

  • get_int64(fieldname: string): [boolean, number]
  • Sets the #gint64 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, number]

  • This is useful in language bindings where unknown #GValue types are not supported. This function will convert the %GST_TYPE_LIST into a newly allocated GValueArray and return it through array. Be aware that this is slower then getting the #GValue directly.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, GObject.ValueArray]

  • get_name(): string
  • get_name_id(): number
  • get_string(fieldname: string): string
  • 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns string

  • get_uint(fieldname: string): [boolean, number]
  • 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, number]

  • get_uint64(fieldname: string): [boolean, number]
  • Sets the #guint64 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.

    Parameters

    • fieldname: string

      the name of a field

    Returns [boolean, number]

  • get_value(fieldname: string): any
  • Get the value of the field with name fieldname.

    Parameters

    • fieldname: string

      the name of the field to get

    Returns any

  • has_field(fieldname: string): boolean
  • Check if structure contains a field named fieldname.

    Parameters

    • fieldname: string

      the name of a field

    Returns boolean

  • has_field_typed(fieldname: string, type: GType<unknown>): boolean
  • Check if structure contains a field named fieldname and with GType type.

    Parameters

    • fieldname: string

      the name of a field

    • type: GType<unknown>

      the type of a value

    Returns boolean

  • has_name(name: string): boolean
  • Checks if the structure has the given name

    Parameters

    • name: string

      structure name to check for

    Returns boolean

  • id_get_value(field: number): any
  • Get the value of the field with GQuark field.

    Parameters

    • field: number

      the #GQuark of the field to get

    Returns any

  • id_has_field(field: number): boolean
  • Check if structure contains a field named field.

    Parameters

    • field: number

      #GQuark of the field name

    Returns boolean

  • id_has_field_typed(field: number, type: GType<unknown>): boolean
  • Check if structure contains a field named field and with GType type.

    Parameters

    • field: number

      #GQuark of the field name

    • type: GType<unknown>

      the type of a value

    Returns boolean

  • id_set_value(field: number, value: any): void
  • 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.

    Parameters

    • field: number

      a #GQuark representing a field

    • value: any

      the new value of the field

    Returns void

  • id_take_value(field: number, value: any): void
  • 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.

    Parameters

    • field: number

      a #GQuark representing a field

    • value: any

      the new value of the field

    Returns void

  • Checks if subset is a subset of superset, i.e. has the same structure name and for all fields that are existing in superset, subset has a value that is a subset of the value in superset.

    Parameters

    • superset: Gst.Structure

      a potentially greater #GstStructure

    Returns boolean

  • 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.

    Parameters

    Returns boolean

  • n_fields(): number
  • nth_field_name(index: number): string
  • Get the name of the given field number, counting from 0 onwards.

    Parameters

    • index: number

      the index to get the name of

    Returns string

  • remove_all_fields(): void
  • remove_field(fieldname: string): void
  • Removes the field with the given name. If the field with the given name does not exist, the structure is unchanged.

    Parameters

    • fieldname: string

      the name of the field to remove

    Returns void

  • Converts structure to a human-readable string representation.

    This version of the caps serialization function introduces support for nested structures and caps but the resulting strings won't be parsable with GStreamer prior to 1.20 unless #GST_SERIALIZE_FLAG_BACKWARD_COMPAT is passed as flag.

    Free-function: g_free

    Parameters

    Returns string

  • This is useful in language bindings where unknown GValue types are not supported. This function will convert a array to %GST_TYPE_ARRAY and set the field specified by fieldname. Be aware that this is slower then using %GST_TYPE_ARRAY in a #GValue directly.

    Parameters

    • fieldname: string

      the name of a field

    • array: GObject.ValueArray

      a pointer to a #GValueArray

    Returns void

  • This is useful in language bindings where unknown GValue types are not supported. This function will convert a array to %GST_TYPE_LIST and set the field specified by fieldname. Be aware that this is slower then using %GST_TYPE_LIST in a #GValue directly.

    Parameters

    • fieldname: string

      the name of a field

    • array: GObject.ValueArray

      a pointer to a #GValueArray

    Returns void

  • set_name(name: string): void
  • 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 "/-_.:".

    Parameters

    • name: string

      the new name of the structure

    Returns void

  • set_parent_refcount(refcount: number): boolean
  • 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.

    Parameters

    • refcount: number

      a pointer to the parent's refcount

    Returns boolean

  • set_value(fieldname: string, value: any): void
  • 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.

    Parameters

    • fieldname: string

      the name of the field to set

    • value: any

      the new value of the field

    Returns void

  • take_value(fieldname: string, value: any): void
  • 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.

    Parameters

    • fieldname: string

      the name of the field to set

    • value: any

      the new value of the field

    Returns void

  • to_string(): string
  • Converts structure to a human-readable string representation.

    For debugging purposes its easier to do something like this: |[ GST_LOG ("structure is %" GST_PTR_FORMAT, structure);


    This prints the structure in human readable form.

    This function will lead to unexpected results when there are nested #GstCaps
    / #GstStructure deeper than one level, you should user
    gst_structure_serialize() instead for those cases.

    Free-function: g_free

    Returns string

  • 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.

    Free-function: gst_structure_free

    Parameters

    • string: string

      a string representation of a #GstStructure.

    Returns Gst.Structure

  • Creates a new, empty #GstStructure with the given name.

    See gst_structure_set_name() for constraints on the name parameter.

    Free-function: gst_structure_free

    Parameters

    • name: string

      name of new structure

    Returns Gst.Structure

  • 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.

    The current implementation of serialization will lead to unexpected results when there are nested #GstCaps / #GstStructure deeper than one level unless the gst_structure_serialize() function is used (without #GST_SERIALIZE_FLAG_BACKWARD_COMPAT)

    Free-function: gst_structure_free

    Parameters

    • string: string

      a string representation of a #GstStructure

    Returns Gst.Structure

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

    Free-function: gst_structure_free

    Parameters

    • quark: number

      name of new structure

    Returns Gst.Structure

  • Atomically modifies a pointer to point to a new structure. The #GstStructure oldstr_ptr is pointing to is freed and newstr is taken ownership over.

    Either newstr and the value pointed to by oldstr_ptr may be %NULL.

    It is a programming error if both newstr and the value pointed to by oldstr_ptr refer to the same, non-%NULL structure.

    Parameters

    Returns [boolean, Gst.Structure]

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method