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 | |
| AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Waits until first ring after time") | |
| static int | load_module (void) |
| static int | unload_module (void) |
| static int | waitforring_exec (struct ast_channel *chan, const char *data) |
Variables | |
| static char * | app = "WaitForRing" |
Wait for Ring Application.
Definition in file app_waitforring.c.
| AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
| "Waits until first ring after time" | ||||
| ) |
| 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, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, and ast_frame::subclass.
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 }
char* app = "WaitForRing" [static] |
Definition at line 58 of file app_waitforring.c.
1.6.1