Skip to main content

Overview

ManagedStreamingExtension works alongside VideoManager to provide managed streaming capabilities. It enables multiple apps to view the same stream, handles Cloudflare Live streaming infrastructure, supports restreaming to multiple destinations, and provides automatic URL discovery for HLS/DASH/WebRTC playback. File: packages/cloud/src/services/streaming/ManagedStreamingExtension.ts

Key Features

  1. Multi-Viewer Support: Multiple apps can view the same stream
  2. Cloudflare Integration: Uses Cloudflare Live for stream infrastructure
  3. Restream Capabilities: Add/remove multiple RTMP output destinations
  4. Automatic URL Discovery: Polls for and distributes playback URLs
  5. Conflict Management: Prevents conflicts between managed/unmanaged streams
  6. Keep-Alive System: Maintains stream health with ACK tracking
  7. Per-App Output Control: Apps manage their own restream outputs

Architecture

Stream Management

Managed Stream State

Stream Creation

URL Discovery

Polling System

Restream Management

Add Output

Remove Output

Keep-Alive System

Keep-Alive Management

ACK Handling

Status Management

Status Distribution

Conflict Detection

Cleanup

Stream Cleanup

Periodic Cleanup

Configuration

Constants

Lifecycle Management

Disposal

Best Practices

  1. Always check stream conflicts before starting
  2. Validate app ownership for output operations
  3. Poll efficiently for URL discovery
  4. Track last sent status to avoid duplicates
  5. Clean up resources when streams end
  6. Handle ACK timeouts to detect dead streams
  7. Enforce limits on outputs per stream/app

Integration Points

  • VideoManager: Works alongside for stream management
  • CloudflareStreamService: Manages live input infrastructure
  • StreamStateManager: Tracks stream state and conflicts
  • SessionService: Retrieves user sessions
  • WebSocket: Communicates with glasses