Different Codec For Different Type Of Calls

Home » Asterisk Users » Different Codec For Different Type Of Calls
Asterisk Users 4 Comments

Hello,

Let’s say I have a SIP client that supports both G711 and G729 codecs and I
have them both enabled in sip.conf and G729 has higher priority.

Can I force the call to choose a different codec based on the dialed number or other conditions?

For instance I would want to do G711 if the call was routed to T1 card over Dahdi but G729 if the call was going to another sip client.

Thanks, Ali Pey

4 thoughts on - Different Codec For Different Type Of Calls

  • If you set up your DAHDI lines as “users” you should be able to do this.

    From: asterisk-users-bounces@lists.digium.com
    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Ali Pey Sent: Thursday, November 01, 2012 10:49 AM
    To: asterisk-users@lists.digium.com Subject: [asterisk-users] Different codec for different type of calls

    Hello,

    Let’s say I have a sip client that supports both G711 and G729 codecs and I
    have them both enabled in sip.conf and G729 has higher priority.

    Can I force the call to choose a different codec based on the dialed number or other conditions?

    For instance I would want to do G711 if the call was routed to T1 card over Dahdi but G729 if the call was going to another sip client.

    Thanks,

    Ali Pey

  • Qasim,

    Thank you for your response. I tried it but still doesn’t work. This is what I have:

    exten => _XXX.,1,NoOP(Set G711 codec)
    exten => _XXX.,n,Set(SIP_CODEC=ulaw)
    exten => _XXX.,n,Set(SIP_CODEC_OUTBOUND=ulaw)
    exten => _XXX.,n,Dial(DAHDI/g1/$EXTEN)

    Then I get this error:

    WARNING[12156]: channel.c:5796 ast_request: No translator path exists for channel type DAHDI (native (ulaw|alaw|slin)) to (h264|silk8)
    WARNING[12156]: app_dial.c:2277 dial_exec_full: Unable to create channel of type ‘DAHDI’ (cause 58 – Bearer capability not available)

    I tried both g711 and ulaw with no luck. I read the SIP_CODEC value and it is set properly.

    Any suggestions/ideas?

    Thanks, Ali Pey

  • SIP_CODEC is only useable on a SIP channel. You can specify DAHDI codecs in users.conf.

    From: asterisk-users-bounces@lists.digium.com
    [mailto:asterisk-users-bounces@lists.digium.com] Hello,

    Let’s say I have a sip client that supports both G711 and G729 codecs and I
    have them both enabled in sip.conf and G729 has higher priority.

    Can I force the call to choose a different codec based on the dialed number or other conditions?

    For instance I would want to do G711 if the call was routed to T1 card over Dahdi but G729 if the call was going to another sip client.

    Thanks,

    Ali Pey