[asterisk-commits] rizzo: branch 1.4 r44665 - /branches/1.4/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Oct 7 04:37:31 MST 2006


Author: rizzo
Date: Sat Oct  7 06:37:30 2006
New Revision: 44665

URL: http://svn.digium.com/view/asterisk?rev=44665&view=rev
Log:
merge revision 44664 - put common code in a function to avoid repetitions.


Modified:
    branches/1.4/channels/chan_sip.c

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?rev=44665&r1=44664&r2=44665&view=diff
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Sat Oct  7 06:37:30 2006
@@ -11791,6 +11791,18 @@
 	return 1;
 }
 
+/*! \brief Immediately stop RTP, VRTP and UDPTL as applicable */
+static void stop_data_flows(struct sip_pvt *p)
+{
+	/* Immediately stop RTP, VRTP and UDPTL as applicable */
+	if (p->rtp)
+		ast_rtp_stop(p->rtp);
+	if (p->vrtp)
+		ast_rtp_stop(p->vrtp);
+	if (p->udptl)
+		ast_udptl_stop(p->udptl);
+}
+
 /*! \brief Handle SIP response in dialogue */
 /* XXX only called by handle_request */
 static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int ignore, int seqno)
@@ -11980,18 +11992,9 @@
 				if ((option_verbose > 2) && (resp != 487))
 					ast_verbose(VERBOSE_PREFIX_3 "Got SIP response %d \"%s\" back from %s\n", resp, rest, ast_inet_ntoa(p->sa.sin_addr));
 				ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
-				if (p->rtp) {
-					/* Immediately stop RTP */
-					ast_rtp_stop(p->rtp);
-				}
-				if (p->vrtp) {
-					/* Immediately stop VRTP */
-					ast_rtp_stop(p->vrtp);
-				}
-				if (p->udptl) {
-					/* Immediately stop UDPTL */
-					ast_udptl_stop(p->udptl);
-				}
+	
+				stop_data_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
+
 				/* XXX Locking issues?? XXX */
 				switch(resp) {
 				case 300: /* Multiple Choices */
@@ -13721,18 +13724,8 @@
 			ast_log(LOG_DEBUG, "Got CANCEL on an answered call. Ignoring... \n");
 		return 0;
 	}
-	if (p->rtp) {
-		/* Immediately stop RTP */
-		ast_rtp_stop(p->rtp);
-	}
-	if (p->vrtp) {
-		/* Immediately stop VRTP */
-		ast_rtp_stop(p->vrtp);
-	}
-	if (p->udptl) {
-		/* Immediately stop UDPTL */
-		ast_udptl_stop(p->udptl);
-	}
+	stop_data_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
+
 	if (p->owner)
 		ast_queue_hangup(p->owner);
 	else
@@ -13753,7 +13746,6 @@
 	struct ast_channel *c=NULL;
 	int res;
 	struct ast_channel *bridged_to;
-	char *audioqos = NULL, *videoqos = NULL;
 	
 	if (p->pendinginvite && !ast_test_flag(&p->flags[0], SIP_OUTGOING) && !ast_test_flag(req, SIP_PKT_IGNORE))
 		transmit_response_reliable(p, "487 Request Terminated", &p->initreq);
@@ -13762,35 +13754,27 @@
 	check_via(p, req);
 	ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 
-	if (p->rtp)
-		audioqos = ast_rtp_get_quality(p->rtp);
-	if (p->vrtp)
-		videoqos = ast_rtp_get_quality(p->vrtp);
-
 	/* Get RTCP quality before end of call */
-	if (recordhistory) {
-		if (p->rtp)
-			append_history(p, "RTCPaudio", "Quality:%s", audioqos);
-		if (p->vrtp)
-			append_history(p, "RTCPvideo", "Quality:%s", videoqos);
-	}
-
+	if (recordhistory || p->owner) {
+		char *audioqos, *videoqos;
 	if (p->rtp) {
+			audioqos = ast_rtp_get_quality(p->rtp);
+			if (recordhistory)
+				append_history(p, "RTCPaudio", "Quality:%s", audioqos);
 		if (p->owner)
 			pbx_builtin_setvar_helper(p->owner, "RTPAUDIOQOS", audioqos);
-		/* Immediately stop RTP */
-		ast_rtp_stop(p->rtp);
 	}
 	if (p->vrtp) {
+			videoqos = ast_rtp_get_quality(p->vrtp);
+			if (recordhistory)
+				append_history(p, "RTCPvideo", "Quality:%s", videoqos);
 		if (p->owner)
 			pbx_builtin_setvar_helper(p->owner, "RTPVIDEOQOS", videoqos);
-		/* Immediately stop VRTP */
-		ast_rtp_stop(p->vrtp);
-	}
-	if (p->udptl) {
-		/* Immediately stop UDPTL */
-		ast_udptl_stop(p->udptl);
-	}
+	}
+	}
+
+	stop_data_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
+
 	if (!ast_strlen_zero(get_header(req, "Also"))) {
 		ast_log(LOG_NOTICE, "Client '%s' using deprecated BYE/Also transfer method.  Ask vendor to support REFER instead\n",
 			ast_inet_ntoa(p->recv.sin_addr));



More information about the asterisk-commits mailing list