Wp.Core

g GObject.Object GObject.Object Wp.Object Wp.Object GObject.Object->Wp.Object Wp.Core Wp.Core Wp.Object->Wp.Core

Subclasses:

None

Methods

Inherited:

Wp.Object (12), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (context, conf, properties)

clone ()

connect ()

disconnect ()

find_object (func, *data)

get_conf ()

get_export_core ()

get_g_main_context ()

get_own_bound_id ()

get_properties ()

get_pw_context ()

get_pw_core ()

get_remote_cookie ()

get_remote_host_name ()

get_remote_name ()

get_remote_properties ()

get_remote_user_name ()

get_remote_version ()

get_vm_type ()

idle_add (function, *data)

idle_add_closure (closure)

install_object_manager (om)

is_connected ()

load_component (component, type, args, provides, cancellable, callback, *data)

load_component_finish (res)

register_object (obj)

remove_object (obj)

sync (cancellable, callback, *user_data)

sync_closure (cancellable, closure)

sync_finish (res)

test_feature (feature)

timeout_add (timeout_ms, function, *data)

timeout_add_closure (timeout_ms, closure)

update_properties (updates)

Virtual Methods

Inherited:

Wp.Object (4), GObject.Object (7)

Properties

Inherited:

Wp.Object (4)

Name

Type

Flags

Short Description

conf

Wp.Conf

r/w/co

The main configuration file

g-main-context

GLib.MainContext

r/w/co

A GLib.MainContext to attach to

properties

Wp.Properties

r/w/co

Extra properties

pw-context

int

r/w/co

The pipewire context

pw-core

int

r

The pipewire core

Signals

Inherited:

GObject.Object (1)

Name

Short Description

connected

disconnected

Fields

Inherited:

GObject.Object (1)

Class Details

class Wp.Core(**kwargs)
Bases:

Wp.Object

Abstract:

No

Structure:

Wp.CoreClass

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 the Wp.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 provided Wp.Conf object.

classmethod new(context, conf, properties)
Parameters:
Returns:

a new Wp.Core

Return type:

Wp.Core

Creates a new core object.

clone()
Returns:

the clone Wp.Core

Return type:

Wp.Core

Clones a core with the same context as self.

connect()
Returns:

True if the core is effectively connected or False if connection failed

Return type:

bool

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 the Wp.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 return True if the object is found or False otherwise

  • data (object or None) – the second argument to func

Returns:

the registered object or None if not found

Return type:

GObject.Object or None

Finds a registered object.

get_conf()
Returns:

the main configuration file

Return type:

Wp.Conf or None

Gets the main configuration file of the core.

get_export_core()
Returns:

the export Wp.Core

Return type:

Wp.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:

GLib.MainContext or None

Gets the GLib.MainContext of the core.

get_own_bound_id()
Returns:

the bound id of this client

Return type:

int

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:

Wp.Properties

Gets the properties of the core.

get_pw_context()
Returns:

the internal pw_context object

Return type:

object or None

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:

object or None

Gets the internal PipeWire core of the core.

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:

int

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:

str

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:

str

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:

Wp.Properties

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:

str

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:

str

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:

str or None

Gets the virtual machine type of the core.

New in version 0.4.11.

idle_add(function, *data)
Parameters:
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 created GLib.Source on the GLib.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 a GObject.Closure instead of a C callback.

install_object_manager(om)
Parameters:

om (Wp.ObjectManager) – a Wp.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()
Returns:

True if the core is connected to PipeWire, False otherwise

Return type:

bool

Checks if the core is connected to PipeWire.

load_component(component, type, args, provides, cancellable, callback, *data)
Parameters:

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:

GLib.Error

Returns:

True if the requested component was loaded, False otherwise

Return type:

bool

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:
Returns:

True if the sync operation was started, False if an error occurred before returning from this function

Return type:

bool

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:
Returns:

True if the sync operation was started, False if an error occurred before returning from this function

Return type:

bool

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) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if the operation succeeded, False otherwise

Return type:

bool

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:

True if the feature is provided, False otherwise

Return type:

bool

Test if a global feature is provided.

timeout_add(timeout_ms, function, *data)
Parameters:
  • timeout_ms (int) – the timeout in milliseconds

  • function (GLib.SourceFunc) – the function to call

  • data (object or None) – data to pass to function

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 as GLib.timeout_add(), but it adds the created GLib.Source on the GLib.MainContext used by this core instead of the default context.

timeout_add_closure(timeout_ms, closure)
Parameters:
  • timeout_ms (int) – the timeout in milliseconds

  • closure (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 a GObject.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)
Signal Name:

connected

Flags:

RUN_LAST

Parameters:

core (Wp.Core) – The object which received the signal

Wp.Core.signals.disconnected(core)
Signal Name:

disconnected

Flags:

RUN_LAST

Parameters:

core (Wp.Core) – The object which received the signal

Property Details

Wp.Core.props.conf
Name:

conf

Type:

Wp.Conf

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The main configuration file

Wp.Core.props.g_main_context
Name:

g-main-context

Type:

GLib.MainContext

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

A GLib.MainContext to attach to

Wp.Core.props.properties
Name:

properties

Type:

Wp.Properties

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Extra properties

Wp.Core.props.pw_context
Name:

pw-context

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The pipewire context

Wp.Core.props.pw_core
Name:

pw-core

Type:

int

Default Value:

None

Flags:

READABLE

The pipewire core