[asterisk-commits] oej: branch oej/codename-pineapple r48201 - in /team/oej/codename-pineapple: ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Dec 2 05:31:46 MST 2006


Author: oej
Date: Sat Dec  2 06:31:45 2006
New Revision: 48201

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48201
Log:
RTP timer changes

Modified:
    team/oej/codename-pineapple/channels/chan_sip3.c
    team/oej/codename-pineapple/channels/sip3/sip3.h
    team/oej/codename-pineapple/channels/sip3/sip3_cliami.c
    team/oej/codename-pineapple/channels/sip3/sip3_dialog.c
    team/oej/codename-pineapple/channels/sip3/sip3_monitor.c
    team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
    team/oej/codename-pineapple/configs/sip3.conf.sample

Modified: team/oej/codename-pineapple/channels/chan_sip3.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_sip3.c?view=diff&rev=48201&r1=48200&r2=48201
==============================================================================
--- team/oej/codename-pineapple/channels/chan_sip3.c (original)
+++ team/oej/codename-pineapple/channels/chan_sip3.c Sat Dec  2 06:31:45 2006
@@ -5245,6 +5245,7 @@
 		/* we need to check the tags and the branch. If they're different, this is
 	   	  in fact a forked call through a SIP proxy somewhere. */
 		transmit_final_response(p, "482 Loop Detected", req, XMIT_RELIABLE);
+		sip_sched_destroy(p, DEFAULT_TRANS_TIMEOUT);
 		return 0;
 	}
 	
@@ -5464,6 +5465,7 @@
 				response = "404 Not Found";
 			transmit_final_response(p, response, req, XMIT_RELIABLE);
 			update_call_counter(p, DEC_CALL_LIMIT);
