[Asterisk-Users] Syncronize Monitored Calls

David Harris davidh at webunited.net
Mon Aug 25 09:20:43 MST 2003


I thought I would post this in case it might be of any use to anyone.
Not anything special but it does work.  Keep in mind you need sox and
wmix.
 
Here is some relevant exerpts of my extensions.conf using John Todds
macro.
 
[globals]
CALLFILENAME=foo
FOO=foo
CALLERIDNUM=foo
 
[default]
 
exten => 287,1,Macro(dial,SIP/agent20002|20)
exten => 287,2,Voicemail(u287)
exten => h,1,Macro(hangup)
 
[macro-dial]
 
exten => s,1,AGI(set-timestamp.agi)
exten =>
s,2,SetVar(CALLFILENAME=${timestamp}-${CALLERIDNUM}-${MACRO_EXTEN})
exten => s,3,Monitor(wav,${CALLFILENAME})
exten => s,4,Dial(${ARG1},${ARG2},${ARG3})
 
[macro-hangup]
 
exten => s,1,SetVar(MONITORDIR=/var/spool/asterisk/monitor)
exten => s,2,GotoIf($[${CALLFILENAME} = ${FOO}]?6:3)
exten => s,3,System(/usr/local/bin/mix_monitor_files.pl ${MONITORDIR}
${CALLFILENAME}-in.wav ${CALLFILENAME}-out.wav ${CALLFILENAME}.wav)
exten => s,6,NoOp
 
 
Here is mix_monitor_files.pl.  sox and wmix must be in the path of your
perl script
 
#!/usr/bin/perl
 
$monitordir = shift;
$infile = shift;
$outfile = shift;
$finishfile = shift;
 
chdir($monitordir);
 
 
$infile_output = `sox $infile -e stat 2>&1`;
$outfile_output = `sox $outfile -e stat 2>&1`;
 
$infile_output =~ /Samples read:\s+(\d+)/;
$infile_samples = $1;
 
$outfile_output =~ /Samples read:\s+(\d+)/;
$outfile_samples = $1;
 
 
if($outfile_samples > $infile_samples)
{
        $diff_samples = $outfile_samples - $infile_samples;
        system("sox $outfile temp${outfile} trim  ${diff_samples}s");
        system("wmix $infile temp${outfile} > $finishfile");
        system("rm -f $infile temp${outfile} $outfile");
}
elsif($infile_samples > $outfile_samples)
{
        $diff_samples = $infile_samples - $outfile_samples;
        system("sox $infile temp${infile} trim  ${diff_samples}s");
        system("wmix temp${infile} $outfile > $finishfile");
        system("rm -f temp${infile} $outfile $infile");
}
else
{
        system("wmix $infile $outfile > $finishfile");
        system("rm -f $infile $outfile");
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20030825/9ae669d6/attachment.htm


More information about the asterisk-users mailing list