vuer.webrtc
WebRTC streaming support for Vuer.
Provides BGRArrayVideoStreamTrack, WebRTCStream, and WebRTCStreamManager for hosting WebRTC video streams on Vuer's existing aiohttp server.
Requires: pip install vuer[webrtc]
serve_debug_page
Serve the WebRTC debug page (standalone, no manager required).
WebRTCStream
A single WebRTC stream that can serve video to multiple peers.
Two usage modes:
- High-level: omit track, use push_frame(bgr_numpy) to send frames.
- Low-level: provide a custom track, frames come from the track itself.
WebRTCStream.init
Args: stream_id: Unique identifier for the stream. vuer: The Vuer server instance. track: Optional custom MediaStreamTrack. If None, creates an internal track and enables push_frame(). codec: Preferred codec ("H264" or "VP8"). Default "H264". max_bitrate: Maximum bitrate in bps (e.g. 2_000_000 for 2 Mbps). None means encoder default. max_framerate: Maximum frames per second (e.g. 15, 30). None means no limit. resolution: Tuple of (width, height) for the black fallback frame when no frames are being pushed. Default (640, 480).
WebRTCStream.ready
Whether the stream's event loop has been set (server is running).
WebRTCStream.wait_ready_sync
Block the current thread until the stream is ready.
Args: timeout: Maximum seconds to wait. Raises TimeoutError if exceeded.
WebRTCStream.push_frame
Push a BGR numpy frame to the stream (thread-safe).
Only available when no custom track was provided.
WebRTCStream.endpoint
Full URL for this stream's offer endpoint.
WebRTCStream.url
Path-only URL for this stream's offer endpoint.
WebRTCStream.handle_offer
Handle an SDP offer and return an SDP answer.
WebRTCStream.set_loop
WebRTCStream.cleanup
Close all peer connections for this stream.
WebRTCStreamManager
Manages multiple WebRTC streams and dispatches offer requests.
WebRTCStreamManager.init
WebRTCStreamManager.create_stream
Create and register a new WebRTC stream.
WebRTCStreamManager.offer_handler
Route handler for /webrtc/offer/{stream_id}.
WebRTCStreamManager.set_loop
Propagate event loop reference to all streams.
WebRTCStreamManager.streams
WebRTCStreamManager.cleanup_all
Cleanup all streams.