tiny-pilot / tinypilot

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

Add video streaming mode to TinyPilot logs #1666

Closed jdeanwallace closed 8 months ago

jdeanwallace commented 8 months ago

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

Video demo:

https://github.com/tiny-pilot/tinypilot/assets/6730025/0165c85d-f9fa-4389-b98d-44de90843f5a

Notes

  1. When there are active WebRTC consumers, I see this in the Janus logs:

    Oct 30 15:27:57 tinypilot janus[1790]: Creating new session: 3545622190134115; 0xed914e28
    Oct 30 15:27:57 tinypilot janus[1790]: Creating new handle in session 3545622190134115: 8464226001965214; 0xed914e28 0xefb019c8
    Oct 30 15:27:57 tinypilot janus[1790]: == ustreamer/main      -- Creating session 0xefb01650 ...
    Oct 30 15:27:57 tinypilot janus[1790]: == ustreamer/video     -- Memsink opened; reading frames ...
    Oct 30 15:27:57 tinypilot janus[1790]: [8464226001965214] Creating ICE agent (ICE Full mode, controlling)
    Oct 30 15:27:57 tinypilot janus[1790]: == ustreamer/audio     -- Detected host audio
    Oct 30 15:27:57 tinypilot janus[1790]: == ustreamer/audio     -- Pipeline configured on 48000Hz; capturing ...
    Oct 30 15:27:58 tinypilot janus[1790]: [8464226001965214] The DTLS handshake has been completed

    When there are no active WebRTC consumers, I see this in the Janus logs:

    Oct 30 15:30:15 tinypilot janus[1790]: [WSS-0xed9005f8] Destroying WebSocket client
    Oct 30 15:30:15 tinypilot janus[1790]: Destroying session 3545622190134115; 0xed914e28
    Oct 30 15:30:15 tinypilot janus[1790]: Detaching handle from ustreamer; 0xefb019c8 0xefb01650 0xefb019c8 (nil)
    Oct 30 15:30:15 tinypilot janus[1790]: [8464226001965214] WebRTC resources freed; 0xefb019c8 0xed914e28
    Oct 30 15:30:15 tinypilot janus[1790]: == ustreamer/main      -- Removing session 0xefb01650 ...
    Oct 30 15:30:15 tinypilot janus[1790]: == ustreamer/audio     -- Pipeline closed
    Oct 30 15:30:15 tinypilot janus[1790]: == ustreamer/video     -- Memsink closed
    Oct 30 15:30:16 tinypilot janus[1790]: == ustreamer/video     -- No active watchers, memsink disconnected

    So based on the above log examples, H264 mode is active when the last Janus log that contains ustreamer/video, also contains Memsink opened; reading frames. For example:

    Oct 30 15:27:57 tinypilot janus[1790]: == ustreamer/video     -- Memsink opened; reading frames ...

    Otherwise, it is assumed that MJPEG is active.

Review on CodeApprove

jdeanwallace commented 8 months ago
Automated comment from CodeApprove ➜

⏳ @jotaen4tinypilot please review this Pull Request