Stream Link Manager
-
struct WpStreamLinkManager
WpStreamLinkManager is a utility class that tracks and manages WpStreamLink objects. It maintains a registry of active stream links and automatically cleans up links when their associated streams are removed.
This class provides mechanisms to create, find, and remove stream links, ensuring proper lifecycle management and preventing dangling references. It also provides the ability to enumerate peer streams (streams linked to a given stream) and to find all links associated with a stream.
The manager can also be used to discover links by their associated streams using wp_stream_link_manager_find_link(), and to enumerate related streams using wp_stream_link_manager_new_peers_iterator().
When activated with the WP_STREAM_LINK_MANAGER_FEATURE_LOADED feature, the stream link manager monitors the PipeWire graph and automatically creates corresponding WpStreamLink objects for any PipeWire links it discovers. It also tracks stream additions and removals, cleaning up obsolete links.
-
enum WpStreamLinkManagerFeatures
Flags to be used as WpObjectFeatures on WpStreamLinkManager.
Values:
-
enumerator WP_STREAM_LINK_MANAGER_FEATURE_LOADED = (1 << 0)
Loads the stream link manager
-
enumerator WP_STREAM_LINK_MANAGER_FEATURE_LOADED = (1 << 0)
-
WpStreamLinkManager *wp_stream_link_manager_new(WpCore *core, const char *name)
Constructs a new stream link manager object.
- Parameters:
core -- the core associated with the stream link manager
name -- the name of stream link manager
- Returns:
(transfer full): the new WpStreamLinkManager
-
WpStreamLinkManager *wp_stream_link_manager_find(WpCore *core, const gchar *name)
Finds a registered WpStreamLinkManager object by name.
- Parameters:
core -- the WpCore
name -- (nullable): the name of stream link manager; NULL returns the first settings object that is found.
- Returns:
(transfer full) (nullable): the WpStreamLinkManager object, or NULL if not found.
-
const gchar *wp_stream_link_manager_get_name(WpStreamLinkManager *self)
Gets the name of the stream link manager.
- Parameters:
self -- the stream link manager
- Returns:
the name of the stream link manager
-
WpStreamLink *wp_stream_link_manager_find_link(WpStreamLinkManager *self, WpStream *output, WpStream *input)
Finds the WpStreamLink for the given output and input streams.
- Parameters:
self -- the stream link manager
output -- (transfer none): the output stream
input -- (transfer none): the input stream
- Returns:
(transfer full) (nullable): the WpStreamLink for the given streams, or NULL if not found.
-
WpStreamLink *wp_stream_link_manager_create_link(WpStreamLinkManager *self, WpStream *output, WpStream *input)
Creates and registers a WpStreamLink object to link the given output stream with the given input stream.
The link has no subject stream, so wp_stream_link_manager_unlink() will not remove it. This is meant for links that already exist on the graph and are only adopted here; use wp_stream_link_manager_link() for a link that this session manager decides to make.
You need to activate the returned WpStreamLink so that both streams are linked. You can also deactivate the WpStreamLink to unlink both streams.
Note
The returned WpStreamLink will automatically be deactivated and removed from the manager if one of its streams was destroyed, so users don't really need to do anything with the returned WpStreamLink other than activating it if they want to start processing right away.
- Parameters:
self -- the stream link manager
output -- (transfer none): the output stream
input -- (transfer none): the input stream
- Returns:
(transfer full) (nullable): the WpStreamLink to link the given output stream with the given input stream, or NULL if the two streams are not of the same media type
-
WpStreamLink *wp_stream_link_manager_link(WpStreamLinkManager *self, WpStream *subject, WpStream *target)
Creates and registers a WpStreamLink object to link the given subject stream with the target stream it asked for.
Which of the two streams is the output and which is the input is decided by the direction of the subject. The subject is recorded on the link, so that wp_stream_link_manager_unlink() can tell the links a stream asked for from the links that other streams asked for on it.
You need to activate the returned WpStreamLink so that both streams are linked, as with wp_stream_link_manager_create_link().
- Parameters:
self -- the stream link manager
subject -- (transfer none): the stream that asks for the link
target -- (transfer none): the stream it wants to be linked to
- Returns:
(transfer full) (nullable): the WpStreamLink to link the two streams, or NULL if they are not of the same media type
-
void wp_stream_link_manager_remove_link(WpStreamLinkManager *self, WpStreamLink *link)
Destroys a single WpStreamLink that is not active, removing it from the manager and from the core.
This is what callers that activate a link themselves must do when the activation fails; a link left in the manager still counts as a peer of both its streams and makes them look linked.
The link must not have WP_STREAM_LINK_FEATURE_ACTIVE. An active link owns the PipeWire links it created and this method does not destroy them; use wp_stream_link_manager_unlink() to unlink an established link.
- Parameters:
self -- the stream link manager
link -- (transfer none): the stream link to destroy; must not be active
-
gboolean wp_stream_link_manager_unlink(WpStreamLinkManager *self, WpStream *stream)
Destroys the WpStreamLink objects that the given stream asked for, unlinking it from the targets it was linked to.
A stream is also part of the links that other streams asked for on it, and those are left alone: they are the other streams' to undo. Links that were adopted from the graph have no subject and are left alone as well.
- Parameters:
self -- the stream link manager
stream -- (transfer none): the stream to be unlinked
- Returns:
TRUE if the stream had links to remove, FALSE otherwise
-
guint wp_stream_link_manager_get_peers_count(WpStreamLinkManager *self, WpStream *stream)
Gets the total number of peer streams the given stream has.
- Parameters:
self -- the stream link manager
stream -- (transfer none): the stream
- Returns:
The total number of peer streams the given stream has
-
WpIterator *wp_stream_link_manager_new_peers_iterator(WpStreamLinkManager *self, WpStream *stream)
Iterates through all the peer streams the given stream has.
- Parameters:
self -- the stream link manager
stream -- (transfer none): the stream
- Returns:
(transfer full): a WpIterator that iterates over all the peer streams the given stream has.
-
WpIterator *wp_stream_link_manager_new_links_iterator(WpStreamLinkManager *self, WpStream *stream)
Iterates through all the stream links the given stream belongs to.
- Parameters:
self -- the stream link manager
stream -- (transfer none): the stream
- Returns:
(transfer full): a WpIterator that iterates over all the stream links the given stream belongs to.
-
WP_TYPE_STREAM_LINK_MANAGER (wp_stream_link_manager_get_type ())
The WpStreamLinkManager GType.