libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.37k stars 1.84k forks source link

Network Gamepad / Streaming Netplay (todo / guide) #2486

Open andres-asm opened 8 years ago

andres-asm commented 8 years ago

So far the implementation works but there is no client, to test, set your network gamepad port to 55400 (just commited a fix that will set that by default) under network settings, and enable the gamepads for the players you want.

Should look like this: gamepad

I open one port for each controller, so: player1 = 55400 player2 = 55401 player3 = 55402 etc.

Then you can use any tool to generate traffic to send a character array that will be converted to the bitmask of the pressed buttons.

For instance sending "128" will be converted to 128 (with atoi) which means "press d-pad right", i guess there could be a better representation, also a better representation will be needed to send analog inputs.

To test I included a small test program that will send "128", sleep for roughly 1 frame and send 128 again, this should make a character move forward

To use it on the same host just compile it (set your port to 55400 in RetroArch to make it easier) and just run it.

gcc -o udp-test libretro-common/utils/udp-test.c chmod +x udp-test ./udp-test

Todo:

Second part would be to hook up the built-in ffmpeg sink to be able to stream a non post processed framebuffer (and audio) to get some sort of streaming netplay ala GameStream co-op

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28667241-network-gamepad-streaming-netplay-todo-guide?utm_campaign=plugin&utm_content=tracker%2F296058&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F296058&utm_medium=issues&utm_source=github).
duduke commented 8 years ago

Can this be used to support virtual gamepads running of a smartphone?

andres-asm commented 8 years ago

Yes but i haven't programmed a client yet

On Fri, Dec 18, 2015, 5:59 AM Dudu Akiva notifications@github.com wrote:

Can this be used to support virtual gamepads running of a smartphone?

— Reply to this email directly or view it on GitHub https://github.com/libretro/RetroArch/issues/2486#issuecomment-165748557 .

duduke commented 8 years ago

Thanks, awesome. looking forward to this.

TheCherry commented 8 years ago

Very awesome. We just need that client (inside retroach) + analog support. I need to play Super Smash Bros 64 with a friend. :))

gouchi commented 8 years ago

For the time being, you can try to use Packet Sender https://f-droid.org/repository/browse/?fdfilter=packet&fdid=com.packetsender.android

Working well !

andres-asm commented 8 years ago

lol that's pretty cool, I'll try to start coding a gamepad core this weekend

gouchi commented 8 years ago

Nice ! Thank you !

TheCherry commented 8 years ago

Any news? Is there a way to control now a game with Analogsticks via packages?

gouchi commented 8 years ago

@TheCherry Development has started but it is still a WIP.

dan83sama commented 8 years ago

Following the previous https://github.com/libretro/RetroArch/issues/3246

Yes, I use the built-in ffmpeg recording. cmd= retroarch --record rtmp://192.168.1.219:1935/retro/mystream --recordconfig stream.cfg cfg= vcodec = libx264 acodec = aac pix_fmt = yuv420p scale_factor = 2 threads = 3 video_crf = 25 video_preset = ultrafast video_tune = zerolatency audio_global_quality = 75 sample_rate = 44100 format = flv

I use a rtmp server(works over net), but works in rtp,udp,... I would recommend a rtsp server(live555,red5,...) or rtmp server(nginx,...), udp and others only works in the same net.

andres-asm commented 8 years ago

Yeah I used nginx once, but do you thing there is a way to do it without a server? I tried an udp stream but I used to get lots of frame drops.

I also tried rtp directly but that needs two streams.

Still, thanks for the info I'll play with it.

dan83sama commented 8 years ago

It is not necessary a server, I use server to works over network, it works too in udp. To work in udp change format to mpegts in cfg file (flv to mpegts in cfg file), and try to play with ffplay, I recommend this cmd to ffplay: ffplay -probesize 32 -sync ext -fflags nobuffer -vf "setpts=(0.5*PTS)" udp://xxxxxxxx

andres-asm commented 8 years ago

@dan83sama I tried your cfg and nginx it works lags is really bad, but on your video it looks perfectly smooth, any pointers?

dan83sama commented 8 years ago

@fr500 Add me to steam for chat better. Creo que eres español o hablas español, agregame a steam y por hay hablamos mejor, pero que si va perfecto. http://steamcommunity.com/id/dan83/

parkerlreed commented 7 years ago

Considering this has been implemented for a while now, is Android not supported as a server? It's missing all the network gamepad options under Settings > Network, while they exist on desktop.

Shyri commented 6 years ago

Hey guys @fr500 @dan83sama , did you get anywhere with the video stream thing? Do you think it would work for netplay? Also as @parkerlreed says Network Remote seems to be missing on Android (v1.7.1), isn't it supported?

Shyri commented 6 years ago

Hey guys, sorry to come here again. I'm asking just to know, if it is worth the effort I am happy to spend some time working on it. But before doing it I'd like to know if you hit a dead end in the past

andres-asm commented 6 years ago

Someone baked it out, and then something changed something that broke it. When I do stuff, it's removed and then broken down I don't feel like working on such stuff anymore, sorry.

inactive123 commented 6 years ago

I baked it out because it didn't work. If you want I can bake it in again, but this time we really have to focus on making it work and also having proper documentation for it. I could not even understand how to use it last time around.

I will repeat again, i will give it a fair shot and I would like to see it being an embedded core.

andres-asm commented 6 years ago

rubdos on IRC asked about it and I wanted to point out what was going on. I wasn't looking at old issues and commenting out at random.

I don't have any interest on fixing this.

andres-asm commented 5 years ago

Sadly I spent a few nights on this and I can't get it any lower than 10 frames. This is using a native framebuffer, intra-frame refresh, no b-frames, zerolatency preset and h264_nvenc: https://streamable.com/cftfv

I figure the player is a bit part of the equation. Sadly RA's ffmpeg player doesn't even like this stream (used ffplay for testing)