[Home]

Summary:ASTERISK-14468: [patch] G726 Codec has choppy audio on Version 1.6.1
Reporter:Scott Johnson (globalnetinc)Labels:
Date Opened:2009-07-15 00:44:00Date Closed:2010-01-25 09:39:01.000-0600
Priority:BlockerRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/CodecHandling
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20091011__issue15504.diff.txt
( 1) 20091011__issue15504r1.diff.txt
( 2) G726-fix
( 3) ht502-g726.pcap
( 4) ht502-g726aal2.pcap
Description:I am using G726 to reduce the rtp steam. It all works great for calls. Quality is good but when VM or a prompt is played the sound is horrible. It seems the translation is not working correctly.

If the call is G726 (caller) => Asterisk => G726 (callee) the voice is great. Sounds as good as G711.

If:
G711 (caller) => Asterisk = > G726 (callee) voice is horrible. You cannot understand most words. Or
Asterisk (VM or prompt playback) => G726 it is also bad.

The hardware is a Linksys spa2102 on the client side and the SIP trunk provider is using Cicso software.  They work perfectly together and if Asterisk is not in the middle the call quality is what you would expect.

We added the option g726nonstandard = yes in the sip.conf file

This made the call to VM or any time Asterisk was involved different but equally bad.

After several hours I found that the source file for 1.6.1 main/frame.c
had to be edited. The G726_AAL2 had to have the name g726 instead of g726aal2 and the g726 current name needed a change. Then the audio is crystal clear.
Comments:By: David Vossel (dvossel) 2009-07-15 16:37:06

Good find!  All code must be attached, so I had to take it out of the additional information section.  You'll need to upload the code and sign a license before we can commit it.

By: Scott Johnson (globalnetinc) 2009-07-16 10:57:59

I have a question though.  If the G726 tag needs to be renamed to work what should the tag be for the g726 RFC version.  I just swapped the names and it did not work so I named the RFC version of the G726 (g726rfc).  Stupid hack but it made my problem go away.

By: David Vossel (dvossel) 2009-07-16 11:47:02

Swapping the names is not a fix, I did not look at it close enough before I removed it.  It seems that there is a problem with the g726 transcoding.

By: Scott Johnson (globalnetinc) 2009-07-16 13:00:25

Thanks.  I could not figure out why there would be a key on the name.  It does however fix the issue foe the Linksys device.

By: David Vossel (dvossel) 2009-07-18 00:25:40

I know I won't be able to get around to this one soon so I'm un-assigning myself.  If its still around when I have time I'll grab it again, just wanted to give someone else a chance to look at it.

By: Jason Parker (jparker) 2009-07-22 13:21:12

Have you tried setting g726nonstandard=yes in sip.conf?  This seems to be the same issue that required this option to be added.

By: Jason Parker (jparker) 2009-07-22 13:23:57

Nevermind - I see now that you said you have..  Not sure how I missed that.

By: Scott Johnson (globalnetinc) 2009-07-26 15:45:36

FYI I have tried every version of 1.6.
1.6.0.1 - 11
1.6.1.0 - 1
1.6.2.0

All have this behavior.  Also I have found several instances where the Asterisk server selects the value of 2 in the RTP map as the codec. This is not correct anymore as the has been depreciated in the RFC.

By: Tilghman Lesher (tilghman) 2009-09-24 14:54:04

Okay, so clearly what the issue is is that the Linksys device is using the AAL2 variant of the G.726 codec, and Asterisk either isn't recognizing a difference in the sdp or the Linksys isn't specifying the variant.

I'd therefore like to see a packet dump of the setup of this call, so we can verify what the session setup actually is.

By: Tilghman Lesher (tilghman) 2009-09-24 15:18:27

One question:  When you set g726nonstandard = yes in sip.conf, did you set it in the peer associated with the Linksys phone or only in the [general] section?  If you set it only in the [general] section, then I think I might know what is wrong.

By: Scott Johnson (globalnetinc) 2009-09-25 14:28:38

I will get his done for you on Monday when I am in the office.  Yes I tried both in the gneral only section and with each peer.

By: Tilghman Lesher (tilghman) 2009-09-29 23:44:08

It is now Wednesday.  Have you had a chance to get a packet dump for this call yet?

By: Johann Steinwendtner (steinwej) 2009-09-30 00:42:41

tilghman, you write that you might know what the problem is, ist it SIP related ? I 've G726 problems also on IAX2. The symptom is, that only one direction is garbled, the other direction is fine.

By: Tilghman Lesher (tilghman) 2009-09-30 12:04:08

steinwej: yes, SIP related.  If you're having an issue with IAX2, please open a separate issue.

By: Scott Johnson (globalnetinc) 2009-09-30 17:12:59

working on it now.  have units setup.  FYI this is not related to just a linksys ATA.  I have a Grandstream HT-502 and an AudioCodes MP-202 that have the same issue.

Shows up with the SIP trunking provider as well.

By: Scott Johnson (globalnetinc) 2009-09-30 17:43:15

