Asterisk 13.14 PJSIP Codec negotiation Problem (with diagram explain)

Hello,
i have really big problem and try to understand why it is wrong. Could you help me about this questions.

Picture 1.

Picture 2.

  1. in Picture 1, even if codecs priority start with G729 and alaw both sides between B side and Asterisk 13.14 , call flows alaw-g729. Why asterisk dont translate alaw to g729 . In addition , it shocks me , both side can hear each other.

  2. in Picture 2, B starts calls, the same codec priority and B and middle asterisk should talk with G729 but middle asterisk dont translate codecs?

  3. in Picture 2 , Middle Asterisk can translate 1 rtp flow, but dont touch other side

Here is conf.

[system]
type=system
;threadpool_auto_increment=15

[global]
type=global
max_forwards=30
 
keep_alive_interval=20
 

[simpletrans]
type=transport
protocol=udp
bind=WANIP

[notsimple]
type=transport
protocol=udp
bind=172.20.10.194

[Bside]
type = endpoint
transport=simpletrans
t38_udptl=no
fax_detect=no
allow_transfer=no
force_rport=yes
direct_media=no
disallow=all
allow=g729
;allow=ulaw
allow=alaw
;allow=g722
aors=Bside
context=Aside-out
;rtp_timeout=60
allow_subscribe=no
;inband_progress=yes

[Bside]
type=identify
endpoint=Bside
match=Bside.0/24

[Bside]
type = aor
max_contacts=10
qualify_frequency=60
qualify_timeout=3.0      ; Qualify timeout in fractional seconds (default: "3.0")
authenticate_qualify=no
contact=sip:BsideIP:5060
qualify_frequency=10
qualify_timeout=5.0      ; Qualify timeout in fractional seconds (default: "3.0")
authenticate_qualify=no

[Aside]
type = endpoint
transport=notsimple
t38_udptl=no
fax_detect=no
allow_transfer=no
direct_media=no
disallow=all
allow=g729
allow=alaw
;allow=ulaw
;allow=g722
aors=Aside
rtp_timeout=120
context=netgsm-in
rewrite_contact=yes
allow_subscribe=no
user_eq_phone=yes
direct_media=no
;inband_progress=yes
;100rel=no

[Aside]
type=identify
endpoint=Aside
match=ALocalIP.0/24

[Aside]
type = aor
qualify_frequency=60
qualify_timeout=5.0      ; Qualify timeout in fractional seconds (default: "3.0")
authenticate_qualify=no
contact=sip:ADestLocalIP

Hello ,
PJSIP_MEDIA_OFFER and PJSIP_SEND_SESSION_REFRESH are added to Dialplan to reinvite as below. Flow like below.

Sometimes one side voice can hearable because PJSIP select wrong codec and dont translate it.

in pjsip conf , asymmetric_rtp_codec=no is added to do it no changes.

PJSIP_MEDIA_OFFER

in addition , PJSIP media OFfer dont work good because i added only G729 but it sends codecs list in endpoints.

Thanks.


Here is extensions.conf.

exten => _001X.,n,Set(PJSIP_MEDIA_OFFER(audio)=!all,g729)
exten => _001X.,n,Set(PJSIP_SEND_SESSION_REFRESH()=invite)
exten => _001X.,n,Dial(PJSIP/Aside/sip:${EXTEN}@ip:5060,b(out-pre-dial,s,1))

[out-pre-dial]
exten => s,1,NOOP(Pre dialer)
exten => s,n,Set(PJSIP_SEND_SESSION_REFRESH()=invite)
exten => s,n,Return()

  1. Because Alaw is an acceptable codec on the outgoing side. Transcoding will only happen of there is no acceptable codec.

  2. (a) A is not allowed to send No SDP!
    (b) A-law is an acceptable codec to B, so there is no need to transcode.

  3. G.729 is not an acceptable codec to A, so transcoding is necessary.

Although you call it negotiation, SIP doesn’t actually negotiate codecs; it simply tells the other side the set of codecs that is acceptable to it and the order of preference. The sender can use any or all of the acceptable codecs during the session. It can even do so if it didn’t offer them itself, although Asterisk will not do that.

So asterisk should understand and convert it which codecs coming from RTP payload? If middle asterisk can send re-invite or update ,can it force to g729 codec?

Here is another example,

Between middle Ast and Bside , talks alaw but priority G729, alaw, i thought it should be G729 but talks with alaw and voice ok.

i need to look at here? to understand better?

The answer about restricting the codecs (no) was given on the forum less than a week ago.

Note that, it is possible to set channel variables to constrain the codecs offered to the B side and accepted from the A side, as long as you do so before calling the B side or answering the A side. Again details were posted less than a week ago.

Your latest image gives “500 Origin Not Reachable”!

I would suggest filing an issue[1] with Asterisk logs, the configuration, etc as when asymmetric is not enabled the incoming and outgoing RTP flow for a single session should use the same codec. They shouldn’t be different.

[1] https://issues.asterisk.org/jira

@jcolp
i will share with dialplan, and wireshark notes on Jira asterisk. Thanks.

@david551 Thanks for your help.

it is solved with
only g729 codec is configured for B trunk and B side and B trunk always talk each other G729
A-side and A trunk talks with G729 or Alaw.

In additon,

in this situtation , i will share core show channels info.

pjsip show channelstats doesnt show true information

fc3129d0 A-00076857 00:00:22 928 0 0 0.000 927 4 0 0.000 0.007

fc3129d0 B-00076856 00:00:33 ulaw 1344 0 0 0.000 1482 0 0 999.999 0.003

here is core show channel ChannelID results.
B side

NativeFormats: (g729|alaw)
WriteFormat: g729
ReadFormat: g729
WriteTranscode: No
ReadTranscode: No

A side

NativeFormats: (alaw)
WriteFormat: alaw
ReadFormat: alaw
WriteTranscode: Yes (g729@8000)->(slin@8000)->(alaw@8000)
ReadTranscode: No

Maybe there is a different between “pjsip reload” and “reload” for asymetric_rtp parameter. Because other server never failed like first , even if i tested so many times and same version.