Functions

base_dirs_find_file (flags, subdir, filename)

base_dirs_new_files_iterator (flags, subdir, suffix)

domain_library_quark ()

get_library_api_version ()

get_library_version ()

init (flags)

json_utils_match_rules (json, match_props, callback, *data)

json_utils_match_rules_update_properties (json, props)

json_utils_merge_containers (a, b)

log_set_level (log_level)

log_writer_default (log_level, fields, n_fields, user_data)

spa_dynamic_id_table_register (name, values)

spa_dynamic_type_deinit ()

spa_dynamic_type_init ()

spa_dynamic_type_register (name, parent, values)

spa_id_table_find_value (table, value)

spa_id_table_find_value_from_name (table, name)

spa_id_table_find_value_from_short_name (table, short_name)

spa_id_table_from_name (name)

spa_id_table_get_type ()

spa_id_table_new_iterator (table)

spa_id_value_array_get_item_type (id)

spa_id_value_from_name (name)

spa_id_value_from_number (table_name, id)

spa_id_value_from_short_name (table_name, short_name)

spa_id_value_get_type ()

spa_id_value_get_value_type (id)

spa_id_value_name (id)

spa_id_value_number (id)

spa_id_value_short_name (id)

spa_log_get_instance ()

Details

Wp.base_dirs_find_file(flags, subdir, filename)
Parameters:
  • flags (Wp.BaseDirsFlags) – flags to specify the directories to look into and other options specific to the kind of file being looked up

  • subdir (str or None) – the name of the subdirectory to search in, inside the specified directories

  • filename (str) – the name of the file to search for

Returns:

A newly allocated string with the absolute, canonicalized file path, or None if the file was not found.

Return type:

str or None

Searches for filename in the hierarchy of directories specified by the flags parameter.

Returns the highest priority file found in the hierarchy of directories specified by the flags parameter. The subdir parameter is the name of the subdirectory to search in, inside the specified directories. If subdir is None, the base path of each directory is used. The filename parameter is the name of the file to search for. If the file is found, its full path is returned. If the file is not found, None is returned. The file is considered found if it is a regular file. If the filename is an absolute path, it is tested for existence and returned as is, ignoring the lookup directories in flags as well as the subdir parameter.

New in version 0.5.0.

Wp.base_dirs_new_files_iterator(flags, subdir, suffix)
Parameters:
  • flags (Wp.BaseDirsFlags) – flags to specify the directories to look into and other options specific to the kind of file being looked up

  • subdir (str or None) – the name of the subdirectory to search in, inside the configuration directories

  • suffix (str or None) – The filename suffix, None matches all entries

Returns:

a new iterator iterating over strings which are absolute & canonicalized paths to the files found

Return type:

Wp.Iterator

Creates an iterator to iterate over all files that match suffix within the subdir of the directories specified in flags.

The subdir parameter is the name of the subdirectory to search in, inside the directories specified by flags. If subdir is None, the base path of each directory is used. If subdir is an absolute path, files are only looked up in that directory and the directories in flags are ignored. The suffix parameter is the filename suffix to match. If suffix is None, all files are matched. The iterator will iterate over the absolute paths of all the files files found, in the order of priority of the directories, starting from the lowest priority directory (e.g. /usr/share/wireplumber) and ending with the highest priority directory (e.g. $XDG_CONFIG_HOME/wireplumber). Files within each directory are also sorted by filename.

New in version 0.5.0.

Wp.domain_library_quark()
Return type:

int

Wp.get_library_api_version()
Returns:

WirePlumber library API version

Return type:

str

Gets the WirePlumber library API version.

New in version 0.4.12.

Wp.get_library_version()
Returns:

WirePlumber library version

Return type:

str

Gets the WirePlumber library version.

New in version 0.4.12.

Wp.init(flags)
Parameters:

flags (Wp.InitFlags) – initialization flags

Initializes WirePlumber and PipeWire underneath.

flags can modify which parts are initialized, in cases where you want to handle part of this initialization externally.

Wp.json_utils_match_rules(json, match_props, callback, *data)
Parameters:
  • json (Wp.SpaJson) – a JSON array containing rules in the described format

  • match_props (Wp.Properties) – the properties to match against the rules

  • callback (Wp.RuleMatchCallback or None) – a function to call for each action on a successful match

  • data (object or None) – data to be passed to callback

Raises:

GLib.Error

Returns:

False if an error occurred, True otherwise

Return type:

bool

Matches the given properties against a set of rules described in JSON and calls the given callback to perform actions on a successful match.

The given JSON should be an array of objects, where each object has a “matches” and an “actions” property. The “matches” value should also be an array of objects, where each object is a set of properties to match. Inside such an object, all properties must match to consider a successful match. However, if multiple objects are provided, only one object needs to match. The “actions” value should be an object where the key is the action name and the value can be any valid JSON. Both the action name and the value are passed as-is on the callback.

Wp.json_utils_match_rules_update_properties(json, props)
Parameters:
Returns:

the number of properties that were updated

Return type:

int

Matches the given properties against a set of rules described in JSON and updates the properties if the rule actions include the “update-props” action.

Wp.json_utils_merge_containers(a, b)
Parameters:
Returns:

a new JSON container containing the merged contents of a and b or None if a and b are not of the same type

Return type:

Wp.SpaJson

Merges two JSON containers (objects or arrays) into one.

If both a and b are objects, the result will be a new object containing all properties from both a and b. If a property exists in both a and b, the values are recursively merged. If a property exists in both a and b and the property name starts with the “override.” prefix in either of those, the value from the key with the prefix is used. If both a and b are arrays, the result will be a new array containing all elements from both a and b. If a and b are not of the same type, None is returned.

Wp.log_set_level(log_level)
Parameters:

log_level (str) –

Return type:

bool

Wp.log_writer_default(log_level, fields, n_fields, user_data)
Parameters:
Return type:

GLib.LogWriterOutput

WirePlumber’s GLib.LogWriterFunc.

This is installed automatically when you call Wp.init() with Wp.InitFlags.SET_GLIB_LOG set in the flags

Wp.spa_dynamic_id_table_register(name, values)
Parameters:
  • name (str) – the name of the id table

  • values (object or None) – an array of spa_type_info that contains the values of the table

Returns:

the new table

Return type:

object

Registers an additional WpSpaIdTable in the spa type system.

This is useful to add custom enumeration types. Note that both name and values must be statically allocated, or otherwise guaranteed to be kept in memory until Wp.spa_dynamic_type_deinit() is called. No memory copy is done by this function.

Wp.spa_dynamic_type_deinit()

Deinitializes the spa type registry.

You do not need to ever call this, unless you want to free memory at the end of the execution of a test, so that it doesn’t show as leaked in the memory profiler.

Wp.spa_dynamic_type_init()

Initializes the spa dynamic type registry.

This allows registering new spa types at runtime. The spa type system still works if this function is not called. Normally called by Wp.init() when Wp.InitFlags.SPA_TYPES is passed in its flags.

Wp.spa_dynamic_type_register(name, parent, values)
Parameters:
  • name (str) – the name of the type

  • parent (Wp.SpaType) – the parent type

  • values (object or None) – an array of spa_type_info that contains the values of the type, used only for Object types

Returns:

the new type

Return type:

Wp.SpaType

Registers an additional type in the spa type system.

This is useful to add a custom pod object type. Note that both name and values must be statically allocated, or otherwise guaranteed to be kept in memory until Wp.spa_dynamic_type_deinit() is called. No memory copy is done by this function.

Wp.spa_id_table_find_value(table, value)
Parameters:
  • table (object) – the id table

  • value (int) – a numeric value that is contained in the table

Returns:

the WpSpaIdValue associated with value, or None

Return type:

object or None

Finds a value in an SPA Id table.

Wp.spa_id_table_find_value_from_name(table, name)
Parameters:
  • table (object) – the id table

  • name (str) – the full name of a value that is contained in the table

Returns:

the WpSpaIdValue associated with name, or None

Return type:

object or None

