Skip to main content

Module g711

Module g711 

Source
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§

G711Codec
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.