Artifact [c37304d8f8]
Not logged in

Artifact c37304d8f8ee348dbbe1a95c77cb5ec0f9cce229:

Wiki page [jsmpeg SDL Video Driver] by chw 2019-04-07 17:48:09.
D 2019-04-07T17:48:09.337
L jsmpeg\sSDL\sVideo\sDriver
P 3084dffd227f370c823447791470e2aa476a5014
U chw
W 3344
An experimental SDL video driver named <b>jsmpeg</b> is provided since Valentine's Day 2019. It uses the technique described in <a href="https://github.com/phoboslab/jsmpeg">https://github.com/phoboslab/jsmpeg</a> and <a href="https://github.com/phoboslab/jsmpeg-vnc">https://github.com/phoboslab/jsmpeg-vnc</a> 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 <b>jsmpeg</b> 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 working EGL which seems only be available on Linux (not MacOSX, Windows only with 3rd party libraries).

For the adventurous, there is a test version for <a href="http://www.ch-werner.de/AndroWish/undroidwish-x86_64-deb9">Linux x86_64</a> (Debian 9, Fedora 29, maybe CentOS 7), <a href="http://www.ch-werner.de/AndroWish/undroidwish-win32.exe">Windows</a> (XP or newer, 32 bit), and <a href="http://www.ch-werner.de/AndroWish/undroidwish.dmg">MacOSX</a> (tested on High Sierra). All can be run using the <b>jsmpeg</b> video driver when the environment variable <b>SDL_VIDEODRIVER</b> has the value <b>jsmpeg</b> and the required FFMpeg DLLs/shared libraries are available on the system, e.g.

<verbatim>
    # POSIX
    SDL_VIDEODRIVER=jsmpeg ./undroidwish-x86_64-deb9 builtin:widget -sdlwidth 800 -sdlheight 600
</verbatim>

<verbatim>
    REM Windows
    SET SDL_VIDEODRIVER=jsmpeg
    undroidwish-win32.exe builtin:widget -sdlwidth 800 -sdlheight 600
</verbatim>

For Windows, the required DLLs are <b>avutil-56.dll</b>, <b>avcodec-58.dll</b>, <b>swresample-3.dll</b>, and <b>swscale-5.dll</b> which are available from <a href="https://www.ffmpeg.org/download.html">https://www.ffmpeg.org/download.html</a> and preferably loaded from <b>%PROGRAMFILES%\ffmpeg\bin</b>. 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 <b>SDL_VIDEO_JSMPEG_PORT</b>. Thus, the URL

<verbatim>
    http://localhost:8080
</verbatim>

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

<verbatim>
    http://localhost:8080/?use2d
</verbatim>

turns off WebGL usage. 

<nowiki>
<center>
<br><br>
<img src="/raw/misc/uw_jsmpeg.png?name=1987f830946ab006f2e462c5e9566a278376f633"
alt="Screenshot widget demo">
<br>Screenshot taken in a GNOME Wayland session<br><br>
</center>
</nowiki>

Z e427ec9f289081baaf31468ca28c3c7c