Skip to content

Commit 2fff3cc

Browse files
committed
feat: add comprehensive documentation for Pixel Streaming setup, deployment, and integration with Unreal Engine and React
1 parent dc1d953 commit 2fff3cc

5 files changed

Lines changed: 334 additions & 0 deletions

File tree

docs/DEPLOYMENT.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Deployment & Scaling: Pixel Streaming with Docker & Cloud
2+
3+
## 1. Docker Compose Example
4+
5+
```yaml
6+
version: "3.8"
7+
services:
8+
ue_streamer:
9+
image: myproject-pixelstream:latest
10+
runtime: nvidia
11+
network_mode: host
12+
environment:
13+
- NVIDIA_DRIVER_CAPABILITIES=all
14+
15+
signaling:
16+
image: ghcr.io/epicgames/pixel-streaming-signalling-server:5.6
17+
network_mode: host
18+
19+
turn:
20+
image: coturn/coturn:latest
21+
command: ["turnserver", "-n", "--log-file=stdout"]
22+
ports:
23+
- "3478:3478/udp"
24+
- "3478:3478/tcp"
25+
```
26+
27+
> Note: Use network_mode: host on Linux for lowest latency. On Windows, map ports manually.
28+
29+
## 2. Cloud Hosting
30+
31+
- **AWS**: EC2 GPU (G4/G5), ECS/EKS for containers, Auto Scaling Group for orchestration.
32+
- **Azure**: NV-series VMs, VM Scale Sets, Azure Pixel Streaming Marketplace Template.
33+
- **Google Cloud**: GPU instances, GKE for containers.
34+
35+
## 3. Staging vs Production
36+
37+
- **Staging:** Single instance, protected by simple auth or VPN. Use for testing/QA.
38+
39+
- **Production:**
40+
- Use autoscaling (ASG/Scale Sets) for demand-based scaling.
41+
- Implement a matchmaker or routing backend to assign users to sessions.
42+
- Terminate idle sessions after timeout to control costs.
43+
- Consider GPU quotas and encoder limits per node.
44+
45+
## 4. Authentication & Security
46+
47+
- Protect signaling server with HTTPS and valid TLS certs.
48+
- Gate frontend via web auth (OAuth, SSO, etc).
49+
- Optionally, require API token for WebSocket upgrade or use reverse proxy for access control.
50+
- Secure TURN/STUN credentials.
51+
52+
## 5. Scaling Scenarios
53+
54+
- 1:1 Streaming: One UE instance per user/session for max interactivity.
55+
- SFU-based: One UE instance, SFU forwards to many viewers (spectators only, single controller).
56+
- Use horizontal scaling for high concurrency.
57+
58+
## 6. Best Practices
59+
60+
- Use health checks to detect and restart failed containers.
61+
- Monitor GPU/CPU usage for scaling triggers.
62+
- Regularly update all images (UE, signaling, TURN) for security.
63+
- Log all connections, user actions, and errors for traceability.
64+
65+
## 7. Troubleshooting
66+
67+
- If video is black, check GPU drivers and encoding settings.
68+
- If clients can't connect, check port forwarding, signaling logs, and TURN config.
69+
- For high latency, prefer host networking and regional cloud instances close to users.

docs/DEVELOPMENT_WORKFLOW.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Development Workflow for UE + React Pixel Streaming
2+
3+
## 1. Prerequisites
4+
5+
- Unreal Engine 5.6 (with Pixel Streaming enabled)
6+
- Node.js (for signaling server)
7+
- Docker & NVIDIA Docker (for containerized workflows)
8+
- React (latest)
9+
- (Optional) TURN/STUN server for public access
10+
11+
## 2. Local Development
12+
13+
### Unreal Side
14+
15+
- Develop and test interaction logic using PIE (Play-In-Editor) and Standalone.
16+
- Use `-PixelStreamingIP=127.0.0.1 -PixelStreamingPort=8888` for local signaling server.
17+
- Set up a test Blueprint with `OnPixelStreamingInputEvent`.
18+
19+
### Signaling Server
20+
21+
- Start signaling server from Epic’s Pixel Streaming Infrastructure.
22+
23+
```sh
24+
./start_with_stun.sh
25+
```
26+
27+
- For Docker: use Epic’s Docker image or build your own.
28+
29+
### React Side
30+
31+
- Run React dev server as usual (`npm run dev` or `npm start`).
32+
- Proxy or CORS may be needed if React and signaling run on different origins.
33+
34+
### Integration
35+
36+
- Open React app, connect to signaling server, and verify video stream.
37+
- Use browser DevTools and UE logs for debugging event handling.
38+
39+
## 3. Version Control
40+
41+
- Use a mono-repo or separate repos for React and UE.
42+
- Store all config files, protocol definitions, and Dockerfiles.
43+
- Maintain documentation in `/docs` or as markdown in repo.
44+
45+
## 4. Testing
46+
47+
- Test all UI commands (color, part, camera, environment).
48+
- Test error paths and unexpected JSON.
49+
- Simulate poor network conditions (using Chrome devtools, etc.).
50+
- Test multi-user and session handover if needed.
51+
52+
## 5. Build Artifacts
53+
54+
- For deployment, package UE project for production.
55+
- Build React app with `npm run build`.
56+
- Containerize both UE and signaling server for cloud deployment.
57+
58+
## 6. CI/CD (Optional)
59+
60+
- Use GitHub Actions or similar for:
61+
- Lint/build React app
62+
- Package UE builds
63+
- Build Docker images
64+
- Push to container registry
65+
- Deploy with Docker Compose or Kubernetes manifests.
66+
67+
## 7. Documentation
68+
69+
- Keep all event protocols, endpoints, and deployment guides up to date.
70+
- Provide architecture diagrams for clarity.

