#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 | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } |
static char * | app = "WaitForRing" |
static struct ast_module_info * | ast_module_info = &__mod_info |
static char * | desc |
static char * | synopsis = "Wait for Ring Application" |
Definition in file app_waitforring.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 126 of file app_waitforring.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 126 of file app_waitforring.c.
static int load_module | ( | void | ) | [static] |
Definition at line 121 of file app_waitforring.c.
References ast_register_application, and waitforring_exec().
00122 { 00123 return ast_register_application(app, waitforring_exec, synopsis, desc); 00124 }
static int unload_module | ( | void | ) | [static] |
Definition at line 116 of file app_waitforring.c.
References ast_unregister_application().
00117 { 00118 return ast_unregister_application(app); 00119 }
static int waitforring_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 48 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(), chan, f, LOG_WARNING, and s.
Referenced by load_module().
00049 { 00050 struct ast_frame *f; 00051 struct ast_silence_generator *silgen = NULL; 00052 int res = 0; 00053 double s; 00054 int ms; 00055 00056 if (!data || (sscanf(data, "%30lg", &s) != 1)) { 00057 ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n"); 00058 return 0; 00059 } 00060 00061 if (ast_opt_transmit_silence) { 00062 silgen = ast_channel_start_silence_generator(chan); 00063 } 00064 00065 ms = s * 1000.0; 00066 while (ms > 0) { 00067 ms = ast_waitfor(chan, ms); 00068 if (ms < 0) { 00069 res = ms; 00070 break; 00071 } 00072 if (ms > 0) { 00073 f = ast_read(chan); 00074 if (!f) { 00075 res = -1; 00076 break; 00077 } 00078 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { 00079 ast_verb(3, "Got a ring but still waiting for timeout\n"); 00080 } 00081 ast_frfree(f); 00082 } 00083 } 00084 /* Now we're really ready for the ring */ 00085 if (!res) { 00086 ms = 99999999; 00087 while(ms > 0) { 00088 ms = ast_waitfor(chan, ms); 00089 if (ms < 0) { 00090 res = ms; 00091 break; 00092 } 00093 if (ms > 0) { 00094 f = ast_read(chan); 00095 if (!f) { 00096 res = -1; 00097 break; 00098 } 00099 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { 00100 ast_verb(3, "Got a ring after the timeout\n"); 00101 ast_frfree(f); 00102 break; 00103 } 00104 ast_frfree(f); 00105 } 00106 } 00107 } 00108 00109 if (silgen) { 00110 ast_channel_stop_silence_generator(chan, silgen); 00111 } 00112 00113 return res; 00114 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 126 of file app_waitforring.c.
char* app = "WaitForRing" [static] |
Definition at line 45 of file app_waitforring.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 126 of file app_waitforring.c.
char* desc [static] |
Initial value:
" WaitForRing(timeout):\n" "Returns 0 after waiting at least timeout seconds. and\n" "only after the next ring has completed. Returns 0 on\n" "success or -1 on hangup\n"
Definition at line 40 of file app_waitforring.c.
char* synopsis = "Wait for Ring Application" [static] |
Definition at line 38 of file app_waitforring.c.