Expand description
G.711 μ-law (PCMU) and A-law (PCMA) codecs.
All four functions are byte-for-byte conversions: one 16-bit PCM sample ↔ one 8-bit codeword. A 20 ms RTP frame at 8 kHz is therefore 160 samples / 160 bytes — no length surprises.
The tables follow ITU-T G.711; see
https://www.itu.int/rec/T-REC-G.711 for the recommendation and
https://en.wikipedia.org/wiki/G.711 for a readable summary.
Implementations are cross-checked against the reference vectors in
Sun Microsystems’ g711.c and SpanDSP’s reference.
G.711 lives in wavekat-core (not wavekat-sip) because codecs are
a consumer-layer choice — wavekat-sip deliberately stays
codec-agnostic; SDP advertises both PCMU and PCMA and the consumer
picks one after answering.
Enums§
- G711
Codec - Codec selection for a session. The wire payload-type number
(
0/8) is the canonical identifier; this enum is the typed version we pass around in code.
Constants§
- G711_
FRAME_ SAMPLES - Samples in a 20 ms G.711 frame (the standard RTP packetization interval).
- G711_
SAMPLE_ RATE - Sample rate of every static G.711 stream. The wire format does not carry the rate; both endpoints just know.
- PCMA_
PAYLOAD_ TYPE - SDP / RTP static payload type for A-law (G.711A).
- PCMU_
PAYLOAD_ TYPE - SDP / RTP static payload type for μ-law (G.711U).
Functions§
- alaw_
to_ linear - Decode one A-law byte to a 16-bit PCM sample.
- linear_
to_ alaw - Encode one 16-bit PCM sample to an A-law byte (G.711A).
- linear_
to_ ulaw - Encode one 16-bit PCM sample to a μ-law byte (G.711U).
- ulaw_
to_ linear - Decode one μ-law byte to a 16-bit PCM sample.