WebRTC/WHEP
Alta delivers live video with low latency over WebRTC using the WHEP (WebRTC-HTTP Egress Protocol). A player sends an SDP offer with an HTTP request, and Alta answers with the video stream.
Requirements
Section titled “Requirements”- The channel variant uses a receiver with an
rtsp://source. WHEP is not available for other sources. - The stream has a video track with H.264 or H.265 codec. Browser support for H.265 depends on the browser.
- The viewer can reach the Alta server directly: Alta does not use STUN or TURN servers.
- Requests go to the OTT Server, not to the API Server. Read more HTTP Server.
WHEP URL
Section titled “WHEP URL”http://<server-address>:<ott-port>/whep/<channel-path>/<variant>- channel-path: Path of the channel.
- variant: Name of the channel variant, for example
hd.
Protocol
Section titled “Protocol”POST <whep-url>with the SDP offer in the request body. Alta replies201 Createdwith the SDP answer in the body and the session URL in theLocationheader:/whep/<channel-path>/<variant>/session/<id>.DELETE <session-url>ends the session.OPTIONS <whep-url>is answered with204 No Contentand CORS headers. Alta allows any origin for WHEP requests.
Trickle ICE is not supported. Send the offer after ICE gathering is complete.
If the channel has an Authorizer, it is checked for POST and DELETE requests. A denied request receives 403 Forbidden.
Example
Section titled “Example”A minimal browser player:
const pc = new RTCPeerConnection()pc.addTransceiver('video', { direction: 'recvonly' })pc.ontrack = (event) => { document.querySelector('video').srcObject = event.streams[0]}
await pc.setLocalDescription(await pc.createOffer())if (pc.iceGatheringState !== 'complete') { await new Promise((resolve) => { pc.addEventListener('icegatheringstatechange', () => { if (pc.iceGatheringState === 'complete') resolve() }) })}
const response = await fetch('http://alta.example.com:8101/whep/discovery/hd', { method: 'POST', headers: { 'Content-Type': 'application/sdp' }, body: pc.localDescription.sdp,})await pc.setRemoteDescription({ type: 'answer', sdp: await response.text() })Add <video autoplay muted playsinline></video> to the page to play the stream.
Troubleshooting
Section titled “Troubleshooting”- 404 Not Found: The channel or variant does not exist, or its source is not an
rtsp://URL. - 403 Forbidden: The authorizer of the channel denied the request.
- 500 Internal Server Error: The variant has no video track with a supported codec yet, or the SDP offer is invalid.