Thu Sep 7 01:03:09 2017

Asterisk developer's documentation


app_senddtmf.c File Reference

App to send DTMF digits. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/manager.h"
#include "asterisk/channel.h"

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Send DTMF digits Application")
static int load_module (void)
static int manager_play_dtmf (struct mansession *s, const struct message *m)
static int senddtmf_exec (struct ast_channel *chan, const char *vdata)
static int unload_module (void)

Variables

static const char senddtmf_name [] = "SendDTMF"

Detailed Description

App to send DTMF digits.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_senddtmf.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Send DTMF digits Application"   
)
static int load_module ( void   )  [static]

Definition at line 180 of file app_senddtmf.c.

References ast_manager_register_xml, ast_register_application_xml, EVENT_FLAG_CALL, manager_play_dtmf(), and senddtmf_exec().

00181 {
00182    int res;
00183 
00184    res = ast_manager_register_xml("PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf);
00185    res |= ast_register_application_xml(senddtmf_name, senddtmf_exec);
00186 
00187    return res;
00188 }

static int manager_play_dtmf ( struct mansession s,
const struct message m 
) [static]

Definition at line 144 of file app_senddtmf.c.

References ast_channel_get_by_name(), ast_channel_unref, ast_senddigit(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), and astman_send_error().

Referenced by load_module().

00145 {
00146    const char *channel = astman_get_header(m, "Channel");
00147    const char *digit = astman_get_header(m, "Digit");
00148    struct ast_channel *chan;
00149 
00150    if (!(chan = ast_channel_get_by_name(channel))) {
00151       astman_send_error(s, m, "Channel not found");
00152       return 0;
00153    }
00154 
00155    if (ast_strlen_zero(digit)) {
00156       astman_send_error(s, m, "No digit specified");
00157       chan = ast_channel_unref(chan);
00158       return 0;
00159    }
00160 
00161    ast_senddigit(chan, *digit, 0);
00162 
00163    chan = ast_channel_unref(chan);
00164 
00165    astman_send_ack(s, m, "DTMF successfully queued");
00166 
00167    return 0;
00168 }

static int senddtmf_exec ( struct ast_channel chan,
const char *  vdata 
) [static]

Definition at line 91 of file app_senddtmf.c.

References args, AST_APP_ARG, ast_app_parse_timelen(), ast_channel_get_by_name(), ast_channel_unref, AST_DECLARE_APP_ARGS, ast_dtmf_stream(), ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_WARNING, and TIMELEN_MILLISECONDS.

Referenced by load_module().

00092 {
00093    int res;
00094    char *data;
00095    int dinterval = 0, duration = 0;
00096    struct ast_channel *chan_found = NULL;
00097    struct ast_channel *chan_dest = chan;
00098    struct ast_channel *chan_autoservice = NULL;
00099    AST_DECLARE_APP_ARGS(args,
00100       AST_APP_ARG(digits);
00101       AST_APP_ARG(dinterval);
00102       AST_APP_ARG(duration);
00103       AST_APP_ARG(channel);
00104    );
00105 
00106    if (ast_strlen_zero(vdata)) {
00107       ast_log(LOG_WARNING, "SendDTMF requires an argument\n");
00108       return 0;
00109    }
00110 
00111    data = ast_strdupa(vdata);
00112    AST_STANDARD_APP_ARGS(args, data);
00113 
00114    if (ast_strlen_zero(args.digits)) {
00115       ast_log(LOG_WARNING, "The digits argument is required (0-9,*#,a-d,A-D,wfF)\n");
00116       return 0;
00117    }
00118    if (!ast_strlen_zero(args.dinterval)) {
00119       ast_app_parse_timelen(args.dinterval, &dinterval, TIMELEN_MILLISECONDS);
00120    }
00121    if (!ast_strlen_zero(args.duration)) {
00122       ast_app_parse_timelen(args.duration, &duration, TIMELEN_MILLISECONDS);
00123    }
00124    if (!ast_strlen_zero(args.channel)) {
00125       chan_found = ast_channel_get_by_name(args.channel);
00126       if (!chan_found) {
00127          ast_log(LOG_WARNING, "No such channel: %s\n", args.channel);
00128          return 0;
00129       }
00130       chan_dest = chan_found;
00131       if (chan_found != chan) {
00132          chan_autoservice = chan;
00133       }
00134    }
00135    res = ast_dtmf_stream(chan_dest, chan_autoservice, args.digits,
00136       dinterval <= 0 ? 250 : dinterval, duration);
00137    if (chan_found) {
00138       ast_channel_unref(chan_found);
00139    }
00140 
00141    return chan_autoservice ? 0 : res;
00142 }

static int unload_module ( void   )  [static]

Definition at line 170 of file app_senddtmf.c.

References ast_manager_unregister(), and ast_unregister_application().

00171 {
00172    int res;
00173 
00174    res = ast_unregister_application(senddtmf_name);
00175    res |= ast_manager_unregister("PlayDTMF");
00176 
00177    return res;
00178 }


Variable Documentation

const char senddtmf_name[] = "SendDTMF" [static]

Definition at line 89 of file app_senddtmf.c.


Generated on 7 Sep 2017 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1