docs/EVENT_HANDLING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Event Handling: Pixel Streaming UI Protocol
2+
3+
## 1. Bi-Directional Communication
4+
5+
- **emitUIInteraction:** Send JSON events from web to UE via WebRTC data channel.
6+
- **SendPixelStreamingResponse:** UE can reply/notify web UI.
7+
8+
## 2. Blueprint Integration (Unreal Side)
9+
10+
- Add **PixelStreamingInputComponent** to PlayerController (or UI manager Actor).
11+
- In Event Graph:
12+
1. On BeginPlay, **Bind Event to OnPixelStreamingInputEvent**.
13+
2. Use the **Descriptor** parameter (JSON string).
14+
3. Parse JSON using Blueprint nodes (`Get JSON Field`, etc).
15+
4. Switch logic based on `"command"` field.
16+
17+
## 3. Example Protocol
18+
19+
| Command | Parameters | Action |
20+
| -------------- | ------------------------------- | ------------------------------ |
21+
| ChangeColor | part, color (hex or RGB) | Set dynamic material on mesh |
22+
| SwapPart | part, variant | Show/hide or attach new mesh |
23+
| FocusCamera | target (part/camera preset) | Play camera animation/sequence |
24+
| SetTimeOfDay | hour (0-23) | Adjust directional light/sky |
25+
| SetEnvironment | preset (day, night, rainy, etc) | Switch HDRI, sublevel, etc |
26+
27+
**Example JS sent from React:**
28+
29+
```js
30+
emitUIInteraction({
31+
command: "ChangeColor",
32+
part: "Body",
33+
color: "#FF0000",
34+
});
35+
```
36+
37+
**Blueprint Pseudocode:**
38+
39+
```c++
40+
OnPixelStreamingInputEvent(Descriptor)
41+
Parse Descriptor as JSON
42+
Switch (Descriptor.command)
43+
"ChangeColor" -> Set Material Color
44+
"SwapPart" -> Swap Mesh
45+
"FocusCamera" -> Play Animation
46+
...
47+
```
48+
49+
## 4. Returning Data to Web
50+
51+
Use `SendPixelStreamingResponse` Blueprint node to send JSON to web.
52+
53+
In React, register a response event listener to handle UE responses (e.g., completion, errors).
54+
55+
## 5. Tips
56+
57+
- Always validate inputs in Blueprint.
58+
59+
- Define a versioned protocol if you expect evolution.
60+
61+
- Log or display unrecognized commands for debugging.

