Package: x2webrtc
x2webrtcx2webrtc is a command-line tool for forwarding an X window as a media track through WebRTC.
It is a simple tool; it just grabs screenshots for the window with Xlib and send them via a WebRTC stream, but it can realize the following features:You can send an X window through the NAT.A media stream is transported using a secure method. (compared to the standard VNC)You can easily install it by pip.You don't necessarily have admin access to the system.InstallNote that Python 3.6+ and X Window System are required to use the tool.pipinstallx2webrtcThe tool requiresaiortcto work with WebRTC.
Please refer tothe install instructionofaiortcif you failed to install it automatically.QuickstartNOTE:
Currently, hand signaling is required to start a WebRTC session.
I am planning to implement a plug-in system so that a user can customize its signaling method.Start x2webrtc.x2webrtcforwardIfDISPLAYenvironment is not set to your environment, pass--displayargument to specify an X server.x2webrtcforward--display:0(tentative) Copy a WebRTC offer.
You will see the following message on your terminal:--Pleasesendthismessagetotheremoteparty--{"sdp":"...","type":"offer"}Please copy the offer json.(tentative) Openthe web viewerand clickConnectbutton.(tentative) Paste the offer json intoInput Offertext-area (A) and clickCreate Answerbutton (B). Then you will get an answer json (C). Copy the json again.(tentative) Go back to your terminal. Paste the answer json into the terminal, then press Enter.Now you will see your screen in the web viewer.Usageusage:x2webrtc[-h][-v]COMMANDS...

Commands:forwardforwardXWindowinfoshowwindowinformationoftheXserver

optionalarguments:-h,--helpshowthishelpmessageandexit-v,--verboseverbose;canbeusedupto3timestoincreaseverbosityx2webrtc forwardForward a specified X window.usage:x2webrtcforward[-h][--displayDISPLAY]optionalarguments:-h,--helpshowthishelpmessageandexit--displayDISPLAYdisplay_nameoftheXservertoconnectto(e.g.,hostname:1,:1.)x2webrtc infoShow information on a specified X server.usage:x2webrtcinfo[-h][--displayDISPLAY][--props]optionalarguments:-h,--helpshowthishelpmessageandexit--displayDISPLAYdisplay_nameoftheXservertoconnectto(e.g.,hostname:1,:1.)--propsshowallpropertiesofeachwindowConfigurationThe order of preference is the$X2WEBRTC_CONFIGenvironment variable, then.x2webrtcfile of the working directory, and then~/.x2webrtc.
The config file must be in the YAML format.
Here is an example of a configuration file:signaling_plugin:"path/to/signaling_plugin.py"# optionalpeer_connection:# optionalice_servers:-url:stun:stun.example.com-url:turn:turn.example.comusername:shamiko# optionalcredential:momo# optionalFor more details, please refer tox2webrtc/config.py.PluginYou can customize the signaling method that x2webrtc uses for a WebRTC peer connection by using a plugin.
Here is an example of a plugin implementation:fromtypingimportTypefromaiortcimportRTCPeerConnectionfromx2webrtc.pluginimportSignalingPluginclassSomePlugin(SignalingPlugin):asyncdef__call__(self,pc:RTCPeerConnection)->bool:returnTruedefplugin()->Type[SignalingPlugin]:returnSomePluginA plugin file must have apluginfunction that returns a subclass ofSignalingPlugin.
The plugin file is required to specify in a configuration file, as already mentioned in the Configuration section.For more details, please refer toCopyAndPasteSignalingclass located inx2webrtc/signaling.py.FAQFailed to install PyAVPyAVusesAV_CODEC_CAP_HARDWAREmacro in its source code, but it seems to be available inlibavcodec >= 58.0. Check the version of libavcodec and try again.