[ previous ] [ next ] [ threads ]
 To : 
 From :  Maciek Kaminski <maciejka@t...>
 Subject :  Re: [yate] how to get rtp off the server after ivr
 Date :  Wed, 17 Dec 2008 14:00:16 +0100
Paul Chitescu pisze:
> Hi!
> 
> Please send a "call.update" with "operation"="initiate" after the outgoing 
> call leg answers. You can even issue that message to the outgoing call leg 
> before it answers as it will save it in a flag for later.
> 
> Which call leg is somehow important. The peer of the call leg you sent the 
> message to will be the first to attempt the reINVITE. If that fails the RTP 
> will remain in Yate. However, if the first reINVITE succeeds but the second 
> fails or offers a different RTP address:port the call will be terminated.
> 
> The call flow should be like this:
> 
> sip/A -> IVR
> ...
> IVR -> sip/B
> call.update operation=initiate targetid=sip/B -> sets flag
> ...
> checks flag <- sip/B <- 200 OK
> reINVITE <- sip/A <- call.update operation=request <- sip/B
> 200 OK -> sip/A -> call.update operation=notify -> sip/B -> reINVITE
> 
> Regards,
> 
> Paul Chitescu

Thanks for the replay. Just in case somebody is interested below is 
yaypm function that does exactly that:

@d...
def forward(yate, callid, targetid, caller, callto):
     try:
         logger.debug("Trying to forward call from: %s to: %s",
	             caller, callto)

         route = yate.msg("call.route",
                            {"called": callto})

         if not (yield route.dispatch()):
            raise Exception("Can't route to: %s", callto)

         callto = route.getRetValue()

         execute = yate.msg("chan.masquerade",
                            {"id": callid,
                             "message": "call.execute",
                             "callto": callto})

         if not (yield execute.dispatch()):
            raise Exception("Can't do call.execute to: %s" % callto)

         logger.debug("Call from: %s forwarded to: %s", caller, callto)

         answered = yield yate.onwatch(
             "call.answered",
             lambda m : m["id"] ==  execute["targetid"],
             until = yate.onwatch("chan.hangup",
                                  lambda m : m["id"] == 
execute["targetid"]))

         logger.debug("%s answered", callto)

         update = yate.msg("call.update",
                            {"operation": "initiate",
                             "message": "call.execute",
                             "targetid": callid})

         logger.debug("Call from: %s updated", caller)

         if not (yield update.dispatch()):
            raise Exception("Can't do call.update to: %s" % callid)

     except AbandonedException:
         logger.debug("Incoming call %s from %s has been disconnected",
                      callid, caller)
     except:
         yate.msg("call.drop",
                  {"id": callid}).dispatch()
         logger.exception("Exception while forwarding incoming call.")

mk