Mon Jun 27 16:51:02 2011

Asterisk developer's documentation


app_waitforring.c File Reference

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, 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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static char * app = "WaitForRing"
static struct ast_module_infoast_module_info = &__mod_info


Detailed Description

Wait for Ring Application.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_waitforring.c.


Function Documentation

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().

00130 {
00131    return ast_register_application_xml(app, waitforring_exec);
00132 }

static int unload_module ( void   )  [static]

Definition at line 124 of file app_waitforring.c.

References ast_unregister_application().

00125 {
00126    return ast_unregister_application(app);
00127 }

static int waitforring_exec ( struct ast_channel chan,
const char *  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, and LOG_WARNING.

Referenced by load_module().

00057 {
00058    struct ast_frame *f;
00059    struct ast_silence_generator *silgen = NULL;
00060    int res = 0;
00061    double s;
00062    int ms;
00063 
00064    if (!data || (sscanf(data, "%30lg", &s) != 1)) {
00065       ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n");
00066       return 0;
00067    }
00068 
00069    if (ast_opt_transmit_silence) {
00070       silgen = ast_channel_start_silence_generator(chan);
00071    }
00072 
00073    ms = s * 1000.0;
00074    while (ms > 0) {
00075       ms = ast_waitfor(chan, ms);
00076       if (ms < 0) {
00077          res = ms;
00078          break;
00079       }
00080       if (ms > 0) {
00081          f = ast_read(chan);
00082          if (!f) {
00083             res = -1;
00084             break;
00085          }
00086          if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) {
00087             ast_verb(3, "Got a ring but still waiting for timeout\n");
00088          }
00089          ast_frfree(f);
00090       }
00091    }
00092    /* Now we're really ready for the ring */
00093    if (!res) {
00094       ms = 99999999;
00095       while(ms > 0) {
00096          ms = ast_waitfor(chan, ms);
00097          if (ms < 0) {
00098             res = ms;
00099             break;
00100          }
00101          if (ms > 0) {
00102             f = ast_read(chan);
00103             if (!f) {
00104                res = -1;
00105                break;
00106             }
00107             if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) {
00108                ast_verb(3, "Got a ring after the timeout\n");
00109                ast_frfree(f);
00110                break;
00111             }
00112             ast_frfree(f);
00113          }
00114       }
00115    }
00116 
00117    if (silgen) {
00118       ast_channel_stop_silence_generator(chan, silgen);
00119    }
00120 
00121    return res;
00122 }


Variable Documentation

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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [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.


Generated on Mon Jun 27 16:51:02 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7