[svn-commits] branch kpfleming/vldtmf r8944 - in /team/kpfleming/vldtmf: ./ include/asterisk/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Jan 31 14:21:01 MST 2006


Author: kpfleming
Date: Mon Jan 30 16:47:26 2006
New Revision: 8944

URL: http://svn.digium.com/view/asterisk?rev=8944&view=rev
Log:
create branch for variable-length DTMF support

Added:
    team/kpfleming/vldtmf/
      - copied from r8942, trunk/
Modified:
    team/kpfleming/vldtmf/include/asterisk/rtp.h
    team/kpfleming/vldtmf/rtp.c

Modified: team/kpfleming/vldtmf/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/team/kpfleming/vldtmf/include/asterisk/rtp.h?rev=8944&r1=8942&r2=8944&view=diff
==============================================================================
--- team/kpfleming/vldtmf/include/asterisk/rtp.h (original)
+++ team/kpfleming/vldtmf/include/asterisk/rtp.h Mon Jan 30 16:47:26 2006
@@ -121,6 +121,10 @@
 
 int ast_rtp_senddigit(struct ast_rtp *rtp, char digit);
 
+int ast_rtp_send_digit_begin(struct ast_rtp *rtp, char digit);
+
+int ast_rtp_send_digit_end(struct ast_rtp *rtp);
+
 int ast_rtp_sendcng(struct ast_rtp *rtp, int level);
 
 int ast_rtp_settos(struct ast_rtp *rtp, int tos);

Modified: team/kpfleming/vldtmf/rtp.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/vldtmf/rtp.c?rev=8944&r1=8942&r2=8944&view=diff
==============================================================================
--- team/kpfleming/vldtmf/rtp.c (original)
+++ team/kpfleming/vldtmf/rtp.c Mon Jan 30 16:47:26 2006
@@ -1189,6 +1189,65 @@
 	return (unsigned int) ms;
 }
 
+struct rtp_header {
+	/* Always keep in network byte order */
+#if __BYTE_ORDER == __BIG_ENDIAN
+	/* first byte */
+        u_int32_t version:2;
+        u_int32_t flow:6;
+	/* second byte */
+	u_int32_t option:1;
+	u_int32_t sync:1;
+	u_int32_t format:6;
+	/* third and fourth bytes */
+	u_int32_t sequence:16;
+	/* fifth through eighth bytes */
+	u_int32_t timestamp;
+	/* ninth through twelfth bytes */
+	u_int32_t ssrc;
+#else
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#else
+#error Byte order not defined
+#endif
+#endif
+};
+
+static char prep_digit(char digit)
+{
+	if ((digit <= '9') && (digit >= '0'))
+		return digit - '0';
+	else if (digit == '*')
+		return 10;
+	else if (digit == '#')
+		return 11;
+	else if ((digit >= 'A') && (digit <= 'D')) 
+		return digit - 'A' + 12;
+	else if ((digit >= 'a') && (digit <= 'd')) 
+		return digit - 'a' + 12;
+	else {
+		ast_log(LOG_WARNING, "Don't know how to represent '%c'\n", digit);
+		return -1;
+	}
+}
+
+int ast_rtp_send_digit_begin(struct ast_rtp *rtp, char digit)
+{
+	/* If we have no peer, return immediately */	
+	if (!rtp->them.sin_addr.s_addr)
+		return 0;
+
+	if ((digit = prep_digit(digit)) == -1)
+		return -1;
+}
+
+int ast_rtp_send_digit_end(struct ast_rtp *rtp)
+{
+	/* If we have no peer, return immediately */	
+	if (!rtp->them.sin_addr.s_addr)
+		return 0;
+}
+
 int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
 {
 	unsigned int *rtpheader;
@@ -1199,25 +1258,14 @@
 	char data[256];
 	char iabuf[INET_ADDRSTRLEN];
 
-	if ((digit <= '9') && (digit >= '0'))
-		digit -= '0';
-	else if (digit == '*')
-		digit = 10;
-	else if (digit == '#')
-		digit = 11;
-	else if ((digit >= 'A') && (digit <= 'D')) 
-		digit = digit - 'A' + 12;
-	else if ((digit >= 'a') && (digit <= 'd')) 
-		digit = digit - 'a' + 12;
-	else {
-		ast_log(LOG_WARNING, "Don't know how to represent '%c'\n", digit);
-		return -1;
-	}
-	payload = ast_rtp_lookup_code(rtp, 0, AST_RTP_DTMF);
-
 	/* If we have no peer, return immediately */	
 	if (!rtp->them.sin_addr.s_addr)
 		return 0;
+
+	if ((digit = prep_digit(digit)) == -1)
+		return -1;
+
+	payload = ast_rtp_lookup_code(rtp, 0, AST_RTP_DTMF);
 
 	rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
 	
@@ -1268,6 +1316,7 @@
 	   that was sent
 	*/
 	rtp->seqno++;
+
 	return 0;
 }
 



More information about the svn-commits mailing list