dtmf

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package dtmf decodes SIP RTP out-of-band DTMF (RFC 2833 / RFC 4733 telephone-event).

Requirements:

  • The remote SDP must offer a=rtpmap:PT telephone-event/8000 (or /48000); pkg/sip/session passes that payload type to the RTP input transport.
  • Key-up events are detected via the E (end) bit; in-band DTMF (audio tones) is not implemented.

SIP INFO: many clients (e.g. Linphone) send DTMF via INFO + application/dtmf-relay; use dtmf.DigitFromSIPINFO — handled in pkg/sip/server handleInfo → conversation.HandleSIPINFODTMF.

Env: SIP_TRANSFER_* for agent URI, SetTransferDialer in cmd/sip.

Package dtmf handles SIP RTP DTMF as telephone-event (RFC 2833 / RFC 4733).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachLogger

func AttachLogger(ms *media.MediaSession)

AttachLogger registers a processor that logs DTMF digits at info level.

func AttachProcessor

func AttachProcessor(ms *media.MediaSession, name string, h Handler)

AttachProcessor registers a high-priority processor that receives *media.DTMFPacket from the media session.

func DigitFromSIPINFO

func DigitFromSIPINFO(contentType, body string) (digit string, ok bool)

DigitFromSIPINFO extracts a DTMF digit from SIP INFO body (Linphone / many UAs use this instead of RTP). Supports:

  • application/dtmf-relay: "Signal=X\r\n" where X is 0-9, *, #
  • application/dtmf: "Signal=X"

If the body contains Signal=, it is parsed even when Content-Type is missing or non-dtmf.

func EventFromRFC2833

func EventFromRFC2833(payload []byte) (digit string, end bool, ok bool)

EventFromRFC2833 parses one telephone-event RTP payload. ok is false if payload is too short. end is the E (end) bit: callers should usually react on end==true to get one key press per digit.

Types

type Handler

type Handler func(ctx context.Context, digit string)

Handler is called for each completed DTMF key (typically when RFC 2833 E bit is set).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL