File: spandsp_fax_pcm_test.pl

package info (click to toggle)
rtpengine 12.5.1.35-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,628 kB
  • sloc: ansic: 80,617; perl: 43,314; python: 3,041; sh: 1,092; makefile: 630; asm: 211
file content (32 lines) | stat: -rwxr-xr-x 662 bytes parent folder | download | duplicates (4)
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
28
29
30
31
32
#!/usr/bin/perl

use strict;
use warnings;
use IPC::Open2;
use POSIX ":sys_wait_h";

my ($send_src, $send_sink);
my $send_pid = open2($send_src, $send_sink, './spandsp_send_fax_pcm test.tif') or die;

unlink('out.tif');

my ($recv_src, $recv_sink);
my $recv_pid = open2($recv_src, $recv_sink, './spandsp_recv_fax_pcm out.tif') or die;

while ($send_pid && $recv_pid) {

	my $buf;

	if (sysread($send_src, $buf = '', 160)) {
		syswrite($recv_sink, $buf) or die;
	}

	if (sysread($recv_src, $buf = '', 160)) {
		syswrite($send_sink, $buf) or die;
	}

	undef($send_pid) if waitpid($send_pid, WNOHANG);
	undef($recv_pid) if waitpid($recv_pid, WNOHANG);
}

sleep(5);