diff --git a/Cargo.lock b/Cargo.lock index 6628861..68da0e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -185,6 +185,16 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" +[[package]] +name = "annotate-snippets" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccaf7e9dfbb6ab22c82e473cd1a8a7bd313c19a5b7e40970f3d89ef5a5c9e81e" +dependencies = [ + "unicode-width", + "yansi-term", +] + [[package]] name = "anyhow" version = "1.0.80" @@ -503,32 +513,13 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "bindgen" -version = "0.66.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" -dependencies = [ - "bitflags 2.4.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.52", -] - [[package]] name = "bindgen" version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ + "annotate-snippets", "bitflags 2.4.2", "cexpr", "clang-sys", @@ -2582,9 +2573,9 @@ dependencies = [ [[package]] name = "libspa" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0434617020ddca18b86067912970c55410ca654cdafd775480322f50b857a8c4" +checksum = "65f3a4b81b2a2d8c7f300643676202debd1b7c929dbf5c9bb89402ea11d19810" dependencies = [ "bitflags 2.4.2", "cc", @@ -2592,18 +2583,18 @@ dependencies = [ "cookie-factory", "libc", "libspa-sys", - "nix 0.26.4", + "nix 0.27.1", "nom", "system-deps", ] [[package]] name = "libspa-sys" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e70ca3f3e70f858ef363046d06178c427b4e0b63d210c95fd87d752679d345" +checksum = "bf0d9716420364790e85cbb9d3ac2c950bde16a7dd36f3209b7dfdfc4a24d01f" dependencies = [ - "bindgen 0.66.1", + "bindgen", "cc", "system-deps", ] @@ -2876,7 +2867,6 @@ dependencies = [ "cfg-if", "libc", "memoffset 0.7.1", - "pin-utils", ] [[package]] @@ -3199,12 +3189,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "percent-encoding" version = "2.3.1" @@ -3310,16 +3294,16 @@ dependencies = [ [[package]] name = "pipewire" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d009c8dd65e890b515a71950f7e4c801523b8894ff33863a40830bf762e9e9" +checksum = "08e645ba5c45109106d56610b3ee60eb13a6f2beb8b74f8dc8186cf261788dda" dependencies = [ "anyhow", "bitflags 2.4.2", "libc", "libspa", "libspa-sys", - "nix 0.26.4", + "nix 0.27.1", "once_cell", "pipewire-sys", "thiserror", @@ -3327,11 +3311,11 @@ dependencies = [ [[package]] name = "pipewire-sys" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "890c084e7b737246cb4799c86b71a0e4da536031ff7473dd639eba9f95039f64" +checksum = "849e188f90b1dda88fe2bfe1ad31fe5f158af2c98f80fb5d13726c44f3f01112" dependencies = [ - "bindgen 0.66.1", + "bindgen", "libspa-sys", "system-deps", ] @@ -3919,7 +3903,7 @@ version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bc61a106126a429bb4775ce5fbe23b2bcaa74d1a9c484997f4700de31480b44" dependencies = [ - "bindgen 0.69.4", + "bindgen", "cc", "flate2", "heck", @@ -4598,6 +4582,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -5505,6 +5495,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" +[[package]] +name = "yansi-term" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" +dependencies = [ + "winapi", +] + [[package]] name = "zbus" version = "3.15.1" diff --git a/Cargo.toml b/Cargo.toml index 7fb92c9..8768a2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,8 @@ once_cell = "1.19.0" anyhow = "1.0.80" # pipewire -pipewire = "0.7.2" -libspa-sys = "0.7.2" +pipewire = "0.8.0" +libspa-sys = "0.8.0" libwayshot = { version = "0.3.0" } rustix = { version = "0.38.31", features = ["fs", "use-libc"] } diff --git a/src/pipewirethread.rs b/src/pipewirethread.rs index 84f9f5f..2feb5ad 100644 --- a/src/pipewirethread.rs +++ b/src/pipewirethread.rs @@ -33,7 +33,7 @@ impl ScreencastThread { Ok((loop_, listener, context, node_id_rx)) => { tx.send(Ok(node_id_rx)).unwrap(); let weak_loop = loop_.downgrade(); - let _receiver = thread_stop_rx.attach(&loop_, move |()| { + let _receiver = thread_stop_rx.attach(loop_.loop_(), move |()| { weak_loop.upgrade().unwrap().quit(); }); loop_.run(); @@ -60,9 +60,9 @@ impl ScreencastThread { } type PipewireStreamResult = ( - pipewire::MainLoop, + pipewire::main_loop::MainLoop, pipewire::stream::StreamListener<()>, - pipewire::Context, + pipewire::context::Context, oneshot::Receiver>, ); @@ -74,9 +74,8 @@ fn start_stream( output: WlOutput, ) -> Result { let connection = libwayshot::WayshotConnection::new().unwrap(); - - let loop_ = pipewire::MainLoop::new()?; - let context = pipewire::Context::new(&loop_).unwrap(); + let loop_ = pipewire::main_loop::MainLoop::new(None).unwrap(); + let context = pipewire::context::Context::new(&loop_).unwrap(); let core = context.connect(None).unwrap(); let name = "wayshot-screenshot"; // XXX randomize? @@ -84,7 +83,7 @@ fn start_stream( let stream = pipewire::stream::Stream::new( &core, name, - pipewire::properties! { + pipewire::properties::properties! { "media.class" => "Video/Source", "node.name" => "wayshot-screenshot", // XXX }, @@ -97,7 +96,7 @@ fn start_stream( let listener = stream .add_local_listener_with_user_data(()) - .state_changed(move |old, new| { + .state_changed(move |_, _, old, new| { tracing::info!("state-changed '{:?}' -> '{:?}'", old, new); match new { StreamState::Paused => { @@ -113,7 +112,7 @@ fn start_stream( _ => {} } }) - .param_changed(|_, id, (), pod| { + .param_changed(|_, _, id, pod| { if id != libspa_sys::SPA_PARAM_Format { return; } @@ -122,7 +121,7 @@ fn start_stream( tracing::info!("param-changed: {} {:?}", id, value); } }) - .add_buffer(move |buffer| { + .add_buffer(move |_, _, buffer| { let buf = unsafe { &mut *(*buffer).buffer }; let datas = unsafe { slice::from_raw_parts_mut(buf.datas, buf.n_datas as usize) }; for data in datas { @@ -144,7 +143,7 @@ fn start_stream( chunk.stride = 4 * width as i32; } }) - .remove_buffer(|buffer| { + .remove_buffer(|_, _, buffer| { let buf = unsafe { &mut *(*buffer).buffer }; let datas = unsafe { slice::from_raw_parts_mut(buf.datas, buf.n_datas as usize) }; @@ -174,7 +173,7 @@ fn start_stream( ]; let flags = pipewire::stream::StreamFlags::ALLOC_BUFFERS; - stream.connect(spa::Direction::Output, None, flags, params)?; + stream.connect(pipewire::spa::utils::Direction::Output, None, flags, params)?; *stream_cell.borrow_mut() = Some(stream); @@ -255,17 +254,17 @@ fn format(width: u32, height: u32) -> Vec { spa::utils::SpaTypes::ObjectParamFormat, spa::param::ParamType::EnumFormat, spa::pod::property!( - spa::format::FormatProperties::MediaType, + spa::param::format::FormatProperties::MediaType, Id, - spa::format::MediaType::Video + spa::param::format::MediaType::Video ), spa::pod::property!( - spa::format::FormatProperties::MediaSubtype, + spa::param::format::FormatProperties::MediaSubtype, Id, - spa::format::MediaSubtype::Raw + spa::param::format::MediaSubtype::Raw ), spa::pod::property!( - spa::format::FormatProperties::VideoFormat, + spa::param::format::FormatProperties::VideoFormat, Choice, Enum, Id, @@ -274,7 +273,7 @@ fn format(width: u32, height: u32) -> Vec { ), // XXX modifiers spa::pod::property!( - spa::format::FormatProperties::VideoSize, + spa::param::format::FormatProperties::VideoSize, Choice, Range, Rectangle, @@ -283,7 +282,7 @@ fn format(width: u32, height: u32) -> Vec { spa::utils::Rectangle { width, height } ), spa::pod::property!( - spa::format::FormatProperties::VideoFramerate, + spa::param::format::FormatProperties::VideoFramerate, Choice, Range, Fraction,