Thank you for your suggestion and apologies for my late reply, but it took time to search for a different approach.
Did you get this from an LLM?
Yes, and upon reading the documentation, this indeed makes no sense, so please disregard.
I imagine that you’d need to use PJSIP_MEDIA_OFFER - Asterisk Documentation but you are setting it on the wrong channel for the outbound leg, and I’m not sure how useful it is on the inbound leg, before the call is answered.
I tried your approach, but as you suspected, it did not work.
My new approach would be as follows (if a new thread is a better idea, please let me know): I have now set up a second endpoint/trunk; the first endpoint I used was on port 5740, and the new one is on 5741. Both endpoints are indeed reachable; my pjsip.conf looks essentially like this, where SBC_HOST is the host (both ports are on this host):
[my-sbc-1]
type=endpoint
disallow=all
allow=g722
aors=my-sbc-1
context=sip-incoming-my-sbc-1
[my-sbc-1]
type=aor
contact=sip:${SBC_HOST}:5740
qualify_frequency=30
[my-sbc-1]
type=identify
endpoint=my-sbc-1
match=${SBC_HOST}
[my-sbc-2]
type=endpoint
disallow=all
allow=alaw
aors=my-sbc-2
context=sip-incoming-my-sbc-2
[my-sbc-2]
type=aor
contact=sip:${SBC_HOST}:5741
qualify_frequency=30
[my-sbc-2]
type=identify
endpoint=my-sbc-2
match=${SBC_HOST}
And I assumed that the following extensions.conf would work:
;Specification for g722
[sip-incoming-my-sbc-1]
exten => +4912345,1,AGI(myscript.agi)
;Specification for alaw
[sip-incoming-my-sbc-2]
exten => +4912346,1,AGI(myscript.agi)
However, when I call +4912346, I see in my logs that this number is not found in sip-incoming-my-sbc-1, so my assumption that Asterisk searches through the entire extensions.conf is incorrect. Do you have any suggestions how I might solve this? I tried the following and then, the number is reachable, but the codec is g722 instead of alaw (presumably because it first goes through sip-incoming-my-sbc-1 which is associated with g722):
;Specification for g722
[sip-incoming-my-sbc-1]
exten => +4912345,1,AGI(myscript.agi)
exten => +4912346,1,Goto(sip-incoming-my-sbc-2,+4912346,1)
;Specification for alaw
[sip-incoming-my-sbc-2]
exten => +4912346,1,AGI(myscript.agi)