jsmpeg SDL Video Driver
Not logged in

jsmpeg SDL Video Driver

An experimental SDL video driver named jsmpeg is provided since Valentine's Day 2019. It uses the technique described in https://github.com/phoboslab/jsmpeg and https://github.com/phoboslab/jsmpeg-vnc in combination with HTML5 and WebGL in a modern browser to provide display, mouse, and keyboard to a normal undroidwish.

This means, that the rendering is performed into a memory buffer, which is encoded into a modified MPEG-1 transport stream, sent over a Websocket to a web browser, which performs MPEG-1 decoding and rendering into a HTML5 canvas optionally using WebGL. Likewise, mouse and keyboard events are sent on the same Websocket from the browser back to the jsmpeg driver, transformed to SDL mouse and keyboard events and further processed by the undroidwish application.

Frame rate and required bandwidth are moderate. Currently, 25 frames per seconds are sent at most, which require some few hundred kilobits per second. Since April 2019 limited support for OpenGL is available for the Canvas3D and tkZinc widgets. It requires a working EGL/OpenGL infrastructure (Linux etc.) or Windows OpenGL.

For the adventurous, there is a test version for Linux x86_64 (Debian 9, Fedora 29, maybe CentOS 7), Windows (XP or newer, 32 bit), and MacOSX (tested on High Sierra). All can be run using the jsmpeg video driver when the environment variable SDL_VIDEODRIVER has the value jsmpeg and the required FFMpeg DLLs/shared libraries are available on the system, e.g.

    # POSIX
    SDL_VIDEODRIVER=jsmpeg ./undroidwish-x86_64-deb9 builtin:widget -sdlwidth 800 -sdlheight 600
    REM Windows
    SET SDL_VIDEODRIVER=jsmpeg
    undroidwish-win32.exe builtin:widget -sdlwidth 800 -sdlheight 600

For Windows, the required DLLs are avutil-56.dll, avcodec-58.dll, swresample-3.dll, and swscale-5.dll which are available from https://www.ffmpeg.org/download.html and preferably loaded from %PROGRAMFILES%\ffmpeg\bin. For Linux, the shared libraries are available per installing the distribution's ffmpeg package(s). For MacOSX, the homebrew ffmpeg package provides the necessary shared libraries.

By default, the HTTP/Websockets port is 8080 which can be overridden with the environment variable SDL_VIDEO_JSMPEG_PORT. Thus, the URL

    http://localhost:8080

connects the browser with the jsmpeg enabled undroidwish. If the browser's WebGL implementation isn't suitable for proper displaying the undroidwish root window, the alternate URL

    http://localhost:8080/?use2d

turns off WebGL usage.



Screenshot widget demo
Screenshot taken in a GNOME Wayland session