From efcd137dbf2a39bb35666b5942e22b8e55eda119 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 6 Oct 2021 14:43:13 -0400 Subject: [PATCH] TT#136956 add tests for DTMF-security Change-Id: If94566bf4cef4c389e6dfbd068abcab3885fa77a --- t/Makefile | 12 +- t/auto-daemon-tests-delay-buffer.pl | 1289 +++++++++++++++++++++++++++ 2 files changed, 1299 insertions(+), 2 deletions(-) create mode 100755 t/auto-daemon-tests-delay-buffer.pl diff --git a/t/Makefile b/t/Makefile index a0217fe09..dd9d27183 100644 --- a/t/Makefile +++ b/t/Makefile @@ -88,7 +88,7 @@ include ../lib/common.Makefile .PHONY: all-tests unit-tests daemon-tests daemon-tests \ daemon-tests-main daemon-tests-jb daemon-tests-dtx daemon-tests-dtx-cn daemon-tests-pubsub \ - daemon-tests-intfs daemon-tests-stats + daemon-tests-intfs daemon-tests-stats daemon-tests-delay-buffer TESTS= test-bitstr aes-crypt aead-aes-crypt test-const_str_hash.strhash ifeq ($(with_transcoding),yes) @@ -111,7 +111,7 @@ unit-tests: $(TESTS) for x in $(TESTS); do echo testing: $$x; G_DEBUG=fatal-warnings ./$$x || exit 1; done daemon-tests: daemon-tests-main daemon-tests-jb daemon-tests-pubsub daemon-tests-websocket \ - daemon-tests-intfs daemon-tests-stats + daemon-tests-intfs daemon-tests-stats daemon-tests-delay-buffer daemon-test-deps: tests-preload.so $(MAKE) -C ../daemon @@ -180,6 +180,14 @@ daemon-tests-intfs: daemon-test-deps test "$$(ls fake-$@-sockets)" = "" rmdir fake-$@-sockets +daemon-tests-delay-buffer: daemon-test-deps + rm -rf fake-$@-sockets + mkdir fake-$@-sockets + LD_PRELOAD=../t/tests-preload.so RTPE_BIN=../daemon/rtpengine TEST_SOCKET_PATH=./fake-$@-sockets \ + perl -I../perl auto-daemon-tests-delay-buffer.pl + test "$$(ls fake-$@-sockets)" = "" + rmdir fake-$@-sockets + test-bitstr: test-bitstr.o spandsp_send_fax_pcm: spandsp_send_fax_pcm.o diff --git a/t/auto-daemon-tests-delay-buffer.pl b/t/auto-daemon-tests-delay-buffer.pl new file mode 100755 index 000000000..948241cef --- /dev/null +++ b/t/auto-daemon-tests-delay-buffer.pl @@ -0,0 +1,1289 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use NGCP::Rtpengine::Test; +use NGCP::Rtpclient::SRTP; +use NGCP::Rtpengine::AutoTest; +use Test::More; +use NGCP::Rtpclient::ICE; +use POSIX; + + +autotest_start(qw(--config-file=none -t -1 -i 203.0.113.1 + -n 2223 -c 12345 -f -L 7 -E -u 2222 --silence-detect=1)) + or die; + + +my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $ssrc_b, $resp, + $sock_ax, $sock_bx, $port_ax, $port_bx, + $srtp_ctx_a, $srtp_ctx_b, $srtp_ctx_a_rev, $srtp_ctx_b_rev, $ufrag_a, $ufrag_b, + @ret1, @ret2, @ret3, @ret4, $srtp_key_a, $srtp_key_b, $ts, $seq, $rseq, $sseq); + + + + + +($sock_a, $sock_b) = new_call([qw(198.51.100.1 2000)], [qw(198.51.100.1 3000)]); + +($port_a) = offer('PCM DTMF block', { }, < ft(), 'DTMF-security' => 'tone', 'delay-buffer' => 1 }); + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb0\xac\xbc\x4c\x39\x3f\x63\xee\x55\x4a\xf6\xba\xaf\xbc\x45\x2c\x2d\x4b\xba\xaf\xbb\x6e\x48\x53\xf3\x5f\x3f\x3a\x52\xba\xac\xb3\x5e\x2f\x2d\x3e\xc8\xb8\xc0\xe8\x6b\xd7\xcc\x66\x39\x30\x3f\xbf\xac\xae\xd2\x37\x2f\x3c\xe1\xc6\xd2\x77\xdd\xbf\xbb\xdc\x38\x2c\x35\xd1\xae\xad\xc2\x43\x37\x40\x6e\xe7\x58\x4e\xdd\xb8\xb1\xc3\x3d\x2b\x2f\x5e\xb5\xaf\xbe\x59\x44\x51\xfb\x5b\x3f\x3d\x6b\xb6\xac\xb8\x4a\x2d\x2d\x47\xbf\xb6\xc1\xfa\x63\xda\xd1\x57\x37\x32\x49\xba\xab\xb0\xfe\x33\x2f\x40\xd2\xc2\xd1\x7e\xda\xbf\xbe\x73\x35\x2d\x3a\xc4\xac\xae\xcd\x3d\x36\x43\xf6\xdf\x5c\x55\xd2\xb7\xb4\xce\x37\x2b\x32\xdf\xb1\xaf\xc3\x4d\x41\x50\x7e\x59\x40")); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb0\xac\xbc\x4c\x39\x3f\x63\xee\x55\x4a\xf6\xba\xaf\xbc\x45\x2c\x2d\x4b\xba\xaf\xbb\x6e\x48\x53\xf3\x5f\x3f\x3a\x52\xba\xac\xb3\x5e\x2f\x2d\x3e\xc8\xb8\xc0\xe8\x6b\xd7\xcc\x66\x39\x30\x3f\xbf\xac\xae\xd2\x37\x2f\x3c\xe1\xc6\xd2\x77\xdd\xbf\xbb\xdc\x38\x2c\x35\xd1\xae\xad\xc2\x43\x37\x40\x6e\xe7\x58\x4e\xdd\xb8\xb1\xc3\x3d\x2b\x2f\x5e\xb5\xaf\xbe\x59\x44\x51\xfb\x5b\x3f\x3d\x6b\xb6\xac\xb8\x4a\x2d\x2d\x47\xbf\xb6\xc1\xfa\x63\xda\xd1\x57\x37\x32\x49\xba\xab\xb0\xfe\x33\x2f\x40\xd2\xc2\xd1\x7e\xda\xbf\xbe\x73\x35\x2d\x3a\xc4\xac\xae\xcd\x3d\x36\x43\xf6\xdf\x5c\x55\xd2\xb7\xb4\xce\x37\x2b\x32\xdf\xb1\xaf\xc3\x4d\x41\x50\x7e\x59\x40")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x40\xe0\xb3\xad\xbd\x3f\x2c\x2f\x54\xbb\xb5\xc4\x6b\x5d\xde\xd9\x4e\x37\x35\x58\xb5\xab\xb4\x52\x2f\x2f\x47\xca\xbf\xd0\xfe\xd8\xc1\xc3\x57\x32\x2e\x40\xbc\xab\xb0\xe0\x39\x35\x46\xe3\xdb\x61\x5d\xcc\xb7\xb7\xe8\x33\x2b\x37\xcb\xae\xb0\xcb\x46\x3f\x50\x7e\x58\x41\x46\xcf\xb1\xae\xc6\x39\x2b\x31\x7d\xb7\xb5\xc8\x5d\x58\xe5\xe1\x4a\x37\x38\xf2\xb1\xab\xba\x44\x2e\x30\x4f\xc3\xbe\xd1\x7d\xd8\xc3\xc9\x4b\x30\x2f\x4c\xb6\xab\xb3\x61\x35\x35\x4b\xd8\xd6\x68\x68\xc8\xb7\xba\x5d\x30\x2c\x3c\xbf\xad\xb1\xd8\x40\x3e\x52\xfb\x58\x44\x4c\xc8\xb0\xb0\xd6\x34\x2b\x35\xd5\xb3\xb5\xcd\x54\x54\xec\xef\x47\x37\x3c\xd3\xaf\xac\xc0\x3c\x2d\x33\x63\xbe")); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x40\xe0\xb3\xad\xbd\x3f\x2c\x2f\x54\xbb\xb5\xc4\x6b\x5d\xde\xd9\x4e\x37\x35\x58\xb5\xab\xb4\x52\x2f\x2f\x47\xca\xbf\xd0\xfe\xd8\xc1\xc3\x57\x32\x2e\x40\xbc\xab\xb0\xe0\x39\x35\x46\xe3\xdb\x61\x5d\xcc\xb7\xb7\xe8\x33\x2b\x37\xcb\xae\xb0\xcb\x46\x3f\x50\x7e\x58\x41\x46\xcf\xb1\xae\xc6\x39\x2b\x31\x7d\xb7\xb5\xc8\x5d\x58\xe5\xe1\x4a\x37\x38\xf2\xb1\xab\xba\x44\x2e\x30\x4f\xc3\xbe\xd1\x7d\xd8\xc3\xc9\x4b\x30\x2f\x4c\xb6\xab\xb3\x61\x35\x35\x4b\xd8\xd6\x68\x68\xc8\xb7\xba\x5d\x30\x2c\x3c\xbf\xad\xb1\xd8\x40\x3e\x52\xfb\x58\x44\x4c\xc8\xb0\xb0\xd6\x34\x2b\x35\xd5\xb3\xb5\xcd\x54\x54\xec\xef\x47\x37\x3c\xd3\xaf\xac\xc0\x3c\x2d\x33\x63\xbe")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xbd\xd3\x77\xd9\xc5\xd0\x44\x30\x32\x65\xb2\xab\xb8\x4c\x32\x35\x50\xcf\xd2\x70\x7a\xc6\xb8\xbe\x4c\x2e\x2d\x45\xb9\xac\xb4\xfd\x3c\x3d\x55\xf2\x5a\x47\x56\xc1\xb0\xb4\x71\x30\x2b\x3a\xc7\xb0\xb6\xd7\x4d\x50\xf6\x78\x45\x38\x41\xc7\xae\xae\xcc\x37\x2c\x36\xe5\xbb\xbd\xd7\x6d\xdb\xc9\xdd\x3f\x30\x36\xdc\xae\xab\xbd\x41\x2f\x37\x5d\xcb\xcf\x7b\xef\xc4\xb9\xc6\x42\x2d\x2e\x55\xb4\xac\xb8\x58\x39\x3d\x59\xea\x5c\x4a\x66\xbd\xb0\xb8\x50\x2e\x2c\x40\xbd\xaf\xb8\xe8\x48\x4e\x7d\x6b\x43\x3a\x4a\xbf\xad\xaf\xe4\x32\x2c\x3a\xcf\xb8\xbd\xdc\x66\xde\xcc\xf5\x3c\x30\x3b\xca\xad\xac\xc6\x3b\x2e\x39\x7c\xc6\xcd\xfa\xe7\xc3\xbb\xce\x3c\x2d\x31\xf2")); +# replaced by tone +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +Time::HiRes::usleep(18000); $seq++; + +# gap + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +# still tone +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# disable blocking + +rtpe_req('unblock DTMF', 'PCM DTMF block', + { 'from-tag' => ft() }); + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# enable blocking + +rtpe_req('block DTMF', 'PCM DTMF block', + { 'from-tag' => ft(), 'DTMF-security' => 'tone', 'delay-buffer' => 100 }); + +# pre-send 100 ms worth of audio + +$rseq = $seq; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# start receiving + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +# start DTMF, interleaved with receiving older audio + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb0\xac\xbc\x4c\x39\x3f\x63\xee\x55\x4a\xf6\xba\xaf\xbc\x45\x2c\x2d\x4b\xba\xaf\xbb\x6e\x48\x53\xf3\x5f\x3f\x3a\x52\xba\xac\xb3\x5e\x2f\x2d\x3e\xc8\xb8\xc0\xe8\x6b\xd7\xcc\x66\x39\x30\x3f\xbf\xac\xae\xd2\x37\x2f\x3c\xe1\xc6\xd2\x77\xdd\xbf\xbb\xdc\x38\x2c\x35\xd1\xae\xad\xc2\x43\x37\x40\x6e\xe7\x58\x4e\xdd\xb8\xb1\xc3\x3d\x2b\x2f\x5e\xb5\xaf\xbe\x59\x44\x51\xfb\x5b\x3f\x3d\x6b\xb6\xac\xb8\x4a\x2d\x2d\x47\xbf\xb6\xc1\xfa\x63\xda\xd1\x57\x37\x32\x49\xba\xab\xb0\xfe\x33\x2f\x40\xd2\xc2\xd1\x7e\xda\xbf\xbe\x73\x35\x2d\x3a\xc4\xac\xae\xcd\x3d\x36\x43\xf6\xdf\x5c\x55\xd2\xb7\xb4\xce\x37\x2b\x32\xdf\xb1\xaf\xc3\x4d\x41\x50\x7e\x59\x40")); +Time::HiRes::usleep(18000); $seq++; + +# still buffered silence + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x40\xe0\xb3\xad\xbd\x3f\x2c\x2f\x54\xbb\xb5\xc4\x6b\x5d\xde\xd9\x4e\x37\x35\x58\xb5\xab\xb4\x52\x2f\x2f\x47\xca\xbf\xd0\xfe\xd8\xc1\xc3\x57\x32\x2e\x40\xbc\xab\xb0\xe0\x39\x35\x46\xe3\xdb\x61\x5d\xcc\xb7\xb7\xe8\x33\x2b\x37\xcb\xae\xb0\xcb\x46\x3f\x50\x7e\x58\x41\x46\xcf\xb1\xae\xc6\x39\x2b\x31\x7d\xb7\xb5\xc8\x5d\x58\xe5\xe1\x4a\x37\x38\xf2\xb1\xab\xba\x44\x2e\x30\x4f\xc3\xbe\xd1\x7d\xd8\xc3\xc9\x4b\x30\x2f\x4c\xb6\xab\xb3\x61\x35\x35\x4b\xd8\xd6\x68\x68\xc8\xb7\xba\x5d\x30\x2c\x3c\xbf\xad\xb1\xd8\x40\x3e\x52\xfb\x58\x44\x4c\xc8\xb0\xb0\xd6\x34\x2b\x35\xd5\xb3\xb5\xcd\x54\x54\xec\xef\x47\x37\x3c\xd3\xaf\xac\xc0\x3c\x2d\x33\x63\xbe")); +Time::HiRes::usleep(18000); $seq++; + +# now replaced by tone + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xbd\xd3\x77\xd9\xc5\xd0\x44\x30\x32\x65\xb2\xab\xb8\x4c\x32\x35\x50\xcf\xd2\x70\x7a\xc6\xb8\xbe\x4c\x2e\x2d\x45\xb9\xac\xb4\xfd\x3c\x3d\x55\xf2\x5a\x47\x56\xc1\xb0\xb4\x71\x30\x2b\x3a\xc7\xb0\xb6\xd7\x4d\x50\xf6\x78\x45\x38\x41\xc7\xae\xae\xcc\x37\x2c\x36\xe5\xbb\xbd\xd7\x6d\xdb\xc9\xdd\x3f\x30\x36\xdc\xae\xab\xbd\x41\x2f\x37\x5d\xcb\xcf\x7b\xef\xc4\xb9\xc6\x42\x2d\x2e\x55\xb4\xac\xb8\x58\x39\x3d\x59\xea\x5c\x4a\x66\xbd\xb0\xb8\x50\x2e\x2c\x40\xbd\xaf\xb8\xe8\x48\x4e\x7d\x6b\x43\x3a\x4a\xbf\xad\xaf\xe4\x32\x2c\x3a\xcf\xb8\xbd\xdc\x66\xde\xcc\xf5\x3c\x30\x3b\xca\xad\xac\xc6\x3b\x2e\x39\x7c\xc6\xcd\xfa\xe7\xc3\xbb\xce\x3c\x2d\x31\xf2")); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +# back to silence + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# still tone + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# finally back to silence + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +# disable blocking + +rtpe_req('unblock DTMF', 'PCM DTMF block', + { 'from-tag' => ft(), 'delay-buffer' => 0 }); + +# buffer flushing + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +# sync forwarding + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + + + + + + +($sock_a, $sock_b) = new_call([qw(198.51.100.1 2002)], [qw(198.51.100.1 3002)]); + +($port_a) = offer('PCM DTMF block w transcoding', { codec => { transcode => ['PCMA'] } }, < ft(), 'DTMF-security' => 'tone', 'delay-buffer' => 1 }); + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb0\xac\xbc\x4c\x39\x3f\x63\xee\x55\x4a\xf6\xba\xaf\xbc\x45\x2c\x2d\x4b\xba\xaf\xbb\x6e\x48\x53\xf3\x5f\x3f\x3a\x52\xba\xac\xb3\x5e\x2f\x2d\x3e\xc8\xb8\xc0\xe8\x6b\xd7\xcc\x66\x39\x30\x3f\xbf\xac\xae\xd2\x37\x2f\x3c\xe1\xc6\xd2\x77\xdd\xbf\xbb\xdc\x38\x2c\x35\xd1\xae\xad\xc2\x43\x37\x40\x6e\xe7\x58\x4e\xdd\xb8\xb1\xc3\x3d\x2b\x2f\x5e\xb5\xaf\xbe\x59\x44\x51\xfb\x5b\x3f\x3d\x6b\xb6\xac\xb8\x4a\x2d\x2d\x47\xbf\xb6\xc1\xfa\x63\xda\xd1\x57\x37\x32\x49\xba\xab\xb0\xfe\x33\x2f\x40\xd2\xc2\xd1\x7e\xda\xbf\xbe\x73\x35\x2d\x3a\xc4\xac\xae\xcd\x3d\x36\x43\xf6\xdf\x5c\x55\xd2\xb7\xb4\xce\x37\x2b\x32\xdf\xb1\xaf\xc3\x4d\x41\x50\x7e\x59\x40")); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\xd5\x9b\x87\x97\x64\x10\x6b\x41\xdc\x73\x66\xd1\x91\x9a\x97\x6d\x07\x04\x67\x91\x9a\x96\x5c\x60\x7d\xd3\x4d\x6b\x11\x7c\x91\x87\x9e\x4f\x1a\x04\x15\xe0\x93\xe8\xda\x59\xf1\xe4\x44\x10\x1b\x6b\xeb\x87\x85\xfc\x12\x1a\x17\xc3\xe2\xfc\x51\xc9\xeb\x96\xcb\x13\x07\x1c\xff\x85\x84\xee\x6f\x12\x68\x5c\xc5\x76\x7b\xc9\x93\x98\xef\x14\x06\x1a\x4f\x9c\x9a\x95\x77\x6c\x7f\xd7\x75\x6b\x14\x59\x9d\x87\x93\x66\x04\x04\x63\xeb\x9d\xe9\xd7\x41\xf4\xff\x71\x12\x19\x61\x91\x86\x9b\xd5\x1e\x1a\x68\xfc\xee\xff\x55\xf4\xeb\x95\x53\x1c\x04\x11\xec\x87\x85\xe5\x14\x1d\x6f\xd1\xcd\x4b\x73\xfc\x92\x9f\xfb\x12\x06\x19\xcd\x98\x9a\xef\x65\x69\x7e\x55\x77\x68")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x40\xe0\xb3\xad\xbd\x3f\x2c\x2f\x54\xbb\xb5\xc4\x6b\x5d\xde\xd9\x4e\x37\x35\x58\xb5\xab\xb4\x52\x2f\x2f\x47\xca\xbf\xd0\xfe\xd8\xc1\xc3\x57\x32\x2e\x40\xbc\xab\xb0\xe0\x39\x35\x46\xe3\xdb\x61\x5d\xcc\xb7\xb7\xe8\x33\x2b\x37\xcb\xae\xb0\xcb\x46\x3f\x50\x7e\x58\x41\x46\xcf\xb1\xae\xc6\x39\x2b\x31\x7d\xb7\xb5\xc8\x5d\x58\xe5\xe1\x4a\x37\x38\xf2\xb1\xab\xba\x44\x2e\x30\x4f\xc3\xbe\xd1\x7d\xd8\xc3\xc9\x4b\x30\x2f\x4c\xb6\xab\xb3\x61\x35\x35\x4b\xd8\xd6\x68\x68\xc8\xb7\xba\x5d\x30\x2c\x3c\xbf\xad\xb1\xd8\x40\x3e\x52\xfb\x58\x44\x4c\xc8\xb0\xb0\xd6\x34\x2b\x35\xd5\xb3\xb5\xcd\x54\x54\xec\xef\x47\x37\x3c\xd3\xaf\xac\xc0\x3c\x2d\x33\x63\xbe")); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x68\xc2\x9e\x84\x94\x6b\x07\x1a\x72\x96\x9c\xec\x59\x49\xcf\xf7\x7b\x12\x1c\x76\x9c\x86\x9f\x7c\x1a\x1a\x63\xe6\xeb\xfe\xd5\xf6\xe9\xef\x71\x19\x05\x68\x97\x86\x9b\xc2\x10\x1c\x62\xc1\xf5\x43\x49\xe4\x92\x92\xda\x1e\x06\x12\xe7\x85\x9b\xe7\x62\x6b\x7e\x55\x76\x69\x62\xf9\x98\x85\xe2\x10\x06\x18\x54\x92\x9c\xe0\x49\x76\xc7\xc3\x66\x12\x13\xd3\x98\x86\x91\x6c\x05\x1b\x79\xef\x95\xff\x54\xf6\xef\xe1\x67\x1b\x1a\x64\x9d\x86\x9e\x43\x1c\x1c\x67\xf6\xf0\x5a\x5a\xe0\x92\x91\x49\x1b\x07\x17\xeb\x84\x98\xf6\x68\x15\x7c\xd7\x76\x6c\x64\xe0\x9b\x9b\xf0\x1f\x06\x1c\xf3\x9e\x9c\xe5\x72\x72\xde\xdd\x63\x12\x17\xfd\x9a\x87\xe8\x17\x04\x1e\x41\x95")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xbd\xd3\x77\xd9\xc5\xd0\x44\x30\x32\x65\xb2\xab\xb8\x4c\x32\x35\x50\xcf\xd2\x70\x7a\xc6\xb8\xbe\x4c\x2e\x2d\x45\xb9\xac\xb4\xfd\x3c\x3d\x55\xf2\x5a\x47\x56\xc1\xb0\xb4\x71\x30\x2b\x3a\xc7\xb0\xb6\xd7\x4d\x50\xf6\x78\x45\x38\x41\xc7\xae\xae\xcc\x37\x2c\x36\xe5\xbb\xbd\xd7\x6d\xdb\xc9\xdd\x3f\x30\x36\xdc\xae\xab\xbd\x41\x2f\x37\x5d\xcb\xcf\x7b\xef\xc4\xb9\xc6\x42\x2d\x2e\x55\xb4\xac\xb8\x58\x39\x3d\x59\xea\x5c\x4a\x66\xbd\xb0\xb8\x50\x2e\x2c\x40\xbd\xaf\xb8\xe8\x48\x4e\x7d\x6b\x43\x3a\x4a\xbf\xad\xaf\xe4\x32\x2c\x3a\xcf\xb8\xbd\xdc\x66\xde\xcc\xf5\x3c\x30\x3b\xca\xad\xac\xc6\x3b\x2e\x39\x7c\xc6\xcd\xfa\xe7\xc3\xbb\xce\x3c\x2d\x31\xf2")); +# replaced by tone +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +Time::HiRes::usleep(18000); $seq++; + +# gap + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +# still tone +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# disable blocking + +rtpe_req('unblock DTMF', 'PCM DTMF block w transcoding', + { 'from-tag' => ft() }); + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# enable blocking + +rtpe_req('block DTMF', 'PCM DTMF block w transcoding', + { 'from-tag' => ft(), 'DTMF-security' => 'tone', 'delay-buffer' => 100 }); + +# pre-send 100 ms worth of audio + +$rseq = $seq; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# start receiving + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +# start DTMF, interleaved with receiving older audio + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb0\xac\xbc\x4c\x39\x3f\x63\xee\x55\x4a\xf6\xba\xaf\xbc\x45\x2c\x2d\x4b\xba\xaf\xbb\x6e\x48\x53\xf3\x5f\x3f\x3a\x52\xba\xac\xb3\x5e\x2f\x2d\x3e\xc8\xb8\xc0\xe8\x6b\xd7\xcc\x66\x39\x30\x3f\xbf\xac\xae\xd2\x37\x2f\x3c\xe1\xc6\xd2\x77\xdd\xbf\xbb\xdc\x38\x2c\x35\xd1\xae\xad\xc2\x43\x37\x40\x6e\xe7\x58\x4e\xdd\xb8\xb1\xc3\x3d\x2b\x2f\x5e\xb5\xaf\xbe\x59\x44\x51\xfb\x5b\x3f\x3d\x6b\xb6\xac\xb8\x4a\x2d\x2d\x47\xbf\xb6\xc1\xfa\x63\xda\xd1\x57\x37\x32\x49\xba\xab\xb0\xfe\x33\x2f\x40\xd2\xc2\xd1\x7e\xda\xbf\xbe\x73\x35\x2d\x3a\xc4\xac\xae\xcd\x3d\x36\x43\xf6\xdf\x5c\x55\xd2\xb7\xb4\xce\x37\x2b\x32\xdf\xb1\xaf\xc3\x4d\x41\x50\x7e\x59\x40")); +Time::HiRes::usleep(18000); $seq++; + +# still buffered silence + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x40\xe0\xb3\xad\xbd\x3f\x2c\x2f\x54\xbb\xb5\xc4\x6b\x5d\xde\xd9\x4e\x37\x35\x58\xb5\xab\xb4\x52\x2f\x2f\x47\xca\xbf\xd0\xfe\xd8\xc1\xc3\x57\x32\x2e\x40\xbc\xab\xb0\xe0\x39\x35\x46\xe3\xdb\x61\x5d\xcc\xb7\xb7\xe8\x33\x2b\x37\xcb\xae\xb0\xcb\x46\x3f\x50\x7e\x58\x41\x46\xcf\xb1\xae\xc6\x39\x2b\x31\x7d\xb7\xb5\xc8\x5d\x58\xe5\xe1\x4a\x37\x38\xf2\xb1\xab\xba\x44\x2e\x30\x4f\xc3\xbe\xd1\x7d\xd8\xc3\xc9\x4b\x30\x2f\x4c\xb6\xab\xb3\x61\x35\x35\x4b\xd8\xd6\x68\x68\xc8\xb7\xba\x5d\x30\x2c\x3c\xbf\xad\xb1\xd8\x40\x3e\x52\xfb\x58\x44\x4c\xc8\xb0\xb0\xd6\x34\x2b\x35\xd5\xb3\xb5\xcd\x54\x54\xec\xef\x47\x37\x3c\xd3\xaf\xac\xc0\x3c\x2d\x33\x63\xbe")); +Time::HiRes::usleep(18000); $seq++; + +# now replaced by tone + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xbd\xd3\x77\xd9\xc5\xd0\x44\x30\x32\x65\xb2\xab\xb8\x4c\x32\x35\x50\xcf\xd2\x70\x7a\xc6\xb8\xbe\x4c\x2e\x2d\x45\xb9\xac\xb4\xfd\x3c\x3d\x55\xf2\x5a\x47\x56\xc1\xb0\xb4\x71\x30\x2b\x3a\xc7\xb0\xb6\xd7\x4d\x50\xf6\x78\x45\x38\x41\xc7\xae\xae\xcc\x37\x2c\x36\xe5\xbb\xbd\xd7\x6d\xdb\xc9\xdd\x3f\x30\x36\xdc\xae\xab\xbd\x41\x2f\x37\x5d\xcb\xcf\x7b\xef\xc4\xb9\xc6\x42\x2d\x2e\x55\xb4\xac\xb8\x58\x39\x3d\x59\xea\x5c\x4a\x66\xbd\xb0\xb8\x50\x2e\x2c\x40\xbd\xaf\xb8\xe8\x48\x4e\x7d\x6b\x43\x3a\x4a\xbf\xad\xaf\xe4\x32\x2c\x3a\xcf\xb8\xbd\xdc\x66\xde\xcc\xf5\x3c\x30\x3b\xca\xad\xac\xc6\x3b\x2e\x39\x7c\xc6\xcd\xfa\xe7\xc3\xbb\xce\x3c\x2d\x31\xf2")); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +# back to silence + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# still tone + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# finally back to silence + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +# disable blocking + +rtpe_req('unblock DTMF', 'PCM DTMF block w transcoding', + { 'from-tag' => ft(), 'delay-buffer' => 0 }); + +# buffer flushing + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +# sync forwarding + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; + + + + +($sock_a, $sock_b) = new_call([qw(198.51.100.1 2004)], [qw(198.51.100.1 3004)]); + +($port_a) = offer('PCM DTMF block w event PT', { }, < ft(), 'DTMF-security' => 'tone', 'delay-buffer' => 1 }); + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +$sseq = $seq; + +snd($sock_a, $port_b, rtp(101 | 0x80, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x0a\x00\xa0")); +# replaced by tone +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(101, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x0a\x01\x40")); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(101, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x8a\x01\xe0")); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +Time::HiRes::usleep(18000); $seq++; + +# gap + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# disable blocking + +rtpe_req('unblock DTMF', 'PCM DTMF block w event PT', + { 'from-tag' => ft() }); + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# enable blocking + +rtpe_req('block DTMF', 'PCM DTMF block w event PT', + { 'from-tag' => ft(), 'DTMF-security' => 'tone', 'delay-buffer' => 100 }); + +# pre-send 100 ms worth of audio + +$rseq = $seq; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# start receiving + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +# send interleaved with received old PCM + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +# send some non-silence to make sure we drop it + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x11" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x11" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x11" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x11" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +# start DTMF + +$sseq = $seq; + +snd($sock_a, $port_b, rtp(101 | 0x80, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x0a\x00\xa0")); +Time::HiRes::usleep(18000); $seq++; + +# tone output immediately + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(101, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x0a\x01\x40")); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(101, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x8a\x01\xe0")); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +# input some non-silence to make sure it's also dropped + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x22" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# still tone + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x22" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x22" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +# switch back to silence + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# still tone + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35\xff\xb5\xa7\x9f\x9c\x9b\x9c\x9f\xa7\xb5\xff\x35\x27\x1f\x1c\x1b\x1c\x1f\x27\x35")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# finally back to silence + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +# disable blocking + +rtpe_req('unblock DTMF', 'PCM DTMF block w event PT', + { 'from-tag' => ft(), 'delay-buffer' => 0 }); + +# buffer flushing + +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(0, 1000 + $rseq, 3000 + 160 * $rseq, 0x1234, "\x00" x 160)); +$rseq++; + +# sync forwarding + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + + + + + + +($sock_a, $sock_b) = new_call([qw(198.51.100.1 2006)], [qw(198.51.100.1 3006)]); + +($port_a) = offer('PCM DTMF block w transcoding w event PT', { codec => { transcode => ['PCMA'] } }, < ft(), 'DTMF-security' => 'tone', 'delay-buffer' => 1 }); + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; + +$sseq = $seq; + +snd($sock_a, $port_b, rtp(101 | 0x80, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x0a\x00\xa0")); +# replaced by tone +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(101, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x0a\x01\x40")); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(101, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x8a\x01\xe0")); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +Time::HiRes::usleep(18000); $seq++; + +# gap + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# disable blocking + +rtpe_req('unblock DTMF', 'PCM DTMF block w transcoding w event PT', + { 'from-tag' => ft() }); + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# enable blocking + +rtpe_req('block DTMF', 'PCM DTMF block w transcoding w event PT', + { 'from-tag' => ft(), 'DTMF-security' => 'tone', 'delay-buffer' => 100 }); + +# pre-send 100 ms worth of audio + +$rseq = $seq; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# start receiving + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +# send interleaved with received old PCM + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +# send some non-silence to make sure we drop it + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x11" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x11" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x11" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x11" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +# start DTMF + +$sseq = $seq; + +snd($sock_a, $port_b, rtp(101 | 0x80, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x0a\x00\xa0")); +Time::HiRes::usleep(18000); $seq++; + +# tone output immediately + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(101, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x0a\x01\x40")); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(101, 1000 + $seq, 3000 + 160 * $sseq, 0x1234, "\x05\x8a\x01\xe0")); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +# input some non-silence to make sure it's also dropped + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x22" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# still tone + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x22" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x22" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +# switch back to silence + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# still tone + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c\xd5\x9c\x82\xb5\xb6\xb1\xb6\xb5\x82\x9c\xd5\x1c\x02\x35\x36\x31\x36\x35\x02\x1c")); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; + +# finally back to silence + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +Time::HiRes::usleep(18000); $seq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +# disable blocking + +rtpe_req('unblock DTMF', 'PCM DTMF block w transcoding w event PT', + { 'from-tag' => ft(), 'delay-buffer' => 0 }); + +# buffer flushing + +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; +rcv($sock_b, $port_a, rtpm(8, 1000 + $rseq, 3000 + 160 * $rseq, $ssrc, "\x2a" x 160)); +$rseq++; + +# sync forwarding + +snd($sock_a, $port_b, rtp(0, 1000 + $seq, 3000 + 160 * $seq, 0x1234, "\x00" x 160)); +rcv($sock_b, $port_a, rtpm(8, 1000 + $seq, 3000 + 160 * $seq, $ssrc, "\x2a" x 160)); +Time::HiRes::usleep(18000); $seq++; + + + + +done_testing(); +#NGCP::Rtpengine::AutoTest::terminate('f00');