3 ms·
What part of streaming a screen on Android do you find complex? You pretty much just setup MediaEncoder and let it do its thing. For the input to the encoder yo
by charcircuit 3y ago
What part of streaming a screen on Android do you find complex? You pretty much just setup MediaEncoder and let it do its thing. For the input to the encoder you create a VirtualDisplay that mirrors the default Display that is backed by the input Surface of the encoder. For the output of the encoder you can just send the output buffer over network.
The PC side isn't complex either. You take those packets from the phone, run it through a decoder that draws the frames to a texture which you can show in a window.
- saagarjha 3y agoBandwidth.
- jampekka 3y agoIf it's so simple, why does it take 30k or so lines of code for scrcpy to do it?
- charcircuit 3y agoBecause there are a lot of features beyond just streaming a screen capture, it supports many versions of Android, and it is a polished utility. The actually screen recording part is simple since you are just using existing Android APIs to have hook up the diplay server to a media encoder and the media encoder to the network. https://github.com/Genymobile/scrcpy/blob/a3cdf1a6b86ea22786e1f7d09b9c202feabc6949/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java https://github.com/Genymobile/scrcpy/blob/a3cdf1a6b86ea22786...
- jampekka 3y agoThat is reasonablish as video APIs go. But it's quite a small part of all scrcpy has to do to mirror the screen over the network. Most of that code would be covered with something like "gst-launch pipewiresrc ! encodebin" and the whole mirroring with adding a few elements. Well, in theory at least; gstreamer has the habbit of getting quite fiddly oftentimes. But I don't see any fundamental problems why this too couldn't work with simple composable tools.