Fri Nov 12 11:51:42 2010

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

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 = "0901e4e500243c855563a2d78b0c03e4" , .load = load_module, .unload = unload_module, }
static char * app = "SendDTMF"
static struct ast_module_infoast_module_info = &__mod_info
static char mandescr_playdtmf []

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

static void __unreg_module ( void   )  [static]

Definition at line 143 of file app_senddtmf.c.

static int load_module ( void   )  [static]

Definition at line 133 of file app_senddtmf.c.

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

00134 {
00135    int res;
00136 
00137    res = ast_manager_register2( "PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf, "Play DTMF signal on a specific channel.", mandescr_playdtmf );
00138    res |= ast_register_application_xml(app, senddtmf_exec);
00139 
00140    return res;
00141 }

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

Definition at line 99 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(), and chan.

Referenced by load_module().

00100 {
00101    const char *channel = astman_get_header(m, "Channel");
00102    const char *digit = astman_get_header(m, "Digit");
00103    struct ast_channel *chan = ast_get_channel_by_name_locked(channel);
00104    
00105    if (!chan) {
00106       astman_send_error(s, m, "Channel not specified");
00107       return 0;
00108    }
00109    if (ast_strlen_zero(digit)) {
00110       astman_send_error(s, m, "No digit specified");
00111       ast_channel_unlock(chan);
00112       return 0;
00113    }
00114 
00115    ast_senddigit(chan, *digit, 0);
00116 
00117    ast_channel_unlock(chan);
00118    astman_send_ack(s, m, "DTMF successfully queued");
00119    
00120    return 0;
00121 }

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

Definition at line 65 of file app_senddtmf.c.

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

Referenced by load_module().

00066 {
00067    int res = 0;
00068    char *data;
00069    int timeout = 0, duration = 0;
00070    AST_DECLARE_APP_ARGS(args,
00071       AST_APP_ARG(digits);
00072       AST_APP_ARG(timeout);
00073       AST_APP_ARG(duration);
00074    );
00075 
00076    if (ast_strlen_zero(vdata)) {
00077       ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
00078       return 0;
00079    }
00080 
00081    data = ast_strdupa(vdata);
00082    AST_STANDARD_APP_ARGS(args, data);
00083 
00084    if (!ast_strlen_zero(args.timeout))
00085       timeout = atoi(args.timeout);
00086    if (!ast_strlen_zero(args.duration))
00087       duration = atoi(args.duration);
00088    res = ast_dtmf_stream(chan, NULL, args.digits, timeout <= 0 ? 250 : timeout, duration);
00089 
00090    return res;
00091 }

static int unload_module ( void   )  [static]

Definition at line 123 of file app_senddtmf.c.

References ast_manager_unregister(), and ast_unregister_application().

00124 {
00125    int res;
00126 
00127    res = ast_unregister_application(app);
00128    res |= ast_manager_unregister("PlayDTMF");
00129 
00130    return res; 
00131 }


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 = "0901e4e500243c855563a2d78b0c03e4" , .load = load_module, .unload = unload_module, } [static]

Definition at line 143 of file app_senddtmf.c.

char* app = "SendDTMF" [static]

Definition at line 63 of file app_senddtmf.c.

Definition at line 143 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 93 of file app_senddtmf.c.


Generated by  doxygen 1.6.2