[asterisk-users] Re: Associating an Originate Request to a Channel before the call is answered

Tony Mountifield tony at softins.clara.co.uk
Mon Aug 14 02:57:42 MST 2006


In article <20060814084404.23407.qmail at web80402.mail.yahoo.com>,
Janahan Vivekanandan <janahanv at yahoo.com> wrote:
> Hi,
> 
> I'm trying to figure out how to cancel a call before the other side answers. 
> 
> It looks like I can do this by issueing a HangUp Action using the ChannelId that asterisk
> initiates the call on. Unfortunately, I don't know of a way to associate the NewChannel
> Event which contains the ChannelId, to the Originate Action. I'm using the Async mode of the
> Originate Action, and it looks like the UniqueID in the Response to the Originate Action is
> null.
> 
> I know that I can use the ActionID to accomplish this once I receive the OriginateSuccess
> event, but I need to be able to cancel the call before it is answered(I'm pretty sure
> OriginateSuccess is only sent after the  call is answered, correct me if I'm wrong...:-)

I don't know whether the ActionID gets propagated to the new channel in
SVN trunk, but that would be a good enhancement.

Apart from that, the only way I have found to do it is to use a Local channel
for the outgiong call, to encode a serial number in the extension part of the
channel, and strip it out in the dialplan before dialling the number. e.g.

Action: Originate
Channel: Local/123-0987654321 at outgoing
etc.

Where 123 is a unique serial number and 0987654321 is the number to dial.

Then in extensions.conf, context [outgoing], use CUT() to discard the serial
number and call Dial with the actual phone number.

When you see the Newchannel event for Local/123-0987654321 at outgoing-xxxx,2
you can match it on the prefix part and associate it with the Originate.

The serial number doesn't need to get used anywhere - it is just to make
sure that every channel identifier is unique.

You will have to make sure you correctly track Rename, Link and Unlink events,
since Local channels optimise themselves out when the call is set up.

Hope this helps!

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list