Up until now, if you wanted to add a header to a callee channel to appear in an outgoing INVITE this had to be done via pre-dial handler.
This worked well, but made it complicated to set those headers from the caller or intermediate channel(s). It could be done, but it required setting inherited channel variables that would then have to be read and converted by the pre-dial handler.
However, with the addition of a new dialplan function: PJSIP_INHERITABLE_HEADER it is now possible to set those headers directly on the callee or local bridged channel and have them inherit to the caller channel automatically.
This functions almost exactly like the PJSIP_HEADER dialplan application, but only the add, modify and remove actions are available:
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=one)
same => n,Set(PJSIP_INHERITABLE_HEADER(update,X-custom)=two)
same => n,Set(PJSIP_INHERITABLE_HEADER(remove,X-custom))
This dialplan application is still available in a pre-dial handler, so it is possible to add from a caller channel, then remove or modify them from a bridge local channel or via pre-dial handler.
[default]
exten => 564,1,noOp()
same => n,Answer()
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=one)
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=two)
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=tres)
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=four)
same => n,Dial(PJSIP/Carrot,,tTb(obheaderhandler^obheader^1))
same => n,Hangup()
[obheaderhandler]
exten => obheader,1,noOp()
same => n,Set(PJSIP_INHERITABLE_HEADER(update,X-custom,3)=three)
same => n,Set(PJSIP_HEADER(add,X-custom-OB)=one)
same => n,Return()