Change Codec When Dial From SIP To DAHDI

Home » Asterisk Users » Change Codec When Dial From SIP To DAHDI
Asterisk Users 6 Comments

Hi:
I am useing asterisk 11.12.
I use G722 as preferred codec for my ip-phone. and my PSTN DAHDI
use alaw. G722 is great when ip-phone talks to each other. but when ip-phone dialout to PSTN DAHDI, G722 is not great, since it is need to transcode to alaw.
so I try to change the codec when dial from SIP to DAHDI. I tried to use IP_CODEC/SIP_CODEC_OUTBOUND at dialplan. but the SIP codec change after dahdi answered the channel. so everything is broken. the call log like below:

[2014-09-23 21:18:46] VERBOSE[11634][C-0000000d] pbx.c:

6 thoughts on - Change Codec When Dial From SIP To DAHDI

  • hi:
    I Have tried asterisk 1.6.2, 1.8, 11, 12, 13. all versions behave the same => transcode in the middle even two legs use the same code.

    but I found an article which seems to solve this kind of problem:

    https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite

    but I tried version 13 and didn’t notice the change, are there new diaplan commands or channel variables to do this?

    thanks a lot for help!!

    Regards, tbskyd

    2014-09-24 1:30 GMT+08:00 d tbsky :

  • hi:
    forgot to mention. not only dialout DAHDI, even I dialout SIP
    TRUNK, the situation is the same:

    asterisk transcode in the middle even two legs use the same code.

    2014-09-25 11:20 GMT+08:00 d tbsky :

  • That article is in the development section of the wiki. While that doesn’t mean any of the information there is necessarily wrong, its purpose was to coordinate development efforts, not to define behavior for end-users.

    In this particular case, portions of that page only affect chan_pjsip:

    {quote}

    The Offer/Answer use cases below only apply to chan_pjsip. chan_sip, for better or worse, has its own fun rules about what codecs are offered and when.

    /* add_sdp: */

    /* Now, start adding audio codecs. These are added in this order:
    – First what was requested by the calling channel
    – Then preferences in order from sip.conf device config for this peer/user
    – Then other codecs in capabilities, including video
    */

    Changing chan_sip is fraught with peril. As such, we’re going to try and give the power/flexibility of how things are offered/answered to where we can better maintain/control the behaviour, which means chan_pjsip.

    {quote}

    We worked to make sure that we *didn’t* change the offer/answer rules in chan_sip. The fact that we did a lot work under the hood and things managed to remain the same was the goal.

    chan_pjsip does use a different set of rules for how it offers its codecs, and should generally follow what it outlined on that wiki page.

    Matt

  • 2014-09-25 20:46 GMT+08:00 Matthew Jordan :

    thanks a lot for the hint! you really save my day!
    I was thinking about studying freeswitch, since people said freeswitch can do that without transcode. now i will spent my time to study chan_pjsip, and hope it can fix the problem. i really want to stay with asterisk 🙂

    thanks again for your kindly help!!

    Regards, tbskyd

  • 2014-09-26 3:34 GMT+08:00 Eric Wieling :
    hi:
    can you give some more hint about the topic?

    in my testing, if the sip phone use G.722 and the sip trunk use G.711, I can hear the quality is not as good as both side use G.711.

    but you maybe right when both legs use G.711 but transcoding in the middle. the quality seems not so bad but I have test it very deeper..

    thanks a lot for your help!!

    Regards, tbskyd