Summary:ASTERISK-02588: [patch] Fixes to support attended transfers from a libiax client
Reporter:bdolljr (bdolljr)Labels:
Date Opened:2004-10-12 14:33:27Date Closed:2008-01-15 15:10:28.000-0600
Versions:Frequency of
Environment:Attachments:( 0) chan_iax2.c.diff
( 1) IAX2-Failure.txt
( 2) IAX2-Success.txt
( 3) libiax2-w32-updates.zip
( 4) mydiff.txt
Description:This patch adds support on the chan_iax2.c side for attended transfers from a client using the libiax library.


I am in the process of also bundling up the changes I made to libiax for full attended transfer support.  I will post those changes soon.
Comments:By: Mark Spencer (markster) 2004-10-12 14:50:26

I don't understand why this patch is necessary?  You can already do attended transfers with Asterisk (the IAXy does it for example).  All you do is make an outbound call and then initiate a transfer.

By: bdolljr (bdolljr) 2004-10-12 15:53:46

What we found is that the peercallno was being overwritten by the TXCNT or TXACC.  This causes the TXREADY to be sent to the wrong peer.

In the scenario where B is a libiax2 client and A calls B and B transfers to C:

The only way this can work is if the callno on A and C happen to be the same.  If for some reason chan_iax2 and the IAXy start their callno's at '1' then it would work since the peercallno and the transfercallno would be the same.  However, we saw that libiax2 compiled on W2K was starting with a random callno and then incrementing from there.  In this case the peercallno and transfercallno were never the same.

BTW, The CVS copy of libiax2 that we checked out did not have support for attended transfers since the sending of the TXREQ command and the processing of the TXREJ and TXREADY were not implemented.  Based on chan_iax2.c we added support to libiax to handle these commands.  

Does the IAXy use the CVS libiax2 library?  When you say the IAXy works, who is initiating the transfer, the IAXy or chan_iax2?  I can see that it would work if chan_iax2 initiates the transfer, but not the other way around if the IAXy uses the same CVS code that we checked out.

By: Mark Spencer (markster) 2004-10-12 23:37:08

Can you confirm you have a disclaimer on file, btw?  Thanks!

By: bdolljr (bdolljr) 2004-10-13 09:48:14

Faxing disclaimer this morning...

More info:  I was attempting to get some IAX2 debug output for you to look at and noticed that if I enabled debugging output on the libiax2 library the transfers would work 95% of the time against an unmodified chan_iax2.  If I disable debugging output on libiax2 then the transfers do not succeed (unless the patch is applied).  Seems to be a definite timing problem.  I will capture a failed and successful iax2 debug and post asap.  Thanks.

By: bdolljr (bdolljr) 2004-10-13 15:36:24

OK.  I think I've got to the bottom of this.  The problem occurs only when the libiax2 client is transferring a call to itself.  You might ask...  Why would you want to do that?  In our application which is a multiport IVR processing platform (now with IAX2 support) we have a need to transfer a call from one application (port) to another application (port).  Another example might be a multiport IAXy :}, or equivalent IAX to analog gateway, where one analog user is doing an attended transfer to another analog user off the same gateway.

Anyway this patch addresses the issue of a TXCNT or TXACC coming from the same IP as the original peer (which is the case above).

Disclaimer is still in process here.  Will send shortly.

Thanks for your help.

By: bdolljr (bdolljr) 2004-10-13 16:52:45

Uploaded changes to libiax2 to support building and running on W32.  This will allow building using VC6.  Adds attended transfer support to the library.  Also adds a 1ms resolution timer for the timestamping of IAX packets instead of windows default 10ms timer.

By: stevekstevek (stevekstevek) 2004-10-13 17:52:06

From one of the few others who use libiax2 (in iaxclient), it's nice to see we're not so alone :)

I haven't actually tried to compile or test your changes yet, and don't have much to say w.r.t. transferring, but here's some comments after reading things over:

- I'll let others comment on style, etc; (using //svt all over the place).
- // doesn't work with older C complilers (pre c99), like gcc 2.95 - need C comments.
- in iax-client.h
 o I think you have your windows timer stuff declared for all platforms, as well as your pragma (although I dunno if the pragma will cause a problem), BOOL isn't defined on all platforms :)
 o Why did you remove all the extern declarations?  [it just makes it hard to see if you change anything]
 o Have you done a lot of testing with your timer-based gettimeofday implementation?  Will windows very reliably call that, or will it skip some calls if it's busy?  If so, that would be quite cool -- I've tried so many different ways to get the right time under windows, and they all seem to suck in one way or another..

o your dbug (and dump_sessions? should be static?
o No problem protecting VOICE_TS_PREDICTION, although I think at astricon we figured out a way to make this work better.
o audio_format:
   - instead of just changing this to make it a paramer to iax_call, we need to really allow callers to set format _and_ capability.  iaxclient can now support 3 codecs, so I want to make calls using a bitmap for capability, and a preferred codec for format.
   - Also need to set formats for incoming calls.
o jitterbuffer:
   - I'm planning on working (soon) with steve davies and whoever else is interested in a completely new, modular jitterbuffer; but I noted that you took the jb debug statements and made them always appear..
   - why wouldn't you dejitter DTMF? [except broken jitterbuffer].  Otherwise,  e.g. if you in voicemail, and you leave a message and press "#", the end of your message is lost.

- iax2-parser.h
 o certainly this didn't compile with VC, with  
unsigned char afdata[0];     in struct iax_frame, right?

By: Mark Spencer (markster) 2004-10-14 00:01:29

How embarassing!  Thanks for the fix.  I applied my slightly modified patch to Asterisk CVS.  As for the iax2 client stuff, I think that should be taken up on the iax2 client list, and then open up a new bug when you guys are ready to have something merged into libiax2.  Thanks!

By: Russell Bryant (russell) 2004-10-14 18:43:23

mark's patch added to the 1.0 branch

By: Digium Subversion (svnbot) 2008-01-15 15:10:17.000-0600

Repository: asterisk
Revision: 3992

U   trunk/channels/chan_iax2.c

r3992 | markster | 2008-01-15 15:10:17 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix trasnfer issue (bug ASTERISK-2588)



By: Digium Subversion (svnbot) 2008-01-15 15:10:28.000-0600

Repository: asterisk
Revision: 4006

U   branches/v1-0/channels/chan_iax2.c

r4006 | russell | 2008-01-15 15:10:28 -0600 (Tue, 15 Jan 2008) | 2 lines

fix for attended transfers (bug ASTERISK-2588)