[coin-dtf-prepay-collect] exten => s,1,Originate(Local/${cointrunkid}@coin-call-spy,exten,coin-get-deposit,0,1,,av(__cointrunkid=${cointrunkid})) ; bring detector into bridge same => n,Originate(Local/${cointrunkid}@coin-call-bridge,exten,coin-dtf-read,${cointrunkid},1,,av(__cointrunkid=${cointrunkid})) ; bring dial tone into bridge same => n,ConfBridge(coincall${cointrunkid},silentbridge,incogtalker) same => n,SoftHangup(${SHARED(coindetector,${cointrunkchannel})}) same => n,Return() exten => h,1,SoftHangup(${SHARED(coindetector,${cointrunkchannel})}) same => n,ExecIf($[${CONFBRIDGE_INFO(parties,coincall${cointrunkid})}>0]?ConfKick(coincall${cointrunkid},all)) [coin-prepay-noise] ; EXTEN = cointrunkid exten => s,1,Set(CDR_PROP(disable)=1) same => n,Answer() same => n,Playback(custom/switch/payphone/prepay/prepay-1-begin) same => n(loop),Playback(custom/switch/payphone/prepay/prepay-2-power-noise-loop) same => n,Goto(loop) [coin-call-bridge] ; EXTEN = cointrunkid exten => _X!,1,Set(CDR_PROP(disable)=1) same => n,Answer() same => n,ConfBridge(coincall${EXTEN},silentbridge,incogtalker) same => n,Hangup() [coin-call-spy] ; EXTEN = cointrunkid. Only used for dial tone first dial tone deposits. exten => _X!,1,Set(CDR_PROP(disable)=1) same => n,Answer() same => n,Set(cointrunkchannel=${DB(coinchannels/${EXTEN})}) ; ChanSpy only works "properly" with the caller UNMUTED in a CONFBRIDGE, so we have a constant media stream (and good quality). No ConfBridge frame queuing issues! same => n,ChanSpy(${cointrunkchannel},qoE) ; q = quiet, o = listen only to audio coming from this channel, E = exit ChanSpy upon spied channel hangup same => n,Hangup() [coin-call-monitor] ; EXTEN = cointrunkid -> once the call has started, we should use ChanSpy, not ConfBridge. We're guaranteed a media stream, it's more efficient, and we can listen to just the channel we want. exten => _X!,1,Set(CDR_PROP(disable)=1) same => n,Answer() same => n,Set(cointrunkchannel=${DB(coinchannels/${cointrunkid})}) same => n,ConfBridge(coincall${EXTEN},silentbridge,incoglistener) same => n,Hangup() [coin-get-deposit] ; __cointrunkid, EXTEN = cents to collect (0 = keep detecting until we get kicked) exten => e,1,Log(WARNING,cointrunkid was undefined) same => n,Hangup() ; we can't even kick people from the bridge... exten => _X!,1,Set(CDR_PROP(disable)=1) same => n,Answer() same => n,ExecIf($["${cointrunkid}"=""]?RaiseException(ERROR)) same => n,Set(cointrunkchannel=${DB(coinchannels/${cointrunkid})}) same => n,Set(SHARED(coindetector,${cointrunkchannel})=${CHANNEL}) same => n,Set(end=$[${EPOCH}+${SHARED(cointimeout,${cointrunkchannel})}]) same => n(loop),GotoIf($[${GROUP_COUNT(${cointrunkid}@cointrunk)}=0|"${SHARED(coincalleehangup,${cointrunkchannel})}"="1"|${EPOCH}>${end}]?done) ; failsafe if something goes wrong same => n,GosubIf($["${SHARED(typecdt,${cointrunkchannel})}"="0"]?gong-read,s,1(2,2):cdt-read,s,1(2,2,${EXTEN})) ; returns cents deposited same => n,GotoIf($["${GOSUB_RETVAL}"="0"]?loop) same => n,Verbose(2, Received Deposit: ${GOSUB_RETVAL} cents!) same => n,Set(SHARED(amtdeposited,${cointrunkchannel})=$[${SHARED(amtdeposited,${cointrunkchannel})}+${GOSUB_RETVAL}]) same => n,GotoIf($[${EXTEN}=0|${EXTEN}>${SHARED(amtdeposited,${cointrunkchannel})}]?loop) same => n(done),ExecIf($[${CONFBRIDGE_INFO(parties,coindeposit${cointrunkid})}>0]?ConfKick(coindeposit${cointrunkid},${cointrunkchannel}):ConfKick(coincall${cointrunkid},${cointrunkchannel})) same => n,Hangup()