Here is an example of what does not work.  Using a Grandstream ATA I call and invalid number.  A voice plays from the media server in Asterisk stating that that it is not a valid extension.  The voice is clear and perfect the codec is g726 or g726aal2.  Both work and dthe device supports both.  Next I call an outbound number.  The SIP provider is set to only support g711u.  The sound both ways is now horrible and broken both ways.

By: Scott Johnson (globalnetinc) 2009-09-30 17:54:09

I have attached the capture files.  One when the ht502 was set for g726 and one when it was set for g726aal2.  the peer has the option:

g726nonstandard=no

set in the sip.conf file

By: Scott Johnson (globalnetinc) 2009-10-11 13:35:25

Here is the config

AudioCodes ATA mp-202b (g726-32) => asterisk server (ulaw) => asterisk server (moh)

the voice is always distorted and choppy.  if you have the settings g726nonstandard=no either way the voice is bad but it does change in the way it plays.  if you edit the lines in main/frame.c to:

{ AST_FORMAT_G726, "g726aal2", 8000, "G.726 RFC3551", 40, 10, 300, 10, 20 },
{ AST_FORMAT_G726_AAL2, "g726", 8000, "G.726 AAL2", 40, 10, 300, 10, 20 },

which swaps the codecs then the voice can be heard crystal clear.  the problem is in the transcoding of asterisk.

By: Tilghman Lesher (tilghman) 2009-10-11 19:59:06

The problem is that you've said that g726nonstandard=yes does not work, yet that code is EXACTLY what that option accomplishes.

By: Scott Johnson (globalnetinc) 2009-10-11 20:18:38

if it worked like that then:

[4065511212]
qualify=60000
ignoresdpversion=yes
nat=yes
accountcode=216.166.169.249
sendrpid=yes
callerid=Scott Johnson <4065511212>
usereqphone=yes
context=from-inside
call-limit=2
canreinvite=no
vmexten=4065511212
secret=zluSel
host=dynamic
trustrpid=no
username=4065511212
subscribecontext=local-extensions
dtmfmode=rfc2833
t38pt_udptl=yes,redundancy,maxdatagram=400
g726nonstandard=yes
type=friend
mailbox=4065511212
disallow=all
allow=g729
allow=g726
allow=g726aal2

Should work.  But it does not. If that did not work then
g726nonstandard=no

Should work.  It does not either.

By: Tilghman Lesher (tilghman) 2009-10-11 21:57:03

One thing that the g726nonstandard option does NOT do is swap an identified AAL2 codec into the normal mode.  I have attached a patch that does this.  IF THIS WORKS, it would mean that the AAL2 and G726 codecs are completely switched somewhere, which would suggest why your change worked.  However, a test is needed before we can suggest the total fix.

To clarify, with this patch applied, please set g726nonstandard=yes in the [general] section (never in the individual user section, please!) and test transcoding.

By: Scott Johnson (globalnetinc) 2009-10-14 10:55:28

Will not compile.

rtp.c: In function âast_rtp_set_rtpmap_typeâ:
rtp.c:2288: error: âAST_FORMAT_G726__AAL2â undeclared (first use in this function)
rtp.c:2288: error: (Each undeclared identifier is reported only once
rtp.c:2288: error: for each function it appears in.)
make[1]: *** [rtp.o] Error 1

By: Elazar Broad (ebroad) 2009-10-14 10:59:41

That should be AST_FORMAT_G726_AAL2 I believe. Try 20091011__issue15504r1.diff.txt.

By: Scott Johnson (globalnetinc) 2009-10-14 11:00:27

found the error:

AST_FORMAT_G726__AAL2 should be

AST_FORMAT_G726_AAL2

By: Tilghman Lesher (tilghman) 2009-10-19 12:31:53

Okay, so does that transcoding patch fix the issue for you?

By: Tilghman Lesher (tilghman) 2009-10-22 10:29:19

globalnetinc: ping.  Please respond to the question, or this issue will be closed due to non-response.

By: Scott Johnson (globalnetinc) 2009-10-25 17:32:31

patch is up and I am testing.  I will have results by end of today.

By: Scott Johnson (globalnetinc) 2009-10-25 18:57:52

does not fix the issue.  the voice is still broke up.

g726nonstandard = yes or
g726nonstandard = no

is only put in the general section.  

If I swap the lines as I have done described before the voice is clear.

By: Scott Johnson (globalnetinc) 2009-10-25 19:01:16

additionally the voice coming from the asterisk server to the ATA is clear.  the voice coming from the ATA to asterisk and out g711u to the remote user is not.  it is has jitter.

By: Joshua C. Colp (jcolp) 2009-11-09 11:28:06.000-0600

I've been able to reproduce this and believe I have narrowed it down to configuration. Can you please try the following:

allow=g726all2
g726nonstandard=yes

Once I set these then everything worked as expected.

By: Scott Johnson (globalnetinc) 2009-11-09 19:42:49.000-0600

If you notice it is in the sip config above.

if you mean allow=g726aal2

By: Joshua C. Colp (jcolp) 2009-11-09 20:02:48.000-0600

Okay, I'll narrow it down further and see.

By: Joshua C. Colp (jcolp) 2009-11-09 20:04:22.000-0600

