SIP sdp codec problem when receive 200 OK

Hi all,

In pjsip.conf, I set following endpoint setting
allow = alaw,ulaw,g729

My test scenario is as follow:

A: support alaw and ulaw.
B: only support ulaw.

A call B, B answer and reply 200 OK with codec alaw.

Internet Protocol Version 4, Src: 192.168.1.252, Dst: 192.168.1.1
User Datagram Protocol, Src Port: 64068, Dst Port: 5060
Session Initiation Protocol (200)
    Status-Line: SIP/2.0 200 OK
    Message Header
    Message Body
        Session Description Protocol
            Session Description Protocol Version (v): 0
            Owner/Creator, Session Id (o): - 3776182999 3776183000 IN IP4 192.168.1.252
            Session Name (s): pjmedia
            Bandwidth Information (b): AS:84
            Time Description, active time (t): 0 0
            Session Attribute (a): X-nat:0
            Media Description, name and address (m): audio 4002 RTP/AVP 0 101
            Connection Information (c): IN IP4 192.168.1.252
            Bandwidth Information (b): TIAS:64000
            Media Attribute (a): rtcp:4003 IN IP4 192.168.1.252
            Media Attribute (a): sendrecv
            Media Attribute (a): rtpmap:0 PCMU/8000
            Media Attribute (a): rtpmap:101 telephone-event/8000
            Media Attribute (a): fmtp:101 0-16
            Media Attribute (a): ssrc:411067583 cname:27123cd0114641ff
            [Generated Call-ID: 9ux0y4-8wj3aUjpT7lXOr7vdq38omgm.]

But Asterisk will send 200 OK to A with codec alaw and ulaw.

Internet Protocol Version 4, Src: 192.168.1.1, Dst: 192.168.1.252
User Datagram Protocol, Src Port: 5060, Dst Port: 51258
Session Initiation Protocol (200)
    Status-Line: SIP/2.0 200 OK
    Message Header
    Message Body
        Session Description Protocol
            Session Description Protocol Version (v): 0
            Owner/Creator, Session Id (o): - 1769454452 3 IN IP4 192.168.1.1
            Session Name (s): Session
            Connection Information (c): IN IP4 192.168.1.1
            Time Description, active time (t): 0 0
            Media Description, name and address (m): audio 51640 RTP/AVP 8 0 101
            Media Attribute (a): rtpmap:8 PCMA/8000
            Media Attribute (a): rtpmap:0 PCMU/8000
            Media Attribute (a): rtpmap:101 telephone-event/8000
            Media Attribute (a): fmtp:101 0-16
            Media Attribute (a): ptime:20
            Media Attribute (a): maxptime:150
            Media Attribute (a): sendrecv
            [Generated Call-ID: 99142MTVhYzNhZTAxMWJiZjBmMjRmYjEwMzAwZDJlYTI4M2E]

Finally, A send alaw rtp, and B send ulaw rtp. But, because our provider doesn’t allow transcoding, the call will be terminated.
How to solve this problem? Is there any way to send 200 OK with only ulaw to B?
Thank you ~

Asterisk will not send 200 OK to B because Asterisk is a UAC in relation to it!

If you meant A, there is no back path for codec information.

It is, however, possible to restrict the codecs in the offer to A from the dialplan.

Sorry, it should send 200 OK to A.
If I retrict the codecs by PJSIP_MEDIA_OFFER in dialplan.
What if B changed codec to another, the call will be fail, right?

I have found this patch : ASTERISK-4703 [patch][post 1.4] New codec negotiation algorithm
It is a new codec negotiation algorithm for chan_sip, is there any similar patch for chan_pjsip?
Thank you

Hi Winnie, you can simply remove G.729 and alaw from the allow field and it will force everything over ulaw. Without really knowing what all of these endpoints are and what the full call flow of what you are telling to do, it’s not clear what the best approach is, but it can almost certainly be handled by choosing carefully what codecs you allow for each endpoint.

Asterisk will try to transcode.