Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "asterisk.h"
00029
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 184082 $")
00031
00032 #include "asterisk/pbx.h"
00033 #include "asterisk/module.h"
00034 #include "asterisk/app.h"
00035 #include "asterisk/manager.h"
00036 #include "asterisk/channel.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 static char *app = "SendDTMF";
00064
00065 static int senddtmf_exec(struct ast_channel *chan, void *vdata)
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 }
00092
00093 static char mandescr_playdtmf[] =
00094 "Description: Plays a dtmf digit on the specified channel.\n"
00095 "Variables: (all are required)\n"
00096 " Channel: Channel name to send digit to\n"
00097 " Digit: The dtmf digit to play\n";
00098
00099 static int manager_play_dtmf(struct mansession *s, const struct message *m)
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 }
00122
00123 static int unload_module(void)
00124 {
00125 int res;
00126
00127 res = ast_unregister_application(app);
00128 res |= ast_manager_unregister("PlayDTMF");
00129
00130 return res;
00131 }
00132
00133 static int load_module(void)
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 }
00142
00143 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send DTMF digits Application");