Net::SIP::DTMF(3pm) | User Contributed Perl Documentation | Net::SIP::DTMF(3pm) |
Net::SIP::DTMF - DTMF RTP packet generating and extracting
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 ... } }
This package provides functions for generating RTP packets containing DTMF events or extracting DTMF events from RTP packets.
EVENT is the event numer (0..15) or undef if it should just generate silence or pause. DURATION is the time for the event in ms. ARGS contain information how the event should be packed: either as RFC2833 RTP event or as RTP audio PCMU/8000 or PCMA/8000. %ARGS can be
The generated function should then be called with SEQUENCE,TIMESTAMP,SRCID to generate the RTP packets and will return @RTP_PACKETS, with
The function will be called with the RTP packet as the only argument and will return () if no new events where found or (EVENT,DURATION,TYPE) if an event finished, where DURATION is the duration in ms and TYPE is audio|rfc2833.
For performance reasons it is best to use only rfc2833 if the peer supports it.
2023-02-04 | perl v5.36.0 |