docs/REACT_INTEGRATION.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# React Integration: Pixel Streaming Configurator UI
2+
3+
## 1. Pixel Streaming Library
4+
5+
- Install Epic’s frontend library (example):
6+
7+
```bash
8+
npm install @epicgames-ps/lib-pixelstreamingfrontend-ue5.6
9+
```
10+
11+
- Use or adapt the provided Pixel Streaming React components.
12+
13+
## 2. Basic Integration
14+
15+
```tsx
16+
import { useEffect, useRef } from "react";
17+
import { PixelStreaming } from "@epicgames-ps/lib-pixelstreamingfrontend-ue5.6";
18+
19+
export default function PixelStreamingView() {
20+
const videoRef = useRef<HTMLVideoElement>(null);
21+
useEffect(() => {
22+
const stream = new PixelStreaming({
23+
videoElement: videoRef.current,
24+
signallingUrl: "ws://your-signal-server:80/signalling",
25+
});
26+
return () => stream.close();
27+
}, []);
28+
return <video ref={videoRef} autoPlay playsInline />;
29+
}
30+
```
31+
32+
## 3. UI Overlay Design
33+
34+
- Build React UI overlay: buttons, color pickers, sliders, etc.
35+
- When user interacts, call:
36+
37+
```js
38+
pixelStreaming.emitUIInteraction({
39+
command: "ChangeColor",
40+
part: "Roof",
41+
color: "#00FF00",
42+
});
43+
```
44+
45+
- For camera, part, environment, repeat with suitable protocol.
46+
47+
## 4. Receiving Responses
48+
49+
```js
50+
pixelStreaming.addResponseEventListener((msg) => {
51+
// Handle events from UE (e.g., completion, error, state sync)
52+
});
53+
```
54+
55+
## 5. Touch & Mouse Controls
56+
57+
- Use `controlScheme` config for pointer lock/hovering as needed.
58+
- Prevent click-through from UI elements to UE video when overlay is active.
59+
- For mobile, ensure touch events are mapped (Pixel Streaming lib does this by default).
60+
61+
## 6. Example UI Features
62+
63+
- Color Picker (for materials)
64+
- Dropdown/Selector (for variants/parts)
65+
- Environment Presets (buttons/sliders)
66+
- Camera Jump buttons (for part highlights)
67+
- Day/Night slider
68+
69+
## 7. Advanced
70+
71+
- Maintain state in React (current config, sync from UE on load).
72+
- Support multi-user with role-based UI (e.g., only one controller).
73+
- Responsive layout for mobile/desktop.

docs/UNREAL_SETUP.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Unreal Engine 5.6 Pixel Streaming Setup
2+
3+
## 1. Enable Pixel Streaming Plugin
4+
5+
- Open your project in Unreal Engine 5.6.
6+
- Go to **Edit > Plugins > Graphics**.
7+
- Enable the **Pixel Streaming** plugin.
8+
- Restart the editor.
9+
10+
## 2. Project Settings
11+
12+
- In **Edit > Project Settings > Pixel Streaming**:
13+
- Set default resolution (e.g., 1920x1080).
14+
- Adjust bitrate (e.g., 10 Mbps) for quality/performance.
15+
- Set framerate (e.g., 60 FPS for smoothness).
16+
- (Optional) Enable AV1 codec for higher quality at lower bitrate (requires supported GPU).
17+
18+
## 3. Packaging the Project
19+
20+
- Go to **File > Package Project > [Windows/Linux]**.
21+
- Select a folder to save your build.
22+
- Ensure Pixel Streaming plugin is included.
23+
- For containerized or cloud use, package for **Linux** when possible (preferred for Docker).
24+
25+
## 4. Pixel Streaming Startup Parameters
26+
27+
- When launching your packaged build, use:
28+
29+
```bash
30+
MyProject.exe -PixelStreamingIP=127.0.0.1 -PixelStreamingPort=8888 -RenderOffscreen -Windowed -ForceRes -ResX=1920 -ResY=1080
31+
```
32+
33+
- `-RenderOffscreen` is crucial for headless operation.
34+
- Adjust IP and port to match your signaling server.
35+
- For Linux, launch the `.sh` wrapper with the same flags.
36+
37+
## 5. Signaling Server (Official)
38+
39+
- Download the Pixel Streaming Infrastructure (signaling server) from Epic’s GitHub or use prebuilt Docker images.
40+
- Run with:
41+
42+
```bash
43+
> cd Engine/Plugins/Media/PixelStreaming/Resources/WebServers/SignallingWebServer/platform_scripts/cmd
44+
45+
> ./start_with_stun.bat (or .sh)
46+
```
47+
48+
- Listens on **port 8888** for streamer, **80** for web clients.
49+
- Modify `config.json` for TURN/STUN settings if needed.
50+
51+
## 6. Networking
52+
53+
- Open required ports: **80** (HTTP/WS), **443** (HTTPS/WSS), **8888** (WebSocket for streamer).
54+
- If internet-facing, use HTTPS with valid certificates.
55+
- Configure TURN/STUN for NAT traversal in production.
56+
57+
## 7. Best Practices
58+
59+
- For multi-user, consider one UE instance per session.
60+
- For spectators, use SFU (Selective Forwarding Unit) in UE 5.5+ (experimental).
61+
- Monitor GPU encoding session limits (NVIDIA cards typically allow 2–5 concurrent streams per GPU).

0 commit comments

Comments
 (0)