[ previous ] [ next ] [ threads ]
 To :  yate@v...
 From :  "lerto.chicco@t..." <lerto.chicco@t...>
 Subject :  IVR with ringback, answer and play
 Date :  Fri, 2 Apr 2010 11:11:10 +0200 (CEST)

Hi,
I have to do an IVR that plays an audio file but that answers the 
call only after 5 seconds of ringback: the caller at first receives the 
ringback and after 5 seconds receives the call answer and can hear the 
audio file.
I use c++ and I'm not so expert of yate so my solution has 
some error that I have difficult to found.
My idea was to create a 
module that performs the ringback and the answer and to use a chan.
attach to play the audio file to the caller.
The problem of my 
implementation is that after the call is answered, the caller doesn't 
not hear the audio file.

The module I create was:

MyModule::MyModule()
 : Driver("myivr","misc")

so in my regexroute.conf I can a a routing 
as:

^99991007$=myivr/

The msgExecute of my module is:

bool MyModule::
msgExecute(Message& msg, String& dest)
{
   CallEndpoint * 
otherEndPoint = static_cast(msg.userData());

   if (!
otherEndPoint)
      return false;   

   MyChannel * channel = new 
MyChannel(dest, &msg);

   if (!otherEndPoint->connect(channel)) 
   {

      channel->destruct();
	  return false;
   }

   msg.setParam
("peerid", channel->id());
   msg.setParam("targetid", channel->id());
  

   channel->callConnect(msg);
   channel->setTargetid(otherEndPoint-
>id());
   channel->ringback();   
   channel->deref();

   return 
true;
}

where the ringback member is:

void MyChannel::ringback()
{
   
status("ringing");

   Message * m = new Message("call.ringing");   

   
   m->addParam("id",id());
   m->addParam("status", "ringing");
   
m->addParam("targetid", m_targetid);
   m->addParam("peerid", 
m_targetid);
   m->userData(this);

   Engine::enqueue(m);
}

I use the 
engine.timer to check the 4 seconds elapsed from ringback and then I 
do:

void MyChannel::TimerTimeout()
{
   CallAnswer();
   PlayWave("C:
/sounds/file.alaw");   
}

where CallAnswer and PlayWave are defined 
as:

void MyChannel::CallAnswer()
{
   status("answered");

   Message m
("call.answered");

   m.addParam("id", id());
   m.addParam
("targetid", m_targetid);
	
   Engine::dispatch(m); 
}

and

void 
MyChannel::PlayWave(String filename)
{
   Message m("chan.masquerade");


   m.addParam("message", "chan.attach");
   m.addParam("id", id());
   
String cmd = String("wave/play/") + filename;
   m.addParam("source", 
cmd);
	
   Engine::dispatch(m);   
}

Please, help me!

Chicco


Presentaci un amico! Invita i tuoi amici a scoprire i servizi Tiscali: per ogni amico che attiverà un servizio Tiscali, potrai avere 30 euro di sconto e lo stesso sconto di 30 euro verrà poi offerto al tuo amico.   Scopri come! http://abbonati.tiscali.it/presentaci_un_amico/?WT.mc_id=01fw