WebRTC (WHIP and WHEP)
The tatolab-webrtc module's two nodes, which send encoded video and audio to a WHIP endpoint or play them from a WHEP endpoint.
The tatolab-webrtc module adds two nodes: WhipPublisher, which sends encoded video and audio to a WHIP endpoint, and WhepPlayer, which plays them from a WHEP endpoint. Cloudflare Stream and most WebRTC media servers take both. It’s an ordinary package with Rust inside, and its native code runs in those nodes’ own processes.
Add the modules from File › Marketplace… in Tato Studio, or from a terminal:
uv add tatolab-webrtc tatolab-h264 tatolab-opusBoth nodes sit on the encoded side of the codecs: H264Encoder and OpusEncoder upstream of the publisher, H264Decoder and OpusDecoder downstream of the player. Each message is one bare Annex-B access unit or one Opus packet.
Publish the camera and microphone
Section titled “Publish the camera and microphone”camera (CameraSource) ── video ──▶ H264Encoder ── encoded_video ──┐ ├──▶ WhipPublisher (tracks)microphone (MicrophoneSource) ── audio ──▶ OpusEncoder ── encoded_audio ──┘WhipPublisher has one input, tracks, that takes several links: each link becomes one RTP track, video or audio by the codec its upstream port states. Its settings are url, the WHIP endpoint, and bearer_token, sent as Authorization: Bearer when the endpoint wants one.
How the session behaves
Section titled “How the session behaves”- A session carries at most one video and one audio track. A second link of either kind is refused.
- Only H.264 video and Opus audio, mono or stereo. A codec the session doesn’t carry is refused, naming it.
- The session opens with the first media frame, not when the stream starts. If the endpoint is unreachable, the stream still plays, and the error is in the log.
- Each track starts at a group start. A link enters at a keyframe, or any Opus packet, and after a loss it discards up to the next one, so the far end never gets a picture it can’t decode.
Video needs a hardware H.264 encoder; see Encode and save.
Play a WHEP stream
Section titled “Play a WHEP stream”WhepPlayer connects to a WHEP endpoint, with the same url and bearer_token settings, and writes what it receives on two outputs, encoded_video (H.264) and encoded_audio (Opus), in the same form the encoders write. It states each port’s stream facts from the stream itself, so a decoder downstream knows the size and channel count before the first frame.
WhepPlayer ─┬─ encoded_video ──▶ H264Decoder ── video ──▶ (the Node visualizer, a model, a virtual camera) └─ encoded_audio ──▶ OpusDecoder ── audio ──▶ SpeakerSinkDecoded, its frames are ordinary frames: watch them in Tato Studio’s Node visualizer, run a model on them, or put them on a virtual camera.
Related
Section titled “Related”- The
camera-webrtc-publishexample, in the streamlib repository. - Encode and save: the encoders and their settings.