[Asterisk-Dev] SIP - asterisk does not handle re-INVITEs correctly

Alex Zeffertt ajz at cambridgebroadband.com
Thu Aug 5 06:12:25 MST 2004


Hi,

Me again, answering my own mail!  I seem to have found a fix - although
I'd like others to sanity check it if poss.  The problem appears to be
that when a new frame is received by sip_rtp_read() this function
attempts to change the read/write formats used by the channel.  However,
because of what *appears* to be an oversight, the calls to
ast_set_read_format() and ast_set_write_format() have no effect.  The
following patch seems to fix this:

diff -u -r1.466 chan_sip.c
--- chan_sip.c	31 Jul 2004 04:04:05 -0000	1.466
+++ chan_sip.c	5 Aug 2004 13:06:42 -0000
@@ -2203,6 +2203,7 @@
 			if (f->subclass != p->owner->nativeformats) {
 				ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
 				p->owner->nativeformats = f->subclass;
+                p->owner->readformat = p->owner->writeformat = ast_best_codec(p->owner->nativeformats);
 				ast_set_read_format(p->owner, p->owner->readformat);
 				ast_set_write_format(p->owner, p->owner->writeformat);
 			}

Does this look OK?

Alex

 Thu, 5 Aug 2004 13:34:13 +0100
Alex Zeffertt <ajz at cambridgebroadband.com> wrote:

> Hi,
> 
> I have some more information on this problem.  It is beginning to look
> more like a codec or RTP problem than a SIP problem.
> 
> In order to eliminate SIP from the equation I tried just dynamically
> switching the codec being sent to asterisk from GSM to ULAW without
> first sending a re-INVITE.  (This is allowed since asterisk offered
> ULAW in its 200 OK message.)
> 
> When I did this I found that the same problem occurred.  Although
> asterisk did change the codec it sent from GSM to ULAW to match its
> peer, the ULAW data was corrupted.  Although the asterisk echotest
> application was receiving a continuous stream of 0xAAs, it  sent back
> data which started at 0xAA and slowly incremented until it reached
> 0xFD.
> 
> It looks like asterisk has a problem with dynamic codec switching. 
> Has anybody else seen this?  Or am I doing something wrong....
> 
> Regards,
> 
> Alex
> 
> 
> On Wed, 4 Aug 2004 15:31:08 +0100
> Alex Zeffertt <ajz at cambridgebroadband.com> wrote:
> 
> > 
> > Hi all,
> > 
> > I've got a problem with the way asterisk behaves following the
> > reception of a  re-INVITE. Although it correctly responds to the
> > SIP/SDP message, there appears to be something wrong with the
> > handling of the RTP data after the codec has been changed.
> > 
> > For example.  I have a SIP UA which I am using to call the
> > EchoTest demo (sip:600 at asterisk).  I can verify using a packet
> > sniffer that a GSM session is created and that the RTP payloads
> > coming back from asterisk match the RTP payloads being sent to
> > asterisk.  The SIP UA then sends asterisk a re-INVITE and using the
> > packet sniffer I can verify that the codec changes to ULAW in both
> > directions.  However, now the data being sent by asterisk does not
> > match the data being sent to asterisk.  In fact, if the SIP UA sends
> > asterisk a continuous stream of 0xAAs, then asterisk sends back
> > roughly 30 0xABs, followed by roughly 30 0xACs, then 0xADs, until it
> > gets to 0xFD at which point it just keeps sending 0xFDs.
> > 
> > Does anybody know what is happening here?
> > 
> > For the record, the reason I need asterisk to be able to handle
> > re-INVITEs is that I am implementing a fax-upspeed scheme.  The idea
> > is that when the SIP-UA recognises a fax tone it attempts to
> > renegotiate the codec used for talking to asterisk to G711, which is
> > low compression enough to allow fax pass-through.
> > 
> > TIA,
> > 
> > Alex
> > 
> > 
> > -- 
> > Alex Zeffertt
> > Software Engineer
> > Cambridge Broadband Ltd.
> > http://www.cambridgebroadband.com
> > _______________________________________________
> > Asterisk-Dev mailing list
> > Asterisk-Dev at lists.digium.com
> > http://lists.digium.com/mailman/listinfo/asterisk-dev
> > To UNSUBSCRIBE or update options visit:
> >    http://lists.digium.com/mailman/listinfo/asterisk-dev
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev


-- 
Alex Zeffertt
Software Engineer
Cambridge Broadband Ltd.
http://www.cambridgebroadband.com



More information about the asterisk-dev mailing list