[Asterisk-Users] Codec control

Eric Wieling aka ManxPower eric at fnords.org
Thu Nov 25 02:42:57 MST 2004


> Eric Wieling wrote:
> 
>> Damian Minkov wrote:
>>
>>> How can i control the codec for the calls. For example I have 3 SIP 
>>> phones registered to asterisk
>>> The firs two are in the local area network (behind nat)- I want to 
>>> use g711 between them and to connect directly (canreinvite=yes)
>>> and the third is in internet - want all calls to it and from it to 
>>> use g729 and media to go through asterisk.
>>> So if Phone 1 calls Phone 2 the codec to be g711, but when Phone 1 
>>> calls Phone 3 to use g729 ?
>>
>>
>>
>> Because of the problem with disallow= in sip.conf peer sections this 
>> may not work the way you expect.  This is what I do.
>>
>> [general]
>> diallow=all
>> allow=ulaw
>> allow=g729
>>
>> [phone1]
>> disallow=all
>> allow=ulaw
>>
>> [phone2]
>> disallow=all
>> allow=ulaw
>>
>> [phone3]
>> disallow=all
>> allow=g729
>>
>> Now for the trick.  Make the PHONE only support the codec you want. 
>> i.e. diallow all the codecs on phone1 and phone 2 except for ulaw.  On 
>> phone 3 disallow all the codecs except for g729.  Because of the 
>> problems with disallow= in the [happypeer] parts of sip.conf this 
>> won't work unless the codecs are specified on the phone.  Do NOT allow 
>> both ulaw and alaw.  I've seen problems with this reported on #asterisk
>>
>> --Eric
>>

Damian Minkov wrote:
> But yhis doesn't deal with the canreinvite
> i have 3 call directions
> 
> 1. Local - Internet / Internet Local  - g729 , media through *
> 2. Local - Local - g711, media not through *
> 3. Internet - Internet - g729, media not through *
> 
> Your solution is working ok , except in the 3-td situation. Can this be 
> done som how with peers ?
> 


You can try playing around with ${SIP_CODEC).  Check README.variables to 
be sure of the correct variable name.  Picking the codec based on the 
destination is not well supported in Asterisk.  Asterisk assumes you 
will want to pick the codec based on the source device of the call, not 
the destintion device.

If you want to have the media NOT go thru Asterisk you will have 
problems with NAT.  Also some Dial options ("t" and "T" come to mind, 
but there may be others) will prevent Asterisk from releasing the media 
stream so the clients can talk directly to each other.

Your needs are complex enough that you might want to investigate using 
SER as a SIP proxy.   I have designed my (small) VoIP network to not 
need SER, but I do not need to pick the codec based on the destination 
device and I don't have the devices communicate directly.


--Eric

-- 
I am seeking part or full time employment in Toronto, The Netherlands,
or Belgium.  My preference is part time employment in Toronto with
some telecommuting. Currently located in New Orleans, Louisiana and am
happy to relocate. Contact eric at fnords.org.




More information about the asterisk-users mailing list