Mon Mar 12 2012 21:26:11

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"
Include dependency graph for app_waitforring.c:

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 = AST_BUILDOPT_SUM, .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 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]
static int unload_module ( void  ) [static]

Definition at line 128 of file app_waitforring.c.

References ast_unregister_application().

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

{
   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.integer == 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.integer == 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;
}

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 = AST_BUILDOPT_SUM, .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.

Definition at line 138 of file app_waitforring.c.