* Fixed timeout logic in the dialing API as setting timeouts

had no effect
* Updated dialing API documentation to indicate that timeouts
  are specified in milliseconds
* Added a new timeout argument to the Page application. If time
  expires, any endpoints which have not answered will be hung up.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@153223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2008-10-31 20:05:46 +00:00
parent 5fe37e47c6
commit d521ad9696
4 changed files with 40 additions and 14 deletions

View File

@@ -49,7 +49,7 @@ static const char *app_page= "Page";
static const char *page_synopsis = "Pages phones";
static const char *page_descrip =
"Page(Technology/Resource&Technology2/Resource2[,options])\n"
"Page(Technology/Resource&Technology2/Resource2[,options][,timeout])\n"
" Places outbound calls to the given technology / resource and dumps\n"
"them into a conference bridge as muted participants. The original\n"
"caller is dumped into the conference as a speaker and the room is\n"
@@ -57,7 +57,10 @@ static const char *page_descrip =
" d - full duplex audio\n"
" q - quiet, do not play beep to caller\n"
" r - record the page into a file (see 'r' for app_meetme)\n"
" s - only dial channel if devicestate says it is not in use\n";
" s - only dial channel if devicestate says it is not in use\n"
"The timeout parameter specifies the length of time that the system\n"
"will attempt to connect a call. After this duration, any intercom\n"
"calls that have not been answered will be hung up by the system.\n";
enum {
PAGE_DUPLEX = (1 << 0),
@@ -77,13 +80,21 @@ AST_APP_OPTIONS(page_opts, {
static int page_exec(struct ast_channel *chan, void *data)
{
char *options, *tech, *resource, *tmp;
char *tech, *resource, *tmp;
char meetmeopts[88], originator[AST_CHANNEL_NAME], *opts[0];
struct ast_flags flags = { 0 };
unsigned int confid = ast_random();
struct ast_app *app;
int res = 0, pos = 0, i = 0;
struct ast_dial *dials[MAX_DIALS];
int timeout = 0;
char *parse;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(devices);
AST_APP_ARG(options);
AST_APP_ARG(timeout);
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n");
@@ -95,21 +106,28 @@ static int page_exec(struct ast_channel *chan, void *data)
return -1;
};
options = ast_strdupa(data);
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
ast_copy_string(originator, chan->name, sizeof(originator));
if ((tmp = strchr(originator, '-')))
if ((tmp = strchr(originator, '-'))) {
*tmp = '\0';
}
tmp = strsep(&options, ",");
if (options)
ast_app_parse_options(page_opts, &flags, opts, options);
if (!ast_strlen_zero(args.options)) {
ast_app_parse_options(page_opts, &flags, opts, args.options);
}
if (!ast_strlen_zero(args.timeout)) {
timeout = atoi(args.timeout);
}
snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
/* Go through parsing/calling each device */
while ((tech = strsep(&tmp, "&"))) {
while ((tech = strsep(&args.devices, "&"))) {
int state = 0;
struct ast_dial *dial = NULL;
@@ -143,11 +161,18 @@ static int page_exec(struct ast_channel *chan, void *data)
}
/* Append technology and resource */
ast_dial_append(dial, tech, resource);
if (ast_dial_append(dial, tech, resource) == -1) {
ast_log(LOG_ERROR, "Failed to add %s to outbound dial\n", tech);
continue;
}
/* Set ANSWER_EXEC as global option */
ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, meetmeopts);
if (timeout) {
ast_dial_set_global_timeout(dial, timeout * 1000);
}
/* Run this dial in async mode */
ast_dial_run(dial, chan, 1);