[asterisk-commits] mmichelson: trunk r174945 - in /trunk: apps/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 11 16:41:01 CST 2009


Author: mmichelson
Date: Wed Feb 11 16:41:01 2009
New Revision: 174945

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=174945
Log:
Fix 'd' option for app_dial and add new option to Answer application

The 'd' option would not work for channel types which use RTP to transport
DTMF digits. The only way to allow for this to work was to answer the channel
if we saw that this option was enabled.

I realized that this may cause issues with CDRs, specifically with giving false
dispositions and answer times. I therefore modified ast_answer to take another
parameter which would tell if the CDR should be marked answered.

I also extended this to the Answer application so that the channel may be answered
but not CDRified if desired.

I also modified app_dictate and app_waitforsilence to only answer the channel if it
is not already up, to help not allow for faulty CDR answer times.

All of these changes are going into Asterisk trunk. For 1.6.0 and 1.6.1, however, all
the changes except for the change to the Answer application will go in since we do
not introduce new features into stable branches

(closes issue #14164)
Reported by: DennisD
Patches:
      14164.patch uploaded by putnopvut (license 60)
Tested by: putnopvut

Review: http://reviewboard.digium.com/r/145


Modified:
    trunk/apps/app_dial.c
    trunk/apps/app_dictate.c
    trunk/apps/app_waitforsilence.c
    trunk/include/asterisk/channel.h
    trunk/main/channel.c
    trunk/main/pbx.c

Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/apps/app_dial.c?view=diff&rev=174945&r1=174944&r2=174945
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Wed Feb 11 16:41:01 2009
@@ -1593,6 +1593,10 @@
 		res = -1; /* reset default */
 	}
 
+	if (ast_test_flag64(&opts, OPT_DTMF_EXIT)) {
+		__ast_answer(chan, 0, 0);
+	}
+
 	if (continue_exec)
 		*continue_exec = 0;
 

Modified: trunk/apps/app_dictate.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/apps/app_dictate.c?view=diff&rev=174945&r1=174944&r2=174945
==============================================================================
--- trunk/apps/app_dictate.c (original)
+++ trunk/apps/app_dictate.c Wed Feb 11 16:41:01 2009
@@ -127,7 +127,9 @@
 		return -1;
 	}
 
-	ast_answer(chan);
+	if (chan->_state != AST_STATE_UP) {
+		ast_answer(chan);
+	}
 	ast_safe_sleep(chan, 200);
 	for (res = 0; !res;) {
 		if (ast_strlen_zero(filename)) {

Modified: trunk/apps/app_waitforsilence.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/apps/app_waitforsilence.c?view=diff&rev=174945&r1=174944&r2=174945
==============================================================================
--- trunk/apps/app_waitforsilence.c (original)
+++ trunk/apps/app_waitforsilence.c Wed Feb 11 16:41:01 2009
@@ -210,7 +210,9 @@
 	int iterations = 1, i;
 	time_t waitstart;
 
-	res = ast_answer(chan); /* Answer the channel */
+	if (chan->_state != AST_STATE_UP) {
+		res = ast_answer(chan); /* Answer the channel */
+	}
 
 	if (!data || ( (sscanf(data, "%d,%d,%d", &timereqd, &iterations, &timeout) != 3) &&
 		(sscanf(data, "%d,%d", &timereqd, &iterations) != 2) &&

Modified: trunk/include/asterisk/channel.h
URL: http://svn.digium.com/svn-view/asterisk/trunk/include/asterisk/channel.h?view=diff&rev=174945&r1=174944&r2=174945
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Wed Feb 11 16:41:01 2009
@@ -971,7 +971,7 @@
  * \retval non-zero on failure
  */
 int ast_answer(struct ast_channel *chan);
-int __ast_answer(struct ast_channel *chan, unsigned int delay);
+int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer);
 
 /*! \brief Make a call 
  * \param chan which channel to make the call on

Modified: trunk/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/channel.c?view=diff&rev=174945&r1=174944&r2=174945
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Wed Feb 11 16:41:01 2009
@@ -1697,7 +1697,7 @@
 }
 
 #define ANSWER_WAIT_MS 500
-int __ast_answer(struct ast_channel *chan, unsigned int delay)
+int __ast_answer(struct ast_channel *chan, unsigned int delay,  int cdr_answer)
 {
 	int res = 0;
 
@@ -1725,7 +1725,9 @@
 			res = chan->tech->answer(chan);
 		}
 		ast_setstate(chan, AST_STATE_UP);
-		ast_cdr_answer(chan->cdr);
+		if (cdr_answer) {
+			ast_cdr_answer(chan->cdr);
+		}
 		ast_channel_unlock(chan);
 		if (delay) {
 			ast_safe_sleep(chan, delay);
@@ -1761,6 +1763,12 @@
 		}
 		break;
 	case AST_STATE_UP:
+		/* Calling ast_cdr_answer when it it has previously been called
+		 * is essentially a no-op, so it is safe.
+		 */
+		if (cdr_answer) {
+			ast_cdr_answer(chan->cdr);
+		}
 		break;
 	default:
 		break;
@@ -1774,7 +1782,7 @@
 
 int ast_answer(struct ast_channel *chan)
 {
-	return __ast_answer(chan, 0);
+	return __ast_answer(chan, 0, 1);
 }
 
 void ast_deactivate_generator(struct ast_channel *chan)

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/pbx.c?view=diff&rev=174945&r1=174944&r2=174945
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Wed Feb 11 16:41:01 2009
@@ -96,6 +96,10 @@
 			<parameter name="delay">
 				<para>Asterisk will wait this number of milliseconds before returning to
 				the dialplan after answering the call.</para>
+			</parameter>
+			<parameter name="nocdr">
+				<para>Asterisk will send an answer signal to the calling phone, but will not
+				set the disposition or answer time in the CDR for this call.
 			</parameter>
 		</syntax>
 		<description>
@@ -8310,15 +8314,33 @@
 static int pbx_builtin_answer(struct ast_channel *chan, void *data)
 {
 	int delay = 0;
-
-	if ((chan->_state != AST_STATE_UP) && !ast_strlen_zero(data))
+	int answer_cdr = 1;
+	char *parse;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(delay);
+		AST_APP_ARG(answer_cdr);
+	);
+
+	if (ast_strlen_zero(data)) {
+		return __ast_answer(chan, 0, 1);
+	}
+
+	parse = ast_strdupa(data);
+
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	if (!ast_strlen_zero(args.delay) && (chan->_state != AST_STATE_UP))
 		delay = atoi(data);
 
 	if (delay < 0) {
 		delay = 0;
 	}
 
-	return __ast_answer(chan, delay);
+	if (!ast_strlen_zero(args.answer_cdr) && !strcasecmp(args.answer_cdr, "nocdr")) {
+		answer_cdr = 0;
+	}
+
+	return __ast_answer(chan, delay, answer_cdr);
 }
 
 static int pbx_builtin_incomplete(struct ast_channel *chan, void *data)
@@ -8335,7 +8357,7 @@
 	if (ast_check_hangup(chan)) {
 		return -1;
 	} else if (chan->_state != AST_STATE_UP && answer) {
-		__ast_answer(chan, 0);
+		__ast_answer(chan, 0, 1);
 	}
 
 	return AST_PBX_INCOMPLETE;




More information about the asterisk-commits mailing list