edit 2018-07-14: The method that follows is no longer working
The linked ticket is not a bug, it is a fundamental misunderstanding of PJSIP. You can’t add custom SIP headers to outbound calls on PJSIP channels using the same old method that works for chan_sip (i.e. using the [macro-dialout-trunk-predial-hook]
context). This is a problem that I struggled with when I first started using PJSIP, and I addressed it by:
Adding custom dial options to the PJSIP trunk, i.e:
Ttb(lgaetz-custom-header^s^1)
Then add the custom dialplan for the subroutine referenced in the trunk dial option:
[lgaetz-custom-header]
exten => s,1,gotoif($["${CHANNEL(channeltype)}"="SIP"]?SIP)
exten => s,n,gotoif($["${CHANNEL(channeltype)}"="PJSIP"]?PJSIP)
exten => s,n,noop(Not a sip channel)
exten => s,n,Return
exten => s,n(SIP),noop(Adding custom header to SIP channel)
exten => s,n,SIPAddHeader(X-Tag:lgaetz)
exten => s,n,Return
exten => s,n(PJSIP),noop(Adding custom header to PJSIP channel)
exten => s,n,Set(PJSIP_HEADER(add,X-Tag)=lgaetz)
exten => s,n,Return
In order to add a custom SIP header to a PJSIP channel, it must be done at the point of dialing