Providing the sip debug would also be useful so we can see how Asterisk is interpreting things.

By: Scott Johnson (globalnetinc) 2009-11-09 22:24:41.000-0600

I will get it tomorrow.

By: Joshua C. Colp (jcolp) 2009-11-10 10:49:38.000-0600

Aha, yes, I have reproduced it. I'll see what I can do.

By: Scott Johnson (globalnetinc) 2009-11-10 11:29:41.000-0600

So you do not need me to do anything yet?

By: Joshua C. Colp (jcolp) 2009-11-10 11:31:47.000-0600

Nothing at this time.

By: Digium Subversion (svnbot) 2009-11-10 14:09:09.000-0600

Repository: asterisk
Revision: 229281

U   branches/1.4/codecs/codec_g726.c

------------------------------------------------------------------------
r229281 | file | 2009-11-10 14:09:09 -0600 (Tue, 10 Nov 2009) | 8 lines

Remove broken support for direct transcoding between G.726 RFC3551 and G.726 AAL2.

On some systems the translation core would actually consider g726aal2 -> g726 -> signed linear
to be a quicker path then g726aal2 -> signed linear which exposed this problem.

(closes issue ASTERISK-14468)
Reported by: globalnetinc

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=229281

By: Digium Subversion (svnbot) 2009-11-10 14:12:08.000-0600

Repository: asterisk
Revision: 229282

_U  trunk/
U   trunk/codecs/codec_g726.c

------------------------------------------------------------------------
r229282 | file | 2009-11-10 14:12:08 -0600 (Tue, 10 Nov 2009) | 15 lines

Merged revisions 229281 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r229281 | file | 2009-11-10 16:03:14 -0400 (Tue, 10 Nov 2009) | 8 lines
 
 Remove broken support for direct transcoding between G.726 RFC3551 and G.726 AAL2.
 
 On some systems the translation core would actually consider g726aal2 -> g726 -> signed linear
 to be a quicker path then g726aal2 -> signed linear which exposed this problem.
 
 (closes issue ASTERISK-14468)
 Reported by: globalnetinc
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=229282

By: Digium Subversion (svnbot) 2009-11-10 14:13:48.000-0600

Repository: asterisk
Revision: 229283

_U  branches/1.6.0/
U   branches/1.6.0/codecs/codec_g726.c

------------------------------------------------------------------------
r229283 | file | 2009-11-10 14:13:48 -0600 (Tue, 10 Nov 2009) | 22 lines

Merged revisions 229282 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r229282 | file | 2009-11-10 16:06:13 -0400 (Tue, 10 Nov 2009) | 15 lines
 
 Merged revisions 229281 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r229281 | file | 2009-11-10 16:03:14 -0400 (Tue, 10 Nov 2009) | 8 lines
   
   Remove broken support for direct transcoding between G.726 RFC3551 and G.726 AAL2.
   
   On some systems the translation core would actually consider g726aal2 -> g726 -> signed linear
   to be a quicker path then g726aal2 -> signed linear which exposed this problem.
   
   (closes issue ASTERISK-14468)
   Reported by: globalnetinc
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=229283

By: Digium Subversion (svnbot) 2009-11-10 14:14:58.000-0600

Repository: asterisk
Revision: 229284

_U  branches/1.6.1/
U   branches/1.6.1/codecs/codec_g726.c

------------------------------------------------------------------------
r229284 | file | 2009-11-10 14:14:57 -0600 (Tue, 10 Nov 2009) | 22 lines

Merged revisions 229282 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r229282 | file | 2009-11-10 16:06:13 -0400 (Tue, 10 Nov 2009) | 15 lines
 
 Merged revisions 229281 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r229281 | file | 2009-11-10 16:03:14 -0400 (Tue, 10 Nov 2009) | 8 lines
   
   Remove broken support for direct transcoding between G.726 RFC3551 and G.726 AAL2.
   
   On some systems the translation core would actually consider g726aal2 -> g726 -> signed linear
   to be a quicker path then g726aal2 -> signed linear which exposed this problem.
   
   (closes issue ASTERISK-14468)
   Reported by: globalnetinc
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=229284

By: Digium Subversion (svnbot) 2009-11-10 14:15:42.000-0600

Repository: asterisk
Revision: 229285

_U  branches/1.6.2/
U   branches/1.6.2/codecs/codec_g726.c

------------------------------------------------------------------------
r229285 | file | 2009-11-10 14:15:42 -0600 (Tue, 10 Nov 2009) | 22 lines

Merged revisions 229282 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r229282 | file | 2009-11-10 16:06:13 -0400 (Tue, 10 Nov 2009) | 15 lines
 
 Merged revisions 229281 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r229281 | file | 2009-11-10 16:03:14 -0400 (Tue, 10 Nov 2009) | 8 lines
   
   Remove broken support for direct transcoding between G.726 RFC3551 and G.726 AAL2.
   
   On some systems the translation core would actually consider g726aal2 -> g726 -> signed linear
   to be a quicker path then g726aal2 -> signed linear which exposed this problem.
   
   (closes issue ASTERISK-14468)
   Reported by: globalnetinc
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=229285