gst.structure

Module for [Structure] class

class Structure

Types 1

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.Structure.setParentRefcount method.

A #GstStructure can be created with gst.structure.Structure.newEmpty or gst.structure.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.Structure.setValue or gst.structure.Structure.set.

Field values can be retrieved with gst.structure.Structure.getValue or the more convenient gst_structure_get_*() functions.

Fields can be removed with gst.structure.Structure.removeField or gst.structure.Structure.removeFields.

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 [harfbuzz.types.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](GST_TYPE_ARRAY) 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](GST_TYPE_LIST) 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.Structure.toString_ won't use that syntax for backward

compatibility reason, gst.structure.Structure.serializeFull has been added for that purpose.

Methods
void * _cPtr(Flag!"Dup" dup = No.Dup) nothrow
GType _getGType() static nothrow
GType _gType() @property nothrow
Structure self() nothrowReturns `this`, for use in `with` statements.
gobject.types.GType type() @property nothrowGet `type` field. Returns: the GType of a structure
void type(gobject.types.GType propval) @property nothrowSet `type` field. Params: propval = the GType of a structure
gst.structure.Structure fromString(string string_, out string end) static nothrowCreates 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.
gst.structure.Structure newEmpty(string name) static nothrowCreates a new, empty #GstStructure with the given name.
gst.structure.Structure newFromString(string string_) static nothrowCreates 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.
gst.structure.Structure newIdEmpty(glib.types.Quark quark) static nothrowCreates a new, empty #GstStructure with the given name as a GQuark.
bool canIntersect(gst.structure.Structure struct2) nothrowTries intersecting struct1 and struct2 and reports whether the result would not be empty.
gst.structure.Structure copy() nothrowDuplicates a #GstStructure and all its fields and values.
void filterAndMapInPlace(gst.types.StructureFilterMapFunc func) nothrowCalls the provided function once for each field in the #GstStructure. In contrast to [gst.structure.Structure.foreach_], the function may modify the fields. In contrast to [gst.structure.Structure....
void fixate() nothrowFixate all values in structure using [gst.global.valueFixate]. structure will be modified in-place and should be writable.
bool fixateField(string fieldName) nothrowFixates a #GstStructure by changing the given field with its fixated value.
bool fixateFieldBoolean(string fieldName, bool target) nothrowFixates a #GstStructure by changing the given field_name field to the given target boolean if that field is not fixed yet.
bool fixateFieldNearestDouble(string fieldName, double target) nothrowFixates a #GstStructure by changing the given field to the nearest double to target that is a subset of the existing field.
bool fixateFieldNearestFraction(string fieldName, int targetNumerator, int targetDenominator) nothrowFixates a #GstStructure by changing the given field to the nearest fraction to target_numerator/target_denominator that is a subset of the existing field.
bool fixateFieldNearestInt(string fieldName, int target) nothrowFixates a #GstStructure by changing the given field to the nearest integer to target that is a subset of the existing field.
bool fixateFieldString(string fieldName, string target) nothrowFixates a #GstStructure by changing the given field_name field to the given target string if that field is not fixed yet.
bool foreach_(gst.types.StructureForeachFunc func) nothrowCalls the provided function once for each field in the #GstStructure. The function must not modify the fields. Also see [gst.structure.Structure.mapInPlace] and [gst.structure.Structure.filterAndMa...
bool getArray(string fieldname, out gobject.value_array.ValueArray array) nothrowThis 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. B...
bool getBoolean(string fieldname, out bool value) nothrowSets 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.
bool getClockTime(string fieldname, out gst.types.ClockTime value) nothrowSets 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.
bool getDate(string fieldname, out glib.date.Date value) nothrowSets 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.
bool getDateTime(string fieldname, out gst.date_time.DateTime value) nothrowSets 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.
bool getDouble(string fieldname, out double value) nothrowSets 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.
bool getEnum(string fieldname, gobject.types.GType enumtype, out int value) nothrowSets 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.
gobject.types.GType getFieldType(string fieldname) nothrowFinds 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.
bool getFlags(string fieldname, gobject.types.GType flagsType, out uint value) nothrowSets the unsigned 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 flagstype is correct.
bool getFlagset(string fieldname, out uint valueFlags, out uint valueMask) nothrowRead the GstFlagSet flags and mask out of the structure into the provided pointers.
bool getFraction(string fieldname, out int valueNumerator, out int valueDenominator) nothrowSets 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.
bool getInt(string fieldname, out int value) nothrowSets 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.
bool getInt64(string fieldname, out long value) nothrowSets 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.
bool getList(string fieldname, out gobject.value_array.ValueArray array) nothrowThis 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 ...
string getName() nothrowGet the name of structure as a string. Returns: the name of the structure.
glib.types.Quark getNameId() nothrowGet the name of structure as a GQuark. Returns: the quark representing the name of the structure.
string getString(string fieldname) nothrowFinds 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.
bool getUint(string fieldname, out uint value) nothrowSets 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.
bool getUint64(string fieldname, out ulong value) nothrowSets 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.
gobject.value.Value getValue(string fieldname) nothrowGet the value of the field with name fieldname.
bool hasField(string fieldname) nothrowCheck if structure contains a field named fieldname.
bool hasFieldTyped(string fieldname, gobject.types.GType type) nothrowCheck if structure contains a field named fieldname and with GType type.
bool hasName(string name) nothrowChecks if the structure has the given name
gobject.value.Value idGetValue(glib.types.Quark field) nothrowGet the value of the field with GQuark field.
bool idHasField(glib.types.Quark field) nothrowCheck if structure contains a field named field.
bool idHasFieldTyped(glib.types.Quark field, gobject.types.GType type) nothrowCheck if structure contains a field named field and with GType type.
void idSetValue(glib.types.Quark field, gobject.value.Value value) nothrowSets 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.
void idTakeValue(glib.types.Quark field, gobject.value.Value value) nothrowSets 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.
gst.structure.Structure intersect(gst.structure.Structure struct2) nothrowIntersects struct1 and struct2 and returns the intersection.
bool isEqual(gst.structure.Structure structure2) nothrowTests if the two #GstStructure are equal.
bool isSubset(gst.structure.Structure superset) nothrowChecks 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.
bool mapInPlace(gst.types.StructureMapFunc func) nothrowCalls the provided function once for each field in the #GstStructure. In contrast to [gst.structure.Structure.foreach_], the function may modify but not delete the fields. The structure must be mut...
int nFields() nothrowGet the number of fields in the structure. Returns: the number of fields in the structure
string nthFieldName(uint index) nothrowGet the name of the given field number, counting from 0 onwards.
void removeAllFields() nothrowRemoves all fields in a GstStructure.
void removeField(string fieldname) nothrowRemoves the field with the given name. If the field with the given name does not exist, the structure is unchanged.
string serialize(gst.types.SerializeFlags flags) nothrowConverts structure to a human-readable string representation.
string serializeFull(gst.types.SerializeFlags flags) nothrowAlias for [gst.structure.Structure.serialize] but with nullable annotation because it can return null when [gst.types.SerializeFlags.Strict] flag is set.
void setArray(string fieldname, gobject.value_array.ValueArray array) nothrowThis 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 thi...
void setList(string fieldname, gobject.value_array.ValueArray array) nothrowThis 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 ...
void setName(string name) nothrowSets 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 "/-_...
void setValue(string fieldname, gobject.value.Value value) nothrowSets 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.
void takeValue(string fieldname, gobject.value.Value value) nothrowSets 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 v...
string toString_() nothrowConverts structure to a human-readable string representation.
bool take(gst.structure.Structure oldstrPtr = null, gst.structure.Structure newstr = null) static nothrowAtomically modifies a pointer to point to a new structure. The #GstStructure oldstr_ptr is pointing to is freed and newstr is taken ownership over.
Constructors
this(void * ptr, Flag!"Take" take)