Conversation
xnorpx
commented
Jun 28, 2026
| Opus, | ||
| PCMU, | ||
| PCMA, | ||
| /// AMR Wideband (RFC 4867), 16 kHz mono telephony/IMS audio. |
xnorpx
commented
Jun 28, 2026
| pub max_red: Option<u32>, | ||
|
|
||
| /// AMR-WB specific parameter (RFC 4867). | ||
| /// |
Collaborator
Author
There was a problem hiding this comment.
make it clearer this is just for parsing and we don't support it
xnorpx
commented
Jun 28, 2026
| } | ||
|
|
||
| if c0.channels != c1.channels { | ||
| if !Self::channels_match(c0, c1) { |
Collaborator
Author
There was a problem hiding this comment.
not related, leave alone
xnorpx
commented
Jun 28, 2026
| return true; | ||
| } | ||
|
|
||
| if c0.codec == Codec::AmrWb && c1.codec == Codec::AmrWb { |
xnorpx
commented
Jun 28, 2026
| return None; | ||
| } | ||
|
|
||
| // Interleaving and robust sorting add RTP payload fields/layouts that |
Collaborator
Author
There was a problem hiding this comment.
put these higher up?
xnorpx
commented
Jun 28, 2026
| pub const FORTY_EIGHT_KHZ: Frequency = Self::make(48_000); | ||
|
|
||
| /// Cycles in a second of a 16 kHz signal. | ||
| pub const SIXTEEN_KHZ: Frequency = Self::make(16_000); |
Collaborator
Author
There was a problem hiding this comment.
will be available in G.722
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not ready, need more iterations
Architecture / mental model
This change adds an AMR-WB RTP payload adapter, not an AMR-WB encoder or decoder. Applications provide and receive already encoded 3GPP IF frames; str0m negotiates the supported transport profile and converts between IF frames and RFC 4867 RTP payloads.
There are three representations to keep distinct:
CodecSpecandFormatParamsdescribe the negotiated payload shape.FT/Qheader followed by encoded speech bytes.flowchart LR subgraph Control["Control plane: SDP negotiation"] Config["CodecConfig<br/>PT 122, 16 kHz, mono"] Params["FormatParam / FormatParams"] Gate["AMR-WB compatibility gate"] Spec["Negotiated CodecSpec"] Config --> Params --> Gate --> Spec end subgraph Send["Send path"] Writer["Writer::write<br/>one 3GPP IF frame + MediaTime"] Payloader["Payloader<br/>select negotiated layout"] Packetizer["AmrWbPacketizer<br/>IF frame -> RFC 4867 payload"] RTPOut["RTP / SRTP"] Writer --> Payloader --> Packetizer --> RTPOut end subgraph Receive["Receive path"] RTPIn["RTP / SRTP"] Buffer["DepacketizingBuffer"] Depacketizer["AmrWbDepacketizer<br/>RFC 4867 -> IF frames"] Event["Event::MediaData"] RTPIn --> Buffer --> Depacketizer --> Event end Spec -. configures .-> Payloader Spec -. configures .-> DepacketizerControl plane
enable_amr_wb(true)adds an opt-in mono codec configuration using dynamic PT 122, a 16 kHz RTP clock, and the common IMS/VoLTE format:The SDP layer parses AMR-WB parameters into typed
FormatParams. Compatibility matching then accepts only configurations the packet layer can actually process. Parameters that change the wire format must match and are echoed unchanged in the answer.Unsupported or malformed configurations are declined rather than negotiated and misdecoded. This includes CRC, interleaving, robust sorting, multiple channels, restricted mode sets, and unsupported mode-change constraints.
Send path
Each
Writer::writecall must contain exactly one 3GPP IF frame and one media timestamp. AMR-WB frames represent 20 ms, or 320 ticks at 16 kHz, so accepting concatenated frames would make timestamp ownership ambiguous.The packetizer:
NO_DATA;The generic RTP layer supplies sequence numbers, the rebased 16 kHz timestamp, extensions, and the talkspurt marker.
Receive path
Incoming RTP is mapped to the negotiated payload type, and the depacketizer is configured from the same
octet-alignsetting as the sender.Unlike the send API, the receiver accepts valid compound RFC 4867 payloads because remote peers may place multiple ToC entries in one RTP packet. These are returned as concatenated IF frames in
Event::MediaData.The receiver rejects reserved frame types, truncated speech data, unexpected trailing octets, and nonzero terminal padding.
Code map
A useful review order is: SDP compatibility rules → packet conversion → runtime wiring → integration and malformed-input tests.