[asterisk-bugs] [Asterisk 0014711]: directrpsetup=yes does not work when canreinvite=n

Asterisk Bug Tracker noreply at bugs.digium.com
Sun Jul 26 09:25:30 CDT 2009


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=14711 
====================================================================== 
Reported By:                rrb3942
Assigned To:                file
====================================================================== 
Project:                    Asterisk
Issue ID:                   14711
Category:                   Channels/chan_sip/General
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
Asterisk Version:           1.6.0.6 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2009-03-20 09:47 CDT
Last Modified:              2009-07-26 09:25 CDT
====================================================================== 
Summary:                    directrpsetup=yes does not work when canreinvite=n
Description: 
If directrtpsetup is set to to 'yes' and canreinvite is set to 'no'
Asterisk will not perform native bridging on the channels during the call
setup.

If directrtpsetup is set to 'yes' and canreinvite is set to 'yes' Asterisk
will perform native bridging on the channels during the call setup.

I did not see any note in the documentation that directrtpsetup requires
the peer to also support canreinvite=yes.

I am not sure if this is intended behavior because without being able to
RE-INVITE Asterisk would not be able to re-insert itself into the media
path for possible features later in the dialplan.
====================================================================== 

---------------------------------------------------------------------- 
 (0108231) hzshlomi (reporter) - 2009-07-26 09:25
 https://issues.asterisk.org/view.php?id=14711#c108231 
---------------------------------------------------------------------- 
BTW

I made a little hack in sip_set_rtp_peer() for the case where asterisk
re-invites after BYE. Not a pretty one. here it is (see the /*SHLOMI*/):


static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
{
	struct sip_pvt *p;
	int changed = 0;

	p = chan->tech_pvt;
	if (!p)
		return -1;

	/* Disable early RTP bridge  */
	if (chan->_state != AST_STATE_UP && !global_directrtpsetup) 	/* We are in
early state */
		return 0;

	sip_pvt_lock(p);
	if (p->alreadygone) {
		/* If we're destroyed, don't bother */
		sip_pvt_unlock(p);
		return 0;
	}

	/* if this peer cannot handle reinvites of the media stream to devices
	   that are known to be behind a NAT, then stop the process now
	*/
	if (nat_active && !ast_test_flag(&p->flags[0], SIP_CAN_REINVITE_NAT)) {
		sip_pvt_unlock(p);
		return 0;
	}

	if (rtp) {
		changed |= ast_rtp_get_peer(rtp, &p->redirip);
	} else if (p->redirip.sin_addr.s_addr || ntohs(p->redirip.sin_port) != 0)
{
		memset(&p->redirip, 0, sizeof(p->redirip));
		changed = 1;
	}
	if (vrtp) {
		changed |= ast_rtp_get_peer(vrtp, &p->vredirip);
	} else if (p->vredirip.sin_addr.s_addr || ntohs(p->vredirip.sin_port) !=
0) {
		memset(&p->vredirip, 0, sizeof(p->vredirip));
		changed = 1;
	}
	if (trtp) {
		changed |= ast_rtp_get_peer(trtp, &p->tredirip);
	} else if (p->tredirip.sin_addr.s_addr || ntohs(p->tredirip.sin_port) !=
0) {
		memset(&p->tredirip, 0, sizeof(p->tredirip));
		changed = 1;
	}
	if (codecs && (p->redircodecs != codecs)) {
		p->redircodecs = codecs;
		changed = 1;
	}
	if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER) &&
!ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
		if (chan->_state != AST_STATE_UP) {	/* We are in early state */
			if (p->do_history)
				append_history(p, "ExtInv", "Initial invite sent with remote bridge
proposal.");
			ast_debug(1, "Early remote bridge setting SIP '%s' - Sending media to
%s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr :
p->ourip.sin_addr));
		} else if (!p->pendinginvite) {		/* We are up, and have no outstanding
invite */
			/*SHLOMI*/
			if (chan->_bridge && chan->_bridge->_softhangup) {
				ast_verbose("Call %s is going down (Skipping SIP RE-INVITE) !\n",
p->callid);
			}
			else {
				ast_verbose("Call %s sending SIP RE-INVITE !\n", p->callid);
				ast_debug(3, "Sending reinvite on SIP '%s' - It's audio soon
redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr
: p->ourip.sin_addr));
				transmit_reinvite_with_sdp(p, FALSE, FALSE);
			}
		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
			ast_debug(3, "Deferring reinvite on SIP '%s' - It's audio will be
redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr
: p->ourip.sin_addr));
			/* We have a pending Invite. Send re-invite when we're done with the
invite */
			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
		}
	}
	/* Reset lastrtprx timer */
	p->lastrtprx = p->lastrtptx = time(NULL);
	sip_pvt_unlock(p);
	return 0;
} 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-07-26 09:25 hzshlomi       Note Added: 0108231                          
======================================================================




More information about the asterisk-bugs mailing list