Phone events #994 - #1012
Draft
xnorpx wants to merge 1 commit into
Draft
Conversation
Collaborator
Author
xnorpx
force-pushed
the
dev/phone_events
branch
2 times, most recently
from
July 18, 2026 16:52
dc11006 to
96dab49
Compare
efer-ms
reviewed
Aug 13, 2026
| fn is_marker(&mut self, _data: &[u8], _previous: Option<&[u8]>, _last: bool) -> bool { | ||
| // The marker bit for the first packet of a new event is set by the | ||
| // caller via the start-of-talkspurt mechanism. | ||
| false |
Contributor
There was a problem hiding this comment.
is this comment accurate? shouldn't this be true for the first packet representing an event?
efer-ms
reviewed
Aug 13, 2026
| /// Emitted once per completed tone received on a negotiated | ||
| /// `telephone-event` payload type. Enable telephone events with | ||
| /// [`CodecConfig::enable_telephone_event`][crate::format::CodecConfig::enable_telephone_event]. | ||
| DtmfEvent(DtmfEvent), |
Contributor
There was a problem hiding this comment.
I'm not clear when this fires. I assume you want to capture the start of the dtmf tone and the end. not just emit when it's complete, but I could be wrong. So maybe you emit a Dtmf event for tone start and another for tone end?
Owner
There was a problem hiding this comment.
It's 2026 and we are pondering DTMF.
I feel old :)
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 to review
This PR adds opt-in support for RFC 4733 telephone events, primarily DTMF tones.
1. Configuration and negotiation
Telephone events are disabled by default and enabled with:
When enabled, str0m adds
telephone-event/8000to audio m-lines using dynamic payload type 126. PT 126 was selected because it does not collide with the existing default codec or RTX payload types.The generated SDP contains:
The
fmtprange is parsed into a compact bitset. Each media line remembers the payload type and event codes accepted by the remote endpoint.2. Sending a tone
Applications send a tone through the existing media writer:
Before queueing the tone, str0m checks that:
telephone-event.Invalid requests return
UnknownPtorUnsupportedDtmfEvent.3. RTP generation
write_dtmfcreates aDtmfToneand places it in a FIFO sender queue.The sender generates one four-byte telephone-event payload every 20 ms:
Events longer than the 16-bit duration field are divided into contiguous RFC 4733 segments. Each segment gets the correct RTP timestamp and wallclock mapping.
4. Receiving a tone
Incoming telephone-event packets use a pass-through depacketizer and are delivered immediately. They are not held for missing sequence numbers because telephone events share sequence numbers with regular audio, so gaps are expected.
The payload parser handles one or more packed four-byte events using a zero-allocation iterator.
The receiver then:
5. Application event
In frame mode, raw telephone-event media is consumed internally and surfaced once as:
The event contains both the raw RFC event code and an optional decoded
Dtmfvalue.In RTP mode, packets continue to be exposed as raw
RtpPacketevents without aggregation.6. Scheduling
DTMF packet deadlines participate in the normal
Rtc::poll_outputtimeout calculation. When multiple media lines have queued tones, the earliest deadline is selected.Testing
The test coverage includes: