-
-
Notifications
You must be signed in to change notification settings - Fork 69
fix: Add handling for missing VideoFormat on Linux #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/capturer/engine/linux/mod.rs
Outdated
let offset = unsafe { (*(*(*buffer).datas).chunk).offset as u64 }; | ||
let raw_fd = unsafe { (*(*buffer).datas).fd as RawFd }; | ||
let mmap_ptr = unsafe { | ||
mmap( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not safe for dmabuf, see the "DMA-BUF Mapping Warning" section in the PipeWire docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issues with tiling and compression can be addressed by requesting PipeWire to provide a linear modifier for the DMA-BUF. Synchronization is also handled by invoking the DMA_BUF_IOCTL_SYNC
ioctl before and after any CPU access to the buffer. However, the problem of accessing the DMA-BUF being extremely slow remains unresolved as I am not familiar with the graphics APIs necessary to handle this efficiently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced this is the way to go about handling dmabufs for two reasons:
- The current implementation should work (there may be bugs causing it to not work + the missing handling of RGBA and MemFd that you kindly fixed in this PR) because the video source node should never give dmabufs when no modifiers is set. The only portal implementation I've tested with that doesn't respect this was cosmic's. Our
param_changed
callback might not handle params correctly, I'll take a look at it. scap
's frame types only store data inVec<u8>
, so any dmabuf handling would basically just do the same that the portal would do for SHM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely correct. My current implementation will work if you are using COSMIC DE
, but it will not guarantee working in all cases due to factors beyond our control (notably, if the portal does not respect the requested parameters from scap
)
I am using COSMIC DE, which uses VideoFormat::RGBA instead of VideoFormat::BGRx like GNOME or KDE, so it leads to a panic "Unsupported frame format received".
In the current code, VideoFormat::RGBA is included in the list of output formats for the buffer
scap/src/capturer/engine/linux/mod.rs
Lines 213 to 222 in 92cabc5
but the case where VideoFormat is VideoFormat::RGBA is not handled
scap/src/capturer/engine/linux/mod.rs
Lines 136 to 164 in 92cabc5
This PR will fix it.