Wp.Core¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The main configuration file |
||
r/w/co |
A |
||
r/w/co |
Extra properties |
||
r/w/co |
The pipewire context |
||
r |
The pipewire core |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Fields¶
- Inherited:
Class Details¶
- class Wp.Core(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The core is the central object around which everything operates. It is essential to create a
Wp.Core
before using any other WirePlumber API. The core object has the following responsibilities:it initializes the PipeWire library
it creates a pw_context and allows connecting to the PipeWire server, creating a local pw_core
it glues the PipeWire library’s event loop system with
GLib.MainLoop
it maintains a list of registered objects, which other classes use to keep objects loaded permanently into memory
it watches the PipeWire registry and keeps track of remote and local objects that appear in the registry, making them accessible through the
Wp.ObjectManager
API.
The core is also responsible for loading components, which are defined in the main configuration file. Components are loaded when
Wp.CoreFeatures.COMPONENTS
is activated. The main configuration file needs to be created and opened before the core is created, using theWp.Conf
API. It is then passed to the core as an argument in the constructor. If a configuration file is not provided, the core will let the underlying pw_context load its own configuration, based on the rules that apply to all pipewire clients (e.g. it respects the PIPEWIRE_CONFIG_NAME environment variable and loads “client.conf” as a last resort). If a configuration file is provided, the core does not let the underlying pw_context load any configuration and instead uses the providedWp.Conf
object.- classmethod new(context, conf, properties)¶
- Parameters:
context (
GLib.MainContext
orNone
) – theGLib.MainContext
to use for eventsproperties (
Wp.Properties
orNone
) – additional properties, which are also passed to pw_context_new() and pw_context_connect()
- Returns:
a new
Wp.Core
- Return type:
Creates a new core object.
- clone()¶
-
Clones a core with the same context as self.
- connect()¶
-
Connects this core to the PipeWire server.
When connection succeeds, the
Wp.Core
“connected” signal is emitted.
- disconnect()¶
Disconnects this core from the PipeWire server.
This also effectively destroys all
Wp.Core
objects that were created through the registry, destroys the pw_core and finally emits theWp.Core
“disconnected” signal.
- find_object(func, *data)¶
- Parameters:
func (
GLib.EqualFunc
) – a function that takes the object being searched as the first argument and data as the second. it should returnTrue
if the object is found orFalse
otherwise
- Returns:
the registered object or
None
if not found- Return type:
Finds a registered object.
- get_conf()¶
-
Gets the main configuration file of the core.
- get_export_core()¶
-
Returns the special
Wp.Core
that is used to maintain a secondary connection to PipeWire, for exporting objects.The export core is enabled by loading the built-in “export-core” component.
- get_g_main_context()¶
- Returns:
the
GLib.MainContext
that is in use by this core for events- Return type:
Gets the
GLib.MainContext
of the core.
- get_own_bound_id()¶
- Returns:
the bound id of this client
- Return type:
Gets the bound id of the client object that is created as a result of this core being connected to the PipeWire daemon.
New in version 0.4.16.
- get_properties()¶
- Returns:
the properties of self
- Return type:
Gets the properties of the core.
- get_pw_context()¶
-
Gets the internal PipeWire context of the core.
- get_pw_core()¶
- Returns:
the internal pw_core object, or
None
if the core is not connected to PipeWire- Return type:
Gets the internal PipeWire core of the core.
- get_remote_cookie()¶
- Returns:
The cookie of the PipeWire instance that self is connected to. The cookie is a unique random number for identifying an instance of PipeWire
- Return type:
Gets the cookie of the core’s connected PipeWire instance.
- get_remote_host_name()¶
- Returns:
The name of the host where the PipeWire instance that self is connected to is running on
- Return type:
Gets the host name of the core’s connected PipeWire instance.
- get_remote_name()¶
- Returns:
The name of the PipeWire instance that self is connected to
- Return type:
Gets the name of the core’s connected PipeWire instance.
- get_remote_properties()¶
- Returns:
the properties of the PipeWire instance that self is connected to
- Return type:
Gets the properties of the core’s connected PipeWire instance.
- get_remote_user_name()¶
- Returns:
The name of the user that started the PipeWire instance that self is connected to
- Return type:
Gets the user name of the core’s connected PipeWire instance.
- get_remote_version()¶
- Returns:
The version of the PipeWire instance that self is connected to
- Return type:
Gets the version of the core’s connected PipeWire instance.
- get_vm_type()¶
- Returns:
a comma separated string with all the virtual machine types that this core matches, or
None
if the core is not running in a virtual machine.- Return type:
Gets the virtual machine type of the core.
New in version 0.4.11.
- idle_add(function, *data)¶
- Parameters:
function (
GLib.SourceFunc
) – the function to call
- Returns:
the source
- Return type:
source:
GLib.Source
Adds an idle callback to be called in the same
GLib.MainContext
as the one used by this core.This is essentially the same as
GLib.idle_add
(), but it adds the createdGLib.Source
on theGLib.MainContext
used by this core instead of the default context.
- idle_add_closure(closure)¶
- Parameters:
closure (
GObject.Closure
) – the closure to invoke- Returns:
the source
- Return type:
source:
GLib.Source
Adds an idle callback to be called in the same
GLib.MainContext
as the one used by this core.This is the same as
Wp.Core.idle_add
(), but it allows you to specify aGObject.Closure
instead of a C callback.
- install_object_manager(om)¶
- Parameters:
om (
Wp.ObjectManager
) – aWp.ObjectManager
Installs the object manager on this core, activating its internal management engine.
This will immediately emit signals about objects added on om if objects that the om is interested in were in existence already.
- is_connected()¶
-
Checks if the core is connected to PipeWire.
- load_component(component, type, args, provides, cancellable, callback, *data)¶
- Parameters:
type (
str
) – the type of the componentargs (
Wp.SpaJson
orNone
) – additional arguments for the component, expected to be a JSON objectprovides (
str
orNone
) – the name of the feature that this component will provide if it loads successfully; this can be queried later withWp.Core.test_feature
()cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
callback (
Gio.AsyncReadyCallback
orNone
) – the callback to call when the operation is done
Loads the specified component on self.
The type will determine which component loader to use. The following types are built-in and will always work without a component loader:
“module” - Loads a WirePlumber module
“array” - Loads multiple components interpreting the args as a JSON array with component definitions, as they would appear in the configuration file. When this type is used, component is ignored and can be
None
- load_component_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – the async result- Raises:
- Returns:
- Return type:
Finishes the operation started by
Wp.Core.load_component
(). This is meant to be called in the callback that was passed to that method.
- register_object(obj)¶
- Parameters:
obj (
GObject.Object
) – the object to register
Registers obj with the core, making it appear on
Wp.ObjectManager
instances as well.The core will also maintain a ref to that object until it is removed.
- remove_object(obj)¶
- Parameters:
obj (
GObject.Object
) – a pointer to the object to remove
Detaches and unrefs the specified object from this core.
- sync(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
to cancel the operationcallback (
Gio.AsyncReadyCallback
orNone
) – a function to call when the operation is done
- Returns:
True
if the sync operation was started,False
if an error occurred before returning from this function- Return type:
Asks the PipeWire server to call the callback via an event.
Since methods are handled in-order and events are delivered in-order, this can be used as a barrier to ensure all previous methods and the resulting events have been handled. In both success and error cases, callback is always called. Use
Wp.Core.sync_finish
() from within the callback to determine whether the operation completed successfully or if an error occurred.
- sync_closure(cancellable, closure)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
to cancel the operationclosure (
GObject.Closure
) – a closure to invoke when the operation is done
- Returns:
True
if the sync operation was started,False
if an error occurred before returning from this function- Return type:
Asks the PipeWire server to invoke the closure via an event.
Since methods are handled in-order and events are delivered in-order, this can be used as a barrier to ensure all previous methods and the resulting events have been handled. In both success and error cases, closure is always invoked. Use
Wp.Core.sync_finish
() from within the closure to determine whether the operation completed successfully or if an error occurred.New in version 0.4.6.
- sync_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
- Return type:
This function is meant to be called from within the callback of
Wp.Core.sync
() in order to determine the success or failure of the operation.
- test_feature(feature)¶
- Parameters:
feature (
str
) – the feature name- Returns:
- Return type:
Test if a global feature is provided.
- timeout_add(timeout_ms, function, *data)¶
- Parameters:
timeout_ms (
int
) – the timeout in millisecondsfunction (
GLib.SourceFunc
) – the function to call
- Returns:
the source
- Return type:
source:
GLib.Source
Adds a timeout callback to be called at regular intervals in the same
GLib.MainContext
as the one used by this core.The function is called repeatedly until it returns
False
, at which point the timeout is automatically destroyed and the function will not be called again. The first call to the function will be at the end of the first interval. This is essentially the same asGLib.timeout_add
(), but it adds the createdGLib.Source
on theGLib.MainContext
used by this core instead of the default context.
- timeout_add_closure(timeout_ms, closure)¶
- Parameters:
timeout_ms (
int
) – the timeout in millisecondsclosure (
GObject.Closure
) – the closure to invoke
- Returns:
the source
- Return type:
source:
GLib.Source
Adds a timeout callback to be called at regular intervals in the same
GLib.MainContext
as the one used by this core.This is the same as
Wp.Core.timeout_add
(), but it allows you to specify aGObject.Closure
instead of a C callback.
- update_properties(updates)¶
- Parameters:
updates (
Wp.Properties
) – updates to apply to the properties of self; this does not need to include properties that have not changed
Updates the properties of self on the connection, making them appear on the client object that represents this connection.
If self is not connected yet, these properties are stored and passed to pw_context_connect() when connecting.
Signal Details¶
- Wp.Core.signals.connected(core)¶
Property Details¶
- Wp.Core.props.conf¶
- Name:
conf
- Type:
- Default Value:
- Flags:
The main configuration file
- Wp.Core.props.g_main_context¶
- Name:
g-main-context
- Type:
- Default Value:
- Flags:
A
GLib.MainContext
to attach to
- Wp.Core.props.properties¶
- Name:
properties
- Type:
- Default Value:
- Flags:
Extra properties
- Wp.Core.props.pw_context¶
- Name:
pw-context
- Type:
- Default Value:
- Flags:
The pipewire context