Architecture Overview
Component Stack
Protocol Flow
Publishing (Creator):- Frontend generates WHIP URL from
eventId - WebRTC connection established to SRS
- Browser captures media stream
- SRS distributes to subscribers
- Frontend generates WHEP URL from
eventId - WebRTC connection established to SRS
- SRS delivers stream to browser
- Real-time interaction enabled
SRS Configuration
Core Settings
SRS Configuration: Listen on port 1935, 1000 max connections, file logging with trace level. HTTP API on port 1985 with crossdomain enabled, HTTP server on 8080, RTC server on 8000 with candidate configuration.WebRTC Configuration
WHIP/WHEP Support: Default vhost with RTC enabled, RTMP-to-RTC bidirectional conversion, HTTP remux for FLV streaming, HLS output with 10-second fragments and 60-second window.API Endpoints
Stream Monitoring:GET /api/v1/streams/- List active streamsGET /api/v1/clients/- Connected client informationPOST /api/v1/clients/{id}- Client management operations
POST /rtc/v1/whip/- Publishing endpointPOST /rtc/v1/whep/- Subscription endpointOPTIONS /rtc/v1/*- CORS preflight handling
URL Generation Strategy
Deterministic URLs
Frontend generates all streaming URLs using direct onchain scheduling, without backend coordination:Benefits of Deterministic Generation
- No backend coordination required for URL management
- Immediate availability after event creation
- Persistent URLs that work across restarts
- Simplified debugging with predictable endpoints
- Reduced infrastructure complexity and costs
Performance Metrics
Latency Tracking:- WebRTC typically achieves sub-500ms end-to-end latency
- SRS optimizations reduce buffering to sub-100ms
- Real-time interaction feels instantaneous for audiences
- Single SRS instance handles 100+ concurrent streams
- nginx proxy distributes load across multiple SRS instances
- Filecoin storage removes local storage constraints
HLS Output Integration
Storage Service Integration
SRS outputs HLS segments that trigger the storage service:Chunk Processing
Segment Aggregation:- SRS outputs 10-second HLS segments
- Storage service combines 6 segments into 60-second chunks
- FFmpeg processes and optimizes video quality
- Filecoin storage provides permanent preservation
Security Considerations
Access Control
Stream Publishing:- Only event creators can publish to their
eventIdstream - Frontend validates creator status before allowing publish attempts
- SRS configuration can add IP-based restrictions if needed
- Ticket ownership verified before generating WHEP URLs
- Room-level access control prevents unauthorized viewing
- WebRTC encryption provides secure transmission
Browser Optimization
Connection Management:- Reuse WebRTC connections when possible
- Implement connection pooling for multiple events
- Graceful degradation for connection failures
- Automatic quality adjustment based on connection speed
- Manual quality selection for user preference
- Fallback to lower bitrates during congestion