Struct pipewire_wrapper::core_api::registry::RegistryRef
source · #[repr(transparent)]pub struct RegistryRef { /* private fields */ }
Expand description
Wrapper for the external pw_sys::pw_registry proxy.
The registry object is a singleton object that keeps track of global objects on the PipeWire instance. When a client creates a registry object, the registry object will emit a global event for each global currently in the registry. Globals come and go as a result of device hotplugs or reconfiguration or other events, and the registry will send out global and global_remove events to keep the client up to date with the changes. To mark the end of the initial burst of events, the client can use the pw_core.sync method immediately after calling pw_core.get_registry.
A client can bind to a global object by using the bind request. This creates a client-side proxy that lets the object emit events to the client and lets the client invoke methods on the object.
Examples
use std::sync::Arc;
use pipewire_wrapper::core_api::core::Core;
use pipewire_wrapper::core_api::device::DeviceRef;
use pipewire_wrapper::core_api::registry::events::RegistryEventsBuilder;
use pipewire_wrapper::listeners::OwnListeners;
use std::time::Duration;
let core = Core::default();
let context = core.context();
let main_loop = context.main_loop();
let registry = core.get_registry(0).unwrap();
let _registry_events = registry.add_listener(
RegistryEventsBuilder::default()
.global(Box::new(
|_id, permissions, type_info, version, properties| {
println!(
"Global {:?} {:?} {:?} {:?}",
permissions, type_info, version, properties
);
},
))
.build(),
);
let timer_callback = |_| {
core.context().main_loop().quit().unwrap();
};
let timer = main_loop
.get_loop()
.add_timer(Box::new(timer_callback))
.unwrap();
main_loop
.get_loop()
.update_timer(&timer, Duration::from_secs(1), Duration::ZERO, false)
.unwrap();
main_loop.run().unwrap();