diff --git a/t/Makefile b/t/Makefile index 79bd45edc..204e22414 100644 --- a/t/Makefile +++ b/t/Makefile @@ -149,7 +149,8 @@ daemon-tests: daemon-tests-main daemon-tests-jb daemon-tests-pubsub daemon-tests daemon-tests-mos-fullband daemon-tests-config-file \ daemon-tests-templ-def daemon-tests-templ-def-offer \ daemon-tests-sdp-manipulations daemon-tests-sdes-manipulations \ - daemon-tests-sdp-orig-replacements daemon-tests-moh daemon-tests-evs-dtx daemon-tests-transform + daemon-tests-sdp-orig-replacements daemon-tests-moh daemon-tests-evs-dtx daemon-tests-transform \ + daemon-tests-transcode-config daemon-test-deps: tests-preload.so $(MAKE) -C ../daemon @@ -172,6 +173,9 @@ daemon-tests-pubsub: daemon-test-deps daemon-tests-transform: daemon-test-deps ./auto-test-helper "$@" perl -I../perl auto-daemon-tests-transform.pl +daemon-tests-transcode-config: daemon-test-deps + ./auto-test-helper "$@" perl -I../perl auto-daemon-tests-transcode-config.pl + daemon-tests-stats: daemon-test-deps ./auto-test-helper "$@" perl -I../perl auto-daemon-tests-stats.pl diff --git a/t/auto-daemon-tests-transcode-config.pl b/t/auto-daemon-tests-transcode-config.pl new file mode 100755 index 000000000..56499c88d --- /dev/null +++ b/t/auto-daemon-tests-transcode-config.pl @@ -0,0 +1,343 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use NGCP::Rtpengine::Test; +use NGCP::Rtpclient::SRTP; +use NGCP::Rtpengine::AutoTest; +use Test::More; +use POSIX; +use Data::Dumper; +use Bencode; +use Socket; + + +autotest_start(qw(--config-file=test4.conf)) + or die; + + + +my ($resp, $sock_sig, $sock_a, $sock_b, $sock_tc, + $port_a, $port_b, $port_tc, $cookie, $addr_sig, $port_sig, $seq, $ts, $ssrc); + + +$sock_sig = IO::Socket::IP->new(Type => &SOCK_DGRAM, Proto => 'udp', LocalHost => '203.0.113.42', LocalPort => 3334); + +($sock_a, $sock_b) = new_call([qw(198.51.100.14 3000)], [qw(198.51.100.14 3002)]); + + +($port_a) = offer('control passthrough', { }, < { transcode => [ 'G722' ] } }, < { transcode => ['PCMU'] } }, < 'ok', + 'call-id' => 'foobar', + 'from-tag' => 'yolo', + 'media' => [ + { + id => 'id', + family => 'IP4', + address => '198.51.100.18', + port => 3012, + }, + ], + } ), $addr_sig ); +}; + +($port_b) = answer('G.711 transform', { }, < 'ok', } ), $addr_sig ); +}; + +rtpe_req('delete', 'delete call', { 'delete-delay' => 0 } ); + +$NGCP::Rtpengine::req_cb = undef; + + + +($sock_a, $sock_b, $sock_tc) = new_call( + [qw(198.51.100.14 3040)], [qw(198.51.100.14 3042)], + [qw(198.51.100.18 3044)] +); + + +$NGCP::Rtpengine::req_cb = sub { + ($port_sig, $addr_sig, $cookie, $port_tc) = rcv($sock_sig, -1, qr/^(.{16}) d7:command9:transform5:mediald4:type5:audio5:codecld5:inputd5:codec4:PCMA12:payload typei8e10:clock ratei8000e8:channelsi1e6:format0:7:options0:e6:outputd5:codec4:PCMU12:payload typei0e10:clock ratei8000e8:channelsi1e6:format0:7:options0:eee11:destinationd6:family3:IP47:address11:203.0.113.14:porti(\d{5})eeee8:instance12:.{12}e$/); + snd($sock_sig, $port_sig, $cookie . ' ' . Bencode::bencode( { + result => 'ok', + 'call-id' => 'foobar', + 'from-tag' => 'yolo', + 'media' => [ + { + id => 'id', + family => 'IP4', + address => '198.51.100.18', + port => 3044, + }, + ], + } ), $addr_sig ); +}; + +($port_a) = offer('G.711 transform reverse', { codec => { transcode => ['PCMA'] } }, <