Guys,

In my module (written in C), I have a call answering edge case that I think there must be an easier way than what I’m doing. Or, more correctly, a right way to do this and I’m currently not doing that.

I have an active/established call. An incoming SIP call arrives and I send it off to switch_ivr_originate to ring my endpoints. Based on action outside of Freeswitch, I want to stop the ringing and have an endpoint from the established call answer this ringing call. I have a custom FS event generated to indicate this condition. In this event handler I want to take a channel from the active call and answer this incoming call.

Here’s what I’m currently doing.

In my event handler I’m taking the endpoint of the active call and sending to a specific dialplan
This dialplan has it call my C application.
At this point the application is the session of the endpoint and it can get the session that’s currently ringing.
It gets the session of the ringing channel
It uses switch_channel_answer to answer the ringing channel.
Then it uses switch_ivr_uuid_bridge to bridge these two endpoints.

Seems simple enough but it’s not working.


The problems I have are:

Doing this seems to make the switch_ivr_originate that was ringing the endpoints fail with ORIGINATOR_CANCEL. I special case this but it leads me to believe I’m going about this the wrong way. I’m not trying to cancel it, I want to answer it.

I’m not breaking the bridge of the original established call. That too seems wrong. I think I should be doing something there but it’s not clear what.


Is there a better way to handle this?


Thanks

Kevin Snow