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"

Include dependency graph for app_senddtmf.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
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 struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Send DTMF digits Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static struct ast_module_infoast_module_info = &__mod_info
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

static void __reg_module ( void   )  [static]

Definition at line 201 of file app_senddtmf.c.

static void __unreg_module ( void   )  [static]

Definition at line 201 of file app_senddtmf.c.

static int load_module ( void   )  [static]

Definition at line 191 of file app_senddtmf.c.

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

00192 {
00193    int res;
00194 
00195    res = ast_manager_register_xml("PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf);
00196    res |= ast_register_application_xml(senddtmf_name, senddtmf_exec);
00197 
00198    return res;
00199 }

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

Definition at line 147 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(), astman_send_error(), and digit.

Referenced by load_module().

00148 {
00149    const char *channel = astman_get_header(m, "Channel");
00150    const char *digit = astman_get_header(m, "Digit");
00151    const char *duration = astman_get_header(m, "Duration");
00152    struct ast_channel *chan;
00153    unsigned int duration_ms = 0;
00154 
00155    if (!(chan = ast_channel_get_by_name(channel))) {
00156       astman_send_error(s, m, "Channel not found");
00157       return 0;
00158    }
00159 
00160    if (ast_strlen_zero(digit)) {
00161       astman_send_error(s, m, "No digit specified");
00162       chan = ast_channel_unref(chan);
00163       return 0;
00164    }
00165    
00166    if (!ast_strlen_zero(duration) && (sscanf(duration, "%30u", &duration_ms) != 1)) {
00167       astman_send_error(s, m, "Could not convert Duration parameter");
00168       chan = ast_channel_unref(chan);
00169       return 0;
00170    }
00171 
00172    ast_senddigit(chan, *digit, duration_ms);
00173 
00174    chan = ast_channel_unref(chan);
00175 
00176    astman_send_ack(s, m, "DTMF successfully queued");
00177 
00178    return 0;
00179 }

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

Definition at line 94 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, NULL, and TIMELEN_MILLISECONDS.

Referenced by load_module().

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

static int unload_module ( void   )  [static]

Definition at line 181 of file app_senddtmf.c.

References ast_manager_unregister(), and ast_unregister_application().

00182 {
00183    int res;
00184 
00185    res = ast_unregister_application(senddtmf_name);
00186    res |= ast_manager_unregister("PlayDTMF");
00187 
00188    return res;
00189 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Send DTMF digits Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 201 of file app_senddtmf.c.

Definition at line 201 of file app_senddtmf.c.

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

Definition at line 92 of file app_senddtmf.c.


Generated on Thu Apr 16 06:28:42 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6