[globals]

; This is the extensions file used in the Burning Man 2008
; site test, with private information removed.
; Jump to the end for handset examples.

[macro-dialvoipoutcall]
exten => s,1,Dial(SIP/${ARG1}@voidoutcall-cn,120)
exten => s,2,Goto(s-${DIALSTATUS},1)
exten => s-ANSWER,1,Hangup
exten => s-CONGESTION,1,Dial(SIP/${ARG1}@voipoutcall-cn,120)
exten => s-CONGESTION,2,Goto(ss-${DIALSTATUS},1)
exten => s-CANCEL,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-CHANUNAVAIL,1,Dial(SIP/${ARG1}@voipoutcall-cn,120)
exten => s-CHANUNAVAIL,2,Goto(ss-${DIALSTATUS},1)
exten => ss-ANSWER,1,Hangup
exten => ss-CONGESTION,1,Congestion(30)
exten => ss-CANCEL,1,Hangup
exten => ss-BUSY,1,Busy(30)
exten => ss-CHANUNAVAIL,1,Congestion(30)


[macro-diallink2voip]
exten => s,1,Dial(SIP/${ARG1}@link2voip-sw1,120)
exten => s,2,Goto(s-${DIALSTATUS},1)
exten => s-ANSWER,1,Hangup
exten => s-CONGESTION,1,Dial(SIP/${ARG1}@link2voip-sw2,120)
exten => s-CONGESTION,2,Goto(ss-${DIALSTATUS},1)
exten => s-CANCEL,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-CHANUNAVAIL,1,Dial(SIP/${ARG1}@link2voip-sw2,120)
exten => s-CHANUNAVAIL,2,Goto(ss-${DIALSTATUS},1)
exten => ss-ANSWER,1,Hangup
exten => ss-CONGESTION,1,Congestion(30)
exten => ss-CANCEL,1,Hangup
exten => ss-BUSY,1,Busy(30)
exten => ss-CHANUNAVAIL,1,Congestion(30)


[macro-dialSIP]
exten => s,1,Dial(SIP/${ARG1})
exten => s,2,Goto(s-${DIALSTATUS},1)
exten => s-CANCEL,1,Hangup
exten => s-NOANSWER,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-CONGESTION,1,Congestion(30)
exten => s-CHANUNAVAIL,1,playback(ss-noservice)
exten => s-CANCEL,1,Hangup

[global]
VSA=/var/spool/asterisk

[outbound-or-wherever-you-dial]
exten => _XXX,1,Macro(Snoop,${EXTEN})
exten => _XXX,n,Dial(SIP/${EXTEN},${TIMEOUT})
exten => _XXX,n,StopMixMonitor
; above in case you're in some loop & Dial fails,
; e.g., swift+monitor crash asterisk


[macro-Snoop]
; ${ARG1} channel
exten => s,1,GotoIf($["${SNOOPING}" = "1"]?snooping)
exten => s,n,Set(SNOOPING=1)
exten => s,n,Set(YYYY=${STRFTIME(${EPOCH},,%Y)})
exten => s,n,Set(MM=${STRFTIME(${EPOCH},,%m)})
exten => s,n,Set(DD=${STRFTIME(${EPOCH},,%d)})
exten => s,n,Set(HMS=${STRFTIME(${EPOCH},,%H%M%S)})
exten => s,n,Set(FILENAME=${HMS}-${CALLERID(num)}-${ARG1}-${UNIQUEID})
exten => s,n,Set(MIXMON_ARGS=mkdir -p ${VSA}/monitor/${YYYY}/${MM}/${DD} && nice -n 19 /usr/local/bin/lame --silent --resample 11.025 -b 16 -t -m m ${VSA}/monitor/${FILENAME}.wav ${VSA}/monitor/${YYYY}/${MM}/${DD}/${FILENAME}.mp3 && rm -f ${VSA}/monitor/${FILENAME}.wav)
exten => s,n,MixMonitor(${FILENAME}.wav,,${MIXMON_ARGS})
exten => s,n(snooping),NoOp(snooping on ${CHANNEL})


[macro-dialSetFramework]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,Background(vm-extension)
exten => s,4,WaitExten(10)
exten => t,1,Playback(vm-goodbye)


; WD9XKN camp
[dialSetWD9XKN]
exten => s,1,Macro(dialSetFramework)
exten => 0,1,Dial(SIP/wiredPhone)	; "hotline"
exten => 1,1,Goto(sip-local,2101,1)	; David
exten => 2,1,Goto(sip-local,2102,1)	; Harvind
exten => 3,1,Goto(sip-local,2103,1)	; Bill
exten => i,1,Playback(invalid)

[dialSet382]
exten => s,1,Macro(dialSetFramework)
exten => 1,1,Goto(sip-local,2723,1)
exten => 2,1,Goto(sip-local,3001,1)
exten => i,1,Playback(invalid)

[dialSet412]
exten => s,1,Macro(dialSetFramework)
exten => i,1,Playback(invalid)

[dialSet328]
exten => s,1,Macro(dialSetFramework)
exten => i,1,Playback(invalid)

; dead end for unassigned numbers
[unassigned]
exten => s,1,Wait(1)
exten => s,2,Playback(ss-noservice)
exten => s,3,Hangup


[from-trunk]
; route incoming calls from the PSTN
exten => s,1,Answer
exten => 17074700739,1,Dial(SIP/wiredPhone)		; "hotline"
exten => 17074700741,1,Goto(unassigned,s,1)		; open
exten => 17074700742,1,Goto(unassigned,s,1)		; open
exten => 17074700743,1,Goto(unassigned,s,1)		; open
exten => 17074700746,1,Goto(unassigned,s,1)		; open
exten => 16506360411,1,Goto(dialSetWD9XKN,s,1)		; testing camp
exten => 16506360412,1,Goto(dialSet412,s,1)
exten => 16506360382,1,Goto(dialSet382,s,1)
exten => 16506360328,1,Goto(dialSet328,s,1)
exten => 16506360368,1,Goto(unassigned,s,1)		; open




[sip-external]
include => sip-local
; outgoing trunk access
; NANP
exten => 1001,1,Macro(dialvoipoutcall,${EXTEN})
exten => _1XXXXXXXXXX,1,Macro(dialvoipoutcall,${EXTEN})
; international
;exten => _011,1,Macro(diallink2voip,${EXTEN})



[sip-local]
; local extensions
exten => 2105,1,Macro(dialSIP,zoiperDavid)
exten => 2100,1,Macro(dialSIP,wiredPhone)
exten => 2101,1,Macro(dialSIP,softPhone)
