Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions src/capturer/engine/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
mpsc::{self, sync_channel, SyncSender},
},
thread::JoinHandle,
time::Duration,
time::{Duration, SystemTime},
};

use pipewire as pw;
Expand All @@ -31,7 +31,7 @@ use pw::{

use crate::{
capturer::Options,
frame::{BGRxFrame, Frame, RGBFrame, RGBxFrame, XBGRFrame},
frame::{BGRxFrame, Frame, RGBFrame, RGBxFrame, VideoFrame, XBGRFrame},
};

use self::{error::LinCapError, portal::ScreenCastPortal};
Expand Down Expand Up @@ -119,6 +119,7 @@ fn process_callback(stream: &StreamRef, user_data: &mut ListenerUserData) {
break 'outside;
}
let timestamp = unsafe { get_timestamp(buffer) };
let system_time = SystemTime::now();

let n_datas = unsafe { (*buffer).n_datas };
if n_datas < 1 {
Expand All @@ -134,30 +135,30 @@ fn process_callback(stream: &StreamRef, user_data: &mut ListenerUserData) {
};

if let Err(e) = match user_data.format.format() {
VideoFormat::RGBx => user_data.tx.send(Frame::RGBx(RGBxFrame {
display_time: timestamp as u64,
VideoFormat::RGBx => user_data.tx.send(Frame::Video(VideoFrame::RGBx(RGBxFrame {
display_time: system_time,
width: frame_size.width as i32,
height: frame_size.height as i32,
data: frame_data,
})),
VideoFormat::RGB => user_data.tx.send(Frame::RGB(RGBFrame {
display_time: timestamp as u64,
}))),
VideoFormat::RGB => user_data.tx.send(Frame::Video(VideoFrame::RGB(RGBFrame {
display_time: system_time,
width: frame_size.width as i32,
height: frame_size.height as i32,
data: frame_data,
})),
VideoFormat::xBGR => user_data.tx.send(Frame::XBGR(XBGRFrame {
display_time: timestamp as u64,
}))),
VideoFormat::xBGR => user_data.tx.send(Frame::Video(VideoFrame::XBGR(XBGRFrame {
display_time: system_time,
width: frame_size.width as i32,
height: frame_size.height as i32,
data: frame_data,
})),
VideoFormat::BGRx => user_data.tx.send(Frame::BGRx(BGRxFrame {
display_time: timestamp as u64,
}))),
VideoFormat::BGRx => user_data.tx.send(Frame::Video(VideoFrame::BGRx(BGRxFrame {
display_time: system_time,
width: frame_size.width as i32,
height: frame_size.height as i32,
data: frame_data,
})),
}))),
_ => panic!("Unsupported frame format received"),
} {
eprintln!("{e}");
Expand Down
2 changes: 1 addition & 1 deletion src/capturer/engine/win/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl GraphicsCaptureApiHandler for Capturer {
frame: &mut WCFrame,
_: InternalCaptureControl,
) -> Result<(), Self::Error> {
let elapsed = frame.timespan().Duration - self.start_time.0;
let elapsed = frame.timestamp().Duration - self.start_time.0;
let display_time = self
.start_time
.1
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod targets;
mod utils;

// Helper Methods
pub use targets::{get_all_targets, get_main_display};
pub use targets::{get_all_targets, get_main_display, get_target_dimensions};
pub use targets::{Display, Target};
pub use utils::has_permission;
pub use utils::is_supported;
Expand Down