From d73af600f34c55dd7d5c8514e467e8a66875ceac Mon Sep 17 00:00:00 2001 From: mmichelson Date: Mon, 24 May 2010 22:16:29 +0000 Subject: 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 #17182) Reported by: rcasas Patches: app_senddtmf.c.patch_trunk uploaded by rcasas (license 641) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@265453 f38db490-d61c-443f-a65b-d21fe96a405b --- apps/app_senddtmf.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c index 16ca4b513..2af67a299 100644 --- a/apps/app_senddtmf.c +++ b/apps/app_senddtmf.c @@ -50,6 +50,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Duration of each digit + + Channel where digits will be played + DTMF digits sent to a channel with half second pause @@ -84,10 +87,12 @@ static int senddtmf_exec(struct ast_channel *chan, const char *vdata) 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)) { @@ -95,6 +100,8 @@ static int senddtmf_exec(struct ast_channel *chan, const char *vdata) return 0; } + dchan = chan; + data = ast_strdupa(vdata); AST_STANDARD_APP_ARGS(args, data); @@ -104,8 +111,17 @@ static int senddtmf_exec(struct ast_channel *chan, const char *vdata) 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; } -- cgit v1.2.3