monitor asterisk calls (when bridge) and save as mp3 file

1. I download sox,lame ,try to build,it report memory too low,I cannot continue,so I use top to found memory usage,it surprised me,it has total 6G memory,but now it’s only 10+ M memory available,dont know why

I try to stop java,tomcat,this give me another 10+ M memory,so I can continue build sox,lame

it ofcourse one problem,I think this server is misconfiged,we dont need pop3,imap,postgresql, tomcat,java,etc

but even we installed that, the 6G memory cannot be used out,so I dont know where is the problem

ok ,below is what I did to make mp3 working

install sox,lame ,I download sourcecode and compile

then in extensions.conf

[test]
[test]
exten => _1NXXNXXXXXX,1,NoOp(MixMonitortest.wav|b) ; here use test.wav,can be any filename
exten => _1NXXNXXXXXX,2,Dial(SIP/${EXTEN}@gafachi,30) ; GAFACHI
exten => _1NXXNXXXXXX,3,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?4:5)
exten => _1NXXNXXXXXX,4,Dial(IAX2/14107@voipjet/${EXTEN},30,S(${var1})M(screen)) ; VoipJet.com NANPA
exten =>_1NXXNXXXXXX,5,Hangup

now make a call, and answered,and hangup

then you will found /var/spool/asterisk/monitor/test.wav

you can convert to mp3 ,simply

type

lame test.wav test.mp3

then it works,I copy test.mp3 to my PC,and play with winamp3 ,works

in production system,we need further improving

below is

after each call done,asterisk will invoke lame command to convert wav file to mp3 file

see extensions.conf

[a2billing]
exten => _X.,1,Answer
exten => _X.,n,NoOp(${UNIQUEID})
exten => _X.,n,DeadAGI(a2billing.php|1)
exten => _X.,n,Hangup
exten =>h,1,NoOp(${UNIQUEID})
exten => h, 2,System(/usr/local/bin/lame /var/spool/asterisk/monitor/${UNIQUEID}.wav /var/spool/asterisk/monitor/${UNIQUEID}.mp3)

you need make a minor change in Class.RateEngine.php
if ($A2B -> agiconfig['record_call'] == 1){
$myres = $agi->exec("MixMonitor " .$A2B->uniqueid.".wav|b");
}