#Capturing Screen with x11rb and using XShm protocol.
37 messages · Page 1 of 1 (latest)
no hence why I built the library
which library please?
this
I'm not quite sure how to do this using that crate, when I look at https://github.com/jknightmmcs/ScreenCaptureLib/blob/fc38e4b90a837df2a089e56c66c9f41a51837a7d/src/ScreenCaptureLib/grabber_backends/xshmgrabber.cpp#L162 they use shmget function which I think is the https://docs.rs/nix/latest/nix/sys/mman/fn.shm_open.html function?
and it seems I need to get the shmid via that function probably and use it with this https://docs.rs/x11rb/latest/x11rb/protocol/shm/fn.attach.html
API documentation for the Rust attach fn in crate x11rb.
ohh libc has those functions
Doesn't x11rb have a capture example?
sadly no, they have a shared memory example but they don't use XShmGetImage there they use the normal XGetImage function
right now I'm able to attach and everything, I used shm functions from libc and they work fine as well, but now I've no idea how I can proceed and get the image
X11Error { error_kind: Value, error_code: 2, sequence: 7, bad_value: 0, minor_opcode: 4, major_opcode: 130, extension_name: Some("MIT-SHM"), request_name: Some("GetImage") })
this is the error that I'm getting right now
memmap2 crate can help with managing access to shm
I think nix provides some utilities for mmap also
I can't seem to find the mit-shm documentation, but the xorg proto repository may be useful: https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/tree/master/
not useful libc works just fine
the issue is that x11rb crate is very rustified in terms of syntax and doesn't correspond 1:1 with the xcb library it seems, the XShmGetImage function for example doesn't have the same parameters as the one provided in the x11rb library
and that makes it hard for me to understand exactly what I need to do, since I can't just copy paste C code structure into rust code and I'm not acquainted with x11 development
I've opened an issue https://github.com/psychon/x11rb/issues/736
to ask the author for insight, there's the source code there as well
Curious cause I did something similar, what does x11rb do for you versus other methods?
you can checkout my screen capturing library at https://github.com/Selyatin/captis and see the current linux implementation there
the thing is right now it's working perfectly fine, it's just that the performance is very shitty (still good enough for most cases) and I wanna try doing it the fast way
by using shared memory
I'm sure you ran across the thing called scrap, and a few other similar, why did you make this one? What's different?
I do need to use this but I need it to be realtime
How does rustdesk do it?
oh shit forgot about rustdesk, thanks I'll check it out
none of them are 100% cross-platform and decent and up-to-date
the las time scrap was updated was in 2018
and I haven't seen any libraries use the XShm protocol on linux
they all use the standard protocol
I'll take a look at rustdesk after eating my 🍕 and update the post
@vernal axle it seems it has a fork of scrap
but I can't even compile it on my machine, the build file generates bindings it seems and shit gets messy
and they just use ffi bindings, I might just go for that as well if x11rb doesn't support what I'm trying to do
issue is fixed, updates and full implementation can be found at https://github.com/Selyatin/captis