Real-Time Transport Protocol (RTP) Payload Format and File Storage Format for the Adaptive Multi-Rate (AMR) and Adaptive Multi-Rate Wideband (AMR-WB) Audio Codecs
obsoleted by
- rfc-4867 — RTP Payload Format and File Storage Format for the Adaptive Multi-Rate (AMR) and Adaptive Multi-Rate Wideband (AMR-WB) Audio Codecs
Extracted elements (31)
IP endpoints SHOULD NOT set the CMR based on packet loss or congestion because the far end may be a gateway to a non-IP radio network that needs the CMR field for radio-link optimization, and IP-side congestion should instead be signalled via RTCP and managed by the IP sender.
The built-in redundant retransmission scheme (including previous frame-blocks in subsequent payloads) provides equivalent functionality to RFC 2198 with less overhead and complexity in most cases. RFC 2198 is preferred only when the spread between primary and redundant encodings exceeds 5 frame times, or when a non-AMR codec is needed for the redundant encoding.
The Q (frame quality indicator) bit is included for interoperability with the ATM payload format (ITU-T I.366.2) and UMTS Iu interface transport formats. It enables damaged frames to be forwarded to the speech decoder for error concealment rather than being discarded, improving speech quality.
Two payload modes are provided: bandwidth-efficient packs all bits contiguously to minimize padding overhead, while octet-aligned aligns every field individually for implementation efficiency. Only octet-aligned mode supports the advanced robustness features: robust sorting, interleaving, and frame CRC.
AMR and AMR-WB are always distinct payload types in RTP. The extra comfort noise frame types native to GSM-EFR, IS-641, and PDC-EFR (included in the AMR frame type table) MUST NOT be used in this payload format because the standardized AMR codec only implements the general AMR SID frame type.
In a gateway scenario between non-IP (GSM/3GPP) and IP networks, the gateway MUST forward CMR values in both directions. For a GW-to-GW scenario, the gateway should forward the minimum of: the CMR received from the IP side, the CMR calculated from non-IP reception quality, and any CMR the gateway chooses for congestion control on the IP side.
A receiver MUST be prepared to receive any speech frame multiple times, in exact duplicates or different AMR rate modes. If multiple versions of the same speech frame are received, it is RECOMMENDED that the mode with the highest rate be used by the speech decoder.
Frame-blocks or speech frames lost in transmission MUST be stored as NO_DATA frames (FT=15) or SPEECH_LOST (FT=14, AMR-WB only) in complete frame-blocks in the storage format to maintain synchronization with the original media.
If receiving a ToC entry with a FT value in the range 9-14 for AMR or 10-13 for AMR-WB, the whole packet SHOULD be discarded to avoid loss of data synchronization in depacketization, which can cause severe degradation in speech quality.
If the calculated payload length based on session parameters and payload header fields does not match the received packet size, the receiver SHOULD discard the packet; decoding a packet with length-field errors can severely degrade speech quality.
If the recalculated CRC over received class A bits does not match the payload CRC, the receiver SHALL consider the class A bits damaged and MUST clear the Q flag (set to 0), causing the frame to be marked SPEECH_BAD or SID_BAD before passing to the speech decoder.
Implementations SHOULD support both bandwidth-efficient and octet-aligned mode for single channel to achieve basic interoperability. No operation mode is mandatory; interleaving, robust sorting, and frame-wise CRC are OPTIONAL.
In a multi-channel session with N channels and K frame-blocks per packet in bandwidth-efficient mode, there MUST be N*K entries in the ToC; the first N entries are from frame-block 1, the next N from frame-block 2, and so on.
It is RECOMMENDED that AMR or AMR-WB applications using this payload format employ congestion control suitable for real-time flows, such as equation-based congestion control for unicast applications (RFC 3448).
The CMR field MUST be set to 15 for packets sent to a multicast group. The encoder SHOULD ignore mode requests when sending to a multicast session but MAY use RTCP feedback as a hint that a mode change is needed.
The frame CRC MUST be calculated only over all class A bits of the frame; class B and C bits MUST NOT be included in the CRC calculation and SHOULD NOT be covered by the transport-layer checksum.
The RTP header marker bit (M) SHALL be set to 1 if the first frame-block in the packet contains a speech frame that is the first in a talkspurt; for all other packets the marker bit SHALL be set to zero.
The RTP timestamp corresponds to the sampling instant of the first sample of the first frame-block in the packet. The timestamp is increased by 160 for AMR (8 kHz sampling) and by 320 for AMR-WB (16 kHz sampling) for each consecutive 20 ms frame-block.
The sender MUST only apply interleaving if the receiver has signalled its use out-of-band. When performing interleaving, the sender MUST use frame-block counts (N) and ILL such that N*(L+1) <= I, where I is the receiver's declared maximum interleave group size.
The CMR (Codec Mode Request) is a 4-bit field in the payload header. Values 0-7 (AMR) or 0-8 (AMR-WB) indicate the requested speech mode; CMR=15 indicates no mode request; other values are reserved. The CMR is valid until the next CMR is received.
The Table of Contents (ToC) consists of one entry per speech frame. Each entry carries: F (1 bit, more frames follow), FT (4 bits, frame type index including SID, SPEECH_LOST, or NO_DATA), and Q (1 bit, frame quality indicator set to 0 for severely damaged frames).
MIME type audio/AMR registered for the Adaptive Multi-Rate codec, covering both RTP real-time transfer and storage file format. Optional RTP parameters include octet-align, mode-set, mode-change-period, mode-change-neighbor, maxptime, ptime, channels, interleaving, and robust-sorting.
MIME type audio/AMR-WB registered for the Adaptive Multi-Rate Wideband codec, covering both RTP real-time transfer and storage file format. Optional parameters mirror those for audio/AMR, adapted for the 9-mode AMR-WB codec operating at 16 kHz.
This payload format has no built-in security mechanisms; external mechanisms such as SRTP MAY be used. When UED/UEP is combined with encryption, stream ciphers without error-propagation are preferred because block ciphers may severely reduce error robustness of the robust-sorting scheme.
To prevent man-in-the-middle tampering, authentication mechanisms SHOULD protect the payload header, ToC, frame CRCs, RTP timestamp, sequence number, and marker bit in addition to speech bits. Combining UED/UEP with authentication is difficult because any bit error in covered bits will cause authentication failure.
Bandwidth-efficient mode payload: 4-bit CMR packed MSB-first into the first octet, followed immediately by 6-bit ToC entries (F|FT|Q) and speech data bits packed contiguously, with zero-bit padding at the end to achieve octet alignment of the complete payload.
Frame CRC in octet-aligned mode: 8-bit CRC (c0..c7) calculated over all class A bits using generator polynomial C(x) = 1 + x^2 + x^3 + x^4 + x^8 (binary: 101110001 MSB..LSB). One CRC per speech frame, placed as a list after the ToC entries; no CRC is present for FT=14 or FT=15 frames.
Octet-aligned mode payload header: 4-bit CMR followed by 4 reserved R bits (MUST be zero, MUST be ignored on receipt). If interleaving is signalled, an additional 8-bit interleaving header follows with 4-bit ILL (interleaving length = ILL+1 frame-blocks) and 4-bit ILP (interleaving index, 0 to ILL).
Storage format multi-channel header: magic number '#!AMR_MC1.0\n' or '#!AMR-WB_MC1.0\n' followed by a 32-bit channel description field; bits 0-27 are reserved (write zero, ignore on read) and bits 28-31 (CHAN, 4-bit unsigned) indicate the number of audio channels.
Storage format single-channel file header: AMR magic number '#!AMR\n' (0x2321414d520a) or AMR-WB magic number '#!AMR-WB\n' (0x2321414d522d57420a). The trailing '\n' is a required part of the magic number and must be included in comparisons.
Storage format speech frame: one-octet header (P|FT|Q|P|P) followed by speech bits in the same bit order as bandwidth-efficient RTP mode, with the last octet zero-padded to achieve octet alignment. Frame-blocks are stored consecutively in time with channels in ascending order.