2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief App to send DTMF digits
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
30 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
36 #include "asterisk/lock.h"
37 #include "asterisk/file.h"
38 #include "asterisk/logger.h"
39 #include "asterisk/channel.h"
40 #include "asterisk/pbx.h"
41 #include "asterisk/module.h"
42 #include "asterisk/translate.h"
43 #include "asterisk/options.h"
44 #include "asterisk/utils.h"
45 #include "asterisk/app.h"
46 #include "asterisk/manager.h"
48 static char *app = "SendDTMF";
50 static char *synopsis = "Sends arbitrary DTMF digits";
52 static char *descrip =
53 " SendDTMF(digits[|timeout_ms]): Sends DTMF digits on a channel. \n"
54 " Accepted digits: 0-9, *#abcd, w (.5s pause)\n"
55 " The application will either pass the assigned digits or terminate if it\n"
56 " encounters an error.\n";
59 static int senddtmf_exec(struct ast_channel *chan, void *data)
62 char *digits = NULL, *to = NULL;
65 if (ast_strlen_zero(data)) {
66 ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
70 digits = ast_strdupa(data);
72 if ((to = strchr(digits,'|'))) {
81 res = ast_dtmf_stream(chan,NULL,digits,timeout);
86 static char mandescr_playdtmf[] =
87 "Description: Plays a dtmf digit on the specified channel.\n"
88 "Variables: (all are required)\n"
89 " Channel: Channel name to send digit to\n"
90 " Digit: The dtmf digit to play\n";
92 static int manager_play_dtmf(struct mansession *s, const struct message *m)
94 const char *channel = astman_get_header(m, "Channel");
95 const char *digit = astman_get_header(m, "Digit");
96 struct ast_channel *chan = ast_get_channel_by_name_locked(channel);
99 astman_send_error(s, m, "Channel not specified");
103 astman_send_error(s, m, "No digit specified");
104 ast_mutex_unlock(&chan->lock);
108 ast_senddigit(chan, *digit);
110 ast_mutex_unlock(&chan->lock);
111 astman_send_ack(s, m, "DTMF successfully queued");
116 static int unload_module(void)
120 res = ast_unregister_application(app);
121 res |= ast_manager_unregister("PlayDTMF");
126 static int load_module(void)
130 res = ast_manager_register2( "PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf, "Play DTMF signal on a specific channel.", mandescr_playdtmf );
131 res |= ast_register_application(app, senddtmf_exec, synopsis, descrip);
136 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send DTMF digits Application");