Skip to content
Products

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.

  • 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.
Terminal window
http://<server-address>:<ott-port>/whep/<channel-path>/<variant>
  • channel-path: Path of the channel.
  • variant: Name of the channel variant, for example hd.
  • POST <whep-url> with the SDP offer in the request body. Alta replies 201 Created with the SDP answer in the body and the session URL in the Location header: /whep/<channel-path>/<variant>/session/<id>.
  • DELETE <session-url> ends the session.
  • OPTIONS <whep-url> is answered with 204 No Content and 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.

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.

  • 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.