Thu Aug 30 20:43:35 2012

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"
Include dependency graph for app_senddtmf.c:

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 char * app = "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 169 of file app_senddtmf.c.

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

00170 {
00171    int res;
00172 
00173    res = ast_manager_register_xml("PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf);
00174    res |= ast_register_application_xml(app, senddtmf_exec);
00175 
00176    return res;
00177 }

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

Definition at line 133 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().

00134 {
00135    const char *channel = astman_get_header(m, "Channel");
00136    const char *digit = astman_get_header(m, "Digit");
00137    struct ast_channel *chan;
00138 
00139    if (!(chan = ast_channel_get_by_name(channel))) {
00140       astman_send_error(s, m, "Channel not found");
00141       return 0;
00142    }
00143 
00144    if (ast_strlen_zero(digit)) {
00145       astman_send_error(s, m, "No digit specified");
00146       chan = ast_channel_unref(chan);
00147       return 0;
00148    }
00149 
00150    ast_senddigit(chan, *digit, 0);
00151 
00152    chan = ast_channel_unref(chan);
00153 
00154    astman_send_ack(s, m, "DTMF successfully queued");
00155 
00156    return 0;
00157 }

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

Definition at line 89 of file app_senddtmf.c.

References args, AST_APP_ARG, ast_app_parse_timelen(), ast_autoservice_start(), ast_autoservice_stop(), 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().

00090 {
00091    int res = 0;
00092    char *data;
00093    int dinterval = 0, duration = 0;
00094    struct ast_channel *dchan;
00095    AST_DECLARE_APP_ARGS(args,
00096       AST_APP_ARG(digits);
00097       AST_APP_ARG(dinterval);
00098       AST_APP_ARG(duration);
00099       AST_APP_ARG(channel);
00100    );
00101 
00102    if (ast_strlen_zero(vdata)) {
00103       ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
00104       return 0;
00105    }
00106 
00107    dchan = chan;
00108 
00109    data = ast_strdupa(vdata);
00110    AST_STANDARD_APP_ARGS(args, data);
00111 
00112    if (!ast_strlen_zero(args.dinterval)) {
00113       ast_app_parse_timelen(args.dinterval, &dinterval, TIMELEN_MILLISECONDS);
00114    }
00115    if (!ast_strlen_zero(args.duration)) {
00116       ast_app_parse_timelen(args.duration, &duration, TIMELEN_MILLISECONDS);
00117    }
00118    if (!ast_strlen_zero(args.channel)) {
00119       dchan = ast_channel_get_by_name(args.channel);
00120    }
00121    if (dchan != chan) {
00122       ast_autoservice_start(chan);
00123    }
00124    res = ast_dtmf_stream(dchan, NULL, args.digits, dinterval <= 0 ? 250 : dinterval, duration);
00125    if (dchan != chan) {
00126       ast_autoservice_stop(chan);
00127       ast_channel_unref(dchan);
00128    }
00129 
00130    return res;
00131 }

static int unload_module ( void   )  [static]

Definition at line 159 of file app_senddtmf.c.

References ast_manager_unregister(), and ast_unregister_application().

00160 {
00161    int res;
00162 
00163    res = ast_unregister_application(app);
00164    res |= ast_manager_unregister("PlayDTMF");
00165 
00166    return res; 
00167 }


Variable Documentation

char* app = "SendDTMF" [static]

Definition at line 87 of file app_senddtmf.c.


Generated on 30 Aug 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1