Disable slin transcoding

Hello all.

I use asterisk 13.30 and chan_sip.
I am using get_data in php agi script for playing the file and collect digit.

$agi->get_data(“/var/lib/asterisk/sounds/voice”, 3000, 1);

All legs use alaw codec only. When this file played from agi script asterisk was transcoded it in the slin codec and then transcoded in alaw. I have converted this wav file to alaw and ulaw codecs, but the file is still played in the slin codec.
transcode_via_sln is set to no in asterisk.conf.
disallow=all allow=alaw allow=ulaw in sip.conf
Transcoding heavily loads the CPU.
When I try to play this file from dialplan directly, it plays correctly in alow codec.

How to disable this slin transcoding?

You are using an unsupported version of Asterisk and an effectively unsupported channel driver (which is about to be removed from the github master version, in the next few weeks).

Transcoding between G.711 and signed linear is very low cost as far as transcoding goes. If it is causing you CPU problems you have an extremely heavily loaded system, which was already near breaking point.

Are you using inband DTMF; that has to be converted to linear format and the tone detection filters are going to be a lot more costly than G.711 linear conversion.

Is there an Originate involved in your AGI version?

Which AGI library are you using?

The underlying AGI code goes directly into stream file without doing any codec manipulation, so it seems unlikely that anything to do with AGI is forcing transcoding for the play out part of the process:

My feeling is that any codec change within the actual AGI action is because of inband DTMF, not for playing the file.

What format was the file in? Asterisk .wav is sln, with an RIFF wrapper, so there is no transcoding step to get to sln. Is that what you actually meant.

For the avoidance of doubt, when you say you have converted the wav file, do you men you have simply changed the payload type, which won’t work, or that you have created raw .alaw and .ulaw files, with no ,wav (RIFF) wrapper.

David, I use phpagi library 2.2 version. I don’t use originate in agi script.
I use call file for originating, then I call script for playing the file and collect digit.
I have converted wav file using sox.
sox -V voice.wav -r 8000 -c 1 -t al voice.alaw

When I Playback(voice) from dialplan, it normally played in alaw format.

In call file i use “Channel: LOCAL/[email protected]” for originate.

exten => s,1,NoOp("Dialer dialed: ${NUM})
same => n,Set(CHANNEL(accountcode)=DIALER)
same => n,Set(CDR(userfield)=${NUM})
same => n,Dial(SIP/ss/${NUM},34)
same => n, NoOp(SIP return code : ${HASH(SIP_CAUSE,${CDR(dstchannel)})})
same => n,NoOp(${DIALSTATUS})
same => n,Set(SIPC=${HASH(SIP_CAUSE,${CDR(dstchannel)})})
same => n,Goto(dialer-${DIALSTATUS},1)

exten => dialer-NOANSWER,1,AGI(dialererror.agi,${ID},${CAMPN},${NUM},${DIALSTATUS},${TRY},${SIPC})
exten => dialer-BUSY,1,AGI(dialererror.agi,${ID},${CAMPN},${NUM},${DIALSTATUS},${TRY},${SIPC})
exten => dialer-CONGESTION,1,AGI(dialererror.agi,${ID},${CAMPN},${NUM},${DIALSTATUS},${TRY},${SIPC})
exten => dialer-CHANUNAVAIL,1,AGI(dialererror.agi,${ID},${CAMPN},${NUM},${DIALSTATUS},${TRY},${SIPC})
exten => dialer-DONTCALL,1,AGI(dialererror.agi,${ID},${CAMPN},${NUM},${DIALSTATUS},${TRY},${SIPC})
exten => dialer-CANCEL,1,AGI(dialererror.agi,${ID},${CAMPN},${NUM},${DIALSTATUS},${TRY},${SIPC})

Call files are, effectively, Originate. Especially because you are using a local channel (although I’m not sure that using the channel directly would be any better), the call will be set up as slin, because the final codec is not known. To force it to something else, you would need to use AMI Originate, as its Codecs option isn’t documented as also present for call files (although might be an undocumented one).

Although you haven’t provided the B side of the call file, the local channel won’t optimised until a bridge is established, and it seems to me that your AGI is likely to be streaming the file before any bridging is done.

As previously noted, lin2alaw should have a low CPU loading (orders of magnitude less than G.729 or GSM, I would guess). alaw2lin is even lighter weight, as it is a simple table lookup. Many people would just use .wav (8kHz mono, signed linear 16 bits), rather than including specific A-law and µ-law files.

(What I think you are actually getting is:

Convert A-law to slin.
Write slin to local channel ;1 side.
Read slin from local channel ;2 side
Convert slin to A-law.
Write A-law to chan_sip.

whereas your original description sounded like:

Convert A-law to slin.
Convert slin to A-law.
Write A-law to chan_sip.

It looks as though Codecs could be undocumented in the main wiki, but actually implemented, even in 13.30:

I added “Codecs: alaw” in call file

Channel: LOCAL/[email protected]
Codecs: alaw
Callerid: 3000
MaxRetries: 2
RetryTime: 43
WaitTime: 37
SET: NUM=8000
Application: AGI
DATA: dialer.agi,1,1,8000,1

but nothing has changed.
I think the channel LOCAL will always use the codec slin.

It looks to me that you may need to start with "!all, " to cancel out the default slin, although I haven’t checked in detail to be sure if slin is added before the codecs lines is processed:

I believe that local channels still accept all codecs, although it would take too long for me to be certain of that with the new code structure for what used to be chan_local.c.

Many thanks David!
"!all, " helped!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.