[asterisk-commits] file: branch group/vldtmf r40488 - /team/group/vldtmf/rtp.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Aug 18 20:48:56 MST 2006


Author: file
Date: Fri Aug 18 22:48:56 2006
New Revision: 40488

URL: http://svn.digium.com/view/asterisk?rev=40488&view=rev
Log:
Few minor tweaks

Modified:
    team/group/vldtmf/rtp.c

Modified: team/group/vldtmf/rtp.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/rtp.c?rev=40488&r1=40487&r2=40488&view=diff
==============================================================================
--- team/group/vldtmf/rtp.c (original)
+++ team/group/vldtmf/rtp.c Fri Aug 18 22:48:56 2006
@@ -670,7 +670,6 @@
 			f = send_dtmf(rtp, AST_FRAME_DTMF_BEGIN);
 	} else if (event_end & 0x80 && rtp->lasteventendseqn != seqno && rtp->resp) {
 		f = send_dtmf(rtp, AST_FRAME_DTMF_END);
-		ast_log(LOG_NOTICE, "Duration=%d\n", duration);
 		f->samples = duration;
 		rtp->resp = 0;
 		rtp->lasteventendseqn = seqno;
@@ -1892,7 +1891,7 @@
 		return -1;
 
 	/* If we have no peer, return immediately */	
-	if (!rtp->them.sin_addr.s_addr)
+	if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
 		return 0;
 
 	payload = ast_rtp_lookup_code(rtp, 0, AST_RTP_DTMF);
@@ -1907,17 +1906,15 @@
 	rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
 
 	for (i = 0; i < 2; i++) {
-		if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
-			res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
-			if (res < 0) 
-				ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
-					ast_inet_ntoa(rtp->them.sin_addr),
-					ntohs(rtp->them.sin_port), strerror(errno));
-			if (rtp_debug_test_addr(&rtp->them))
-				ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
-					    ast_inet_ntoa(rtp->them.sin_addr),
-					    ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
-		}
+		res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
+		if (res < 0) 
+			ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
+				ast_inet_ntoa(rtp->them.sin_addr),
+				ntohs(rtp->them.sin_port), strerror(errno));
+		if (rtp_debug_test_addr(&rtp->them))
+			ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+				    ast_inet_ntoa(rtp->them.sin_addr),
+				    ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 		/* Increment sequence number */
 		rtp->seqno++;
 		/* Clear marker bit and set seqno */
@@ -1938,7 +1935,7 @@
 	int hdrlen = 12, res = 0;
 	char data[256];
 
-	if (!rtp->them.sin_addr.s_addr)
+	if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
 		return 0;
 
 	/* Setup packet to send */
@@ -1950,17 +1947,15 @@
 	rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
 	
 	/* Transmit */
-	if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
-		res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
-		if (res < 0)
-			ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
-				ast_inet_ntoa(rtp->them.sin_addr),
-				ntohs(rtp->them.sin_port), strerror(errno));
-		if (rtp_debug_test_addr(&rtp->them))
-			ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
-				    ast_inet_ntoa(rtp->them.sin_addr),
-				    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
-	}
+	res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
+	if (res < 0)
+		ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
+			ast_inet_ntoa(rtp->them.sin_addr),
+			ntohs(rtp->them.sin_port), strerror(errno));
+	if (rtp_debug_test_addr(&rtp->them))
+		ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+			    ast_inet_ntoa(rtp->them.sin_addr),
+			    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 
 	/* Increment sequence number */
 	rtp->seqno++;
@@ -1976,7 +1971,7 @@
 	char data[256];
 	
 	/* If no address, then bail out */
-	if (!rtp->them.sin_addr.s_addr)
+	if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
 		return 0;
 	
 	/* Convert our digit to the crazy RTP way */
@@ -1995,17 +1990,15 @@
 	rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
 	/* Send 3 termination packets */
 	for (i = 0; i < 3; i++) {
-		if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
-			res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
-			if (res < 0)
-				ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
-					ast_inet_ntoa(rtp->them.sin_addr),
-					ntohs(rtp->them.sin_port), strerror(errno));
-			if (rtp_debug_test_addr(&rtp->them))
-				ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
-					    ast_inet_ntoa(rtp->them.sin_addr),
-					    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
-		}
+		res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
+		if (res < 0)
+			ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
+				ast_inet_ntoa(rtp->them.sin_addr),
+				ntohs(rtp->them.sin_port), strerror(errno));
+		if (rtp_debug_test_addr(&rtp->them))
+			ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+				    ast_inet_ntoa(rtp->them.sin_addr),
+				    ntohs(rtp->them.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 	}
 	rtp->send_digit = 0;
 	/* Increment lastdigitts */



More information about the asterisk-commits mailing list