Fri Jul 24 00:41:14 2009

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

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, void *vdata)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, }
static char * app = "SendDTMF"
static struct ast_module_infoast_module_info = &__mod_info
static char * descrip
static char mandescr_playdtmf []
static char * synopsis = "Sends arbitrary DTMF digits"


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 129 of file app_senddtmf.c.

static void __unreg_module ( void   )  [static]

Definition at line 129 of file app_senddtmf.c.

static int load_module ( void   )  [static]

Definition at line 119 of file app_senddtmf.c.

References ast_manager_register2(), ast_register_application, EVENT_FLAG_CALL, manager_play_dtmf(), and senddtmf_exec().

00120 {
00121    int res;
00122 
00123    res = ast_manager_register2( "PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf, "Play DTMF signal on a specific channel.", mandescr_playdtmf );
00124    res |= ast_register_application(app, senddtmf_exec, synopsis, descrip);
00125 
00126    return res;
00127 }

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

Definition at line 85 of file app_senddtmf.c.

References ast_channel_unlock, ast_get_channel_by_name_locked(), ast_senddigit(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), chan, and s.

Referenced by load_module().

00086 {
00087    const char *channel = astman_get_header(m, "Channel");
00088    const char *digit = astman_get_header(m, "Digit");
00089    struct ast_channel *chan = ast_get_channel_by_name_locked(channel);
00090    
00091    if (!chan) {
00092       astman_send_error(s, m, "Channel not specified");
00093       return 0;
00094    }
00095    if (ast_strlen_zero(digit)) {
00096       astman_send_error(s, m, "No digit specified");
00097       ast_channel_unlock(chan);
00098       return 0;
00099    }
00100 
00101    ast_senddigit(chan, *digit, 0);
00102 
00103    ast_channel_unlock(chan);
00104    astman_send_ack(s, m, "DTMF successfully queued");
00105    
00106    return 0;
00107 }

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

Definition at line 51 of file app_senddtmf.c.

References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_dtmf_stream(), ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), chan, and LOG_WARNING.

Referenced by load_module().

00052 {
00053    int res = 0;
00054    char *data;
00055    int timeout = 0, duration = 0;
00056    AST_DECLARE_APP_ARGS(args,
00057       AST_APP_ARG(digits);
00058       AST_APP_ARG(timeout);
00059       AST_APP_ARG(duration);
00060    );
00061 
00062    if (ast_strlen_zero(vdata)) {
00063       ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
00064       return 0;
00065    }
00066 
00067    data = ast_strdupa(vdata);
00068    AST_STANDARD_APP_ARGS(args, data);
00069 
00070    if (!ast_strlen_zero(args.timeout))
00071       timeout = atoi(args.timeout);
00072    if (!ast_strlen_zero(args.duration))
00073       duration = atoi(args.duration);
00074    res = ast_dtmf_stream(chan, NULL, args.digits, timeout <= 0 ? 250 : timeout, duration);
00075 
00076    return res;
00077 }

static int unload_module ( void   )  [static]

Definition at line 109 of file app_senddtmf.c.

References ast_manager_unregister(), and ast_unregister_application().

00110 {
00111    int res;
00112 
00113    res = ast_unregister_application(app);
00114    res |= ast_manager_unregister("PlayDTMF");
00115 
00116    return res; 
00117 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static]

Definition at line 129 of file app_senddtmf.c.

char* app = "SendDTMF" [static]

Definition at line 38 of file app_senddtmf.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 129 of file app_senddtmf.c.

char* descrip [static]

Definition at line 42 of file app_senddtmf.c.

char mandescr_playdtmf[] [static]

Initial value:

"Description: Plays a dtmf digit on the specified channel.\n"
"Variables: (all are required)\n"
"  Channel: Channel name to send digit to\n"
"  Digit: The dtmf digit to play\n"

Definition at line 79 of file app_senddtmf.c.

char* synopsis = "Sends arbitrary DTMF digits" [static]

Definition at line 40 of file app_senddtmf.c.


Generated on Fri Jul 24 00:41:14 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7