# Codec can't be set to G729

**URL:** <https://community.asterisk.org/t/codec-cant-be-set-to-g729/26647>\
**Category:** Asterisk Support\
**Created:** [April 20, 2009, 1:07pm UTC](https://community.asterisk.org/t/codec-cant-be-set-to-g729/26647 "2009-04-20T13:07:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![emrom](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@emrom](https://community.asterisk.org/u/emrom)\
**Post date:** [April 20, 2009, 1:07pm UTC](https://community.asterisk.org/t/codec-cant-be-set-to-g729/26647/1 "2009-04-20T13:07:30Z")

</div>

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:

```auto

```

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:

```auto
[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:

```auto
[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](mailto: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!

---

<div class="post-metadata">

**Author:** ![david55](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@david55](https://community.asterisk.org/u/david55)\
**Post date:** [April 20, 2009, 1:34pm UTC](https://community.asterisk.org/t/codec-cant-be-set-to-g729/26647/2 "2009-04-20T13:34:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![emrom](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@emrom](https://community.asterisk.org/u/emrom)\
**Post date:** [April 20, 2009, 3:35pm UTC](https://community.asterisk.org/t/codec-cant-be-set-to-g729/26647/3 "2009-04-20T15:35:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![emrom](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@emrom](https://community.asterisk.org/u/emrom)\
**Post date:** [April 21, 2009, 1:36pm UTC](https://community.asterisk.org/t/codec-cant-be-set-to-g729/26647/4 "2009-04-21T13:36:24Z")

</div>

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

```auto

```

to

```auto

```

Thanks for your reply.
