dtmf

package
v0.0.0-...-ea94ab3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const SDPName = "telephone-event/8000"
View Source
const SampleRate = 8000

Variables

This section is empty.

Functions

func Encode

func Encode(out []byte, ev Event) (int, error)

func Tone

func Tone(digit byte) (code byte, freq []tones.Hz)

Tone returns DTMF tone frequencies for a given digit.

func Write

func Write(ctx context.Context, audio media.Writer[media.PCM16Sample], events *rtp.Stream, startTs uint32, digits string) error

Write in-band (analog) and off-band (digital) DTMF tones to audio and RTP streams respectively.

Digits may contain a special character 'w' which adds a 0.5 sec delay.

Types

type Event

type Event struct {
	Code   byte
	Digit  byte
	Volume byte   // in dBm0 (without sign)
	Dur    uint16 // in timestamp units
	End    bool
}

func Decode

func Decode(data []byte) (Event, error)

func DecodeRTP

func DecodeRTP(h *rtp.Header, payload []byte) (Event, bool)

func DecodeRTPWithEnd

func DecodeRTPWithEnd(h *rtp.Header, payload []byte) (Event, bool)

DecodeRTPWithEnd decodes a DTMF event from an RTP packet using both the Marker bit and the End bit to determine event completion. This is useful for SIP providers that may or may not set the Marker bit. See RFC 4733 §2.3.1.

type Handler

type Handler func(ev Event)

type Writer

type Writer interface {
	WriteDTMF(ctx context.Context, ev string) error
}

Jump to

Keyboard shortcuts

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