Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 upsubdir (
str
orNone
) – the name of the subdirectory to search in, inside the specified directoriesfilename (
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:
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 upsubdir (
str
orNone
) – the name of the subdirectory to search in, inside the configuration directoriessuffix (
str
orNone
) – 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:
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 isNone
, 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.get_library_api_version()¶
- Returns:
WirePlumber library API version
- Return type:
Gets the WirePlumber library API version.
New in version 0.4.12.
- Wp.get_library_version()¶
- Returns:
WirePlumber library version
- Return type:
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 formatmatch_props (
Wp.Properties
) – the properties to match against the rulescallback (
Wp.RuleMatchCallback
orNone
) – a function to call for each action on a successful match
- Raises:
- Returns:
- Return type:
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:
json (
Wp.SpaJson
) – a JSON array containing rules in the format accepted byWp.json_utils_match_rules
()props (
Wp.Properties
) – the properties to match against the rules and also update, acting on the “update-props” action
- Returns:
the number of properties that were updated
- Return type:
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:
a (
Wp.SpaJson
) – a JSON containerb (
Wp.SpaJson
) – a JSON container
- 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:
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_writer_default(log_level, fields, n_fields, user_data)¶
- Parameters:
log_level (
GLib.LogLevelFlags
) –fields (
GLib.LogField
) –n_fields (
int
) –
- Return type:
WirePlumber’s
GLib.LogWriterFunc
.This is installed automatically when you call
Wp.init
() withWp.InitFlags.SET_GLIB_LOG
set in the flags
- Wp.spa_dynamic_id_table_register(name, values)¶
- Parameters:
- Returns:
the new table
- Return type:
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
() whenWp.InitFlags.SPA_TYPES
is passed in its flags.
- Wp.spa_dynamic_type_register(name, parent, values)¶
- Parameters:
name (
str
) – the name of the typeparent (
Wp.SpaType
) – the parent typevalues (
object
orNone
) – an array of spa_type_info that contains the values of the type, used only for Object types
- Returns:
the new type
- Return type:
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:
- Returns:
the WpSpaIdValue associated with value, or
None
- Return type:
Finds a value in an SPA Id table.
- Wp.spa_id_table_find_value_from_name(table, name)¶
- Parameters:
- Returns:
the WpSpaIdValue associated with name, or
None
- Return type:
Finds a named value in an SPA Id table.
- Wp.spa_id_table_find_value_from_short_name(table, short_name)¶
- Parameters:
- Returns:
the WpSpaIdValue associated with short_name, or
None
- Return type:
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:
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:
- Wp.spa_id_table_new_iterator(table)¶
- Parameters:
table (
object
) – the id table- Returns:
a
Wp.Iterator
that iterates over WpSpaIdValue items- Return type:
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:
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:
- Returns:
the id value or
None
if it was not found- Return type:
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:
- Returns:
the id value or
None
if it was not found- Return type:
Looks up an id value given its container table_name and its short_name.
- Wp.spa_id_value_get_type()¶
- Return type:
- 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)¶
-
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:
Gets the numeric value of an id value.
- Wp.spa_id_value_short_name(id)¶
-
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 callWp.init
() withWp.InitFlags.SET_PW_LOG
set in the flags- Return type:
Gets WirePlumber’s instance of spa_log