node-x11 icon indicating copy to clipboard operation
node-x11 copied to clipboard

Is there share memory functions to get display canvas data like xcb_shm?

Open guodong opened this issue 9 years ago • 16 comments

Is there share memory functions to get display canvas data like xcb_shm?

guodong avatar Aug 23 '15 06:08 guodong

no, shm extensions is not implemnted yet. It's relatively straightforward at protocol level, but I need to check what is the status of shm addons for node

sidorares avatar Aug 23 '15 09:08 sidorares

https://www.npmjs.com/browse/keyword/shm

sidorares avatar Aug 23 '15 09:08 sidorares

http://www.x.org/releases/X11R7.7/doc/xextproto/shm.txt

sidorares avatar Aug 23 '15 09:08 sidorares

DRI might be more useful - it serves similar purpose: you ask server to allocate region of video memory for you and then write to it directly bypassing server and serialisation ( similar to shm works only locally of course ) - also on my TODO list - http://www.x.org/releases/X11R7.7/doc/dri2proto/dri2proto.txt

sidorares avatar Aug 23 '15 09:08 sidorares

Thanks for your reply, and I will check DRI and node shm later. In my application, I must get display flow with low latency, and send it to another process to compress and publish. I think I could add some code to Xorg to implement mmap file to work with node, this may be a just passable way.

guodong avatar Aug 24 '15 03:08 guodong

what are you displaying? One easy option would be to wrap external application, see example in https://github.com/sidorares/node-x11/blob/master/examples/simple/embed.js For example you can embed mplayer via -wid [parent id] command line parameter and stream some dynamic data to it

sidorares avatar Aug 24 '15 03:08 sidorares

I want to render x11 window to a client browser, just like x11 architecture but use browser as xserver, but not total same as x11 arch, let me use a picture to explain. image In one word, I want to make a software which uses browser as display and uses browser tab as window manager to run remote software. I need to send mouse and keyboard event to app server and the proxy is writen by node(in order to fit with socket.io in websocket server). Now the xserver changed bitmap is send by another domain sock to proxy, and proxy compress it and send it to websocket server. In this issue, I think if node-x11 has shm functions, there is no need to use another domain socket and reduce the complexity of it. I am a totally newbie of x11 and node, and say sorry if my question is naive in this area. So do you have any advices or suggestions on it?

guodong avatar Aug 24 '15 08:08 guodong

similar to https://github.com/ttaubert/x-server-js or https://github.com/GothAck/javascript-x-server ?

sidorares avatar Aug 24 '15 10:08 sidorares

not sure how shm could help you as you going to serialise communication over websockets

sidorares avatar Aug 24 '15 10:08 sidorares

Thank you, I have already studied the 2 projects above, the difference is that I use original xorg as xserver, but not rewrite a new xserver in js, so I need to get rendered bitmap from xorg, Currently, I use xcb functions to get image from shm, but it must be copied to proxy. So I am looking for ways to get image directlly in proxy.

guodong avatar Aug 24 '15 11:08 guodong

so it's more like RDP or VNC viewer in the browser?

sidorares avatar Aug 24 '15 11:08 sidorares

Yes, just like VNC, but only render one application window nor the desktop.

guodong avatar Aug 24 '15 11:08 guodong

"-id windowid" in http://www.karlrunge.com/x11vnc/x11vnc_opts.html

sidorares avatar Aug 24 '15 11:08 sidorares

really helpful! I'll look into it, thanks again!

guodong avatar Aug 24 '15 12:08 guodong

Sounds like VNC may be the best option for you, but I've had to solve a similar problem and looked a bit into Crouton, which is the project for ChromeOS that lets you run X11. It packs up X11 to run over a websocket. Unfortunately the code for it is very ChromeOS-specific, but it may be something to look into.

polpo avatar Aug 24 '15 17:08 polpo

@polpo very interesting

sidorares avatar Aug 24 '15 22:08 sidorares