[asterisk-users] Why doesn't Asterisk try to prevent transcoding

Ryan Wagoner rswagoner at gmail.com
Sun Dec 15 07:28:51 CST 2013


On Sun, Dec 15, 2013 at 5:07 AM, jg <webaccounts at jgoettgens.de> wrote:

> I think the order or elements is relevant:
>
> [100]
> disallow=all
> allow=ulaw
> allow=g722
> or
> [100]
> allow=!all,ulaw,g722
>
> should work.
>
> jg


If I choose that order and the phone supports both ulaw and g722 only ulaw
will be used. I want to use g722 when available on both devices, fallback
to ulaw without transcoding if both devices support it, or transcode if
only one device supports ulaw.

I looked at the code more and here is what happens. Device 100 dials 101.
The sip_new function is called and AST_CODEC_CHOOSE g722 is set as the
read/write format.

[2013-12-14 22:51:59] DEBUG[25200][C-0000004d]: chan_sip.c:7911 sip_new:
*** Our native formats are (g722)
[2013-12-14 22:51:59] DEBUG[25200][C-0000004d]: chan_sip.c:7912 sip_new:
*** Joint capabilities are (ulaw|g722)
[2013-12-14 22:51:59] DEBUG[25200][C-0000004d]: chan_sip.c:7913 sip_new:
*** Our capabilities are (ulaw|g722)
[2013-12-14 22:51:59] DEBUG[25200][C-0000004d]: chan_sip.c:7914 sip_new:
*** AST_CODEC_CHOOSE formats are g722

Dial 101 is executed in the dialplan, sip_request_call is called, which in
turn calls sip_new. The AST_CODEC_CHOOSE g722 from above becomes the
incoming preferred format. We can only have one preferred format as
sip_request_call takes in struct ast_format_cap *cap.

[2013-12-14 22:51:59] DEBUG[27830][C-0000004d]: chan_sip.c:7911 sip_new:
*** Our native formats are (ulaw)
[2013-12-14 22:51:59] DEBUG[27830][C-0000004d]: chan_sip.c:7912 sip_new:
*** Joint capabilities are (nothing)
[2013-12-14 22:51:59] DEBUG[27830][C-0000004d]: chan_sip.c:7913 sip_new:
*** Our capabilities are (ulaw)
[2013-12-14 22:51:59] DEBUG[27830][C-0000004d]: chan_sip.c:7914 sip_new:
*** AST_CODEC_CHOOSE formats are ulaw
[2013-12-14 22:51:59] DEBUG[27830][C-0000004d]: chan_sip.c:7916 sip_new:
*** Our preferred formats from the incoming channel are (g722)

Asterisk tries to find a common codec between this channels capabilities
and the incoming channel preferred format. Of course there are none (g722
and ulaw don't match) so we pick ulaw and transcode. What I am proposing is
Asterisk passes fallback formats to sip_request_call. If the joint
capabilities are none, then check the fallback formats. In this case it
would be ulaw and ulaw. If there is a match switch the incoming channel to
that format (ulaw) and AST_CODEC_CHOOSE would be ulaw this for channel.
However I'm not sure how to make this change as I don't know my way around
the interaction with the Asterisk core and the channels.

Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20131215/040b35cc/attachment.html>


More information about the asterisk-users mailing list