* 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
1.6.2
Mark Michelson 17 years ago
parent 5fe37e47c6
commit d521ad9696

@ -685,6 +685,7 @@ Other Dialplan Application Changes
WaitForRing() now takes floating pt timeout arg. WaitForRing() now takes floating pt timeout arg.
SpeechBackground() -- clarified in the docstrings that the timeout is an integer seconds. SpeechBackground() -- clarified in the docstrings that the timeout is an integer seconds.
* Added 's' option to Page application. * Added 's' option to Page application.
* Added an optional timeout argument to the Page application.
* Added 'E', 'V', and 'P' commands to ExternalIVR. * Added 'E', 'V', and 'P' commands to ExternalIVR.
* Added 'o' and 'X' options to Chanspy. * Added 'o' and 'X' options to Chanspy.
* Added a new dialplan application, Bridge, which allows you to bridge the * Added a new dialplan application, Bridge, which allows you to bridge the

@ -49,7 +49,7 @@ static const char *app_page= "Page";
static const char *page_synopsis = "Pages phones"; static const char *page_synopsis = "Pages phones";
static const char *page_descrip = 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" " Places outbound calls to the given technology / resource and dumps\n"
"them into a conference bridge as muted participants. The original\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" "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" " d - full duplex audio\n"
" q - quiet, do not play beep to caller\n" " q - quiet, do not play beep to caller\n"
" r - record the page into a file (see 'r' for app_meetme)\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 { enum {
PAGE_DUPLEX = (1 << 0), PAGE_DUPLEX = (1 << 0),
@ -77,13 +80,21 @@ AST_APP_OPTIONS(page_opts, {
static int page_exec(struct ast_channel *chan, void *data) 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]; char meetmeopts[88], originator[AST_CHANNEL_NAME], *opts[0];
struct ast_flags flags = { 0 }; struct ast_flags flags = { 0 };
unsigned int confid = ast_random(); unsigned int confid = ast_random();
struct ast_app *app; struct ast_app *app;
int res = 0, pos = 0, i = 0; int res = 0, pos = 0, i = 0;
struct ast_dial *dials[MAX_DIALS]; 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)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n"); 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; return -1;
}; };
options = ast_strdupa(data); parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
ast_copy_string(originator, chan->name, sizeof(originator)); ast_copy_string(originator, chan->name, sizeof(originator));
if ((tmp = strchr(originator, '-'))) if ((tmp = strchr(originator, '-'))) {
*tmp = '\0'; *tmp = '\0';
}
if (!ast_strlen_zero(args.options)) {
ast_app_parse_options(page_opts, &flags, opts, args.options);
}
tmp = strsep(&options, ","); if (!ast_strlen_zero(args.timeout)) {
if (options) timeout = atoi(args.timeout);
ast_app_parse_options(page_opts, &flags, opts, options); }
snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"), snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") ); (ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
/* Go through parsing/calling each device */ /* Go through parsing/calling each device */
while ((tech = strsep(&tmp, "&"))) { while ((tech = strsep(&args.devices, "&"))) {
int state = 0; int state = 0;
struct ast_dial *dial = NULL; struct ast_dial *dial = NULL;
@ -143,11 +161,18 @@ static int page_exec(struct ast_channel *chan, void *data)
} }
/* Append technology and resource */ /* 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 */ /* Set ANSWER_EXEC as global option */
ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, meetmeopts); 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 */ /* Run this dial in async mode */
ast_dial_run(dial, chan, 1); ast_dial_run(dial, chan, 1);

@ -154,7 +154,7 @@ void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback
/*! \brief Set the maximum time (globally) allowed for trying to ring phones /*! \brief Set the maximum time (globally) allowed for trying to ring phones
* \param dial The dial structure to apply the time limit to * \param dial The dial structure to apply the time limit to
* \param timeout Maximum time allowed * \param timeout Maximum time allowed in milliseconds
* \return nothing * \return nothing
*/ */
void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout); void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout);
@ -162,7 +162,7 @@ void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout);
/*! \brief Set the maximum time (per channel) allowed for trying to ring the phone /*! \brief Set the maximum time (per channel) allowed for trying to ring the phone
* \param dial The dial structure the channel belongs to * \param dial The dial structure the channel belongs to
* \param num Channel number to set timeout on * \param num Channel number to set timeout on
* \param timeout Maximum time allowed * \param timeout Maximum time allowed in milliseconds
* \return nothing * \return nothing
*/ */
void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout); void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout);

@ -1038,7 +1038,7 @@ void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
{ {
dial->timeout = timeout; dial->timeout = timeout;
if (dial->timeout > 0 && dial->actual_timeout > dial->timeout) if (dial->timeout > 0 && (dial->actual_timeout > dial->timeout || dial->actual_timeout == -1))
dial->actual_timeout = dial->timeout; dial->actual_timeout = dial->timeout;
return; return;
@ -1059,7 +1059,7 @@ void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout)
channel->timeout = timeout; channel->timeout = timeout;
if (channel->timeout > 0 && dial->actual_timeout > channel->timeout) if (channel->timeout > 0 && (dial->actual_timeout > channel->timeout || dial->actual_timeout == -1))
dial->actual_timeout = channel->timeout; dial->actual_timeout = channel->timeout;
return; return;

Loading…
Cancel
Save