gstreamermm
1.10.0
|
Generic class containing fields of names and values. More...
#include <gstreamermm/structure.h>
Public Types | |
typedef sigc::slot< bool, const Glib::ustring&, const Glib::ValueBase& > | SlotForeach |
For example, bool on_foreach(const Glib::ustring& id, const Glib::ValueBase& value);. More... | |
typedef sigc::slot< bool, const Glib::ustring&, Glib::ValueBase& > | SlotMap |
For example, bool on_map(const Glib::ustring& id, Glib::ValueBase& value);. More... | |
Public Member Functions | |
Structure () | |
Structure (GstStructure* gobject, bool make_a_copy=true) | |
Structure (const Structure& other) | |
Structure& | operator= (const Structure& other) |
Structure (Structure&& other) noexcept | |
Structure& | operator= (Structure&& other) noexcept |
~Structure () noexcept | |
void | swap (Structure& other) noexcept |
GstStructure* | gobj () |
Provides access to the underlying C instance. More... | |
const GstStructure* | gobj () const |
Provides access to the underlying C instance. More... | |
GstStructure* | gobj_copy () const |
Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. More... | |
template<class ... DataTypes> | |
Structure (const Glib::ustring& name, DataTypes... data) | |
Creates a Structure with the given name. More... | |
operator const void* () const | |
Use this to discover if the Structure is a valid object. More... | |
GstStructure* | release () noexcept |
Release the ownership of underlying GstStructure instance. More... | |
Glib::ustring | get_name () const |
Get the name of structure as a string. More... | |
bool | has_name (const Glib::ustring& name) const |
Checks if the structure has the given name. More... | |
void | set_name (const Glib::ustring& name) |
Sets the name of the structure to the given name. More... | |
Glib::QueryQuark | get_name_id () const |
Get the name of structure as a GQuark. More... | |
void | remove_all_fields () |
Removes all fields in a GstStructure. More... | |
GType | get_field_type (const Glib::ustring& fieldname) const |
Finds the field with the given name, and returns the type of the value it contains. More... | |
int | size () const |
Get the number of fields in the structure. More... | |
Glib::ustring | get_nth_field_name (guint index) const |
Get the name of the given field number, counting from 0 onwards. More... | |
Glib::ustring | to_string () const |
Converts structure to a human-readable string representation. More... | |
bool | fixate_field_nearest_int (const Glib::ustring& name, int target) |
Fixates a Gst::Structure by changing the given field to the nearest integer to target that is a subset of the existing field. More... | |
bool | fixate_field_nearest_double (const Glib::ustring& name, double target) |
Fixates a Gst::Structure by changing the given field to the nearest double to target that is a subset of the existing field. More... | |
bool | fixate_field_string (const Glib::ustring& name, const Glib::ustring& target) |
Fixates a Gst::Structure by changing the given name field to the given target string if that field is not fixed yet. More... | |
bool | fixate_field (const Glib::ustring& name) |
Fixates a Gst::Structure by changing the given field with its fixated value. More... | |
bool | fixate_field_boolean (const Glib::ustring& name, bool target) |
Fixates a Gst::Structure by changing the given name field to the given target boolean if that field is not fixed yet. More... | |
Gst::Structure | intersect (const Gst::Structure& struct2) const |
Intersects struct1 and struct2 and returns the intersection. More... | |
bool | is_equal (const Gst::Structure& struct2) const |
Tests if the two Gst::Structure are equal. More... | |
bool | is_subset (const Gst::Structure& superset) const |
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. More... | |
bool | can_intersect (const Gst::Structure& struct2) const |
Tries intersecting struct1 and struct2 and reports whether the result would not be empty. More... | |
void | fixate () |
Fixate all values in structure using gst_value_fixate(). More... | |
bool | get_flagset (const Glib::ustring& fieldname, guint& value_flags, guint& value_mask) const |
Read the GstFlagSet flags and mask out of the structure into the provided pointers. More... | |
bool | has_field (const Glib::ustring& fieldname) const |
Check if structure contains a field named fieldname. More... | |
bool | has_field (const Glib::ustring& fieldname, GType type) const |
Check if structure contains a field named fieldname and with GType type. More... | |
void | get_field (const Glib::ustring& fieldname, Glib::ValueBase& value) const |
Get the value of the field with name fieldname. More... | |
template<typename DataType > | |
void | get_field (const Glib::ustring& fieldname, Glib::Value< DataType >& value) const |
Get the value of the field with name fieldname. More... | |
bool | get_field (const Glib::ustring& fieldname, GType enumtype, int& value) const |
Gets the value of field fieldname with GType enum type enumtype into integer value. More... | |
template<typename DataType > | |
bool | get_field (const Glib::ustring& fieldname, DataType& value) const |
Gets the value of field fieldname into DataType value. More... | |
void | set_field (const Glib::ustring& fieldname, const Glib::ValueBase& value) |
Sets the field with name fieldname to value. More... | |
template<typename DataType > | |
void | set_field (const Glib::ustring& fieldname, const Glib::Value< DataType >& value) |
Sets the field with name fieldname to value. More... | |
void | set_field (const Glib::ustring& fieldname, const char* value) |
Sets the field with name fieldname to value. More... | |
template<class DataType , class ... DataTypes> | |
void | set_fields (const Glib::ustring& fieldname, const DataType& value, DataTypes ...further_data) |
Sets the fields with name fieldname to values. More... | |
void | set_field (const Glib::ustring& fieldname, GType enumtype, int value) |
Sets the field with name fieldname to the value value of the enum type enum_type. More... | |
template<typename DataType > | |
void | set_field (const Glib::ustring& fieldname, const DataType& value) |
Sets the field with name fieldname field to the DataType value. More... | |
void | remove_field (const Glib::ustring& fieldname) |
Removes the field with name fieldname. More... | |
bool | foreach (const SlotForeach& slot) |
Calls the provided slot once for each field in the Gst::Structure. More... | |
bool | map_in_place (const SlotMap& slot) |
Calls the provided slot once for each field in the Gst::Structure. More... | |
bool | fixate_nearest_fraction (const Glib::ustring& field_name, const Gst::Fraction& target) |
Fixates a Gst::Structure by changing the given field to the nearest fraction to given Gst::Fraction that is a subset of the existing field. More... | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. More... | |
static Structure | create_from_string (const Glib::ustring& the_string) |
Creates a Gst::Structure from a string representation. More... | |
Protected Attributes | |
GstStructure* | gobject_ |
Related Functions | |
(Note that these are not member functions.) | |
void | swap (Structure& lhs, Structure& rhs) noexcept |
Gst::Structure | wrap (GstStructure* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
Generic class containing fields of names and values.
A Gst::Structure 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 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.
A Gst::Structure can be created with constructor, which take a name and an optional set of key/value pairs along with the types of the values.
Field values can be changed with set_field() or set_fields().
Field values can be retrieved with gst_get_field().
Fields can be removed with remove_field().
Strings in structures must be ASCII or UTF-8 encoded.
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.
Last reviewed on 2016-07-12 (1.8.0)
typedef sigc::slot<bool, const Glib::ustring&, const Glib::ValueBase&> Gst::Structure::SlotForeach |
For example, bool on_foreach(const Glib::ustring& id, const Glib::ValueBase& value);.
The on_foreach function should return true if the foreach operation should continue, or false if the operation should stop with false.
typedef sigc::slot<bool, const Glib::ustring&, Glib::ValueBase&> Gst::Structure::SlotMap |
For example, bool on_map(const Glib::ustring& id, Glib::ValueBase& value);.
The map function should return true if the map operation should continue, or false if the operation should stop with false.
Gst::Structure::Structure | ( | ) |
|
explicit |
Gst::Structure::Structure | ( | const Structure& | other | ) |
|
noexcept |
|
noexcept |
|
explicit |
Creates a Structure 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 and value
bool Gst::Structure::can_intersect | ( | const Gst::Structure& | struct2 | ) | const |
Tries intersecting struct1 and struct2 and reports whether the result would not be empty.
struct2 | A Gst::Structure. |
true
if intersection would not be empty.
|
static |
Creates a Gst::Structure from a string representation.
the_string | A string representation of a Gst::Structure. See to_string(). |
void Gst::Structure::fixate | ( | ) |
Fixate all values in structure using gst_value_fixate().
structure will be modified in-place and should be writable.
bool Gst::Structure::fixate_field | ( | const Glib::ustring & | name | ) |
Fixates a Gst::Structure by changing the given field with its fixated value.
name | A field in structure. |
true
if the structure field could be fixated. bool Gst::Structure::fixate_field_boolean | ( | const Glib::ustring & | name, |
bool | target | ||
) |
Fixates a Gst::Structure by changing the given name field to the given target boolean if that field is not fixed yet.
name | A field in structure. |
target | The target value of the fixation. |
true
if the structure could be fixated. bool Gst::Structure::fixate_field_nearest_double | ( | const Glib::ustring & | name, |
double | target | ||
) |
Fixates a Gst::Structure by changing the given field to the nearest double to target that is a subset of the existing field.
name | A field in structure. |
target | The target value of the fixation. |
true
if the structure could be fixated. bool Gst::Structure::fixate_field_nearest_int | ( | const Glib::ustring & | name, |
int | target | ||
) |
Fixates a Gst::Structure by changing the given field to the nearest integer to target that is a subset of the existing field.
name | A field in structure. |
target | The target value of the fixation. |
true
if the structure could be fixated. bool Gst::Structure::fixate_field_string | ( | const Glib::ustring & | name, |
const Glib::ustring & | target | ||
) |
Fixates a Gst::Structure by changing the given name field to the given target string if that field is not fixed yet.
name | A field in structure. |
target | The target value of the fixation. |
true
if the structure could be fixated. bool Gst::Structure::fixate_nearest_fraction | ( | const Glib::ustring & | field_name, |
const Gst::Fraction& | target | ||
) |
Fixates a Gst::Structure by changing the given field to the nearest fraction to given Gst::Fraction that is a subset of the existing field.
field_name | A field in structure. |
target | The target value of the fixation. |
bool Gst::Structure::foreach | ( | const SlotForeach& | slot | ) |
Calls the provided slot once for each field in the Gst::Structure.
The slot must not modify the fields. See also map_in_place().
slot | A slot to call for each field. |
void Gst::Structure::get_field | ( | const Glib::ustring & | fieldname, |
Glib::ValueBase & | value | ||
) | const |
Get the value of the field with name fieldname.
fieldname | The name of the field to get. |
value | The Value class in which to store the value. |
void Gst::Structure::get_field | ( | const Glib::ustring & | fieldname, |
Glib::Value< DataType > & | value | ||
) | const |
Get the value of the field with name fieldname.
fieldname | The name of the field to get. |
value | The Value class in which to store the value. |
bool Gst::Structure::get_field | ( | const Glib::ustring & | fieldname, |
GType | enumtype, | ||
int & | value | ||
) | const |
Gets the value of field fieldname with GType enum type enumtype into integer value.
Caller is responsible for making sure the field exists and has the correct type. A call to this method would look like so:
fieldname | The name of a field. |
enumtype | The enum GType of the field. |
value | An output parameter that will be set with the value. |
bool Gst::Structure::get_field | ( | const Glib::ustring & | fieldname, |
DataType & | value | ||
) | const |
Gets the value of field fieldname into DataType value.
The caller is responsible for making sure the field exists and has the correct type.
fieldname | The name of a field. |
value | The DataType to set. |
GType Gst::Structure::get_field_type | ( | const Glib::ustring & | fieldname | ) | const |
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.
fieldname | The name of the field. |
bool Gst::Structure::get_flagset | ( | const Glib::ustring & | fieldname, |
guint & | value_flags, | ||
guint & | value_mask | ||
) | const |
Read the GstFlagSet flags and mask out of the structure into the provided pointers.
fieldname | The name of a field. |
value_flags | A pointer to a unsigned int for the flags field. |
value_mask | A pointer to a unsigned int for the mask field. |
true
if the values could be set correctly. If there was no field with fieldname or the existing field did not contain a GstFlagSet, this function returns false
. Glib::ustring Gst::Structure::get_name | ( | ) | const |
Get the name of structure as a string.
Glib::QueryQuark Gst::Structure::get_name_id | ( | ) | const |
Get the name of structure as a GQuark.
Glib::ustring Gst::Structure::get_nth_field_name | ( | guint | index | ) | const |
Get the name of the given field number, counting from 0 onwards.
index | The index to get the name of. |
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C instance.
|
inline |
Provides access to the underlying C instance.
GstStructure* Gst::Structure::gobj_copy | ( | ) | const |
Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
bool Gst::Structure::has_field | ( | const Glib::ustring & | fieldname | ) | const |
Check if structure contains a field named fieldname.
fieldname | The name of a field. |
true
if the structure contains a field with the given name. bool Gst::Structure::has_field | ( | const Glib::ustring & | fieldname, |
GType | type | ||
) | const |
Check if structure contains a field named fieldname and with GType type.
fieldname | The name of a field. |
type | The type of a value. |
true
if the structure contains a field with the given name and type. bool Gst::Structure::has_name | ( | const Glib::ustring & | name | ) | const |
Checks if the structure has the given name.
name | Structure name to check for. |
true
if name matches the name of the structure. Gst::Structure Gst::Structure::intersect | ( | const Gst::Structure& | struct2 | ) | const |
Intersects struct1 and struct2 and returns the intersection.
struct2 | A Gst::Structure. |
bool Gst::Structure::is_equal | ( | const Gst::Structure& | struct2 | ) | const |
Tests if the two Gst::Structure are equal.
struct2 | A Gst::Structure. |
true
if the two structures have the same name and field. bool Gst::Structure::is_subset | ( | const Gst::Structure& | superset | ) | const |
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.
superset | A potentially greater Gst::Structure. |
true
if subset is a subset of superset. bool Gst::Structure::map_in_place | ( | const SlotMap& | slot | ) |
Calls the provided slot once for each field in the Gst::Structure.
In contrast to foreach(), the function may modify but not delete the fields. The structure must be mutable.
slot | A slot to call for each field. |
Gst::Structure::operator const void * | ( | ) | const |
Use this to discover if the Structure is a valid object.
|
noexcept |
Release the ownership of underlying GstStructure instance.
Gst::Structure's underlying instance is set to nullptr, therefore underlying object can't be accessed through this Gst::Structure anymore.
Most users should not use release(). It can spoil the automatic destruction of the managed object.
void Gst::Structure::remove_all_fields | ( | ) |
Removes all fields in a GstStructure.
void Gst::Structure::remove_field | ( | const Glib::ustring & | fieldname | ) |
Removes the field with name fieldname.
If the field with the given name does not exist, the structure is unchanged.
fieldname | The name of the field to remove. |
void Gst::Structure::set_field | ( | const Glib::ustring & | fieldname, |
const Glib::ValueBase & | value | ||
) |
Sets the field with name fieldname to value.
If the field does not exist, it is created. If the field exists, the previous value is replaced and freed.
fieldname | The name of the field to set. |
value | The value to set the field to. |
void Gst::Structure::set_field | ( | const Glib::ustring & | fieldname, |
const Glib::Value< DataType > & | value | ||
) |
Sets the field with name fieldname to value.
If the field does not exist, it is created. If the field exists, the previous value is replaced and freed.
fieldname | The name of the field to set. |
value | The value to set the field to. |
void Gst::Structure::set_field | ( | const Glib::ustring & | fieldname, |
const char * | value | ||
) |
Sets the field with name fieldname to value.
If the field does not exist, it is created. If the field exists, the previous value is replaced and freed.
fieldname | The name of the field to set. |
value | The value to set the field to. |
void Gst::Structure::set_field | ( | const Glib::ustring & | fieldname, |
GType | enumtype, | ||
int | value | ||
) |
Sets the field with name fieldname to the value value of the enum type enum_type.
If the field does not exist, it is created. If the field exists, the previous value is replaced and freed. Caller is responsible for making sure that value is a valid enumtype. A call to this method would look like so:
fieldname | The name of the field to set. |
enumtype | The enum GType that value should be treated as. |
value | The value to set the field to. |
void Gst::Structure::set_field | ( | const Glib::ustring & | fieldname, |
const DataType & | value | ||
) |
Sets the field with name fieldname field to the DataType value.
If the field does not exist, it is created. If the field exists, the previous value is replaced and freed. Please note that when setting fields to special types such as Gst::Fourcc and Gst::Fraction and Glib::Date they are converted to the GStreamer GTypes and thus when attempting to get these fields back as GValues, they will have the GStreamer GType.
fieldname | The name of the field to set. |
value | The value to set the field to. |
void Gst::Structure::set_fields | ( | const Glib::ustring & | fieldname, |
const DataType & | value, | ||
DataTypes ... | further_data | ||
) |
Sets the fields with name fieldname to values.
If one of the fields does not exist, it is created. If the field exists, the previous value is replaced and freed.
fieldname | The name of the field to set. |
value | The value to set the field to. |
further_data | List of pairs of the format: fieldname, value. |
void Gst::Structure::set_name | ( | const Glib::ustring & | 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 "/-_.:".
name | The new name of the structure. |
int Gst::Structure::size | ( | ) | const |
Get the number of fields in the structure.
|
noexcept |
Glib::ustring Gst::Structure::to_string | ( | ) | const |
Converts structure to a human-readable string representation.
For debugging purposes its easier to do something like this:
[C example ellipted] 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.
lhs | The left-hand side |
rhs | The right-hand side |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
|
protected |