One source, multiple protocols, global reach
Enable all protocols with one API call
import { WaveClient } from '@wave/sdk';
import { DesignTokens, getContainer, getSection } from '@/lib/design-tokens';
const wave = new WaveClient({
apiKey: process.env.WAVE_API_KEY
});
// Create multi-protocol stream
const stream = await wave.streams.create({
title: 'Global Event Stream',
protocols: ['webrtc', 'srt', 'rtmp', 'ndi'],
settings: {
// WebRTC for browser viewers (<500ms latency)
webrtc: {
quality: 'uhd',
codec: 'vp9',
enable_simulcast: true
},
// SRT for reliable contribution (<2s latency)
srt: {
latency_ms: 1000,
encryption: true,
mode: 'caller'
},
// RTMP for legacy compatibility (<5s latency)
rtmp: {
codec: 'h264',
bitrate: '5000k'
},
// NDI for production workflows (<100ms)
ndi: {
source_name: 'WAVE-MULTI',
enable_tally: true,
bandwidth: 'high'
}
}
});
console.log('WebRTC URL:', stream.webrtc_url);
console.log('SRT URL:', stream.srt_url);
console.log('RTMP URL:', stream.rtmp_url);
console.log('NDI Source:', stream.ndi_source);Choose the right protocol for each use case
| Protocol | Latency | Best For | Quality | Business Value |
|---|---|---|---|---|
| WebRTC | <500ms | Browser viewers, real-time interaction | HD to UHD | 42% more engagement with sub-500ms latency. Enables interactive monetization (polls, auctions) |
| SRT | 1-3s | Contribution feeds, unreliable networks | Broadcast quality | Save $100K+/yr on backup infrastructure. 99.99% uptime without expensive redundancy |
| RTMP | 3-10s | Legacy encoders, social platforms | SD to HD | Zero encoder changes. Works with 100+ legacy systems. Drop-in replacement for existing setups |
| NDI | <100ms | Production, studio workflows | Uncompressed | Eliminate $20K-50K transcoding infrastructure. Reduce production setup by 12+ hours |
Serve optimized streams based on viewer capabilities
// Smart protocol selection based on viewer
async function getOptimalPlaybackUrl(
streamId: string,
viewerContext: ViewerContext
) {
const stream = await wave.streams.get(streamId);
// Browser with WebRTC support
if (viewerContext.browser && viewerContext.webrtc_supported) {
return stream.webrtc_url; // <500ms latency
}
// Professional broadcast equipment
if (viewerContext.equipment === 'broadcast') {
return stream.ndi_source; // <100ms, full quality
}
// Reliable connection needed
if (viewerContext.network_reliability < 0.8) {
return stream.srt_url; // FEC enabled
}
// Fallback to RTMP for legacy
return stream.rtmp_url;
}Track performance across all protocols
// Get analytics for all protocols
const analytics = await wave.analytics.get(streamId, {
breakdown_by: 'protocol',
metrics: ['viewers', 'latency', 'bitrate', 'errors']
});
analytics.protocols.forEach(protocol => {
console.log(`${protocol.name}:`);
console.log(` Viewers: ${protocol.viewers}`);
console.log(` Avg Latency: ${protocol.latency_ms}ms`);
console.log(` Bitrate: ${protocol.bitrate}`);
console.log(` Error Rate: ${protocol.error_rate}%`);
});
// Output:
// webrtc:
// Viewers: 12,453
// Avg Latency: 287ms
// Bitrate: 2.4 Mbps
// Error Rate: 0.02%
// srt:
// Viewers: 156
// Avg Latency: 1,245ms
// Bitrate: 8.5 Mbps
// Error Rate: 0.01%