Mandated Audio Codecs in WebRTC
This article provides a clear overview of the audio codecs that are natively supported and mandated by the WebRTC (Web Real-Time Communication) specification. To ensure seamless, cross-browser interoperability without requiring external plugins, the Internet Engineering Task Force (IETF) has established strict baseline requirements for audio codecs that every WebRTC-compliant browser and device must implement.
According to RFC 7874, there are two primary audio codecs mandated for all WebRTC endpoints: Opus and G.711.
1. Opus (The Default Standard)
Opus is the primary, default audio codec for WebRTC. It is a highly versatile, open-source, and royalty-free codec designed specifically for interactive speech and music transmission over the internet.
- Adaptability: Opus can seamlessly adapt to varying network conditions. It supports both constant bitrate (CBR) and variable bitrate (VBR) encoding from 6 kbps to 510 kbps.
- Audio Quality: It handles everything from low-bandwidth narrowband voice (8 kHz) to high-fidelity fullband stereo audio (48 kHz).
- Latency and Robustness: Opus features very low algorithmic delay (typically 20 ms) and built-in forward error correction (FEC) to mitigate packet loss over unstable networks.
2. G.711 (Legacy Compatibility)
G.711 is a legacy, narrowband waveform audio codec operating at 64 kbps. The WebRTC specification mandates support for both of its primary companding algorithms: * PCMU (ยต-law): Primarily used in North America and Japan. * PCMA (A-law): Primarily used in Europe and the rest of the world.
While G.711 offers lower audio quality compared to Opus, its inclusion is mandatory to guarantee backward compatibility with the Public Switched Telephone Network (PSTN) and legacy Voice over IP (VoIP) systems.
Additional Requirements
In addition to Opus and G.711, the WebRTC specification requires endpoints to support: * DTMF (Dual-Tone Multi-Frequency): Mandated via RFC 4733 tones for touch-tone telephone interaction. * Comfort Noise (CN): Mandated via RFC 3389 to generate artificial background noise during silence suppression, ensuring users do not think the call has dropped.