Wait for Ring Application. More...
#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | load_module (void) |
static int | unload_module (void) |
static int | waitforring_exec (struct ast_channel *chan, void *data) |
Variables | |
static struct ast_module_info __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Waits until first ring after time" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
static char * | app = "WaitForRing" |
static struct ast_module_info * | ast_module_info = &__mod_info |
Wait for Ring Application.
Definition in file app_waitforring.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 134 of file app_waitforring.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 134 of file app_waitforring.c.
static int load_module | ( | void | ) | [static] |
Definition at line 129 of file app_waitforring.c.
References ast_register_application_xml, and waitforring_exec().
{ return ast_register_application_xml(app, waitforring_exec); }
static int unload_module | ( | void | ) | [static] |
Definition at line 124 of file app_waitforring.c.
References ast_unregister_application().
{ return ast_unregister_application(app); }
static int waitforring_exec | ( | struct ast_channel * | chan, |
void * | data | ||
) | [static] |
Definition at line 56 of file app_waitforring.c.
References ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), AST_CONTROL_RING, AST_FRAME_CONTROL, ast_frfree, ast_log(), ast_opt_transmit_silence, ast_read(), ast_verb, ast_waitfor(), f, ast_frame::frametype, LOG_WARNING, s, and ast_frame::subclass.
Referenced by load_module().
{ struct ast_frame *f; struct ast_silence_generator *silgen = NULL; int res = 0; double s; int ms; if (!data || (sscanf(data, "%30lg", &s) != 1)) { ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n"); return 0; } if (ast_opt_transmit_silence) { silgen = ast_channel_start_silence_generator(chan); } ms = s * 1000.0; while (ms > 0) { ms = ast_waitfor(chan, ms); if (ms < 0) { res = ms; break; } if (ms > 0) { f = ast_read(chan); if (!f) { res = -1; break; } if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { ast_verb(3, "Got a ring but still waiting for timeout\n"); } ast_frfree(f); } } /* Now we're really ready for the ring */ if (!res) { ms = 99999999; while(ms > 0) { ms = ast_waitfor(chan, ms); if (ms < 0) { res = ms; break; } if (ms > 0) { f = ast_read(chan); if (!f) { res = -1; break; } if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { ast_verb(3, "Got a ring after the timeout\n"); ast_frfree(f); break; } ast_frfree(f); } } } if (silgen) { ast_channel_stop_silence_generator(chan, silgen); } return res; }
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Waits until first ring after time" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 134 of file app_waitforring.c.
char* app = "WaitForRing" [static] |
Definition at line 54 of file app_waitforring.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 134 of file app_waitforring.c.