more meaningful make call example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using the "200 lines of code" sample able to compile and place an outbound
call no problem to an Asterisk PBX. But each example I see enters a tight
loop and waits for the users to press 'q' to exit.

I want to be able to do something once connected. Walk an IVR tree with DTMF
to test that an IVR application is alive. Or play a message to the user,
asking them to press X DTMF key to acknowledge they received the call.

Not stuck on the DTMF generation or receipt but more the structure of the
application. What is typically used here? Some sort of state machine that
hooks in to the call state change callback to determine when connected,
disconnected, etc...? Anyone have an example of this they would like to
share? Something like below.



#define MYAPP_STATE_DONE 0
#define MYAPP_STATE_SENDDTMF 1
#define MYAPP_STATE_LISTENDTMF 2
#define MYAPP_STATE_CONNECTED 3
#define MYAPP_STATE_DISCONNECTED 4

int myapp_state;

static void on_call_state(pjsua_call_id call_id, pjsip_event *e) {

   pjsua_call_info ci;
   PJ_UNUSED_ARG(e);

   pjsua_call_get_info(call_id, &ci);
   if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
      myapp_state = MYAPP_STATE_DISCONNECTED;
   }
}


switch(myapp_ state) {

   case: PJSIP_CALL_ESTABLISHED
      myapp_state = MYAPP_STATE_SENDDTMF;
      break;

   case: MYAPP_STATE_SENDDTMF
      myapp_state = MYAPP_STATE_LISTENDTMF;
      break;

   case: MYAPP_STATE_LISTENDTMF
      myapp_state = MYAPP_STATE_DISCONNECTED;
      break;

   case: PJSIP_CALL_DISCONNECTED
      myapp_state = MYAPP_STATE_DONE;
      pjsua_destroy();
      break;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090209/5e679939/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux