dtmf

package
v0.0.0-...-67dd4ed Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 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)

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