[asterisk-app-dev] ARI: add channel to bridge immediatelly after originate action

Marin Odrljin marin at maxcom.hr
Tue Oct 25 08:09:36 CDT 2016


Hello members,

 

I'm working with ARI interface (Asterisk 13.9.1, 13.11.2) and trying to make
simple routing app with bridging inbound and outbound call together.

 

Scenario: 

 

1.       Inbound call comes via ARI to my app and it isn't answered yet,

2.       My app finds route for outdial and originates new call to
destination,

3.       Originate result is reflected to inbound call (e.g. if there is no
answer on outbound call, hangup with no answer code is sent to inbound call.
Or when outbound call is answered, inbound is answered as well, etc...)

 

Inbound and outbound calls must be bridged ASAP in order not to lose media
between them. First, I've tried to make bridge and add channels to bridge
after both channels have been answered, but then I realized that there is a
gap in media around 200-300 millis, which means that inbound call doesn't
hear media from inbound call for first few hundred millis which is not
acceptible for me. Then, I have changed app in the way to create bridge and
add inbound call into it before outbound call even starts, and add only
outbound channel to bridge later to reduce neccessary time for joining
bridge as much as possible after both channels are connected. That works and
improvement is visible. Lost media is reduced to only approx. 50 millis
which is much better.

 

Now the problem. What I have tried to do when developing second version is
to add oubound channel to bridge before it is answered, so after sending
'originate' command. Response from 'originate' gave me a hope that this will
actaually work, because events that app gets almost immediately are:
ChannelCreated, ..., ChannelStateChange (Dialing), ChannelStateChange
(Ringing),... which means there is a channel created, there is channel ID,
it is sent to my Stasis app (it must be app is registered for channel's
events), remote end is dialed and it is even ringing. But no, when I try to
add this channel to bridge, response is quite strange for me: Channel not in
Stasis application!

 

I'm wondering how it can be that newly created channel from my Stasis app
which even gets almost immediately events for it, is not in Stasis
application?

 

Also, some of the events that are coming after 'originate' are also not so
clear to me. Below you can see the log:

 

16-10-21 14:04:34.218 TRACE | Make call to DAHDI/r1/42999104 from 98765 with
early media to channel

16-10-21 14:04:34.248 TRACE | Event ChannelCreated - Channel: 1477051663.413

16-10-21 14:04:34.258 TRACE | Event DeviceStateChanged - Name:
DAHDI/i1/42999104 | State: INUSE

16-10-21 14:04:34.268 TRACE | Event ChannelVarset - Channel: 1477051663.413
| Variable: TRANSFERCAPABILITY | Value: SPEECH

16-10-21 14:04:34.288 TRACE | Event ChannelDialplan - Channel:
1477051663.413 | DialplanApp: AppDial2

16-10-21 14:04:34.298 TRACE | Event ChannelCallerId - Channel:
1477051663.413 | CallerPresentationTxt: Presentation Allowed, Not Screened |
CallerPresentation: 0

16-10-21 14:04:34.308 TRACE | Event ChannelConnectedLine - Channel:
1477051663.413 | Caller:  (98765) | ConnectedLine:  (98765)

16-10-21 14:04:34.318 TRACE | Event DeviceStateChanged - Name:
DAHDI/i1/42999104 | State: INUSE

16-10-21 14:04:34.338 TRACE | Event ChannelStateChange - Channel:
1477051663.413 | State: Dialing | Name: DAHDI/i1/42999104-3e

16-10-21 14:04:34.358 TRACE | Event Dial - Caller: null | Peer:  (98765) |
DialStatus:  | DialString: r1/42999104

16-10-21 14:04:34.588 TRACE | Event DeviceStateChanged - Name:
DAHDI/i1/42999104 | State: RINGING

16-10-21 14:04:34.598 TRACE | Event ChannelStateChange - Channel:
1477051663.413 | State: Ringing | Name: DAHDI/i1/42999104-3e

16-10-21 14:04:34.618 DEBUG | Enter bridge R-1-30-31 | channel
1477051663.413

16-10-21 14:04:34.618 ERROR | Error entering bridge R-1-30-31

ch.loway.oss.ari4java.tools.RestException: Channel not in Stasis application

 

I have to emphasise that bridge is created before, indial channel was
successfully added to it although it is not answered yet.

 

Events that are odd to me are:

 

1.       ChannelDialplan - DialplanApp is ' AppDial2' (my ARI app is called
differently, I assume this is some native Asterisk app that does the
originate work)

2.       StasisStart is not received yet. It will come after destination is
answered, so after event: ChannelStateChange (Up). Probably this is the
essence of the problem.

 

As soon as event ChannelStateChange (Up) comes, app can successfully add
outbound channel to bridge, event if it is started before StasisStart event
comes. But I would like to add channel to bridge before it is answered, so
channels are already bridged in the moment they are both connected.

 

Can somebody please tell me if this behaviour is intended and fine? Or maybe
I have to use different approach to solve the problem?

 

Also, I have found thread that talks about similar or even the same problem:
Expected Early Bridge Behavior
(http://lists.digium.com/pipermail/asterisk-app-dev/2016-March/000769.html),
but I didn't find answer there.

 

Thank you,

Marin Odrljin

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-app-dev/attachments/20161025/d3f8c0dc/attachment.html>


More information about the asterisk-app-dev mailing list