Repository navigation
Add H.264 WebRTC signaling and snapshots, moved from the Home Assistant integration - #65
Merged
Merged
Conversation
open_webrtc_signaling() picks the signaling endpoint for the detected hardware and returns a WebRTCSignaling session: one offer in, one answer and trickled candidates out, on either family. For the Pro it splits the browser offer into its separate video and audio peers, merges their answers, maps candidates both ways and keeps the session alive with the application heartbeat. A Pro video-status of -4 raises NanoKVMVideoModeError. Moved from the Home Assistant integration.
open_webrtc_signaling() joins open_ws() in the sync client's async-only set: its session belongs to the client's event loop. Rename home_assistant_candidate_for_kind to client_candidate_for_kind, the counterpart of upstream_candidate_for_kind.
get_snapshot() returns the first raw JPEG of the MJPEG stream within a timeout. The Pro refuses it: its MJPEG and H.264 streams share one encoder mode, so opening MJPEG would interrupt WebRTC (NanoKVM-Pro#157). Moved from the Home Assistant integration's camera snapshot.
docs/streaming.md covers snapshots, the MJPEG streams and the WebRTC signaling session step by step, with the Pro's single encoder and its offer split and answer merge. The API reference keeps the method table and points to it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the H.264 WebRTC signaling and the camera snapshot from the Home Assistant integration into the client, so any caller can open a WebRTC session or grab a still image without knowing how the two hardware families differ. Adds a streaming guide to
docs/.Changes
open_webrtc_signaling()picks the signaling endpoint for the detected hardware and returns ananokvm.webrtc.WebRTCSignalingsession on its own WebSocket. One offer goes in, and one answer and trickled candidates come out, on either family.split_pro_webrtc_offer()andmerge_pro_webrtc_answers()are public for callers that run their own signaling.NanoKVMVideoModeErroris raised from the iteration when the Pro reports video status -4, which means another video mode took the encoder.get_snapshot(timeout=20.0)(non-Pro) returns the first raw JPEG of the MJPEG stream. The Pro refuses it withNanoKVMNotSupportedErrorbefore any request, because opening MJPEG there stops WebRTC (Reading one frame from/api/stream/mjpegfreezes active H.264/H.265 streams sipeed/NanoKVM-Pro#157).open_webrtc_signaling()joinsopen_ws()as async-only, because its WebSocket belongs to the client's event loop.get_snapshot()works as a blocking call.docs/streaming.mdcovers snapshots, MJPEG and the WebRTC session step by step, including the Pro's single encoder.docs/api.mdkeeps the method table and links to it.Notes
ice-serversevent (its configured STUN/TURN) on connect, before the offer, since 2.4.2. The session doesn't expose it yet. It only matters when TURN is configured on the device.Behaviour changes
None. All methods are additions.
Testing
504 unit tests pass, 29 of them new. Against devices:
get_snapshot()returned a complete 48 KB JPEG in 0.28 s.get_snapshot()was refused without a request.open_webrtc_signaling().