Standalone headsets have strict thermal and power limits. Cloud XR solves this by rendering the scene on a powerful cloud GPU and streaming the encoded video frames to the headset via WebRTC.


Module 1: Low-Latency Encoding with WebCodecs

WebCodecs API allows raw access to hardware video decoders, bypassing the HTMLMediaElement pipeline for ultra-low latency.

decoder.jsjavascript
const decoder = new VideoDecoder({
  output: (frame) => {
    // Render frame to WebGL texture for the VR headset
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, frame);
    frame.close();
  },
  error: (e) => console.error(e)
});
decoder.configure({ codec: 'vp09.00.10.08' });