root@vmi2819626:/etc/asterisk# vi sip.conf
qualify=yes ; Enable DNS SRV lookups on outbound calls
[authentication] basic-options ; a template
dtmfmode=rfc2833
context=from-office
type=friend natted-phone ; another template inheriting basic-options
directmedia=no
host=dynamic public-phone ; another template inheriting basic-options
directmedia=yes my-codecs ; a template for my preferred codecs
disallow=all
allow=ilbc
allow=g729
allow=gsm
allow=g723
allow=ulaw
allow=alaw ulaw-phone ; and another one for ulaw-only
disallow=all
allow=ulaw
allow=alaw
allow=gsm
[mobile]
type=friend
context=phones
allow=ulaw,alaw,gsm
disallow=all
directmedia=no
nat=force_rport,comedia
secret=12345678
host=dynamic
[desktop]
type=friend
context=phones
allow=ulaw,alaw,gsm
disallow=all
directmedia=no
nat=force_rport,comedia
secret=09876543
host=dynamic
[phones]
exten => 777,1,NoOp(first line)
same => n,NoOp(second line)
same => n,Playback(tt-monkeys)
same => n,Dial(SIP/desktop)
same => n,Hangup
exten => 999,1,NoOp(first line)
same => n,NoOp(second line)
same => n,playback(hello-world)
same => n,Dial(SIP/mobile)
same => n,Hangup
[Sep 27 21:17:44] NOTICE[47426][C-0000178d]: chan_sip.c:10997 process_sdp: No compatible codecs, not accepting this offer!
Please use the channel driver that comes with current official versions of Asterisk. Your chan_sip configuration has several bits of bad practice and outright errors, and very few people now have any familiarity with chan_sip.
Neither desktop nor mobile have any codecs allocated. You start with all, try to add some a second time, then remove them all. I think this is the cause of your headline problem, but if you had specified some codecs, we would have needed to see the SDP, from the other side, or detailed logging, to determine why the codecs mismatched.
You can’t have a line outside a section, and the comment is far from what this option actually does.
You define templates, but never use them!
If these are inside NAT, other than any NAT which Asterisk is inside, and don’t compensate for it, you will need extra options to work round the incorrect addresses present in the SIP headers, and the SDP. If they are outside the NAT containing Asterisk you need extra options to allow Asterisk to place the correct addresses in the above places.
This is sometimes necessary, but, in most cases, causes reduced security and can cause misoperation.
I hope this is really in extensions.conf, as it is not valid in sip.conf.
For various reasons, you probably don’t want either of these.
G.729 is not transcodable into anything else without extra software. Sangoma do not provide that software free of charge
GSM has been replaced by far better low bit rate codecs, and the general trend is to increase audio quality rather than push the minimum usable quality through as little bandwidth as possible, as, for most users, bandwidth is cheap. That’s also true of G.729.