# SFU (One-to-Many Streaming)

SFU (Selective Forwarding Unit) enables one Unreal Engine instance to stream to multiple viewers simultaneously.

## Video Tutorial

{% embed url="<https://youtube.com/watch?v=mYtOnX7FX2U>" %}
Introducing Meeting Rooms
{% endembed %}

## Architecture

In standard mode, each viewer gets a dedicated UE instance (1:1). With SFU:

* One UE instance renders the content
* The SFU server receives the stream and forwards it to multiple viewers
* One user is the **Host** (can send input to UE), all others are **Players/Viewers** (watch-only)

{% hint style="info" %}
There is exactly one host per SFU session. The host is the only user who can send mouse, keyboard, and other input to the Unreal Engine application.
{% endhint %}

## Roles

### Host

The host controls the UE application. There is one host per SFU session. The host can send mouse, keyboard, and other input to UE.

{% code lineNumbers="true" %}

```javascript
await StreamPixelApplication({
  appId: 'your-project-id',
  sfuHost: 'true',
  AutoConnect: true,
});
```

{% endcode %}

### Player (Viewer)

Players watch the stream but cannot send input to UE. Multiple players can connect simultaneously.

{% hint style="warning" %}
Players and viewers are watch-only. They cannot send any input (mouse, keyboard, touch, gamepad) to the Unreal Engine application.
{% endhint %}

{% code lineNumbers="true" %}

```javascript
await StreamPixelApplication({
  appId: 'your-project-id',
  sfuPlayer: 'true',
  AutoConnect: true,
});
```

{% endcode %}

### Default (Neither)

When neither `sfuHost` nor `sfuPlayer` is set, the SDK uses standard 1:1 streaming.

## Configuration via URL Parameters

SFU mode can also be set via URL query parameters, which is useful for sharing links:

```
https://yourapp.com/PROJECT_ID?sfuHost=true
https://yourapp.com/PROJECT_ID?sfuPlayer=true
```

You can also target a specific streamer instance:

```
https://yourapp.com/PROJECT_ID?sfuPlayer=true&streamerId=hostInstance123
```

## Use Cases

* **Live presentations**: One person presents in UE, many watch
* **Spectator mode**: Players watch a game being played by the host
* **Virtual events**: Stream a virtual environment to a large audience
* **Training/demos**: Instructor controls the application, trainees observe
* **Cost optimization**: Serve many viewers from a single UE instance
