[svn-commits] mmichelson: trunk r265453 - /trunk/apps/app_senddtmf.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon May 24 17:16:31 CDT 2010


Author: mmichelson
Date: Mon May 24 17:16:29 2010
New Revision: 265453

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=265453
Log:
Allow SendDTMF to play digits to a specified channel.

Patch supplied by reporter was modified to use autoservice and
prevent a potential channel ref leak but is otherwise as the
reporter uploaded it.

(closes issue #17109)
Reported by: under
Patches:
      logstream.diff uploaded by under (license 914)


Modified:
    trunk/apps/app_senddtmf.c

Modified: trunk/apps/app_senddtmf.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_senddtmf.c?view=diff&rev=265453&r1=265452&r2=265453
==============================================================================
--- trunk/apps/app_senddtmf.c (original)
+++ trunk/apps/app_senddtmf.c Mon May 24 17:16:29 2010
@@ -50,6 +50,9 @@
 			<parameter name="duration_ms" required="false">
 				<para>Duration of each digit</para>
 			</parameter>
+                        <parameter name="channel" required="false">
+                                <para>Channel where digits will be played</para>
+                        </parameter>
 		</syntax>
 		<description>
 			<para>DTMF digits sent to a channel with half second pause</para>
@@ -84,16 +87,20 @@
 	int res = 0;
 	char *data;
 	int dinterval = 0, duration = 0;
+	struct ast_channel *dchan;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(digits);
 		AST_APP_ARG(dinterval);
 		AST_APP_ARG(duration);
+		AST_APP_ARG(channel);
 	);
 
 	if (ast_strlen_zero(vdata)) {
 		ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
 		return 0;
 	}
+
+	dchan = chan;
 
 	data = ast_strdupa(vdata);
 	AST_STANDARD_APP_ARGS(args, data);
@@ -104,8 +111,17 @@
 	if (!ast_strlen_zero(args.duration)) {
 		ast_app_parse_timelen(args.duration, &duration, TIMELEN_MILLISECONDS);
 	}
-
-	res = ast_dtmf_stream(chan, NULL, args.digits, dinterval <= 0 ? 250 : dinterval, duration);
+	if (!ast_strlen_zero(args.channel)) {
+		dchan = ast_channel_get_by_name(args.channel);
+	}
+	if (dchan != chan) {
+		ast_autoservice_start(chan);
+	}
+	res = ast_dtmf_stream(dchan, NULL, args.digits, dinterval <= 0 ? 250 : dinterval, duration);
+	if (dchan != chan) {
+		ast_autoservice_stop(chan);
+		ast_channel_unref(dchan);
+	}
 
 	return res;
 }




More information about the svn-commits mailing list