Skip to main content

Module dtmf

Module dtmf 

Source
Expand description

DTMF as named telephone events (RFC 4733).

A keypress is not audio. Sending it as audio works over a clean codec and falls apart the moment anything transcodes, so RFC 4733 carries the digit instead, in a four-byte payload on its own payload type.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     event     |E|R| volume    |          duration             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The part that is easy to get wrong is not the layout, it is the timing. One keypress is a run of packets that all share the RTP timestamp of the moment the tone started; the duration field grows while the digit is held. A sender that advances the timestamp per packet turns one keypress into a stream of separate digits, and the far end dials something nobody typed.

Structs§

Event
One telephone-event payload.
Receiver
Reassembles received events into digits.
TonePacket
One packet of a keypress: the event payload, plus where its segment sits in the event’s timeline.

Enums§

Digit
A DTMF digit.

Constants§

DEFAULT_PAYLOAD_TYPE
The conventional payload type for telephone-event. Dynamic, so the SDP decides — this is only the value sipx offers.
END_RETRANSMISSIONS
How many copies of the final packet to send.
EVENT_LEN
How many bytes a telephone event occupies.

Functions§

tone
Build the packets for one keypress.