Mon Mar 31 07:38:45 2008

Asterisk developer's documentation


app_senddtmf.c File Reference

App to send DTMF digits. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/options.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/manager.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, void *data)
static int unload_module (void)

Variables

static char * app = "SendDTMF"
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

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Send DTMF digits Application"   
)

static int load_module ( void   )  [static]

Definition at line 133 of file app_senddtmf.c.

References ast_manager_register2(), ast_register_application(), 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(app, senddtmf_exec, synopsis, descrip);
00139 
00140    return res;
00141 }

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

Definition at line 97 of file app_senddtmf.c.

References ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_senddigit(), astman_get_header(), astman_send_ack(), astman_send_error(), ast_channel::lock, and s.

Referenced by load_module().

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

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

Definition at line 59 of file app_senddtmf.c.

References ast_dtmf_stream(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_strdupa, ast_strlen_zero(), ast_module_user::chan, LOG_WARNING, and timeout.

Referenced by load_module().

00060 {
00061    int res = 0;
00062    struct ast_module_user *u;
00063    char *digits = NULL, *to = NULL;
00064    int timeout = 250;
00065 
00066    if (ast_strlen_zero(data)) {
00067       ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
00068       return 0;
00069    }
00070 
00071    u = ast_module_user_add(chan);
00072 
00073    digits = ast_strdupa(data);
00074 
00075    if ((to = strchr(digits,'|'))) {
00076       *to = '\0';
00077       to++;
00078       timeout = atoi(to);
00079    }
00080       
00081    if (timeout <= 0)
00082       timeout = 250;
00083 
00084    res = ast_dtmf_stream(chan,NULL,digits,timeout);
00085       
00086    ast_module_user_remove(u);
00087 
00088    return res;
00089 }

static int unload_module ( void   )  [static]

Definition at line 121 of file app_senddtmf.c.

References ast_manager_unregister(), ast_module_user_hangup_all, and ast_unregister_application().

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


Variable Documentation

char* app = "SendDTMF" [static]

Definition at line 48 of file app_senddtmf.c.

char* descrip [static]

Initial value:

 
" SendDTMF(digits[|timeout_ms]): Sends DTMF digits on a channel. \n"
" Accepted digits: 0-9, *#abcd, w (.5s pause)\n"
" The application will either pass the assigned digits or terminate if it\n"
" encounters an error.\n"

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

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

Definition at line 50 of file app_senddtmf.c.


Generated on Mon Mar 31 07:38:45 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1