#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, const char *data) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Waits until first ring after time" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
static char * | app = "WaitForRing" |
static struct ast_module_info * | ast_module_info = &__mod_info |
Definition in file app_waitforring.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 138 of file app_waitforring.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 138 of file app_waitforring.c.
static int load_module | ( | void | ) | [static] |
Definition at line 133 of file app_waitforring.c.
References ast_register_application_xml, and waitforring_exec().
00134 { 00135 return ast_register_application_xml(app, waitforring_exec); 00136 }
static int unload_module | ( | void | ) | [static] |
Definition at line 128 of file app_waitforring.c.
References ast_unregister_application().
00129 { 00130 return ast_unregister_application(app); 00131 }
static int waitforring_exec | ( | struct ast_channel * | chan, | |
const char * | data | |||
) | [static] |
Definition at line 60 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, and LOG_WARNING.
Referenced by load_module().
00061 { 00062 struct ast_frame *f; 00063 struct ast_silence_generator *silgen = NULL; 00064 int res = 0; 00065 double s; 00066 int ms; 00067 00068 if (!data || (sscanf(data, "%30lg", &s) != 1)) { 00069 ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n"); 00070 return 0; 00071 } 00072 00073 if (ast_opt_transmit_silence) { 00074 silgen = ast_channel_start_silence_generator(chan); 00075 } 00076 00077 ms = s * 1000.0; 00078 while (ms > 0) { 00079 ms = ast_waitfor(chan, ms); 00080 if (ms < 0) { 00081 res = ms; 00082 break; 00083 } 00084 if (ms > 0) { 00085 f = ast_read(chan); 00086 if (!f) { 00087 res = -1; 00088 break; 00089 } 00090 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) { 00091 ast_verb(3, "Got a ring but still waiting for timeout\n"); 00092 } 00093 ast_frfree(f); 00094 } 00095 } 00096 /* Now we're really ready for the ring */ 00097 if (!res) { 00098 ms = 99999999; 00099 while(ms > 0) { 00100 ms = ast_waitfor(chan, ms); 00101 if (ms < 0) { 00102 res = ms; 00103 break; 00104 } 00105 if (ms > 0) { 00106 f = ast_read(chan); 00107 if (!f) { 00108 res = -1; 00109 break; 00110 } 00111 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) { 00112 ast_verb(3, "Got a ring after the timeout\n"); 00113 ast_frfree(f); 00114 break; 00115 } 00116 ast_frfree(f); 00117 } 00118 } 00119 } 00120 00121 if (silgen) { 00122 ast_channel_stop_silence_generator(chan, silgen); 00123 } 00124 00125 return res; 00126 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Waits until first ring after time" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 138 of file app_waitforring.c.
char* app = "WaitForRing" [static] |
Definition at line 58 of file app_waitforring.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 138 of file app_waitforring.c.