[asterisk-dev] app_channelredirect: proposing a patch for letting original-called channel know that the call gets completed elsewhere...

Nils B. boulder at renzel.net
Fri Mar 5 04:10:58 CST 2021


Hi,

please find attached a rudimentary patch for adding a "call completed elsewhere"-notification for
the orginal-called channel in "app_channelredirect".

We use "ChannelRedirect" for call-pickups so that the pickup-phone will ring first instead of directly
answering the incoming call.

"ChannelRedirect" does exactly what we wanted to have, but it was really disturbing that after a
successfully picked-up call the original called device still showed a missed call. And I don't
know a way how to inform already ringing channels through Asterisk dialplans about that the call
will be completed elsewhere.

That patch should work with all available Asterisk versions, but unfortunately is not compatible
with existing dialplans as it adds an additional parameter "origCalledChan" before the parameter
"label". And "origCalledChan" expects a single channel name, so it's not possible to inform
multiple called channels with "AST_CAUSE_ANSWERED_ELSEWHERE" at once at the moment. I have no
idea how to get all called channels from a calling channel within the asterisk source code. Maybe
someone could give me a hint how to do that properly.

A dialplan could look like this then:
----------------------------------------------------------------------------------------------------
[macro-stdexten]
; ARG1 = Exten
; ARG2 = Hint
exten = s,1,ExecIf($[${LEN(${CALLERID(RDNIS)})}>2]?SIPAddHeader(History-Info: <sip:${CALLERID(RDNIS)}@[IP]>\;index=1))
exten = s,n,ExecIf($[${LEN(${BLINDTRANSFER})}>2]?SIPAddHeader(History-Info: <sip:${CALLERID(DNID)}@[IP]>\;index=1))
exten = s,n,Set(SrcDevice=${CUT(CHANNEL,-,1)})
exten = s,n,GotoIf($["${EXTENSION_STATE(${ARG1})}" = "NOT_INUSE" | ${REGEX("${SrcDevice}" ${ARG2})}]?s-DIAL,1:s-INUSE,1)

exten = s-DIAL,1,Ringing()
exten = s-DIAL,n,Wait(1)
exten = s-DIAL,n,Set(CalledDevices=${ARG2})
exten = s-DIAL,n,While($["${SET(CalledExten=${SHIFT(CalledDevices,&)})}" != ""])
exten = s-DIAL,n,Set(CalledExten=${CalledExten:4})
exten = s-DIAL,n,Set(DB(CALLERCHAN/${CalledExten})=${CHANNEL})
exten = s-DIAL,n,EndWhile
exten = s-DIAL,n,Dial(${ARG2},60,${DIALOPTIONS})
exten = s-DIAL,n,Goto(s-${DIALSTATUS},1)
(...)

[CallPickup]
exten = _**.,1,NoOP(Pickup trial from ${CHANNEL} for ${EXTEN:2})
exten = _**.,n,Set(EXTTOBEPICKUP=${EXTEN:2})
exten = _**.,n,NoOp(-> this device is ${EXTENSION_STATE(${EXTTOBEPICKUP})})
exten = _**.,n,ExecIf($["${EXTENSION_STATE(${EXTTOBEPICKUP})}"!="RINGING"]?Busy())
exten = _**.,n,Set(CALLERCHAN=${DB(CALLERCHAN/${EXTEN:2})})
exten = _**.,n,Set(CALLEDCHANS=${CHANNELS(SIP/${EXTTOBEPICKUP})})
exten = _**.,n,Set(CALLEDCHAN=${CUT(CALLEDCHANS, ,1)})
exten = _**.,n,GotoIf($["${CALLERCHAN}"=""]?CallPickupOldSchool,${EXTEN},1)
exten = _**.,n,Answer()
exten = _**.,n,SoftHangup(${CHANNEL})
exten = _**.,n,NoOp(this will never be executed)
exten = h,1,ChannelRedirect(${CALLERCHAN},${CALLEDCHAN},DLPN_DialPlan1,${CALLERID(num)},1)
----------------------------------------------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: app_channelredirect.c.patch
Type: text/x-patch
Size: 2349 bytes
Desc: not available
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20210305/fe147dc9/attachment.bin>


More information about the asterisk-dev mailing list