smcameron / space-nerds-in-space

Multi-player spaceship bridge simulator game. Captain your starship through adventures with your friends. See https://smcameron.github.io/space-nerds-in-space
GNU General Public License v2.0
729 stars 73 forks source link

Add bridge-to-bridge video chat #315

Open smcameron opened 2 years ago

smcameron commented 2 years ago

This post https://forum.freegamedev.net/viewtopic.php?f=3&t=18409&p=104965#p104965 made me realize that perhaps bridge-to-bridge video chat is possible, and maybe not so different from the voice chat feature already implemented.

This library seems the place to start: https://www.theora.org/doc/libtheora-1.1/

I don't think I can use the library from freegamedev.net as is, since it doesn't do encoding, only decoding, and that only from a file (I think), and also I think I would want to handle the audio differently.

Encoding functions described here: https://www.theora.org/doc/libtheora-1.1/group__encfuncs.html Decoding functions described here: https://www.theora.org/doc/libtheora-1.1/group__decfuncs.html Functions shared by encoding/decoding here: https://www.theora.org/doc/libtheora-1.1/group__basefuncs.html

Not covered by any of that is how to get raw frames and audio from webcam. This repo may be of interest: https://github.com/djtrance/webcam_viewer Edit: I forked that repo and made this: https://github.com/smcameron/webcam_viewer which splits apart the camera capture code from the SDL display code.

Maybe capture video and audio separately and use existing audio chat functionality somehow. Maybe use external program with shared memory for video frame capture?

I imagine a similar system as the voice chat uses in which we transmit encoded video frames from snis_client to snis_server, then relay to video receiving client(s). Not sure about how to keep video and audio in sync.