I am implementing the Monitor() command for calls. And i have experienced a couple things. What i want to accomplish is this…
Record the calls… when the call is finished, merge the two files into a single wav and then email me the wav. All of which work fine per se , the problem is in the timing.
When executing a block, i do this:
exten => s,1,Answer
exten => s,2,playback(pls-wait-connect-call)
exten => s,3,playback(this-call-may-be-monitored-or-recorded)
exten => s,4,Monitor(wav,TestRecord,m)
exten => s,5,Dial(SIP/2230115555551212@1.2.3.4,g)
exten => s,6,Macro(sendRecording)
The macro looks like this:
exten => s,1,SetVar(EMAILADDR=theaddress@gmail.com)
exten => s,2,system(mime-construct --to ${EMAILADDR} --subject “Recording” --attachment “TestRecord.wav” --type wav --file /var/spool/asterisk/monitor/TestRecord.wav)
What happens is this, the moment the call ends it fires off the email send macro which works, and AFTER this the merger of the current files happens…
Example:
Feb 28 14:28:47 VERBOSE[8680] logger.c: – Executing Macro(“SIP/65.248.16.32-097551e0”, “sendRecording”) in new stack
Feb 28 14:28:47 VERBOSE[8680] logger.c: – Executing SetVar(“SIP/65.248.16.32-097551e0”, "EMAILADDR=theemail@gmail.com") in new stack
Feb 28 14:28:47 VERBOSE[8680] logger.c: – Executing System(“SIP/65.248.16.32-097551e0”, “mime-construct --to theemail@gmail.com --subject “Recording” --attachment “TestRecord.wav” --type wav --file /var/spool/asterisk/monitor/TestRecord.wav”) in new stack
Feb 28 14:28:49 DEBUG[8680] cdr_addon_mysql.c: cdr_mysql: inserting a CDR record.
Feb 28 14:28:49 DEBUG[8680] cdr_addon_mysql.c: cdr_mysql: SQL command as follows: INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid) VALUES (‘2006-02-28 14:28:12’,‘8585761010’,‘8585761010’,‘s’,‘custom-Transfer’, ‘SIP/65.248.16.32-097551e0’,‘SIP/65.248.16.31-56ba’,‘System’,‘mime-construct --to themail@gmail.com --subject “Recording” --attachment "Tes’,37,37,‘ANSWERED’,3,’’,‘1141154892.97’)
Feb 28 14:28:49 DEBUG[8680] chan_sip.c: update_call_counter() - decrement call limit counter
Feb 28 14:28:49 DEBUG[8680] res_monitor.c: monitor executing ( nice -n 19 soxmix “/var/spool/asterisk/monitor/TestRecord-in.wav” “/var/spool/asterisk/monitor/TestRecord-out.wav” “/var/spool/asterisk/monitor/TestRecord.wav” && rm -f “/var/spool/asterisk/monitor/TestRecord-”* )
the bold sections i want to fire in reverse order of current…
I need to wait until this process is complete before sending the email. Is there an event that I can use to call this macro so that it is outside of the scope of the call block… OR is there a way that I can schedule a recurring function ( say for instance every hour to loop through the directory and send me the file(s) )