Finds a named value in an SPA Id table.

Wp.spa_id_table_find_value_from_short_name(table, short_name)
Parameters:
  • table (object) – the id table

  • short_name (str) – the short name of a value that is contained in the table

Returns:

the WpSpaIdValue associated with short_name, or None

Return type:

object or None

Finds a short named value in an SPA Id table.

Wp.spa_id_table_from_name(name)
Parameters:

name (str) – the full name of an id table

Returns:

the associated table, or None

Return type:

object or None

Finds a WpSpaIdTable given its name.

This name can either be the full type name of an object type, or the name of an enum (which is (!!) a type). For example, “Spa:Pod:Object:Param:Format” and “Spa:Enum:ParamId” are both valid table names.

Wp.spa_id_table_get_type()
Return type:

GObject.GType

Wp.spa_id_table_new_iterator(table)
Parameters:

table (object) – the id table

Returns:

a Wp.Iterator that iterates over WpSpaIdValue items

Return type:

Wp.Iterator

This function returns an iterator that allows you to iterate through the values associated with this table.

The items in the iterator are of type WpSpaIdValue.

Wp.spa_id_value_array_get_item_type(id)
Parameters:

id (object) – an id value

Returns:

the type that is allowed in the array, if id represents an object field that takes an array as value

table:

the associated WpSpaIdTable

Return type:

(Wp.SpaType, table: object)

If the value type of id is SPA_TYPE_Array, this function returns the type that is allowed to be contained inside the array.

When the returned type is (or is derived from) SPA_TYPE_Id or SPA_TYPE_Object, table is set to point to the WpSpaIdTable that contains the possible Id values / object fields.

Wp.spa_id_value_from_name(name)
Parameters:

name (str) – the full name of an id value

Returns:

the id value for name, or None if no such id value was found

Return type:

object

Looks up an id value (enum, flag or object field) directly from its full name.

For instance, “Spa:Enum:Direction:Input” will resolve to the id value that represents “Input” in the “Spa:Enum:Direction” enum.

Wp.spa_id_value_from_number(table_name, id)
Parameters:
  • table_name (str) – the name of the WpSpaIdTable to look up the value in

  • id (int) – the numeric representation of the value to look up

Returns:

the id value or None if it was not found

Return type:

object

Looks up an id value given its container table_name and its numeric representation, id.

Wp.spa_id_value_from_short_name(table_name, short_name)
Parameters:
  • table_name (str) – the name of the WpSpaIdTable to look up the value in

  • short_name (str) – the short name of the value to look up

Returns:

the id value or None if it was not found

Return type:

object

Looks up an id value given its container table_name and its short_name.

Wp.spa_id_value_get_type()
Return type:

GObject.GType

Wp.spa_id_value_get_value_type(id)
Parameters:

id (object) – an id value

Returns:

the value type associated with id

table:

the associated WpSpaIdTable

Return type:

(Wp.SpaType, table: object)

Returns the value type associated with this WpSpaIdValue.

This information is useful when id represents an object field, which can take a value of an arbitrary type. When the returned type is (or is derived from) SPA_TYPE_Id or SPA_TYPE_Object, table is set to point to the WpSpaIdTable that contains the possible Id values / object fields.

Wp.spa_id_value_name(id)
Parameters:

id (object) – an id value

Returns:

the full name of this id value

Return type:

str

Gets the name of an id value.

Wp.spa_id_value_number(id)
Parameters:

id (object) – an id value

Returns:

the numeric representation of this id value

Return type:

int

Gets the numeric value of an id value.

Wp.spa_id_value_short_name(id)
Parameters:

id (object) – an id value

Returns:

the short name of this id value

Return type:

str

Gets the short name of an id value.

Wp.spa_log_get_instance()
Returns:

WirePlumber’s instance of spa_log, which can be used to redirect PipeWire’s log messages to the currently installed GLib.LogWriterFunc. This is installed automatically when you call Wp.init() with Wp.InitFlags.SET_PW_LOG set in the flags

Return type:

object or None

Gets WirePlumber’s instance of spa_log