Codec can't be set to G729

Hi all,

I’m trying to call a peer with the G729A codec, but between Asterisk and my gateway/peer the SDP header doesn’t even have “G729”.

Here’s my setup:

Softphone1<—>Asterisk has no issue negotiating G729 (as initiated by the softphone), but Asterisk<—>Peer1 negotiate with codecs I have not allowed (GSM and G711).

My sip.conf looks like this:

[general]
context=default
fromdomain=192.168.0.14:5060
canreinvite=no

[peer1] 
bindport=5060
port=5060
type=friend
context=Inbound
host=192.168.0.42
defaultip=192.168.0.14
defaultport=5060
qualify=yes
disallow=all
allow=G729

[softphone1]
type=friend
context=from-softphone
host=dynamic
qualify=yes
fromdomain=192.168.0.14:5060
callerid=0223456789 <0223456789>
disallow=all
allow=G729

My extensions.conf looks like this:

[Inbound] ; appels entrant                                                                                                                   
exten => 0223456789,1,Set(SIP_CODEC=G729)
exten => 0223456789,n,Dial(SIP/softphone1)

[from-softphone]
exten => 2123,1,Set(SIP_CODEC=G729)
exten => 2123,n,Dial(SIP/0623456789@192.168.0.42,20,rt)
exten => 2123,n,Hangup()

I activated SIP debug on peer1, and this is what I got:

[code]*CLI> – Executing [2123@from-softphone:1] Set(“SIP/softphone1-b6415cd0”, “SIP_CODEC=G729”) in new stack
– Executing [2123@from-softphone:2] Dial(“SIP/softphone1-b6415cd0”, “SIP/0623456789@192.168.0.42|20|rt”) in new stack
Audio is at 192.168.0.14 port 13930
Adding codec 0x2 (gsm) to SDP
Adding codec 0x4 (ulaw) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 192.168.0.42:5060:
INVITE sip:0623456789@192.168.0.42 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.14:5060;branch=z9hG4bK1bbee8f0;rport
From: “0223456789” sip:0223456789@192.168.0.14:5060;tag=as5d5f585b
To: sip:0623456789@192.168.0.42
Contact: sip:0223456789@192.168.0.14
Call-ID: 1fe2687b179c507b468ce81b2184110e@192.168.0.14:5060
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Max-Forwards: 70
Date: Mon, 20 Apr 2009 10:39:38 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Type: application/sdp
Content-Length: 287

v=0
o=root 23620 23620 IN IP4 192.168.0.14
s=session
c=IN IP4 192.168.0.14
t=0 0
m=audio 13930 RTP/AVP 3 0 8 101
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv



– SIP/192.168.0.42-09a4f528 answered SIP/softphone1-b6415cd0
[Apr 20 14:52:28] NOTICE[31306]: chan_sip.c:3659 try_suggested_sip_codec: Changing codec to ‘G729’ for this call because of ${SIP_CODEC} variable
[Apr 20 14:52:28] NOTICE[31306]: chan_sip.c:3659 try_suggested_sip_codec: Changing codec to ‘G729’ for this call because of ${SIP_CODEC} variable
[/code]
What bothers me in particular is that none of the codecs added to the SDP in the above debug are those which I suggested.

I looked this up quite a bit before asking here, which is why I set “canreinvite=no” but because I’m using peer1 as a gateway I guess it doesn’t matter. Any ideas?

Thanks!

You haven’t built G.729 support into your Asterisk binaries or you don’t have enough G.729 licences.

Thanks for your quick reply David. I will look into it.

It would appear that I would call my gateway’s IP directly as opposed to its nominal SIP profile name…The fix is:
Change

to

Thanks for your reply.