[asterisk-commits] russell: branch group/vldtmf r39593 - /team/group/vldtmf/channels/chan_zap.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Aug 13 15:02:46 MST 2006


Author: russell
Date: Sun Aug 13 17:02:45 2006
New Revision: 39593

URL: http://svn.digium.com/view/asterisk?rev=39593&view=rev
Log:
revert changes to attempt to allow sending variable length dtmf to zap channels
because it is more complicated than I originally thought and it's starting to
look like something that should be put off until after 1.4

Modified:
    team/group/vldtmf/channels/chan_zap.c

Modified: team/group/vldtmf/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/group/vldtmf/channels/chan_zap.c?rev=39593&r1=39592&r2=39593&view=diff
==============================================================================
--- team/group/vldtmf/channels/chan_zap.c (original)
+++ team/group/vldtmf/channels/chan_zap.c Sun Aug 13 17:02:45 2006
@@ -1005,130 +1005,57 @@
 	return 0;
 }
 
-static int digit_to_dtmfindex(char digit)
-{
-	if (isdigit(digit))
-		return ZT_TONE_DTMF_BASE + (digit - '0');
-	else if (digit >= 'A' && digit <= 'D')
-		return ZT_TONE_DTMF_A + (digit - 'A');
-	else if (digit >= 'a' && digit <= 'd')
-		return ZT_TONE_DTMF_A + (digit - 'a');
-	else if (digit == '*')
-		return ZT_TONE_DTMF_s;
-	else if (digit == '#')
-		return ZT_TONE_DTMF_p;
-	else
-		return -1;
-}
-
-static char dtmfindex_to_digit(int dtmfindex)
-{
-	if (dtmfindex >= ZT_TONE_DTMF_BASE && dtmfindex <= ZT_TONE_DTMF_9)
-		return '0' + (dtmfindex - ZT_TONE_DTMF_BASE);
-	else if (dtmfindex >= ZT_TONE_DTMF_A && dtmfindex <= ZT_TONE_DTMF_D)
-		return 'A' + (dtmfindex - ZT_TONE_DTMF_A);
-	else if (dtmfindex == ZT_TONE_DTMF_s)
-		return '*';
-	else if (dtmfindex == ZT_TONE_DTMF_p)
-		return '#';
-	else
-		return 'x';
-}
-
 static int zt_digit_begin(struct ast_channel *chan, char digit)
 {
-	struct zt_pvt *pvt;
-	int index;
-	int dtmf = -1;
-	
-	pvt = chan->tech_pvt;
-
-	ast_mutex_lock(&pvt->lock);
-
-	index = zt_get_index(chan, pvt, 0);
-
-	if ((index != SUB_REAL) || !pvt->owner)
-		goto out;
-
-#ifdef HAVE_PRI
-	if (pvt->sig == SIG_PRI)
-		goto out;
-#endif
-	dtmf = digit_to_dtmfindex(digit);
-
-	if (dtmf == -1)
-		goto out;
-
-	if (!ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, &dtmf)) {
-		ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit);
-		pvt->dialing = 1;
-		pvt->begindigit = dtmf;
-	} else
-		pvt->begindigit = 0;
-
-out:
-	ast_mutex_unlock(&pvt->lock);
-
 	return 0; /* Tell Asterisk not to generate inband indications */
 }
 
 static int zt_digit_end(struct ast_channel *chan, char digit)
 {
 	ZT_DIAL_OPERATION zo;
-	struct zt_pvt *pvt;
+	struct zt_pvt *p;
 	int res = 0;
 	int index;
+
+	p = chan->tech_pvt;
+
+	ast_mutex_lock(&p->lock);
 	
-	pvt = chan->tech_pvt;
-
-	ast_mutex_lock(&pvt->lock);
-	
-	index = zt_get_index(chan, pvt, 0);
-
-	if ((index != SUB_REAL) || !pvt->owner)
+	index = zt_get_index(chan, p, 0);
+
+	if ((index != SUB_REAL) || !p->owner)
 		goto out;
 
 #ifdef HAVE_PRI
-	if ((pvt->sig == SIG_PRI) && (chan->_state == AST_STATE_DIALING) && !pvt->proceeding) {
-		if (pvt->setup_ack) {
-			if (!pri_grab(pvt, pvt->pri)) {
-				pri_information(pvt->pri->pri, pvt->call, digit);
-				pri_rel(pvt->pri);
+	if ((p->sig == SIG_PRI) && (chan->_state == AST_STATE_DIALING) && !p->proceeding) {
+		if (p->setup_ack) {
+			if (!pri_grab(p, p->pri)) {
+				pri_information(p->pri->pri,p->call,digit);
+				pri_rel(p->pri);
 			} else
-				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->span);
-		} else if (strlen(pvt->dialdest) < sizeof(pvt->dialdest) - 1) {
+				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span);
+		} else if (strlen(p->dialdest) < sizeof(p->dialdest) - 1) {
 			ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit);
-			res = strlen(pvt->dialdest);
-			pvt->dialdest[res++] = digit;
-			pvt->dialdest[res] = '\0';
+			res = strlen(p->dialdest);
+			p->dialdest[res++] = digit;
+			p->dialdest[res] = '\0';
 		}
 	} else {
 #else
 	{
 #endif
-		if (!pvt->begindigit) {
-			zo.op = ZT_DIAL_OP_APPEND;
-			zo.dialstr[0] = 'T';
-			zo.dialstr[1] = digit;
-			zo.dialstr[2] = 0;
-			if ((res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_DIAL, &zo)))
-				ast_log(LOG_WARNING, "Couldn't dial digit %c\n", digit);
-			else
-				pvt->dialing = 1;
-		} else {
-			ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit);
-			if (pvt->begindigit != digit_to_dtmfindex(digit)) {
-				ast_log(LOG_WARNING, "We already started playing dtmf index '%c', but asked to end digit '%c'!  :(\n",
-					dtmfindex_to_digit(pvt->begindigit), digit);
-			}
-			res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, -1);
-			pvt->dialing = 0;
-			pvt->begindigit = 0;
-		}
+		zo.op = ZT_DIAL_OP_APPEND;
+		zo.dialstr[0] = 'T';
+		zo.dialstr[1] = digit;
+		zo.dialstr[2] = 0;
+		if ((res = ioctl(p->subs[SUB_REAL].zfd, ZT_DIAL, &zo)))
+			ast_log(LOG_WARNING, "Couldn't dial digit %c\n", digit);
+		else
+			p->dialing = 1;
 	}
 
 out:
-	ast_mutex_unlock(&pvt->lock);
+	ast_mutex_unlock(&p->lock);
 
 	return res;
 }



More information about the asterisk-commits mailing list