· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
Asterisk Ver0-1-0/Pbx Builtin


static int pbx_builtin_answer(struct ast_channel *, void *);
static int pbx_builtin_goto(struct ast_channel *, void *);
static int pbx_builtin_hangup(struct ast_channel *, void *);
static int pbx_builtin_background(struct ast_channel *, void *);
static int pbx_builtin_dtimeout(struct ast_channel *, void *);
static int pbx_builtin_rtimeout(struct ast_channel *, void *);
static int pbx_builtin_wait(struct ast_channel *, void *);

static struct pbx_builtin {
        char name[AST_MAX_APP];
        int (*execute)(struct ast_channel *chan, void *data);
} builtins[] =
        { "Answer", pbx_builtin_answer },
        { "Goto", pbx_builtin_goto },
        { "Hangup", pbx_builtin_hangup },
        { "DigitTimeout", pbx_builtin_dtimeout },
        { "ResponseTimeout", pbx_builtin_rtimeout },
        { "BackGround", pbx_builtin_background },
        { "Wait", pbx_builtin_wait },

* int pbx_builtin_answer(struct ast_channel *chan, void *data)
  • if (chan->state != AST_STATE_RING) {
    • Ignoring answer request since line is not ringing
    • return 0;
  • return ast_answer(chan);
    • channel 에 해당하는 answer 함수가 수행된다.

* int ast_answer(struct ast_channel *chan)
  • if (chan->state == AST_STATE_RING) {
    • if (chan->pvt->answer)
      • return chan->pvt->answer(chan);
  • }
  • return 0;

Goto requires an argument (optional context|optional extension|priority)

GoTo(5) ; example for priority
GoTo(112,5) ; example for extension and priority
GoTo(test1,112,5) ; example for context extension and priority
* int pbx_builtin_goto(struct ast_channel *chan, void *data)
  • data 를 처리하여 context, extension, priority 값을 찾아내고, 이를 chan structure 에 assign 한다.
  • return 0;

* int pbx_builtin_hangup(struct ast_channel *chan, void *data)
  • return -1;

* int pbx_builtin_background(struct ast_channel *chan, void *data)
  • ast_stopstream(chan);
  • res = ast_streamfile(chan, (char *)data);
  • return res;
  • 화일을 찾고, 있으면 이에 알맞는 codec 을 찾아 play 한다.

The maximum amount of time permitted between digits when the
         user is typing in an extension.  When this timeout expires,
         after the user has started to type in an extension, the
         extension will be considered complete, and will be
         interpreted.  Note that if an extension typed in is valid,
         it will not have to timeout to be tested, so typically at
         the expiry of this timeout, the extension will be considered
         invalid (and thus control would be passed to the 'i'
         extension, or if it doesn't exist the call would be
         terminated).  The default timeout is 5 seconds. 
* int pbx_builtin_dtimeout(struct ast_channel *chan, void *data)
  • chan->pbx->dtimeout = atoi((char *)data);
  • Set the timeout for how long to wait between digits
  • return 0;

The maximum amount of time permitted after falling through a
          series of priorities for a channel in which the user may
          begin typing an extension.  If the user does not begin typing an
          extension in this amount of time, control will pass to the
          't' extension if it exists, and if not the call would be
          terminated. Once the user begins to type an extension Asterisk
          will wait for digit timeout to be reached and response timeout has
          no effect. The default timeout is 10 seconds. 
* int pbx_builtin_rtimeout(struct ast_channel *chan, void *data)
  • chan->pbx->rtimeout = atoi((char *)data);
  • Set Response Timeout
  • return 0;

* int pbx_builtin_wait(struct ast_channel *chan, void *data)
  • if (data && atoi((char *)data))
    • sleep(atoi((char *)data));
  • return 0;

Your own qualities will help prevent your advancement in the world.

sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-07-14 08:51:51
Processing time 0.0046 sec