WebRTC Audio Codec and Processing Requirements
Extracted elements (21)
No specific AEC algorithm or standard is mandated because the dominant WebRTC use case (notebook with built-in microphone and speakers) presents challenging echo cancellation problems without a single universally applicable remedy. AEC is RECOMMENDED but not required.
Opus is RECOMMENDED to be offered before PCMA/PCMU for endpoints supporting sampling rates above 8 kHz because Opus provides higher quality, includes its own comfort noise mechanism, and natively supports wideband and fullband audio — making G.711 fallback unnecessary when both sides support Opus.
The target audio level of -19 dBm0 aligns with ITU-T G.169 and G.115 recommendations. However, frequency normalization above 300 Hz (rather than the G.712 passband) is required because WebRTC audio is not constrained to the G.712 passband and can be sampled at 8–48 kHz or higher.
The mandatory codec requirements (Opus and G.711 PCMA/PCMU) ensure a minimum level of voice interoperability between WebRTC endpoints and legacy phone systems that support G.711, without requiring audio transcoding.
A local endpoint MAY include a far-end echo canceller for cases where the remote endpoint lacks one, but when included, it SHOULD be disabled by default.
All Opus decoder modes MUST be supported on the decoder side; the choice of encoder-side modes is left to the implementer. Endpoints MAY use offer/answer to signal a preference for a particular mode or ptime.
DTMF events generated by a WebRTC endpoint MUST have a duration between 40 ms and 8000 ms (recommended default 100 ms), and the gap between events MUST be no less than 30 ms (recommended default 70 ms).
Endpoints SHOULD allow the AEC and/or nonlinear processing (NLP) to be turned off for applications such as music, and SHOULD detect the presence of a headset and disable echo cancellation in that case.
Endpoints SHOULD suppress in-band DTMF tones when sending 'audio/telephone-event' events. Endpoints receiving RFC 4733 tones are only required to gracefully drop them; there is no API to inform JavaScript of received DTMF.
For endpoints capable of processing audio at sampling rates higher than 8 kHz, Opus SHOULD be offered before PCMA/PCMU in the SDP offer to prefer higher-quality wideband audio.
For music or desktop-sharing applications, the audio level SHOULD NOT be automatically adjusted, and the endpoint SHOULD allow the user to set gain manually. Endpoints MAY increase gain before playback to compensate for devices calibrated for commercial music.
If a WebRTC endpoint controls the entire audio-capture path, it is RECOMMENDED that gain be adjusted so an average speaker produces an RMS of 2600 (-19 dBm0). Software endpoints that do not control the full capture path SHOULD use AGC to dynamically adjust to 2600 +/- 6 dB.
The audio level for speech transmission SHOULD be normalized to -19 dBm0, considering only frequencies above 300 Hz regardless of sampling rate. The level SHOULD be adapted to avoid clipping, either by lowering gain or using a compressor.
WebRTC endpoints are REQUIRED to implement Opus (RFC 6716 with RFC 7587 payload format), PCMA and PCMU (G.711 with RFC 3551 payload format), RFC 3389 comfort noise, and the 'audio/telephone-event' media type (RFC 4733). These form the mandatory baseline codec set.
WebRTC endpoints MUST support RFC 3389 comfort noise (CN) for streams encoded with G.711 or any other supported codec that does not provide its own CN. Use of RFC 3389 CN with Opus is NOT RECOMMENDED because Opus provides its own CN mechanism.
WebRTC endpoints SHOULD include acoustic echo cancellation (AEC) or another form of echo control. Endpoint AECs SHOULD be robust to ADC/DAC clock differences (e.g., webcam capture with separate soundcard playback), unless hardware guarantees a shared clock.
DTMF events 0–15 are REQUIRED to be generated and consumed by WebRTC endpoints: digits 0–9 (codes 0–9), '*' (code 10), '#' (code 11), and letters A–D (codes 12–15), all as defined in RFC 4733.
The mandatory WebRTC audio codec set consists of: Opus (RFC 6716/RFC 7587), G.711 PCMA and PCMU (ITU-T G.711/RFC 3551), RFC 3389 comfort noise, and RFC 4733 telephone-event DTMF. Additional codecs SHOULD be offered when available to maximize session establishment without transcoding.
The recommended signal-energy normalization filter is a second-order Butterworth filter with a 300 Hz cutoff frequency, used to exclude low-frequency content when computing the -19 dBm0 active-speech RMS level.
Implementers should consult RFC 6562 guidelines to determine whether variable bitrate (VBR) audio is appropriate for their application, as VBR can leak information about audio content through packet size patterns even when encrypted.
Security considerations for the individual codecs are addressed in their respective specifications (RFC 6716, RFC 7587, RFC 3551, RFC 3389, RFC 4733). Encryption and authentication are out of scope for this document; implementers should consult the WebRTC security documents.