mafintosh / hypervision

P2P Television
MIT License
447 stars 59 forks source link

Stream freezes if sources are changed mid-stream #31

Open t-mullen opened 7 years ago

t-mullen commented 7 years ago

If you change the sources after the stream has already started, the video of all connected peers will freeze.

Any peers that try to reconnect will just get the last few seconds before sources were changed, then a freeze.

t-mullen commented 7 years ago

If we push the audio stream through WebAudio and the video stream through a canvas, we won't need to change the sources going into the mediaRecorder at all.

Plus this will let us do fancy things with video resizing + merging and sound effects. One more reason!

t-mullen commented 7 years ago

Got the canvas part of this down: video-stream-merger

louiscenter commented 7 years ago

@RationalCoding ah! Thanks for spotting this.

There must have been a regression at some point because when I first re-build the UI, the quality/settings buttons disappeared when you were broadcasting, so you weren't able to change them. It doesn't make sense at this point to change the quality mid broadcast, but I think it's definitely worth being able to change input sources.

I think why I hadn't implemented this yet is because the source inputs are piped directly into the recorder, so if you changed the video source input from say, your FaceTime camera, to screen sharing, the entire dimensions of the output video would be altered.

Your solution sounds interesting, it may fix a lot of outstanding issues!

t-mullen commented 7 years ago

The streams are freezing because the media devices get stopped on unload of /broadcast, which fires when you open the settings menu.

mediaDevice.stop() should only get called when you click "Back to Menu". Don't know enough about choo routing to fix this one.