# Interface SessionOptions

Defines configuration options for a CloudXR streaming session.

Defines all configuration parameters needed to create and configure a CloudXR streaming session. Required parameters must be provided, while optional parameters have sensible defaults.

#### Example

    const sessionOptions: SessionOptions = {
      // Required parameters
      serverAddress: '192.168.1.100',
      serverPort: 49100,
      useSecureConnection: false,
      gl: webglContext,
      perEyeWidth: 2048,
      perEyeHeight: 1792,
      referenceSpace: xrReferenceSpace,

      // Optional parameters with defaults
      deviceFrameRate: 90,
      maxStreamingBitrateKbps: 150000,
      codec: 'av1'
    };

interface SessionOptions {
serverAddress : string;
serverPort : number;
useSecureConnection : boolean;
gl : WebGL2RenderingContext;
perEyeWidth : number;
perEyeHeight : number;
referenceSpace : XRReferenceSpace;
glBinding ?: XRWebGLBinding;
codec ?: string;
deviceFrameRate ?: number;
maxStreamingBitrateKbps ?: number;
telemetry ?: {
enabled?: boolean;
appInfo?: { version?: string; product?: string };
};
enablePoseSmoothing ?: boolean;
posePredictionFactor ?: number;
}

#####
Index

### Properties

serverAddress
serverPort
useSecureConnection
gl
perEyeWidth
perEyeHeight
referenceSpace
glBinding?
codec?
deviceFrameRate?
maxStreamingBitrateKbps?
telemetry?
enablePoseSmoothing?
posePredictionFactor?

##
Properties

### serverAddress

serverAddress: string

Address of the CloudXR Runtime.

Can be an IP address (e.g., '192.168.1.100') or hostname. For local development, use 'localhost' or '127.0.0.1'.

#### Example

    serverAddress: '192.168.1.100'  // IP address
    serverAddress: 'cloudxr-server.local'  // Hostname
    serverAddress: 'localhost'  // Local development

### serverPort

serverPort: number

Port of the CloudXR Runtime.

The default CloudXR Runtime port is 49100. Ensure this port is accessible and not blocked by firewalls.

#### Default

    49100

#### Example

    serverPort: 49100  // Default CloudXR port

### useSecureConnection

useSecureConnection: boolean

Connect using secure connection (WSS/HTTPS).

When true, uses secure WebSocket (WSS) connection. When false, uses unsecured WebSocket (WS) connection. For production deployments, secure connections are recommended.

#### Default

    false

#### Example

    useSecureConnection: false  // Development
    useSecureConnection: true   // Production

### gl

gl: WebGL2RenderingContext

WebGL context for rendering.

Must be a WebGL2RenderingContext obtained from a canvas element. This context will be used for all CloudXR rendering operations.

#### Example

    const canvas = document.createElement('canvas');
    const gl = canvas.getContext('webgl2');
    // Use gl in sessionOptions

### perEyeWidth

perEyeWidth: number

Width of each eye in pixels.

This should match the per-eye resolution you want to render. Must be a multiple of 16 for optimal performance. The actual stream width will be calculated as perEyeWidth * 2.

#### Example

    perEyeWidth: 2048  // Max width if using H264 codec

### perEyeHeight

perEyeHeight: number

Height of each eye in pixels.

This should match the per-eye resolution you want to render. Must be a multiple of 16 for optimal performance. The actual stream height will be calculated as perEyeHeight * 9 / 4.

#### Example

    perEyeHeight: 1792  // Max height if using H264 codec

### referenceSpace

referenceSpace: XRReferenceSpace

XR reference space to use for coordinate system calculations.

This is used for getting the viewer pose from the XR frame and should be obtained from the WebXR session.

#### Example

    const referenceSpace = await xrSession.requestReferenceSpace('local-floor');

### `Optional` glBinding

glBinding?: XRWebGLBinding

XR WebGL binding used to query viewport information for each eye.

Optional binding that provides additional viewport information. If not provided, default viewport calculations will be used.

#### Example

    const glBinding = new XRWebGLBinding(xrSession, gl);

### `Optional` codec

codec?: string

Video codec for streaming.

Supported codecs: 'h264', 'av1'. AV1 provides better compression but requires more CPU/GPU resources for encoding/decoding.

#### Default

    'av1'

#### Example

    codec: 'av1'   // Better compression, more CPU intensive
    codec: 'h264'  // Faster encoding/decoding, larger bandwidth

### `Optional` deviceFrameRate

deviceFrameRate?: number

Device frame rate (maximum FPS).

The server will treat this as a maximum FPS and choose an appropriate streaming frame rate that is lower than this value. Higher frame rates provide smoother motion but require more bandwidth.

#### Default

    90

#### Example

    deviceFrameRate: 90   // Quest 3 standard
    deviceFrameRate: 120  // High refresh rate
    deviceFrameRate: 72   // Lower power mode

### `Optional` maxStreamingBitrateKbps

maxStreamingBitrateKbps?: number

Maximum streaming bitrate in Kilobits per second.

Controls the maximum bandwidth used for streaming. Higher bitrates provide better quality but require more network bandwidth.

#### Default

    150000

#### Example

    maxStreamingBitrateKbps: 150000  // 150 Mbps
    maxStreamingBitrateKbps: 100000  // 100 Mbps (lower bandwidth)
    maxStreamingBitrateKbps: 200000  // 200 Mbps (high quality)

### `Optional` telemetry

telemetry?: {
enabled?: boolean;
appInfo?: { version?: string; product?: string };
}

Telemetry configuration options

#### Type declaration

- ##### `Optional` enabled?: boolean

  Enable telemetry collection. Default is true.

- ##### `Optional` appInfo?: { version?: string; product?: string }

  Application information for telemetry

  - ##### `Optional` version?: string

    Application version (e.g., "1.0.0")

  - ##### `Optional` product?: string

    Product name (e.g., "MyApp")

### `Optional` enablePoseSmoothing

enablePoseSmoothing?: boolean

Enable secondary smoothing on predicted positions.

When enabled, applies an additional smoothing pass to reduce jitter in predicted positions. This only affects position, not orientation.

#### Default

    true

#### Example

    enablePoseSmoothing: false  // Disable position smoothing

### `Optional` posePredictionFactor

posePredictionFactor?: number

Pose prediction factor (0.0 to 1.0) that scales the prediction horizon.

This multiplier is applied to the calculated prediction horizon for both position and orientation. A value of 1.0 uses full prediction, 0.5 uses half the prediction horizon, and 0.0 disables prediction entirely.

#### Default

    1.0

#### Example

    posePredictionFactor: 0.5  // Use 50% of calculated prediction
    posePredictionFactor: 0.0  // Disable prediction