Genymobile / Genymobile/scrcpy
[Suggestion] Using a webclient instead sdl app.
- Dominant language
- C
- Stars
- 150k
- Forks
- 13.7k
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 2
Description
Hello, i firtsly want to say thanks to the dev of this project where i learned interesting stuff.
As im developing similar project i focused on the communication of data/video and rendering, as my current platform is web-driven i wanted to be able to control the device from a webapp, i set up a simple server (with simplicity far beyond scrcpy) just used MicroHTTPD to serve some http endpoints:
**/stream** -> that launchs on a thread a process "_screenrecord --bit-rate 1M --size 1280x720 --output-format=h264 -_" the outputstream of this process is tied to the inputstream of http request, serving a chunked stream of h264 (just like scrcpy does, but with less hassle)
**/control?tapx=x&tapy=y** -> launches "_input tap x y_", simple...
**/control?text=txt** -> launches "_input text txt_", simple...
one can just use ffmpeg&ffplay to access this stream _"ffplay -f h264 -i http://127.0.0.1:8088/stream"_ but i wanted to draw on web, remember, so im using Broadway.js, that does h264 decoding on client browser with any given raw data. We have to do a break here, for this specific case, triying to use the http feed with xhr need to write a custom inputsource for xhr, but we have new Fetch api liying around that we can use to constantly pump new data from opened http request, then give it to broadway player and render it to a canvas.

https://imgur.com/a/0mYstz5
The input consists on a always focused input that process all keyevents and make xhr calls to control endpoint, also clicks are sent, being transformed from virtual screen->real coordinates.

https://i.imgur.com/IPOXI2X.gifv
The code:
java https://pastebin.com/RQQUvaE9
html https://pastebin.com/mscEYvA8
This sample demonstrates that web rendering is possible even without the need of raw socket/websocket usage, and broadway does the job while outperformed ffmpeg on all my tests.
One could for example render directly on electron app, while still have an easy api to work with other comands/shells/tools on easier graphic mode.
Disclaimer: obviously this code is POC grade and not usable beyond testing, just wanted to share a different point of view on rendering process and possibilitate better UI.
Again many thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.