aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-05-24 22:16:29 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-05-24 22:16:29 +0000
commitd73af600f34c55dd7d5c8514e467e8a66875ceac (patch)
tree094495d39164e19c70ba4267c0ccbbd56ef8bdce
parenta1151ca4aefd7969084ce035ec3b6d607d680c61 (diff)
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
-rw-r--r--apps/app_senddtmf.c20
1 files changed, 18 insertions, 2 deletions
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$")
<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,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;
}