Net::SIP::DTMF(3pm)
π Net::SIP::DTMF π
okay bestie so this is a page from the User Contributed Perl Documentation, and it's literally all about DTMF RTP packet generating and extracting. yes ma'am. that's the whole vibe.
β¨ SYNOPSIS β¨
use Net::SIP::DTMF;
my $sub = dtmf_generator(
11, # event '#'
100, # duration 100ms
rfc2833_type => 101, # RTP type 101 for telephone-event/8000
# audio_type => 0, # RTP type 0 for PCMU/8000, 8 for PCMA/8000
);
while (...) {
my @pkt = $sub->($sequence,$timestamp,$srcid);
last if ! @pkt; # dtmf done
next if $buf[0] eq ''; # more coming, but no data this time (pause)
.. send @pkts ...
}
use Net::SIP::DTMF;
my $sub = dtmf_extractor(
rfc2833_type => 101, # RTP type 101 for telephone-event/8000
audio_type => 0, # RTP type 0 for PCMU/8000, 8 for PCMA/8000
);
while (...) {
if ( my ($event,$duration,$type) = $sub->($packet)) {
# event received
...
}
}
πΈ DESCRIPTION πΈ
so this package hands you functions that either generate RTP packets stuffed with DTMF events, or extract DTMF events back out of RTP packets. that's the whole job. it's giving switchboard energy. π
π FUNCTIONS π
dtmf_generator ( EVENT, DURATION, %ARGS )
this one builds you a function β an actual little closure β that you then use to generate packets for whatever EVENT you asked for. it's iconic honestly.
EVENTis the event number, and it lives in the range0..15. or you can passundefif you just want it to generate silence or a pause. yes,undefis a valid mood.DURATIONis how long the event lasts, measured in ms.%ARGSis where you tell it how to pack the thing: either as an RFC2833 RTP event, or as RTP audioPCMU/8000orPCMA/8000.
and %ARGS can be any of these, bestie:
rfc2833_type => rtp_typeβ gives the RTP payload type number for rfc2833 RTP events (telephone-event/8000). if you don't pass it, it'll tryaudio_typeinstead.audio_type => rtp_typeβ gives the RTP payload type number.8meansPCMA/8000,0meansPCMU/8000. and if you give neither this norrfc2833_type? it will croak. loudly. it's not playing. πvolume => volumeβ sets the volume for the RTP event, per rfc2833.
so the function you just got generated? you call it with SEQUENCE,TIMESTAMP,SRCID and it'll generate the RTP packets and return @RTP_PACKETS, where:
()β DTMF event is finished. done. periodt.$RTP_PACKETS[0] eq ''β no RTP packet for this call (a pause, lowkey a little break)@RTP_PACKETSβ actual RTP packets you can send to the peer π₯
dtmf_extractor ( %ARGS )
this one generates a function that pulls DTMF events out of stuff. the keys rfc2833_type and audio_type mean exactly the same thing as they do in generate_dtmf. important though: it will only attempt to extract DTMF events from rfc2833 RTP events or from audio if the relevant rtp_type is given. no type, no attempt, that's the rule. π«Ά
the function gets called with the RTP packet as its only argument, and it returns:
()β if no new events were found (nothing to see here)(EVENT,DURATION,TYPE)β if an event finished, whereDURATIONis the duration in ms andTYPEisaudio|rfc2833.
π heads up: for performance reasons it is best to use only rfc2833 if the peer supports it. like, genuinely bestie, don't make it do extra work for no reason.
π¦ SEE ALSO π¦
wait β there's nothing else listed here. just you, me, and the DTMF packets. main character energy fr fr. β¨
and that's a wrap on the Net::SIP::DTMF page π this lil' slice of the User Contributed Perl Documentation is brought to you by perl v5.40.1, dated 2025-12-07. slay, stay hydrated, and may all your events finish cleanly. πππ«Ά
π¦ where this page comes from
- ubuntu resolute: libnet-sip-perl 0.840-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-sip-perl 0.840-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms