Skip to content

Commit

Permalink
chore: bump pipewire
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Mar 17, 2024
1 parent db73e7f commit bf128ad
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 61 deletions.
79 changes: 39 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
37 changes: 18 additions & 19 deletions src/pipewirethread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -60,9 +60,9 @@ impl ScreencastThread {
}

type PipewireStreamResult = (
pipewire::MainLoop,
pipewire::main_loop::MainLoop,
pipewire::stream::StreamListener<()>,
pipewire::Context<pipewire::MainLoop>,
pipewire::context::Context,
oneshot::Receiver<anyhow::Result<u32>>,
);

Expand All @@ -74,17 +74,16 @@ fn start_stream(
output: WlOutput,
) -> Result<PipewireStreamResult, pipewire::Error> {
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?

let stream = pipewire::stream::Stream::new(
&core,
name,
pipewire::properties! {
pipewire::properties::properties! {
"media.class" => "Video/Source",
"node.name" => "wayshot-screenshot", // XXX
},
Expand All @@ -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 => {
Expand All @@ -113,7 +112,7 @@ fn start_stream(
_ => {}
}
})
.param_changed(|_, id, (), pod| {
.param_changed(|_, _, id, pod| {
if id != libspa_sys::SPA_PARAM_Format {
return;
}
Expand All @@ -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 {
Expand All @@ -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) };

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -255,17 +254,17 @@ fn format(width: u32, height: u32) -> Vec<u8> {
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,
Expand All @@ -274,7 +273,7 @@ fn format(width: u32, height: u32) -> Vec<u8> {
),
// XXX modifiers
spa::pod::property!(
spa::format::FormatProperties::VideoSize,
spa::param::format::FormatProperties::VideoSize,
Choice,
Range,
Rectangle,
Expand All @@ -283,7 +282,7 @@ fn format(width: u32, height: u32) -> Vec<u8> {
spa::utils::Rectangle { width, height }
),
spa::pod::property!(
spa::format::FormatProperties::VideoFramerate,
spa::param::format::FormatProperties::VideoFramerate,
Choice,
Range,
Fraction,
Expand Down

0 comments on commit bf128ad

Please sign in to comment.