dect
/
asterisk
Archived
13
0
Fork 0

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
This commit is contained in:
mmichelson 2010-05-24 22:16:29 +00:00
parent a1151ca4ae
commit d73af600f3
1 changed files with 18 additions and 2 deletions

View File

@ -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;
}