Gst.Structure

Fields

Name Type Access Description
name int r  
type GObject.GType r/w the GObject.GType of a structure

Methods

class from_string (string)
class new_empty (name)
class new_from_string (string)
class new_id_empty (quark)
  can_intersect (struct2)
  copy ()
  filter_and_map_in_place (func, *user_data)
  fixate ()
  fixate_field (field_name)
  fixate_field_boolean (field_name, target)
  fixate_field_nearest_double (field_name, target)
  fixate_field_nearest_fraction (field_name, target_numerator, target_denominator)
  fixate_field_nearest_int (field_name, target)
  fixate_field_string (field_name, target)
  foreach (func, *user_data)
  free ()
  get_array (fieldname)
  get_boolean (fieldname)
  get_clock_time (fieldname)
  get_date (fieldname)
  get_date_time (fieldname)
  get_double (fieldname)
  get_enum (fieldname, enumtype)
  get_field_type (fieldname)
  get_flagset (fieldname)
  get_fraction (fieldname)
  get_int (fieldname)
  get_int64 (fieldname)
  get_list (fieldname)
  get_name ()
  get_name_id ()
  get_string (fieldname)
  get_uint (fieldname)
  get_uint64 (fieldname)
  get_value (fieldname)
  has_field (fieldname)
  has_field_typed (fieldname, type)
  has_name (name)
  id_get_value (field)
  id_has_field (field)
  id_has_field_typed (field, type)
  id_set_value (field, value)
  id_take_value (field, value)
  intersect (struct2)
  is_equal (structure2)
  is_subset (superset)
  map_in_place (func, *user_data)
  n_fields ()
  nth_field_name (index)
  remove_all_fields ()
  remove_field (fieldname)
  set_array (fieldname, array)
  set_list (fieldname, array)
  set_name (name)
  set_parent_refcount (refcount)
  set_value (fieldname, value)
  take_value (fieldname, value)
  to_string ()

Details

class Gst.Structure

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

In addition to the key/value pairs, a Gst.Structure also has a name. The name starts with a letter and can be filled by letters, numbers and any of “/-_.:”.

Gst.Structure is used by various GStreamer subsystems to store information in a flexible and extensible way. A Gst.Structure does not have a refcount because it usually is part of a higher level object such as Gst.Caps, Gst.Message, Gst.Event, Gst.Query. It provides a means to enforce mutability using the refcount of the parent with the Gst.Structure.set_parent_refcount() method.

A Gst.Structure 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 None however.

Be aware that the current Gst.Caps / Gst.Structure serialization into string has limited support for nested Gst.Caps / Gst.Structure fields. It can only support one level of nesting. Using more levels will lead to unexpected behavior when using serialization features, such as Gst.Caps.to_string() or Gst.value_serialize() and their counterparts.

classmethod from_string(string)[source]
Parameters:string (str) – a string representation of a Gst.Structure.
Returns:a new Gst.Structure or None when the string could not be parsed. Free with Gst.Structure.free() after use.
end:pointer to store the end of the string in.
Return type:(Gst.Structure or None, end: str)

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

Free-function: Gst.Structure.free

classmethod new_empty(name)[source]
Parameters:name (str) – name of new structure
Returns:a new, empty Gst.Structure
Return type:Gst.Structure

Creates a new, empty Gst.Structure with the given name.

See Gst.Structure.set_name() for constraints on the name parameter.

Free-function: Gst.Structure.free

classmethod new_from_string(string)[source]
Parameters:string (str) – a string representation of a Gst.Structure
Returns:a new Gst.Structure or None when the string could not be parsed. Free with Gst.Structure.free() after use.
Return type:Gst.Structure or None

Creates a Gst.Structure from a string representation. If end is not None, 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 Gst.Caps / Gst.Structure deeper than one level.

Free-function: Gst.Structure.free

New in version 1.2.

classmethod new_id_empty(quark)[source]
Parameters:quark (int) – name of new structure
Returns:a new, empty Gst.Structure
Return type:Gst.Structure

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

Free-function: Gst.Structure.free

can_intersect(struct2)[source]
Parameters:struct2 (Gst.Structure) – a Gst.Structure
Returns:True if intersection would not be empty
Return type:bool

Tries intersecting self and struct2 and reports whether the result would not be empty.

copy()[source]
Returns:a new Gst.Structure.
Return type:Gst.Structure

Duplicates a Gst.Structure and all its fields and values.

Free-function: Gst.Structure.free

filter_and_map_in_place(func, *user_data)[source]
Parameters:

Calls the provided function once for each field in the Gst.Structure. 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.

New in version 1.6.

fixate()[source]

