tiny-pilot / tinypilot

Use your Raspberry Pi as a browser-based KVM.
https://tinypilotkvm.com
MIT License
2.99k stars 250 forks source link

Maintain h.264 video stream when target machine is switched off #1619

Closed jdeanwallace closed 11 months ago

jdeanwallace commented 12 months ago

Resolves https://github.com/tiny-pilot/tinypilot/issues/1487

This PR refactors our remote-screen WebRTC API to allow media tracks to be added/removed without automatically enabling/disabling the WebRTC streaming mode. This gives more responsibility to the (function) caller, but also gives more control in deciding when to change streaming modes.

Demo video:

https://github.com/tiny-pilot/tinypilot/assets/6730025/d891fbcb-1cea-41fe-b775-948b5a9879e6

Notes

  1. We've renamed enableWebrtcStreamTrack -> addWebrtcStreamTrack
    • This method no longer enables WebRTC mode (i.e., shows the video element)
  2. We've renamed disableWebrtcStreamTrack -> removeWebrtcStreamTrack
    • This method no longer disables WebRTC mode (i.e., hides the video element)
  3. WebRTC mode can now both be enabled and have zero media tracks
    • This was the cause of the original bug
  4. The remote-screen will still failover to MJPEG when the connection to Janus fails, but will not try to reconnect until a full page refresh

Review on CodeApprove

jdeanwallace commented 12 months ago
Automated comment from CodeApprove ➜

⏳ @mtlynch please review this Pull Request

mtlynch commented 11 months ago
Automated comment from CodeApprove ➜

⏳ @jotaen4tinypilot please review this Pull Request

mtlynch commented 11 months ago

I'm reassigning this one to @jotaen4tinypilot. I think he'll do a better review, and he's back pretty soon. I'm a bit swamped this week.