Summary: | ASTERISK-10123: [patch] teach chan_iax2 to offer the calling channel's codec first, like chan_sip does it | ||
Reporter: | Steve Davies . (stevedavies) | Labels: | |
Date Opened: | 2007-08-20 11:24:00 | Date Closed: | 2008-01-17 16:47:45.000-0600 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Channels/chan_iax2 |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) iax-prefer-current-codec.1.4.patch ( 1) iax-prefer-current-codec.patch | |
Description: | We discussed this issue on asterisk-dev under the title "IAX codec selection". Currently, outgoing IAX NEW packets contain two codec-related IEs. "FORMAT" will contain the format bits for the calling channel. CODEC_PREFS is a list of codecs allowed, taken as-is from the allow= of the peer. Now it is preferable not to transcode - so it makes sense that the calling channel's codec should be moved first in the CODEC_PREFS list (provided that it is one of the allowed codecs). This is what chan_sip does. So this patch brings that behaviour to IAX. As a demonstration of the issue, here's a peer: [xxxx] type=friend host=xxx.co.za username=us secret=ourpass trunk=no notransfer=yes transfer=no context=from-peer-xxxx disallow=all allow=alaw allow=ulaw allow=g729 allow=ilbc allow=gsm allow=speex qualify=500 qualifysmoothing=yes Now we send a call to this peer from a phone using iLBC. chan_iax2 as was sends this NEW: Tx-Frame Retry[000] -- OSeqno: 000 ISeqno: 000 Type: IAX Subclass: NEW Timestamp: 00017ms SCall: 00001 DCall: 00000 [A.B.C.D:4569] VERSION : 2 CALLED NUMBER : 082XXXXXXX CODEC_PREFS : (alaw|ulaw|g729|ilbc|gsm|speex) CALLING NUMBER : 021XXXXXXX CALLING PRESNTN : 35 CALLING TYPEOFN : 0 CALLING TRANSIT : 0 CALLING NAME : Steve Davies LANGUAGE : en USERNAME : us FORMAT : 1024 CAPABILITY : 59150 ADSICPE : 2 DATE TIME : 2007-08-15 10:18:02 So even though ILBC is the current codec, the CODEC_PREFS has ALAW first. After my patch, the NEW is: Tx-Frame Retry[000] -- OSeqno: 000 ISeqno: 000 Type: IAX Subclass: NEW Timestamp: 00016ms SCall: 00012 DCall: 00000 [A.B.C.D:4569] VERSION : 2 CALLED NUMBER : 082XXXXXXX CODEC_PREFS : (ilbc|alaw|ulaw|g729|gsm|speex) CALLING NUMBER : 021XXXXXXX CALLING PRESNTN : 35 CALLING TYPEOFN : 0 CALLING TRANSIT : 0 CALLING NAME : Steve Davies LANGUAGE : en USERNAME : us FORMAT : 1024 CAPABILITY : 59150 ADSICPE : 2 DATE TIME : 2007-08-20 18:37:16 ****** ADDITIONAL INFORMATION ****** I'd like to push to put this fix into 1.4 too! | ||
Comments: | By: Steve Davies . (stevedavies) 2007-08-20 11:26:38 By the way - I tested this change also with calls coming from a SIP phone, and also coming from a SIP phone with video. By: pj (pj) 2007-08-20 13:36:54 this will work automaticaly? I think in SIP case, to avoid unneeded transcoding, is needed to set some variable like in SIP_CODEC before dial command... it will be great if asterisk now handle codecs negotiation better to avoid transcoding in full voice path, ie. even in case crossing multiple asterisks... By: Steve Davies . (stevedavies) 2007-08-20 13:56:56 yeah - it works automatically. My motivation is that I take calls from customers using their choice of codecs. Then I need to pass calls on to other boxes - both mine and not. I want to keep the codec the same through to the end point where the calls gets passed to PSTN. By: Steve Davies . (stevedavies) 2007-08-30 12:27:01 How do I get this one to get merged? Any feedback for me? By: Steve Davies . (stevedavies) 2007-08-31 02:54:16 iax-prefer-current-codec.1.4.patch contains the change for 1.4 Steve By: pj (pj) 2007-09-05 14:47:27 it's not working as expected for me, I have folowing call, placed in direction: idefisk (gsm) --->asteriskA---(alaw/gsm/g729)---->asteriskB between asteriskA and B is always negotiated alaw, not gsm as expected to avoid transcoding I have patch applied on asteriskA. By: Steve Davies . (stevedavies) 2007-09-08 01:27:40 pj - might relate to how your codecpriority is set? (ie caller or host)? Can you post up the relevant zapata.conf on the two sides, plus a "iax2 debug" output from a call? Steve By: pj (pj) 2007-09-10 06:40:52 I tried your patch once again, with 1.4branch, and seems, that is works quite well, but have question: should it also work for iax->chan_h323 connections? I really don't know, why asterisk is still transcoding on both legs via slinear, even if I have permited alaw on iax and h323 :-\ incomming IAX (allow=alaw,gsm,ilbc,g729, codec preference caller): NativeFormats: 0x8 (alaw) WriteFormat: 0x40 (slin) ReadFormat: 0x40 (slin) WriteTranscode: Yes ReadTranscode: Yes outgoing h323 (allow=g729,alaw): NativeFormats: 0x8 (alaw) WriteFormat: 0x40 (slin) ReadFormat: 0x40 (slin) WriteTranscode: Yes ReadTranscode: Yes By: pj (pj) 2007-09-28 16:49:51 other direction h323->iax is also quite weird: incomming h323 leg (allow=g729,alaw): NativeFormats: 0x8 (alaw) WriteFormat: 0x100 (g729) ReadFormat: 0x100 (g729) WriteTranscode: Yes ReadTranscode: Yes (why trancode on h323 leg from incomming alaw to g729 and not teach IAX to connect via alaw?) outgoing IAX leg (allow=alaw,gsm,ilbc,g729, codec preference caller): NativeFormats: 0x100 (g729) WriteFormat: 0x100 (g729) ReadFormat: 0x100 (g729) WriteTranscode: No ReadTranscode: No other relations, like iax<->sip or iax<->skinny seems, that works fine. By: pj (pj) 2007-09-28 16:51:31 warning messages from my last example (h323->iax): [Sep 29 00:00:01] WARNING[21844]: translate.c:199 framein: g729tolin did not update samples 253440 [Sep 29 00:00:02] WARNING[21844]: translate.c:199 framein: g729tolin did not update samples 255040 [Sep 29 00:00:03] WARNING[21844]: translate.c:199 framein: g729tolin did not update samples 261920 [Sep 29 00:00:04] WARNING[21844]: translate.c:199 framein: g729tolin did not update samples 277120 [Sep 29 00:00:09] WARNING[21844]: translate.c:199 framein: g729tolin did not update samples 314400 By: Steve Davies . (stevedavies) 2007-10-11 01:42:47 > [Sep 29 00:00:01] WARNING[21844]: translate.c:199 framein: g729tolin did not update samples 253440 This is because you are using the non-licensed G729. It isn't up to date with the latest codec API inside Asterisk. So nothing to do with my patch. Steve By: Sheldon Hearn (sheldonh) 2007-10-11 01:57:33 We've been carrying this patch on Debian's asterisk-1.4.11-1 package, backported to Etch. It's been working well for us. The customer who requested that we carry it, is happy with the results, and it hasn't generated new complaints. By: pj (pj) 2007-10-11 02:24:05 OK, but tried anybody this patch with in h323-iax environment? as I wrote (msg 0071188, 0070248), seems that it not working as expected in this case.... By: pj (pj) 2007-11-26 11:34:32.000-0600 I'm using this patch regularly, and it working quite well, except that has problem with teaching other channels with codec used (eg. iax with g729 doesn't teach h323 or skinny to use also g729), but that probably isn't goal of this patch. Only minor issue, that should be solved, is with h323, that currently doesn't teach iax, my example: h323 (with negotiated g729) -> iax (alaw,g729), on iax channel, g729 should be used, but currently is used first codecs (alaw) and asterisk is doing transcoding g729->alaw. no issues with other channels, like sip->iax, skinny->iax. core show channel h323: NativeFormats: 0x100 (g729) WriteFormat: 0x8 (alaw) ReadFormat: 0x8 (alaw) WriteTranscode: Yes ReadTranscode: Yes core show channel iax: NativeFormats: 0x8 (alaw) WriteFormat: 0x8 (alaw) ReadFormat: 0x8 (alaw) WriteTranscode: No ReadTranscode: No h323.conf [general] disallow=all allow=alaw,g729 iax.conf allow=alaw,gsm,ilbc,g729 By: Steve Davies . (stevedavies) 2007-11-26 12:09:53.000-0600 Hi PJ, I'll try to take a look at your H323 issue. Which H323 are you using? Steve By: pj (pj) 2007-11-26 12:25:44.000-0600 thanks, I'm using original chan_h323 from channels/h323 in asterisk source (I'm using asterisk trunk). if you would like some debugs from my environment, tell me. By: Digium Subversion (svnbot) 2008-01-17 16:34:54.000-0600 Repository: asterisk Revision: 99004 U branches/1.4/channels/chan_iax2.c U branches/1.4/include/asterisk/frame.h U branches/1.4/main/frame.c ------------------------------------------------------------------------ r99004 | russell | 2008-01-17 16:34:53 -0600 (Thu, 17 Jan 2008) | 10 lines Have IAX2 optimize the codec translation path just like chan_sip does it. If the caller's codec is in our codec list, move it to the top to avoid transcoding. (closes issue ASTERISK-10123) Reported by: stevedavies Patches: iax-prefer-current-codec.patch uploaded by stevedavies (license 184) iax-prefer-current-codec.1.4.patch uploaded by stevedavies (license 184) Tested by: stevedavies, pj, sheldonh ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=99004 By: Digium Subversion (svnbot) 2008-01-17 16:47:45.000-0600 Repository: asterisk Revision: 99006 _U trunk/ U trunk/channels/chan_iax2.c U trunk/include/asterisk/frame.h U trunk/main/frame.c ------------------------------------------------------------------------ r99006 | russell | 2008-01-17 16:47:45 -0600 (Thu, 17 Jan 2008) | 18 lines Merged revisions 99004 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r99004 | russell | 2008-01-17 16:37:22 -0600 (Thu, 17 Jan 2008) | 10 lines Have IAX2 optimize the codec translation path just like chan_sip does it. If the caller's codec is in our codec list, move it to the top to avoid transcoding. (closes issue ASTERISK-10123) Reported by: stevedavies Patches: iax-prefer-current-codec.patch uploaded by stevedavies (license 184) iax-prefer-current-codec.1.4.patch uploaded by stevedavies (license 184) Tested by: stevedavies, pj, sheldonh ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=99006 |