[Asterisk-Users] Macro's and Var Scope's

Alex Barnes abarnes at ubiquitysoftware.com
Mon Oct 4 06:08:38 MST 2004


Hi,
 
I am having difficulty getting my record phone call dial-plan script
working.  I have tried the example record call scripts but they start
recording before they are actually connected to an end point, e.g. you
get ringing or announcements being recorded.
 
It seems to me that these are bugs with the Dial() command:
 
1) Using M(x) in a dial command does not allow argument to be passed.
Using something like "Dial(${ARG2},10,tTM(record-start,1111))" means
that the macro cannnot be found.
 
2) Variables are not passed from one context into another when using the
M(x) command.  For example the variable CALLFILENAME set in stdexten
cannot be seen by record-start but can be seen if I use the Macro()
command rather than Dial() with the M(x) switch.
 
 
If anyone can offer any advice it would be much appreciated. Pls note
the working method is included but commented out I hope thats not
confusing.  Also record-cleanup is called from the default context when
ever a call is hung-up (not sure if thats a good thing to do or not).
 
If I set the vars as globals then the script works perfectly but I
assume this would go horribly wrong once there are two or more calls
connected.
 
 
SCRIPT
----------------------------------
;-----------------------------------------------------------------------
------
[macro-stdexten]
exten => s,1,Answer
exten => s,2,Playback(transfer)                 ;play transfer (please
hold whilst i try to conenct you)
 ;exten => s,3,Macro(record-start)    ; WORKS but starts recording
before connect
 ;exten => s,4,Dial(${ARG2},10,tT))    ; WORKS but starts recording
before connect
exten =>
s,3,SetVar(CALLFILENAME=/tmp/call_logs/${ARG1}/${TIMESTAMP}-${CALLERID})
exten => s,4,Dial(${ARG2},10,tTM(record-start))
exten => s,5,Goto(s-${DIALSTATUS},1)            ; Jump based on status
(NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
 
;--<SNIP>--
 
;-----------------------------------------------------------------------
------
[macro-record-start]
 ;exten =>
s,1,SetVar(CALLFILENAME=/tmp/call_logs/${ARG1}/${TIMESTAMP}-${CALLERID})
; WORKS but starts recording before connect
exten => s,1,SetVar(STARTREC=true)
exten => s,2,NoOp(${CALLFILENAME})   ; Debug
exten => s,3,NoOp(${ARG1})     ; Debug
exten => s,4,NoOp(${EXTEN})     ; Debug
exten => s,5,Monitor(wav,${CALLFILENAME})
exten => s,6,NoOp
 
;-----------------------------------------------------------------------
------
[macro-record-cleanup]
 ;exten => s,1,GotoIf($[${CALLFILENAME} = ${NULL}]?6:2) ; WORKS but
starts recording before connect
exten => s,1,GotoIf($[${STARTREC} = ${NULL}]?6:2)
exten => s,2,StopMonitor
exten => s,3,System(/usr/local/bin/soxmix ${CALLFILENAME}-in.wav
${CALLFILENAME}-out.wav ${CALLFILENAME}.wav)
exten => s,4,System(/usr/bin/notlame --preset phone ${CALLFILENAME}.wav
${CALLFILENAME}.mp3)
exten => s,5,System(rm ${CALLFILENAME}*.wav)
 
; End of routine, return to calling point (note: NoOp required for
GotoIf called from priority 2)
exten => s,6,NoOp

 


Dear Friends of Ubiquity Software: 
 
As you may have noticed, Ubiquity Software began using the web domain ubiquity.com earlier this year in addition to the previously established ubiquity.net for our website and email communications to you.  However, since that time, a dispute has emerged with respect to actual ownership of the ubiquity.com domain.
 
As an international software company founded over decade ago, you can always reach Ubiquity Software under the website www.ubiquity.net <http://www.ubiquity.net/>  and via email at @ubiquity.net.  However, we have also chosen to expand our domain to the more specific www.ubiquitysoftware.com <http://www.ubiquitysoftware.com/>  for web and @ubiquitysoftware.com for email communications.
 
Please use either the historical ubiquity.net or begin to use the new ubiquitysoftware.com domain for all email communications to Ubiquity employees from now on. 
 
Thank you.
 
Regards,
 
Ubiquity Software 
www.ubiquitysoftware.com <http://www.ubiquitysoftware.com/> 
info at ubiquitysoftware.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20041004/ec0eecb7/attachment.htm


More information about the asterisk-users mailing list