File: 24_dtmf_audio.t

package info (click to toggle)
libnet-sip-perl 0.838-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,132 kB
  • sloc: perl: 11,988; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 707 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl

use strict;
use warnings;
use Test::More;
use Net::SIP::DTMF qw(dtmf_generator dtmf_extractor);

my $duration = 10;
my @symbols = split //, '0123456789*#ABCD';
my %types = (pcmu => 0, pcma => 8);

foreach my $codec (qw(pcmu pcma)) {
	my @got;
	my $ext = dtmf_extractor(audio_type => $types{$codec});
	my $seq = 1;
	foreach my $symbol (@symbols, undef) {
		my $gen = dtmf_generator($symbol, $duration, audio_type => $types{$codec});
		while (my $rtp = $gen->($seq, $seq*$duration/8000, 0)) {
			$seq++;
			my ($event) = $ext->($rtp);
			push @got, $event if defined $event;
		}
	}
	is_deeply(\@got, \@symbols, "DTMF audio generator and extractor for codec $codec works");
}

done_testing();