Fixate all values in self using Gst.value_fixate(). self will be modified in-place and should be writable.

fixate_field(field_name)[source]
Parameters:field_name (str) – a field in self
Returns:True if the structure field could be fixated
Return type:bool

Fixates a Gst.Structure by changing the given field with its fixated value.

fixate_field_boolean(field_name, target)[source]
Parameters:
  • field_name (str) – a field in self
  • target (bool) – the target value of the fixation
Returns:

True if the structure could be fixated

Return type:

bool

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

fixate_field_nearest_double(field_name, target)[source]
Parameters:
  • field_name (str) – a field in self
  • target (float) – the target value of the fixation
Returns:

True if the structure could be fixated

Return type:

bool

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

fixate_field_nearest_fraction(field_name, target_numerator, target_denominator)[source]
Parameters:
  • field_name (str) – a field in self
  • target_numerator (int) – The numerator of the target value of the fixation
  • target_denominator (int) – The denominator of the target value of the fixation
Returns:

True if the structure could be fixated

Return type:

bool

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

fixate_field_nearest_int(field_name, target)[source]
Parameters:
  • field_name (str) – a field in self
  • target (int) – the target value of the fixation
Returns:

True if the structure could be fixated

Return type:

bool

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

fixate_field_string(field_name, target)[source]
Parameters:
  • field_name (str) – a field in self
  • target (str) – the target value of the fixation
Returns:

True if the structure could be fixated

Return type:

bool

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

foreach(func, *user_data)[source]
Parameters:
Returns:

True if the supplied function returns True For each of the fields, False otherwise.

Return type:

bool

Calls the provided function once for each field in the Gst.Structure. The function must not modify the fields. Also see Gst.Structure.map_in_place() and Gst.Structure.filter_and_map_in_place().

free()[source]

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

