PJSIP Outgoing call - Ringback tone

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

 



Hi all,

I am facing a problem with outgoing call ring-back. This is how it goes. 
I make call to a PSTN, and at times i get 180 and other i get 183, where 
i am playing ringtone from file. Here again the ring-back stream may 
contain tone data or simply silence, which i am unable to detect. When i 
get  a stream from server during ringback, whether it be silence or not, 
on_call_media_state is called, where i am stopping the ringtone played 
from and audio file if PJSUA_CALL_MEDIA_ACTIVE.

Is there any way to handle this scenario.

I have done a few changed to code like below, so that the ringback tone 
from server is ignored, instead tone will be played from local file.

Please let me know if it is acceptable to use media as in the code given 
below and if there is any risk that PJSIP_SC_OK will not get called when 
call is accepted.

Thanks in advance

Anil


Sample:



static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
{
      pjsua_call_info call_info;
      PJ_UNUSED_ARG(e);
      pjsua_call_get_info(call_id, &call_info);

      if (call_info.state == PJSIP_INV_STATE_DISCONNECTED)
      {
         ....
           setStatus("CALL","Disconnected");
          if (call_id == g_current_call)
          {
              find_next_call();
          }
         ....
      }
     else if(call_info.state == PJSIP_INV_STATE_INCOMING)
      {
         ....
         setStatus("CALL","Calling");
         ....
      }
     else if (call_info.state == PJSIP_INV_STATE_CALLING)
     {
         ....
         g_current_call = call_id;
         setStatus("CALL","Dialing");\
         ....
     }
      else
      {
          if (call_info.last_status ==PJSIP_SC_RINGING)
          {
             setStatus("CALL","Ringing");//play ringbacktone
          }
          if (call_info.last_status ==PJSIP_SC_PROGRESS)
          {
             setStatus("CALL","Ringing"); //play ringbacktone
          }
         if (call_info.last_status ==PJSIP_SC_OK)
          {
             callmedia(call_id); // Connect media once call is accepted
             setStatus("CALL","Connected");
          }

          if (g_current_call==PJSUA_INVALID_ID)
              g_current_call = call_id;
      }
}

static void on_call_media_state(pjsua_call_id call_id)
{
      // Removed the entire code here. Once call is connected, 
callmedia(...) will be called from state PJSIP_SC_OK in callback 
on_call_state(...)
}

//Start Media once connected
static void callmedia(pjsua_call_id call_id)
{
     pjsua_call_info call_info;
     pjsua_call_get_info(call_id, &call_info);

     if (call_info.media_status == PJSUA_CALL_MEDIA_ACTIVE)
     {
         pj_bool_t connect_sound = PJ_TRUE;
         /* Put call in conference with other calls, if desired */
         if (app_config.auto_conf)
         {
             pjsua_call_id call_ids[PJSUA_MAX_CALLS];
             unsigned call_cnt=PJ_ARRAY_SIZE(call_ids);
             unsigned i;

             /* Get all calls, and establish media connection between
             * this call and other calls.
             */
             pjsua_enum_calls(call_ids, &call_cnt);

             for (i=0; i<call_cnt; ++i)
             {
                 if (call_ids[i] == call_id)
                     continue;

                 if (!pjsua_call_has_media(call_ids[i]))
                     continue;
                 pjsua_conf_connect(call_info.conf_slot,
                     pjsua_call_get_conf_port(call_ids[i]));
                 pjsua_conf_connect(pjsua_call_get_conf_port(call_ids[i]),
                     call_info.conf_slot);
             }
             connect_sound = PJ_TRUE;
         }
         if (connect_sound)
         {
             pjsua_conf_connect(call_info.conf_slot, 0);
             pjsua_conf_connect(0, call_info.conf_slot);
             setStatus("CALL","RingBackStop");
         }
     }
}



[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