Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/polymeilex/ripewire
PipeWire client liblary in idiomatic Rust
https://github.com/polymeilex/ripewire
Last synced: 1 day ago
JSON representation
PipeWire client liblary in idiomatic Rust
- Host: GitHub
- URL: https://github.com/polymeilex/ripewire
- Owner: PolyMeilex
- License: mit
- Created: 2023-04-30T21:13:06.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-09T23:15:53.000Z (13 days ago)
- Last Synced: 2024-12-18T06:34:33.632Z (4 days ago)
- Language: Rust
- Size: 404 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RipeWire
PipeWire client library in idiomatic Rust
## WIP...
Real proof of concept: [helvum ported to RipeWire](https://github.com/PolyMeilex/helvum-ripewire)
And simpler example (definitely not final API):
```rs
#[derive(Default)]
struct State {
globals: GlobalList,
}impl State {
pub fn core_event(
&mut self,
context: &mut Context,
core: PwCore,
event: pw_core::Event,
) {
match event {
pw_core::Event::Done(done) => {
if done.id == 0 && done.seq == 0 {
// Let's print globals advertised by the registry
dbg!(&self.globals)
}
}
_ => {}
}
}pub fn registry_event(
&mut self,
context: &mut Context,
registry: PwRegistry,
event: pw_registry::Event,
) {
self.globals.handle_event(&event);
}
}let mut ctx = Context::connect("/run/user/1000/pipewire-0").unwrap();
let core = ctx.core();
let client = ctx.client();core.hello(&mut ctx);
client.update_properties(
&mut ctx,
Dictionary::from([
("application.name", "RipeWire"),
("application.process.binary", "ripewire"),
]),
);let registry = core.get_registry(&mut ctx);
core.sync(&mut ctx, 0, 0);
ctx.set_object_callback(&core, State::core_event);
ctx.set_object_callback(®istry, State::registry_event);ctx.set_object_callback(&client, |state, client, event| {
println!("You can use closures as well: {:?}", event);
});let mut state = State::default();
loop { // any event loop or async runtime of your choice
let (messages, fds) = ctx.rcv_msg();for msg in messages {
ctx.dispatch_event(&mut state, msg, &fds);
}
}
```