get_array(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
array:a pointer to a GObject.ValueArray
Return type:(bool, array: GObject.ValueArray)

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

get_boolean(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
value:a pointer to a bool to set
Return type:(bool, value: bool)

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.

get_clock_time(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
value:a pointer to a #GstClockTime to set
Return type:(bool, value: int)

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.

get_date(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
value:a pointer to a GLib.Date to set
Return type:(bool, value: 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 GLib.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).

get_date_time(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
value:a pointer to a Gst.DateTime to set
Return type:(bool, value: 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.DateTime.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).

get_double(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
value:a pointer to a float to set
Return type:(bool, value: float)

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.

get_enum(fieldname, enumtype)[source]
Parameters:
  • fieldname (str) – the name of a field
  • enumtype (GObject.GType) – the enum type of a field
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.

value:a pointer to an int to set

Return type:

(bool, value: int)

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.

get_field_type(fieldname)[source]
Parameters:fieldname (str) – the name of the field
Returns:the GObject.Value of the field
Return type:GObject.GType

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

get_flagset(fieldname)[source]
Parameters:fieldname (str) – the name of a field
Returns:True if the values could be set correctly. If there was no field with fieldname or the existing field did not contain a Gst.FlagSet, this function returns False.
value_flags:a pointer to a int for the flags field
value_mask:a pointer to a int for the mask field
Return type:(bool, value_flags: int, value_mask: int)

Read the Gst.FlagSet flags and mask out of the structure into the provided pointers.

New in version 1.6.

get_fraction(fieldname)[source]
Parameters:fieldname (str) – the name of a field
Returns:True if the values could be set correctly. If there was no field with fieldname or the existing field did not contain a Gst.Fraction, this function returns False.
value_numerator:
 a pointer to an int to set
value_denominator:
 a pointer to an int to set
Return type:(bool, value_numerator: int, value_denominator: int)

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.

get_int(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
value:a pointer to an int to set
Return type:(bool, value: int)

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.

get_int64(fieldname)[source]
Parameters:fieldname (str) – the name of a field
Returns:True if the value could be set correctly. If there was no field with fieldname or the existing field did not contain a #gint64, this function returns False.
value:a pointer to a #gint64 to set
Return type:(bool, value: int)

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.

New in version 1.4.

get_list(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
array:a pointer to a GObject.ValueArray
Return type:(bool, array: GObject.ValueArray)

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

get_name()[source]
Returns:the name of the structure.
Return type:str

Get the name of self as a string.

get_name_id()[source]
Returns:the quark representing the name of the structure.
Return type:int

Get the name of self as a GQuark.

get_string(fieldname)[source]
Parameters:fieldname (str) – the name of a field
Returns:a pointer to the string or None when the field did not exist or did not contain a string.
Return type:str or None

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.

get_uint(fieldname)[source]
Parameters:fieldname (str) – the name of a field
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.
value:a pointer to a uint to set
Return type:(bool, value: int)

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.

get_uint64(fieldname)[source]
Parameters:fieldname (str) – the name of a field
Returns:True if the value could be set correctly. If there was no field with fieldname or the existing field did not contain a #guint64, this function returns False.
value:a pointer to a #guint64 to set
Return type:(bool, value: int)

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.

New in version 1.4.

get_value(fieldname)[source]
Parameters:fieldname (str) – the name of the field to get
Returns:the GObject.Value corresponding to the field with the given name.
Return type:GObject.Value or None

Get the value of the field with name fieldname.

has_field(fieldname)[source]
Parameters:fieldname (str) – the name of a field
Returns:True if the structure contains a field with the given name
Return type:bool

Check if self contains a field named fieldname.

has_field_typed(fieldname, type)[source]
Parameters:
  • fieldname (str) – the name of a field
  • type (GObject.GType) – the type of a value
Returns:

True if the structure contains a field with the given name and type

Return type:

bool

Check if self contains a field named fieldname and with GObject.GType type.

has_name(name)[source]
Parameters:name (str) – structure name to check for
Returns:True if name matches the name of the structure.
Return type:bool

Checks if the structure has the given name

id_get_value(field)[source]
Parameters:field (int) – the #GQuark of the field to get
Returns:the GObject.Value corresponding to the field with the given name identifier.
Return type:GObject.Value or None

Get the value of the field with GQuark field.

id_has_field(field)[source]
Parameters:field (int) – #GQuark of the field name
Returns:True if the structure contains a field with the given name
Return type:bool

Check if self contains a field named field.

id_has_field_typed(field, type)[source]
Parameters:
  • field (int) – #GQuark of the field name
  • type (GObject.GType) – the type of a value
Returns:

True if the structure contains a field with the given name and type

Return type:

bool

Check if self contains a field named field and with GObject.GType type.

id_set_value(field, value)[source]
Parameters:
  • field (int) – a #GQuark representing a field
  • value (GObject.Value) – the new value of the field

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.

id_take_value(field, value)[source]
Parameters:
  • field (int) – a #GQuark representing a field
  • value (GObject.Value) – the new value of the field

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.

intersect(struct2)[source]
Parameters:struct2 (Gst.Structure) – a Gst.Structure
Returns:Intersection of self and struct2
Return type:Gst.Structure or None

Intersects self and struct2 and returns the intersection.

is_equal(structure2)[source]
Parameters:structure2 (Gst.Structure) – a Gst.Structure.
Returns:True if the two structures have the same name and field.
Return type:bool

Tests if the two Gst.Structure are equal.

is_subset(superset)[source]
Parameters:superset (Gst.Structure) – a potentially greater Gst.Structure
Returns:True if self is a subset of superset
Return type:bool

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

map_in_place(func, *user_data)[source]
Parameters:
Returns:

True if the supplied function returns True For each of the fields, False otherwise.

Return type:

bool

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

n_fields()[source]
Returns:the number of fields in the structure
Return type:int

Get the number of fields in the structure.

nth_field_name(index)[source]
Parameters:index (int) – the index to get the name of
Returns:the name of the given field number
Return type:str

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

remove_all_fields()[source]

Removes all fields in a Gst.Structure.

remove_field(fieldname)[source]
Parameters:fieldname (str) – the name of the field to remove

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

set_array(fieldname, array)[source]
Parameters:

This is useful in language bindings where unknown GObject.Value 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 GObject.Value directly.

New in version 1.12.

set_list(fieldname, array)[source]
Parameters:

This is useful in language bindings where unknown GObject.Value 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 GObject.Value directly.

New in version 1.12.

set_name(name)[source]
Parameters:name (str) – the new name of the structure

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 “/-_.:”.

set_parent_refcount(refcount)[source]
Parameters:refcount (int) – a pointer to the parent’s refcount
Returns:True if the parent refcount could be set.
Return type:bool

Sets the parent_refcount field of Gst.Structure. 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 Gst.Structure, as described in the MT Refcounting section of the design documents.

set_value(fieldname, value)[source]
Parameters:
  • fieldname (str) – the name of the field to set
  • value (GObject.Value) – the new value of the field

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.

take_value(fieldname, value)[source]
Parameters:
  • fieldname (str) – the name of the field to set
  • value (GObject.Value) – the new value of the field

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.

to_string()[source]
Returns:a pointer to string allocated by GLib.malloc(). GLib.free() after usage.
Return type:str

Converts self 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.

The current implementation of serialization will lead to unexpected results when there are nested Gst.Caps / Gst.Structure deeper than one level.

Free-function: GLib.free