+			return 0;
 		} else {
 			/* If no extension was specified, use the s one */
 			/* Basically for calling to IP/Host name only */
@@ -5480,10 +5482,8 @@
 			/* Save Record-Route for any later requests we make on this dialogue */
 			build_route(p, req, 0);
 
-			if (c) {
-				/* Pre-lock the call */
+			if (c) /* Pre-lock the call */
 				ast_channel_lock(c);
-			}
 		}
 	} else {
 		if (option_debug > 1 && sipdebug) {

Modified: team/oej/codename-pineapple/channels/sip3/sip3.h
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3.h?view=diff&rev=48201&r1=48200&r2=48201
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3.h (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3.h Sat Dec  2 06:31:45 2006
@@ -816,9 +816,6 @@
 	struct sockaddr_in vredirip;		/*!< Where our Video RTP should be going if not to us */
 	time_t lastrtprx;			/*!< Last RTP received */
 	time_t lastrtptx;			/*!< Last RTP sent */
-	int rtptimeout;				/*!< RTP timeout time */
-	int rtpholdtimeout;			/*!< RTP timeout when on hold */
-	int rtpkeepalive;			/*!< Send RTP packets for keepalive */
 	struct ast_dsp *vad;			/*!< Inband DTMF Detection dsp */
 	int autoframing;			/*!< ???? */
 

Modified: team/oej/codename-pineapple/channels/sip3/sip3_cliami.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_cliami.c?view=diff&rev=48201&r1=48200&r2=48201
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_cliami.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_cliami.c Sat Dec  2 06:31:45 2006
@@ -759,6 +759,7 @@
 	ast_cli(fd, "  T1 minimum:             %d\n", global.t1min);
 	ast_cli(fd, "  Relax DTMF:             %s\n", global.relaxdtmf ? "Yes" : "No");
 	ast_cli(fd, "  Compact SIP headers:    %s\n", global.compactheaders ? "Yes" : "No");
+	ast_cli(fd, "  RTP Keepalive:          %d %s\n", global.rtpkeepalive, global.rtpkeepalive ? "" : "(Disabled)" );
 	ast_cli(fd, "  RTP Timeout:            %d %s\n", global.rtptimeout, global.rtptimeout ? "" : "(Disabled)" );
 	ast_cli(fd, "  RTP Hold Timeout:       %d %s\n", global.rtpholdtimeout, global.rtpholdtimeout ? "" : "(Disabled)");
 	ast_cli(fd, "  MWI NOTIFY mime type:   %s\n", global.default_notifymime);

Modified: team/oej/codename-pineapple/channels/sip3/sip3_dialog.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_dialog.c?view=diff&rev=48201&r1=48200&r2=48201
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_dialog.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_dialog.c Sat Dec  2 06:31:45 2006
@@ -737,16 +737,19 @@
 		ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
 		ast_rtp_setdtmfcompensate(p->rtp, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
 		ast_rtp_settos(p->rtp, global.tos_audio);
+		ast_rtp_set_rtptimeout(p->rtp, global.rtptimeout);
+		ast_rtp_set_rtpholdtimeout(p->rtp, global.rtpholdtimeout);
+		ast_rtp_set_rtpkeepalive(p->rtp, global.rtpkeepalive);
 		if (p->vrtp) {
 			ast_rtp_settos(p->vrtp, global.tos_video);
 			ast_rtp_setdtmf(p->vrtp, 0);
 			ast_rtp_setdtmfcompensate(p->vrtp, 0);
+			ast_rtp_set_rtptimeout(p->vrtp, global.rtptimeout);
+			ast_rtp_set_rtpholdtimeout(p->vrtp, global.rtpholdtimeout);
+			ast_rtp_set_rtpkeepalive(p->vrtp, global.rtpkeepalive);
 		}
 		if (p->udptl)
 			ast_udptl_settos(p->udptl, global.tos_audio);
-		p->rtptimeout = global.rtptimeout;
-		p->rtpholdtimeout = global.rtpholdtimeout;
-		p->rtpkeepalive = global.rtpkeepalive;
 		p->maxcallbitrate = global.default_maxcallbitrate;
 	}
 

Modified: team/oej/codename-pineapple/channels/sip3/sip3_monitor.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_monitor.c?view=diff&rev=48201&r1=48200&r2=48201
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_monitor.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_monitor.c Sat Dec  2 06:31:45 2006
@@ -154,61 +154,74 @@
 	return 0;
 }
 
-
-/*! \brief Check if we need to send RTP keepalive or hangup, due to RTP timers */
-static void check_rtp_timeout(struct sip_dialog *sip, time_t t)
-{
-	/* Do we have a channel that is UP and do we handle RTP inside the box? */
-	if (!(sip->rtp && sip->owner && (sip->owner->_state == AST_STATE_UP) &&
-	    !sip->redirip.sin_addr.s_addr) )
+/*! \brief Check RTP timeouts and send RTP keepalives 
+	\note We're only sending audio keepalives yet.	
+*/
+static void check_rtp_timeout(struct sip_pvt *dialog, time_t t)
+{
+	/* If we have no RTP or no active owner, no need to check timers */
+	if (!dialog->rtp || !dialog->owner)
 		return;
-
-	/* Do we need to sent RTP keepalive ? */
-	if (sip->lastrtptx && sip->rtpkeepalive &&
-	    (t > sip->lastrtptx + sip->rtpkeepalive)) {
+	/* If the call is not in UP state or redirected outside Asterisk, no need to check timers */
+	if (dialog->owner->_state != AST_STATE_UP || dialog->redirip.sin_addr.s_addr)
+		return;
+
+	/* If we have no timers set, return now */
+	if (ast_rtp_get_rtpkeepalive(dialog->rtp) == 0 || (ast_rtp_get_rtptimeout(dialog->rtp) == 0 && ast_rtp_get_rtpholdtimeout(dialog->rtp) == 0))
+		return;
+
+	/* Check AUDIO RTP keepalives */
+	if (dialog->lastrtptx && ast_rtp_get_rtpkeepalive(dialog->rtp) &&
+		    (t > dialog->lastrtptx + ast_rtp_get_rtpkeepalive(dialog->rtp))) {
 		/* Need to send an empty RTP packet */
-		sip->lastrtptx = time(NULL);
-		ast_rtp_sendcng(sip->rtp, 0);
-	}
-
-	if (sip->lastrtprx && (sip->rtptimeout || sip->rtpholdtimeout) &&
-	    (t > sip->lastrtprx + sip->rtptimeout)) {
+		dialog->lastrtptx = time(NULL);
+		ast_rtp_sendcng(dialog->rtp, 0);
+	}
+
+	/*! \todo Check video RTP keepalives
+
+		Do we need to move the lastrtptx to the RTP structure to have one for audio and one
+		for video? It really does belong to the RTP structure.
+	*/
+
+	/* Check AUDIO RTP timers */
+	if (dialog->lastrtprx && (ast_rtp_get_rtptimeout(dialog->rtp) || ast_rtp_get_rtpholdtimeout(dialog->rtp)) &&
+		    (t > dialog->lastrtprx + ast_rtp_get_rtptimeout(dialog->rtp))) {
+
 		/* Might be a timeout now -- see if we're on hold */
 		struct sockaddr_in sin;
-		ast_rtp_get_peer(sip->rtp, &sin);
-		if (sin.sin_addr.s_addr || 
-		    (sip->rtpholdtimeout && (t > sip->lastrtprx + sip->rtpholdtimeout))) {
+		ast_rtp_get_peer(dialog->rtp, &sin);
+		if (sin.sin_addr.s_addr || (ast_rtp_get_rtpholdtimeout(dialog->rtp) &&
+		     (t > dialog->lastrtprx + ast_rtp_get_rtpholdtimeout(dialog->rtp)))) {
 			/* Needs a hangup */
-			if (!sip->rtptimeout)
-				return;
-			while (sip->owner && ast_channel_trylock(sip->owner)) {
-				dialog_lock(sip, FALSE);
-				usleep(1);
-				dialog_lock(sip, TRUE);
+			if (dialog->rtptimeout) {
+				while (dialog->owner && ast_channel_trylock(dialog->owner)) {
+					sip_pvt_unlock(dialog);
+					usleep(1);
+					sip_pvt_lock(dialog);
+				}
+				if (!(ast_rtp_get_bridged(dialog->rtp))) {
+					ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
+						dialog->owner->name, (long) (t - dialog->lastrtprx));
+					/* Issue a softhangup */
+					ast_softhangup_nolock(dialog->owner, AST_SOFTHANGUP_DEV);
+				} else
+					ast_log(LOG_NOTICE, "'%s' will not be disconnected in %ld seconds because it is directly bridged to another RTP stream\n", dialog->owner->name, (long) (t - dialog->lastrtprx));
+				ast_channel_unlock(dialog->owner);
+				/* forget the timeouts for this call, since a hangup
+				   has already been requested and we don't want to
+				   repeatedly request hangups
+				*/
+				ast_rtp_set_rtptimeout(dialog->rtp, 0);
+				ast_rtp_set_rtpholdtimeout(dialog->rtp, 0);
+				if (dialog->vrtp) {
+					ast_rtp_set_rtptimeout(dialog->vrtp, 0);
+					ast_rtp_set_rtpholdtimeout(dialog->vrtp, 0);
+				}
 			}
-			if (!sip->owner) 
-				return;
-
-			if (ast_rtp_get_bridged(sip->rtp)) 
-				ast_log(LOG_NOTICE, "'%s' will not be disconnected in %ld seconds because it is directly bridged to another RTP stream\n", sip->owner->name, (long) (t - sip->lastrtprx));
-			else {
-				ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
-					sip->owner->name,
-					(long) (t - sip->lastrtprx));
-				/* Issue a softhangup */
-				ast_softhangup_nolock(sip->owner, AST_SOFTHANGUP_DEV);
-			} 
-			ast_channel_unlock(sip->owner);
-			/* forget the timeouts for this call, since a hangup
-			   has already been requested and we don't want to
-			   repeatedly request hangups
-			*/
-			sip->rtptimeout = 0;
-			sip->rtpholdtimeout = 0;
-		}
-	}
-}
-
+		}
+	}
+}
 /*! \brief Check whether peer needs a new MWI notification check */
 static int does_peer_need_mwi(struct sip_peer *peer)
 {

Modified: team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c?view=diff&rev=48201&r1=48200&r2=48201
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c Sat Dec  2 06:31:45 2006
@@ -358,22 +358,6 @@
 	if (vhp)
 		memcpy(&vsin.sin_addr, vhp->h_addr, sizeof(vsin.sin_addr));
 		
-	if (p->rtp) {
-		if (portno > 0) {
-			sin.sin_port = htons(portno);
-			ast_rtp_set_peer(p->rtp, &sin);
-			if (debug)
-				ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
-		} else {
-			ast_rtp_stop(p->rtp);
-			if (debug)
-				ast_verbose("Peer doesn't provide audio\n");
-		}
-	}
-	/* Setup video port number */
-	if (vportno != -1)
-		vsin.sin_port = htons(vportno);
-
 	/* Setup UDPTL port number */
 	if (p->udptl) {
 		if (udptlportno > 0) {
@@ -387,6 +371,26 @@
 				ast_log(LOG_DEBUG, "Peer doesn't provide T.38 UDPTL\n");
 		}
 	}
+	if (p->rtp) {
+		if (portno > 0) {
+			sin.sin_port = htons(portno);
+			ast_rtp_set_peer(p->rtp, &sin);
+			if (debug)
+				ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+		} else {
+			if (utptlportno > 0) {
+				if (debug)
+					ast_log(LOG_DEBUG, "Got T.38 re-invite without audio. Keeping RTP active during T.38 session. Call-Id %s\n", p->callid);
+			} else 
+				ast_rtp_stop(p->rtp);
+			if (debug)
+				ast_verbose("Peer doesn't provide audio: Call-Id: %s\n", p->callid);
+		}
+	}
+	/* Setup video port number */
+	if (vportno != -1)
+		vsin.sin_port = htons(vportno);
+
 
 	/* Next, scan through each "a=rtpmap:" line, noting each
 	 * specified RTP payload type (with corresponding MIME subtype):

Modified: team/oej/codename-pineapple/configs/sip3.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/configs/sip3.conf.sample?view=diff&rev=48201&r1=48200&r2=48201
==============================================================================
--- team/oej/codename-pineapple/configs/sip3.conf.sample (original)
+++ team/oej/codename-pineapple/configs/sip3.conf.sample Sat Dec  2 06:31:45 2006
@@ -139,10 +139,6 @@
 ;language=en			; Default language setting for all users/peers
 				; This may also be set for individual users/peers
 ;relaxdtmf=yes			; Relax dtmf handling
-;rtptimeout=60			; Terminate call if 60 seconds of no RTP activity
-				; when we're not on hold
-;rtpholdtimeout=300		; Terminate call if 300 seconds of no RTP activity
-				; when we're on hold (must be > rtptimeout)
 ;trustrpid = no			; If Remote-Party-ID should be trusted
 ;sendrpid = yes			; If Remote-Party-ID should be sent
 ;progressinband=never		; If we should generate in-band ringing always
@@ -198,6 +194,21 @@
 ;
 ;regcontext=sipregistrations
 ;
+;--------------------------- RTP timers ----------------------------------------------------
+; These timers are currently used for both audio and video streams. The RTP timeouts
+; are only applied to the audio channel.
+; The settings are settable in the global section as well as per device
+;
+;rtptimeout=60                 ; Terminate call if 60 seconds of no RTP or RTCP activity
+                               ; on the audio channel
+                               ; when we're not on hold. This is to be able to hangup
+                               ; a call in the case of a phone disappearing from the net,
+                               ; like a powerloss or grandma tripping over a cable.
+;rtpholdtimeout=300            ; Terminate call if 300 seconds of no RTP or RTCP activity
+                               ; on the audio channel
+                               ; when we're on hold (must be > rtptimeout)
+;rtpkeepalive=<secs>           ; Send keepalives in the RTP stream to keep NAT open
+                               ; (default is off - zero)
 ;--------------------------- SIP DEBUGGING ---------------------------------------------------
 ;sipdebug = yes			; Turn on SIP debugging by default, from
 				; the moment the channel loads this configuration
@@ -223,8 +234,9 @@
 ;
 ; This setting is available in the [general] section as well as in device configurations.
 ; Setting this to yes, enables T.38 fax (UDPTL) passthrough on SIP to SIP calls, provided
-; both parties have T38 support enabled in their Asterisk configuration (either general or
-; peer/user/friend sections)
+; both parties have T38 support enabled in their Asterisk configuration 
+; This has to be enabled in the general section for all devices to work. You can then
+; disable it on a per device basis. 
 ;
 ; t38pt_udptl = yes            ; Default false
 ;



More information about the asterisk-commits mailing list