[Asterisk-Users] Syncronize Monitored Calls
Brian West
brian at bkw.org
Mon Aug 25 13:14:16 MST 2003
Note that h will not be called if you park the call and pick it backup.
bkw
On Mon, 25 Aug 2003, David Harris wrote:
> 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");
> }
>
More information about the asterisk-users
mailing list