Module wireplumber::registry

source ·
Expand description

Remote object change notifications

When combined with a Core, an ObjectManager emits signals whenever objects change on the remote service if they match any filters specified by the registered Interest’s Constraints.

Example

use futures_util::StreamExt;
use wireplumber::{
  prelude::*,
  registry::{ObjectManager, Interest, Constraint, ConstraintType},
  core::{Core, Object, ObjectFeatures},
  pw::Node,
};

async fn watch_nodes(core: &Core) {
  let om = ObjectManager::new();
  om.add_interest([
    Constraint::compare(ConstraintType::PwProperty, "media.class", "Audio/Sink", true),
  ].iter().collect::<Interest<Node>>());

  let mut objects = om.signal_stream(ObjectManager::SIGNAL_OBJECT_ADDED);

  om.request_object_features(Object::static_type(), ObjectFeatures::ALL);
  core.install_object_manager(&om);

  while let Some((obj,)) = objects.next().await {
    let node = obj.dynamic_cast_ref::<Node>()
      .expect("we're only interested in nodes");
    println!("new object: {node:?}");
  }
}

See also

C API docs for:

Structs

Enums

Traits