RTCDTMFSender

DTMF tones sent over an audio sender.

class webrtc.interfaces.rtc_dtmf_sender.RTCDTMFSender(native_obj=None)

Sends DTMF (telephone keypad) tones over an audio sender, from webrtc.RTCRtpSender.dtmf.

See MDN: RTCDTMFSender.

Events:

tonechange (webrtc.RTCDTMFToneChangeEvent) – A tone started playing, or the last one ended (with an empty tone).

Events

Handlers are registered with on().

insert_dtmf(tones, duration=100, inter_tone_gap=70)

Queues tones to play, replacing the ones not played yet.

Durations and gaps out of range are clamped to the nearest limit.

See MDN: RTCDTMFSender/insertDTMF.

Parameters:
  • tones (str) – The tones: 0 to 9, A to D (any case), #, *, and , for a 2-second pause. An empty string cancels the tones not played yet.

  • duration (int, optional) – The length of each tone in milliseconds, clamped to 40 to 6000.

  • inter_tone_gap (int, optional) – The pause after each tone in milliseconds, clamped to 30 to 6000.

Raises:
property tone_buffer: str

The tones not played yet, in upper case.

See MDN: RTCDTMFSender/toneBuffer.

Type:

str

property can_insert_dtmf: bool

Whether tones can be sent.

That needs the sender to be negotiated to send with a telephone-event codec. See MDN: RTCDTMFSender/canInsertDTMF.

Type:

bool